diff --git a/.devcontainer b/.devcontainer new file mode 160000 index 00000000..3a7e0dd4 --- /dev/null +++ b/.devcontainer @@ -0,0 +1 @@ +Subproject commit 3a7e0dd4ceb00c90efe6fb56dcf1836ddcc7b379 diff --git a/.github/workflows/xpbuild.yml b/.github/workflows/xpbuild.yml new file mode 100644 index 00000000..f0192ca9 --- /dev/null +++ b/.github/workflows/xpbuild.yml @@ -0,0 +1,30 @@ +name: Build +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + workflow_dispatch: +jobs: + linux: + uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2 + with: + cmake-workflow-preset: Linux + runon: ubuntu-latest + secrets: inherit + linux-arm64: + uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2 + with: + cmake-workflow-preset: Linux + runon: ubuntu-24.04-arm + secrets: inherit + macos: + uses: externpro/externpro/.github/workflows/build-macos.yml@25.05.2 + with: + cmake-workflow-preset: Darwin + secrets: inherit + windows: + uses: externpro/externpro/.github/workflows/build-windows.yml@25.05.2 + with: + cmake-workflow-preset: Windows + secrets: inherit diff --git a/.github/workflows/xprelease.yml b/.github/workflows/xprelease.yml new file mode 100644 index 00000000..273199e9 --- /dev/null +++ b/.github/workflows/xprelease.yml @@ -0,0 +1,20 @@ +name: Release +on: + workflow_dispatch: + inputs: + workflow_run_url: + description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)' + required: true + type: string +jobs: + # Upload build artifacts as release assets + release-from-build: + uses: externpro/externpro/.github/workflows/release-from-build.yml@25.05.2 + with: + workflow_run_url: ${{ github.event.inputs.workflow_run_url }} + artifact_pattern: "*.tar.xz" + permissions: + contents: write + id-token: write + attestations: write + secrets: inherit diff --git a/.gitignore b/.gitignore index 36437460..4bba7d04 100644 --- a/.gitignore +++ b/.gitignore @@ -61,3 +61,8 @@ Temporary Items #Build cmake dir build + +# externpro +.env +_bld*/ +docker-compose.override.yml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..18932abf --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".devcontainer"] + path = .devcontainer + url = https://github.com/externpro/externpro diff --git a/CMakeLists.txt b/CMakeLists.txt index 242c5936..c3308251 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,8 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.5...3.31) +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake) project(wirehair) + set(CMAKE_CXX_STANDARD 11) include(xpflags) @@ -11,6 +13,7 @@ if(NOT CMAKE_BUILD_TYPE) endif() option(MARCH_NATIVE "Use -march=native option" ON) +option(BUILD_TESTS "build testsuite" ON) set(LIB_SOURCE_FILES wirehair.cpp @@ -79,18 +82,15 @@ else() endforeach() if(XP_BUILD_VERBOSE) message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") - message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") - message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") + message(STATUS "CMAKE_CXX_FLAGS_DEBUG: ${CMAKE_CXX_FLAGS_DEBUG}") # "-g -O0" + message(STATUS "CMAKE_CXX_FLAGS_RELEASE: ${CMAKE_CXX_FLAGS_RELEASE}") # "-O3" + message(STATUS "CMAKE_CXX_FLAGS_RELWITHDEBINFO: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}") # "-g -O3" endif() if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") add_definitions(-DLINUX_ARM=1) endif() endif() -if(DONT_INSTALL_PYTHON) - set(optionalInstall EXCLUDE_FROM_ALL) -endif() - add_library(wirehair ${LIB_SOURCE_FILES}) set_target_properties(wirehair PROPERTIES VERSION 2) set_target_properties(wirehair PROPERTIES SOVERSION 2) @@ -98,37 +98,44 @@ target_include_directories(wirehair PUBLIC $ ) -add_executable(unit_test ${UNIT_TEST_SOURCE_FILES}) -target_link_libraries(unit_test wirehair) +if (BUILD_TESTS) + add_executable(unit_test ${UNIT_TEST_SOURCE_FILES}) + target_link_libraries(unit_test wirehair) -add_executable(gen_small_dseeds ${GEN_SMALL_DSEEDS}) -target_link_libraries(gen_small_dseeds wirehair) + add_executable(gen_small_dseeds ${GEN_SMALL_DSEEDS}) + target_link_libraries(gen_small_dseeds wirehair) -add_executable(gen_peel_seeds ${GEN_PEEL_SEEDS}) -target_link_libraries(gen_peel_seeds wirehair) + add_executable(gen_peel_seeds ${GEN_PEEL_SEEDS}) + target_link_libraries(gen_peel_seeds wirehair) -add_executable(gen_most_dseeds ${GEN_MOST_DSEEDS}) -target_link_libraries(gen_most_dseeds wirehair) + add_executable(gen_most_dseeds ${GEN_MOST_DSEEDS}) + target_link_libraries(gen_most_dseeds wirehair) -add_executable(gen_dcounts ${GEN_DCOUNTS}) -target_link_libraries(gen_dcounts wirehair) + add_executable(gen_dcounts ${GEN_DCOUNTS}) + target_link_libraries(gen_dcounts wirehair) -add_executable(gen_tables ${GEN_TABLES}) -target_link_libraries(gen_tables wirehair) + add_executable(gen_tables ${GEN_TABLES}) + target_link_libraries(gen_tables wirehair) +endif() include(GNUInstallDirs) -set(targetsFile ${PROJECT_NAME}-targets) -install(TARGETS wirehair EXPORT ${targetsFile} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +set(lib wirehair) if(DEFINED XP_NAMESPACE) set(nameSpace NAMESPACE ${XP_NAMESPACE}::) + string(PREPEND lib "${XP_NAMESPACE}::") endif() if(NOT DEFINED XP_INSTALL_CMAKEDIR) set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake) endif() +set(targetsFile ${PROJECT_NAME}-targets) +xpPackageDevel(TARGETS_FILE ${targetsFile} LIBRARIES ${lib}) +install(TARGETS wirehair EXPORT ${targetsFile} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(EXPORT ${targetsFile} DESTINATION ${XP_INSTALL_CMAKEDIR} ${nameSpace}) install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(DIRECTORY python DESTINATION ${CMAKE_INSTALL_PREFIX} ${optionalInstall}) +if(NOT DONT_INSTALL_PYTHON) + install(DIRECTORY python DESTINATION ${CMAKE_INSTALL_PREFIX}) +endif() diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000..f82cfdd2 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,8 @@ +{ + "version": 8, + "include": [ + ".devcontainer/cmake/presets/xpLinuxNinja.json", + ".devcontainer/cmake/presets/xpDarwinNinja.json", + ".devcontainer/cmake/presets/xpWindowsVs2022.json" + ] +} diff --git a/CMakePresetsBase.json b/CMakePresetsBase.json new file mode 100644 index 00000000..6ca17cf9 --- /dev/null +++ b/CMakePresetsBase.json @@ -0,0 +1,21 @@ +{ + "version": 8, + "configurePresets": [ + { + "name": "config-base", + "hidden": true, + "binaryDir": "${sourceDir}/_bld-${presetName}", + "cacheVariables": { + "XP_NAMESPACE": "xpro", + "DONT_INSTALL_PYTHON": true, + "MARCH_NATIVE": "OFF" + } + } + ], + "buildPresets": [ + { + "name": "build-base", + "hidden": true + } + ] +} diff --git a/docker-compose.sh b/docker-compose.sh new file mode 120000 index 00000000..85f182f0 --- /dev/null +++ b/docker-compose.sh @@ -0,0 +1 @@ +.devcontainer/compose.pro.sh \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 120000 index 00000000..46c1f891 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1 @@ +.devcontainer/compose.bld.yml \ No newline at end of file diff --git a/include/wirehair/gf256.h b/include/wirehair/gf256.h index 8396a44e..3a66b606 100644 --- a/include/wirehair/gf256.h +++ b/include/wirehair/gf256.h @@ -54,12 +54,12 @@ // Platform/Architecture #if defined(__ARM_ARCH) || defined(__ARM_NEON) || defined(__ARM_NEON__) - #if !defined IOS + #if !defined(__APPLE__) #define LINUX_ARM #endif #endif -#if defined(ANDROID) || defined(IOS) || defined(LINUX_ARM) || defined(__powerpc__) || defined(__s390__) +#if defined(ANDROID) || defined(__ARM_ARCH) || defined(__ARM_NEON) || defined(__ARM_NEON__) || defined(__powerpc__) || defined(__s390__) #define GF256_TARGET_MOBILE #endif // ANDROID diff --git a/include/wirehair/wirehair.h b/include/wirehair/wirehair.h index 451368a0..6636e0e9 100644 --- a/include/wirehair/wirehair.h +++ b/include/wirehair/wirehair.h @@ -243,7 +243,7 @@ WIREHAIR_EXPORT WirehairResult wirehair_decode( ); /** - wirehair_reconstruct() + wirehair_recover() Reconstruct the message after reading is complete.