Skip to content
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

Modular bld #7

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ jobs:
strategy:
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
python: ["3.8", "3.9", "3.10"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
Expand All @@ -30,12 +31,12 @@ jobs:
- name: linux conda build
if: matrix.os == 'ubuntu-latest'
shell: bash -l {0}
run: conda mambabuild -c conda-forge conda-recipe
run: conda mambabuild -c conda-forge --python=${{ matrix.python }} conda-recipe
- name: osx conda build
if: matrix.os == 'macos-latest'
shell: bash -l {0}
run: conda mambabuild -c conda-forge conda-recipe
run: conda mambabuild -c conda-forge --python=${{ matrix.python }} conda-recipe
- name: windows conda build
if: matrix.os == 'windows-latest'
shell: cmd /C CALL {0}
run: conda mambabuild -c conda-forge conda-recipe
run: conda mambabuild -c conda-forge --python=${{ matrix.python }} conda-recipe
42 changes: 25 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ project(dpct)
# user defined configuration
set(WITH_TESTS "false" CACHE BOOL "Build tests.")
set(WITH_LOG "false" CACHE BOOL "Enable logs.")
set(WITH_SHARED_LIB "true" CACHE BOOL "Build shared library.")
set(WITH_PYTHON "true" CACHE BOOL "Build python wrapper.")
set(WITH_TRACKING_BIN "false" CACHE BOOL "Build track executable.")

if(WITH_LOG)
add_definitions(-DDEBUG_LOG)
Expand Down Expand Up @@ -34,7 +36,7 @@ if (NOT WIN32)
endif()

# C++ STL debug symbols
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
set(WITH_DEBUG_STL "False" CACHE BOOL "Build with C++ stl debug symbols?")
if(WITH_DEBUG_STL)
add_definitions(-D_GLIBCXX_DEBUG)
Expand All @@ -47,23 +49,27 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_extensions/)
find_package( Lemon REQUIRED )
include_directories(${LEMON_INCLUDE_DIR})


# ------------------------------------------
# build library
file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS include/*.h)
add_library(dpct SHARED ${SOURCES} ${HEADERS})
target_link_libraries(dpct ${LEMON_LIBRARIES})

# installation
install(TARGETS dpct
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
DESTINATION include/dpct
PATTERN ".h"
PATTERN ".git" EXCLUDE)
if(WITH_SHARED_LIB)
file(GLOB_RECURSE SOURCES src/*.cpp)
file(GLOB_RECURSE HEADERS include/*.h)
add_library(dpct SHARED ${SOURCES} ${HEADERS})
target_link_libraries(dpct ${LEMON_LIBRARIES})

# installation
install(TARGETS dpct
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
DESTINATION include/dpct
PATTERN ".h"
PATTERN ".git" EXCLUDE)
else()
find_package(dpct REQUIRED)
endif()
# ------------------------------------------
# add subdirectories
if(WITH_TESTS)
Expand All @@ -72,7 +78,9 @@ if(WITH_TESTS)
endif()

if(WITH_PYTHON)
add_subdirectory(python)
add_subdirectory(python)
endif()

add_subdirectory(bin)
if(WITH_TRACKING_BIN)
add_subdirectory(bin)
endif()
1 change: 1 addition & 0 deletions conda-recipe/bld.bat → conda-recipe/bld-lib.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cmake .. -G "NMake Makefiles" ^
-DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
-DPYTHON_EXECUTABLE="%PYTHON%" ^
-DWITH_LOG="OFF" ^
-DWITH_PYTHON="OFF" ^
-DBoost_NO_BOOST_CMAKE=ON


Expand Down
41 changes: 41 additions & 0 deletions conda-recipe/bld-py.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
cd build

set CONFIGURATION=Release

REM set LINKER_FLAGS="-L${PREFIX}/lib"
REM set DYLIB="dylib"
REM if [ `uname` != "Darwin" ]; then
REM LINKER_FLAGS="-Wl,-rpath-link,${PREFIX}/lib ${LINKER_FLAGS}"
REM set DYLIB="so"
REM fi

cmake .. -G "NMake Makefiles" ^
-DCMAKE_BUILD_TYPE=%CONFIGURATION% ^
-DCMAKE_PREFIX_PATH="%LIBRARY_PREFIX%" ^
-DCMAKE_INSTALL_PREFIX="%LIBRARY_PREFIX%" ^
-DPYTHON_EXECUTABLE="%PYTHON%" ^
-DWITH_LOG="OFF" ^
-DWITH_PYTHON="ON" ^
-DWITH_SHARED_LIB="OFF" ^
-DBoost_NO_BOOST_CMAKE=ON


if errorlevel 1 exit 1

REM cmake .. \
REM -DCMAKE_C_COMPILER=${PREFIX}/bin/gcc \
REM -DCMAKE_CXX_COMPILER=${PREFIX}/bin/g++ \
REM -DCMAKE_OSX_DEPLOYMENT_TARGET=10.7 \
REM -DCMAKE_INSTALL_PREFIX=${PREFIX} \
REM -DCMAKE_BUILD_TYPE=Release \
REM -DPYTHON_EXECUTABLE=${PYTHON} \
REM -DPYTHON_LIBRARY=${PREFIX}/lib/libpython2.7.${DYLIB} \
REM -DPYTHON_INCLUDE_DIR=${PREFIX}/include/python2.7 \
REM -DPYTHON_INCLUDE_DIR2=${PREFIX}/include/python2.7 \
REM -DWITH_LOG=OFF

nmake all
if errorlevel 1 exit 1

nmake install
if errorlevel 1 exit 1
25 changes: 25 additions & 0 deletions conda-recipe/build-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
mkdir build
cd build

if [ $(uname) == "Darwin" ]; then
LDFLAGS="-undefined dynamic_lookup -L${PREFIX}/lib ${LDFLAGS}"
else
LDFLAGS="-Wl,-rpath-link,${PREFIX}/lib -L${PREFIX}/lib ${LDFLAGS}"
fi

cmake .. \
-DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOSX_DEPLOYMENT_TARGET}" \
-DCMAKE_INSTALL_PREFIX=${PREFIX} \
-DCMAKE_BUILD_TYPE=Release \
-DWITH_LOG=OFF \
-DCMAKE_CXX_LINK_FLAGS="${LDFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DBoost_INCLUDE_DIR=${PREFIX}/include \
-DBoost_LIBRARY_DIRS=${PREFIX}/lib \
-DBoost_PYTHON_LIBRARY=${PREFIX}/lib/libboost_python${CONDA_PY}${SHLIB_EXT} \
-DBoost_NO_BOOST_CMAKE=ON \
-DWITH_PYTHON=OFF \
"${CMAKE_PLATFORM_FLAGS[@]}" \

make -j${CPU_COUNT}
make install
2 changes: 1 addition & 1 deletion conda-recipe/build.sh → conda-recipe/build-py.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mkdir build
cd build

if [ $(uname) == "Darwin" ]; then
Expand All @@ -20,6 +19,7 @@ cmake .. \
-DBoost_LIBRARY_DIRS=${PREFIX}/lib \
-DBoost_PYTHON_LIBRARY=${PREFIX}/lib/libboost_python${CONDA_PY}${SHLIB_EXT} \
-DBoost_NO_BOOST_CMAKE=ON \
-DWITH_PYTHON=ON \
"${CMAKE_PLATFORM_FLAGS[@]}" \

make -j${CPU_COUNT}
Expand Down
4 changes: 1 addition & 3 deletions conda-recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ boost:
lemon:
- 1.3.1
python:
- 3.7 # [not (osx and arm64)]
- 3.8
- 3.9


- 3.10


pin_run_as_build:
Expand Down
111 changes: 71 additions & 40 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,51 +1,82 @@
package:
name: dpct

{% set tagged_version = GIT_DESCRIBE_TAG %}

# If we're using a non-tagged revision, append '.postN' to the version
{% if GIT_DESCRIBE_NUMBER|int != 0 %}
{% set tagged_version = tagged_version + '.post' + GIT_DESCRIBE_NUMBER %}
{% endif %}
# {% set dpct_version = "1.0.0" %}
{% set dpct_version = GIT_DESCRIBE_TAG %}

version: {{tagged_version}}
# If we're using a non-tagged revision, append '.postN' to the version
{% if GIT_DESCRIBE_NUMBER is defined %}
{% if GIT_DESCRIBE_NUMBER|int != 0 %}
{% set dpct_version = dpct_version + '.post' + GIT_DESCRIBE_NUMBER %}
{% endif %}
{% endif %}

source:
path: ../
package:
name: libdpct
version: {{ dpct_version }}

build:
number: 0
string: py{{CONDA_PY}}_{{PKG_BUILDNUM}}_h{{PKG_HASH}}_g{{GIT_FULL_HASH[:7]}}
skip:
true # [py2k]

requirements:
build:
- cross-python_{{ target_platform }} # [build_platform != target_platform]
- python # [build_platform != target_platform]
- cython # [build_platform != target_platform]
- cmake
- make # [not win]
- {{ compiler("c") }}
- {{ compiler("cxx") }}
host:
- boost {{ boost }}*
- lemon {{ lemon }}*
- python
run:
- {{ pin_compatible('boost') }}
- lemon {{ lemon }}
- {{ pin_compatible('python') }}

test:
source_files:
- test

imports:
- dpct

commands:
- python test/test.py
source:
path: ../

outputs:
- name: libdpct

version: {{ dpct_version }}
script: build-lib.sh # [not win]
script: bld-lib.bat # [win]
build:
run_exports:
- {{ pin_subpackage('libdpct', max_pin="x.x") }}


requirements:
build:
- cmake
- make # [not win]
- {{ compiler("c") }}
- {{ compiler("cxx") }}
host:
- lemon {{ lemon }}*
run:
- lemon {{ lemon }}

- name: dpct
version: {{ dpct_version }}
script: build-py.sh # [not win]
script: bld-py.bat # [win]

requirements:
build:
# - cross-python_{{ target_platform }} # [build_platform != target_platform]
- python # [build_platform != target_platform]
- cython # [build_platform != target_platform]
- cmake
- make # [not win]
- {{ compiler("c") }}
- {{ compiler("cxx") }}
host:
- {{ pin_subpackage('libdpct', exact=True) }}
- boost {{ boost }}*
- lemon {{ lemon }}*
- python
run:
- {{ pin_subpackage('libdpct', exact=True) }}
- libdpct
- {{ pin_compatible('boost') }}
- {{ pin_compatible('python') }}


test:
source_files:
- test

imports:
- dpct

commands:
- python test/test.py

about:
home: https://github.com/chaubold/dpct
Expand Down
Loading