diff --git a/.github/workflows/build-larch.yml b/.github/workflows/build-larch.yml new file mode 100644 index 00000000..0c4dfea8 --- /dev/null +++ b/.github/workflows/build-larch.yml @@ -0,0 +1,45 @@ +name: Build and run tests +on: + workflow_dispatch: +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + with: + submodules: true + - name: Prepare build environment + run: | + sudo apt-get update + sudo apt-get install build-essential cmake zlib1g-dev python3-pip python3-pytest + - name: Install conda + run: | + curl -L https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh > Miniconda3-latest-Linux-x86_64.sh + bash Miniconda3-latest-Linux-x86_64.sh -b -p ~/miniconda + ~/miniconda/bin/conda update -n base -c defaults conda + - name: Create conda env + run: | + source ~/miniconda/etc/profile.d/conda.sh + conda env create -f environment.yml + - name: Build (cmake step) + run: | + source ~/miniconda/etc/profile.d/conda.sh + conda activate larch-dev + mkdir build + cd build + export CMAKE_NUM_THREADS="8" + cmake -DCMAKE_BUILD_TYPE=Debug .. + - name: Build (make step) + run: | + source ~/miniconda/etc/profile.d/conda.sh + conda activate larch-dev + cd build + make -j20 + ln -s ../data + - name: Run tests + run: | + source ~/miniconda/etc/profile.d/conda.sh + conda activate larch-dev + cd build + ./larch-test -tag slow diff --git a/README.md b/README.md index 84a314b3..2ede660e 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,8 @@ file provided: Building -------- +- Note: If you run against memory limitations during the cmake step, you can regulate number of parallel threads with `export CMAKE_NUM_THREADS="8"` (reduce number as necessary). + `git submodule update --init --recursive` `mkdir build` `cd build` diff --git a/protobuf.cmake b/protobuf.cmake index fe9e723e..1f4c7ef5 100644 --- a/protobuf.cmake +++ b/protobuf.cmake @@ -3,6 +3,10 @@ include(FetchContent) set(Protobuf_USE_STATIC_LIBS ON) cmake_policy(SET CMP0026 OLD) +if(NOT DEFINED CMAKE_NUM_THREADS) + set(CMAKE_NUM_THREADS "16") +endif() + FetchContent_Declare( protocolbuffers_protobuf GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git @@ -19,33 +23,36 @@ set(Protobuf_ROOT ${protocolbuffers_protobuf_SOURCE_DIR}) message(STATUS "Setting up protobuf ...") execute_process( COMMAND - ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -D protobuf_BUILD_TESTS=OFF -D protobuf_BUILD_PROTOC_BINARIES=ON -D CMAKE_POSITION_INDEPENDENT_CODE=ON -G "${CMAKE_GENERATOR}" . + ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -D protobuf_BUILD_TESTS=OFF -D protobuf_BUILD_PROTOC_BINARIES=ON -D CMAKE_POSITION_INDEPENDENT_CODE=ON -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE result WORKING_DIRECTORY ${Protobuf_ROOT}) + if(result) message(FATAL_ERROR "Failed to download protobuf (${result})!") endif() message(STATUS "Building protobuf ...") execute_process( - COMMAND ${CMAKE_COMMAND} --build . --parallel + COMMAND ${CMAKE_COMMAND} --build . --parallel ${CMAKE_NUM_THREADS} RESULT_VARIABLE result WORKING_DIRECTORY ${Protobuf_ROOT}) + if(result) message(FATAL_ERROR "Failed to build protobuf (${result})!") endif() message(STATUS "Installing protobuf ...") execute_process( - COMMAND ${CMAKE_COMMAND} --install . --config ${CMAKE_BUILD_TYPE} --prefix ${Protobuf_ROOT}/install -RESULT_VARIABLE result -WORKING_DIRECTORY ${Protobuf_ROOT}) + COMMAND ${CMAKE_COMMAND} --install . --config ${CMAKE_BUILD_TYPE} --prefix ${Protobuf_ROOT}/install + RESULT_VARIABLE result + WORKING_DIRECTORY ${Protobuf_ROOT}) + if(result) - message(FATAL_ERROR "Failed to build protobuf (${result})!") + message(FATAL_ERROR "Failed to build protobuf (${result})!") endif() -if (NOT EXISTS ${Protobuf_ROOT}/install/lib64) - file (CREATE_LINK ${Protobuf_ROOT}/install/lib ${Protobuf_ROOT}/install/lib64 SYMBOLIC) +if(NOT EXISTS ${Protobuf_ROOT}/install/lib64) + file(CREATE_LINK ${Protobuf_ROOT}/install/lib ${Protobuf_ROOT}/install/lib64 SYMBOLIC) endif() find_package(Protobuf CONFIG REQUIRED HINTS ${Protobuf_ROOT}/install/lib64/cmake) @@ -67,7 +74,7 @@ if(Protobuf_FOUND) else() message( FATAL_ERROR - "Protobuf package not found -> specify search path via Protobuf_ROOT variable" + "Protobuf package not found -> specify search path via Protobuf_ROOT variable" ) endif()