-
Notifications
You must be signed in to change notification settings - Fork 7
merge CMake build process and Python wrapper shared library into main #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
adamant-pwn
wants to merge
4
commits into
main
Choose a base branch
from
cmake_merge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,545
−335
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Docker Build and Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
workflow_dispatch: | ||
inputs: | ||
use_cache: | ||
description: 'Use cache for this run' | ||
required: true | ||
default: 'true' | ||
num_build_jobs: | ||
description: 'Number of build jobs' | ||
required: true | ||
default: '2' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Delete huge unnecessary tools folder | ||
run: rm -rf /opt/hostedtoolcache | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Cache build directory | ||
if: github.event_name != 'workflow_dispatch' || github.event.inputs.use_cache == 'true' | ||
uses: actions/cache@v3 | ||
with: | ||
path: build | ||
key: ${{ runner.os }}-build-${{ github.sha }} | ||
restore-keys: | | ||
${{ runner.os }}-build- | ||
|
||
- name: Set lowercase repository owner | ||
id: repo_owner | ||
run: echo "::set-output name=owner::${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]' | ||
|
||
- name: Build Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
load: true | ||
tags: ghcr.io/${{ steps.repo_owner.outputs.owner }}/build_test:latest | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
build-args: | | ||
BUILDKIT_INLINE_CACHE=1 | ||
RAWHASH_NUM_BUILD_JOBS=${{ github.event.inputs.num_build_jobs || '2' }} | ||
|
||
- name: Extract build directory from Docker image | ||
run: | | ||
container_id=$(docker create ghcr.io/${{ steps.repo_owner.outputs.owner }}/build_test:latest) | ||
docker cp $container_id:/rawhash2/build ./build | ||
docker rm $container_id | ||
|
||
- name: Run Docker container | ||
run: docker run --rm ghcr.io/${{ steps.repo_owner.outputs.owner }}/build_test:latest -h |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
project(RawHash2Root) | ||
|
||
add_subdirectory(src) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM gcc:latest | ||
|
||
RUN apt-get update && apt-get install -y \ | ||
cmake make mold ccache \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
WORKDIR /rawhash2 | ||
COPY . /rawhash2 | ||
|
||
ARG RAWHASH_NUM_BUILD_JOBS | ||
RUN mkdir -p build && cd build \ | ||
&& cmake .. \ | ||
&& make -j $RAWHASH_NUM_BUILD_JOBS | ||
|
||
ENTRYPOINT ["./build/bin/rawhash2"] | ||
|
||
LABEL Name=rawhash2 Version=0.0.1 |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
function(enable_ccache) | ||
# export PATH="/usr/lib/ccache:$PATH" | ||
find_program(CCACHE_EXE ccache) | ||
if(CCACHE_EXE) | ||
message(STATUS "found ccache at ${CCACHE_EXE}, using it") | ||
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_EXE}" CACHE STRING "C compiler launcher") | ||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_EXE}" CACHE STRING "C++ compiler launcher") | ||
else() | ||
message(STATUS "ccache not found, not using it") | ||
endif() | ||
endfunction() | ||
|
||
# mold is a much faster linker than ld, also see for mold: https://github.com/heavyai/heavydb/blob/master/CMakeLists.txt | ||
# or try: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8861, can now use CMAKE_LINKER_TYPE | ||
macro(set_alternate_linker linker) | ||
find_program(LINKER_EXECUTABLE ld.${linker} ${linker}) | ||
if(LINKER_EXECUTABLE) | ||
message(STATUS "Found linker ${linker}: ${LINKER_EXECUTABLE}") | ||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 12.0.0) | ||
add_link_options("-ld-path=${linker}") | ||
elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS 12.1.0 AND "${linker}" STREQUAL "mold") | ||
# LINKER_EXECUTABLE will be a full path to ld.mold, so we replace the end of the path, resulting in the relative | ||
# libexec/mold dir, and tell GCC to look there first for an override version of executables, in this case, ld | ||
string(REPLACE "bin/ld.mold" "libexec/mold" PATH_TO_LIBEXEC_MOLD ${LINKER_EXECUTABLE}) | ||
add_link_options("-B${PATH_TO_LIBEXEC_MOLD}") | ||
else() | ||
add_link_options("-fuse-ld=${linker}") | ||
endif() | ||
else() | ||
message(FATAL_ERROR "Could not find linker ${linker}") | ||
endif() | ||
endmacro() | ||
|
||
# not working | ||
# function(setup_ccache_mold) | ||
# if(USE_CCACHE) | ||
# find_program(CCACHE_PROGRAM ccache) | ||
# if(CCACHE_PROGRAM) | ||
# message(STATUS "ccache found: ${CCACHE_PROGRAM}") | ||
# set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") | ||
# set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}") | ||
# else() | ||
# message(WARNING "ccache not found, using default compiler") | ||
# endif() | ||
# endif() | ||
|
||
# if(USE_MOLD) | ||
# find_program(MOLD_PROGRAM mold) | ||
# # todo: does not seem to work, for a working configuration, see https://github.com/ratschlab/readuntil_fake/blob/refactor/cmake/utils.cmake | ||
# if(MOLD_PROGRAM) | ||
# message(STATUS "mold found: ${MOLD_PROGRAM}") | ||
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=${MOLD_PROGRAM}") | ||
# else() | ||
# message(WARNING "mold not found, using default linker") | ||
# endif() | ||
# endif() | ||
# endfunction() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
include(${CMAKE_CURRENT_LIST_DIR}/Utils.cmake) | ||
|
||
function(add_hdf5_to_target TARGET_NAME) | ||
if(NOHDF5) | ||
target_compile_definitions(${TARGET_NAME} PRIVATE NHDF5RH=1) | ||
else() | ||
if(HDF5_COMPILE) | ||
add_dependencies(${TARGET_NAME} hdf5_build) | ||
endif() | ||
add_imported_library(${TARGET_NAME} hdf5) | ||
endif() | ||
endfunction() | ||
|
||
function(setup_hdf5) | ||
if(NOT NOHDF5) | ||
# print HDF5_DIR | ||
message(STATUS "EXTERNAL_PROJECTS_BUILD_DIR: ${EXTERNAL_PROJECTS_BUILD_DIR}") | ||
message(STATUS "HDF5_DIR: ${HDF5_DIR}") | ||
set(HDF5_SOURCE_DIR ${CMAKE_SOURCE_DIR}/extern/hdf5) | ||
if(HDF5_COMPILE) | ||
if(NOT HDF5_DIR) | ||
override_cached(HDF5_DIR ${EXTERNAL_PROJECTS_BUILD_DIR}/hdf5) | ||
endif() | ||
set(HDF5_BUILD_DIR ${HDF5_DIR}/build) | ||
ExternalProject_Add( | ||
hdf5_build | ||
BUILD_ALWAYS 1 # Rebuild if local checkout is updated | ||
SOURCE_DIR ${HDF5_SOURCE_DIR} | ||
BINARY_DIR ${HDF5_BUILD_DIR} | ||
CONFIGURE_COMMAND ${HDF5_SOURCE_DIR}/configure --enable-threadsafe --disable-hl --prefix=${HDF5_BUILD_DIR} | ||
# INSTALL_DIR and DCMAKE_INSTALL_PREFIX are ignored by hdf5 | ||
INSTALL_COMMAND make install prefix=${HDF5_DIR} | ||
) | ||
else() | ||
if(NOT HDF5_DIR) | ||
message(FATAL_ERROR "HDF5_COMPILE is OFF, but no dir provided") | ||
endif() | ||
endif() | ||
define_imported_library(hdf5 ${HDF5_DIR} SHARED) | ||
endif() | ||
endfunction() |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should keep this