Skip to content

Commit

Permalink
add SimpleArray caster
Browse files Browse the repository at this point in the history
  • Loading branch information
tigercosmos committed Jan 27, 2024
1 parent e024978 commit 451b4f3
Show file tree
Hide file tree
Showing 22 changed files with 1,267 additions and 28 deletions.
43 changes: 33 additions & 10 deletions .github/workflows/devbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,15 @@ jobs:
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=OFF \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
make buildext VERBOSE=1
- name: make pytest BUILD_QT=OFF
run: |
python3 -c "import modmesh; assert modmesh.HAS_VIEW == False"
make pytest VERBOSE=1
- name: make buildext BUILD_QT=ON
- name: make buildext BUILD_QT=ON USE_PYTEST_HELPER_BINDING=OFF
run: |
rm -f build/*/Makefile
make cmake \
Expand All @@ -177,7 +177,18 @@ jobs:
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
make buildext VERBOSE=1
- name: make pytest BUILD_QT=ON
# build with pytest helper binding for testing
- name: make buildext BUILD_QT=ON USE_PYTEST_HELPER_BINDING=ON
run: |
rm -f build/*/Makefile
make cmake \
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=ON \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
make buildext VERBOSE=1
- name: make pytest BUILD_QT=ON USE_PYTEST_HELPER_BINDING=ON
run: |
python3 -c "import modmesh; assert modmesh.HAS_VIEW == True"
make pytest VERBOSE=1
Expand All @@ -189,7 +200,7 @@ jobs:
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=ON \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
- name: make run_viewer_pytest
run: |
Expand All @@ -205,7 +216,7 @@ jobs:
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=OFF \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_SANITIZER=OFF"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_SANITIZER=OFF -DUSE_PYTEST_HELPER_BINDING=ON"
make buildext VERBOSE=1
make pytest VERBOSE=1
Expand Down Expand Up @@ -291,7 +302,7 @@ jobs:
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=OFF \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
make buildext VERBOSE=1
- name: make pytest BUILD_QT=OFF
Expand All @@ -302,7 +313,7 @@ jobs:
fi
make pytest ${JOB_MAKE_ARGS}
- name: make buildext BUILD_QT=ON
- name: make buildext BUILD_QT=ON USE_PYTEST_HELPER_BINDING=OFF
run: |
rm -f build/*/Makefile
make cmake \
Expand All @@ -312,7 +323,18 @@ jobs:
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
make buildext VERBOSE=1
- name: make pytest BUILD_QT=ON
# build with pytest helper binding for testing
- name: make buildext BUILD_QT=ON USE_PYTEST_HELPER_BINDING=ON
run: |
rm -f build/*/Makefile
make cmake \
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=ON \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
make buildext VERBOSE=1
- name: make pytest BUILD_QT=ON USE_PYTEST_HELPER_BINDING=ON
run: |
# PySide6 installed by pip will bundle with a prebuilt Qt,
# this will cause duplicated symbol.
Expand All @@ -331,7 +353,7 @@ jobs:
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=ON \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
- name: make run_viewer_pytest
run: |
Expand All @@ -346,7 +368,7 @@ jobs:
VERBOSE=1 USE_CLANG_TIDY=OFF \
BUILD_QT=OFF \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_SANITIZER=OFF"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_SANITIZER=OFF -DUSE_PYTEST_HELPER_BINDING=ON"
make buildext VERBOSE=1
make pytest VERBOSE=1
Expand Down Expand Up @@ -427,6 +449,7 @@ jobs:
cmake `
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} `
-Dpybind11_DIR="$(pybind11-config --cmakedir)" `
-DUSE_PYTEST_HELPER_BINDING=ON `
-S${{ github.workspace }} `
-B${{ github.workspace }}/build
cmake --build ${{ github.workspace }}/build `
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ jobs:
make viewer \
${JOB_MAKE_ARGS} \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
- name: make run_viewer_pytest
run: |
export LD_LIBRARY_PATH=$(python3 -c "import sys, os, shiboken6; sys.stdout.write(os.path.dirname(shiboken6.__file__))")
make run_viewer_pytest \
${JOB_MAKE_ARGS} \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
- name: make flake8
run: |
Expand Down Expand Up @@ -208,7 +208,7 @@ jobs:
make viewer \
${JOB_MAKE_ARGS} \
CMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3)"
CMAKE_ARGS="-DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON"
- name: make run_viewer_pytest
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nouse_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
- name: setup.py install build_ext
run: |
sudo python3 setup.py install build_ext \
--cmake-args="${JOB_CMAKE_ARGS} -DPYTHON_EXECUTABLE=$(which python3)" \
--cmake-args="${JOB_CMAKE_ARGS} -DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON" \
--make-args="VERBOSE=1"
- name: pytest
Expand Down Expand Up @@ -154,7 +154,7 @@ jobs:
# Using pip install instead of legacy install
# ref: https://stackoverflow.com/questions/52375693/troubleshooting-pkg-resources-distributionnotfound-error
python3 -m pip install -v . --no-use-pep517 --global-option=build_ext \
--global-option="--cmake-args=${JOB_CMAKE_ARGS} -DPYTHON_EXECUTABLE=$(which python3)" \
--global-option="--cmake-args=${JOB_CMAKE_ARGS} -DPYTHON_EXECUTABLE=$(which python3) -DUSE_PYTEST_HELPER_BINDING=ON" \
--global-option="--make-args="VERBOSE=1""
- name: pytest
Expand Down
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ option(LINT_AS_ERRORS "clang-tidy warnings as errors" OFF)
option(USE_SANITIZER "use sanitizer (undefined, leak, address)" OFF)


option(USE_PYTEST_HELPER_BINDING "use helper bindings to run pytest. should be ON if the build is for pytest" OFF)
if(USE_PYTEST_HELPER_BINDING)
add_definitions(-D USE_PYTEST_HELPER_BINDING)
endif()
message(STATUS "USE_PYTEST_HELPER_BINDING: ${USE_PYTEST_HELPER_BINDING}")


if(BUILD_QT)
option(QT3D_USE_RHI "Qt use RHI" OFF)
message(STATUS "QT3D_USE_RHI: ${QT3D_USE_RHI}")
Expand Down Expand Up @@ -82,8 +89,10 @@ message(STATUS "DEBUG_SYMBOL: ${DEBUG_SYMBOL}")
if(DEBUG_SYMBOL)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /DEBUG")
add_compile_options(/O2 /Ob2)
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") # /RTC1 incompatible with /O2
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O2")
endif()
endif()

Expand Down
10 changes: 9 additions & 1 deletion contrib/standalone_buffer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,24 @@ $(SETUPROOT)/wrap_ConcreteBuffer.o: $(SETUPROOT)/modmesh/buffer/pymod/wrap_Concr
$(SETUPROOT)/wrap_SimpleArray.o: $(SETUPROOT)/modmesh/buffer/pymod/wrap_SimpleArray.cpp Makefile
c++ $(CFLAGS) -c $< -o $@

$(SETUPROOT)/wrap_SimpleArrayPlex.o: $(SETUPROOT)/modmesh/buffer/pymod/wrap_SimpleArrayPlex.cpp Makefile
c++ $(CFLAGS) -c $< -o $@

$(SETUPROOT)/buffer_pymod.o: $(SETUPROOT)/modmesh/buffer/pymod/buffer_pymod.cpp Makefile
c++ $(CFLAGS) -c $< -o $@

$(SETUPROOT)/SimpleArray.o: $(SETUPROOT)/modmesh/buffer/SimpleArray.cpp Makefile
c++ $(CFLAGS) -c $< -o $@

$(SETUPROOT)/modbuf.o: modbuf.cpp
c++ $(CFLAGS) -c $< -o $@

$(MODPATH): Makefile $(SETUPROOT)/wrap_ConcreteBuffer.o $(SETUPROOT)/wrap_SimpleArray.o $(SETUPROOT)/buffer_pymod.o $(SETUPROOT)/modbuf.o
$(MODPATH): Makefile $(SETUPROOT)/SimpleArray.o $(SETUPROOT)/wrap_ConcreteBuffer.o $(SETUPROOT)/wrap_SimpleArray.o $(SETUPROOT)/wrap_SimpleArrayPlex.o $(SETUPROOT)/buffer_pymod.o $(SETUPROOT)/modbuf.o
c++ $(LDFLAGS) \
$(SETUPROOT)/SimpleArray.o \
$(SETUPROOT)/wrap_ConcreteBuffer.o \
$(SETUPROOT)/wrap_SimpleArray.o \
$(SETUPROOT)/wrap_SimpleArrayPlex.o \
$(SETUPROOT)/buffer_pymod.o \
$(SETUPROOT)/modbuf.o \
-o $@
Expand Down
5 changes: 5 additions & 0 deletions cpp/modmesh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ add_subdirectory(spacetime)
add_subdirectory(view)
add_subdirectory(inout)

if(USE_PYTEST_HELPER_BINDING)
add_subdirectory(testhelper)
endif() # USE_PYTEST_HELPER_BINDING

set(MODMESH_ROOT_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/modmesh.hpp
${CMAKE_CURRENT_SOURCE_DIR}/base.hpp
Expand Down Expand Up @@ -84,6 +88,7 @@ set(MODMESH_TERMINAL_FILES
${MODMESH_SPACETIME_FILES}
${MODMESH_PYTHON_FILES}
${MODMESH_INOUT_FILES}
${MODMESH_TESTHELPER_FILES}
CACHE FILEPATH "" FORCE)

set(MODMESH_GRAPHIC_FILES
Expand Down
3 changes: 3 additions & 0 deletions cpp/modmesh/buffer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,20 @@ set(MODMESH_BUFFER_HEADERS
CACHE FILEPATH "" FORCE)

set(MODMESH_BUFFER_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/SimpleArray.cpp
CACHE FILEPATH "" FORCE)

set(MODMESH_BUFFER_PYMODHEADERS
${CMAKE_CURRENT_SOURCE_DIR}/pymod/buffer_pymod.hpp
${CMAKE_CURRENT_SOURCE_DIR}/pymod/TypeBroadcast.hpp
${CMAKE_CURRENT_SOURCE_DIR}/pymod/SimpleArrayCaster.hpp
CACHE FILEPATH "" FORCE)

set(MODMESH_BUFFER_PYMODSOURCES
${CMAKE_CURRENT_SOURCE_DIR}/pymod/buffer_pymod.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pymod/wrap_ConcreteBuffer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pymod/wrap_SimpleArray.cpp
${CMAKE_CURRENT_SOURCE_DIR}/pymod/wrap_SimpleArrayPlex.cpp
CACHE FILEPATH "" FORCE)

set(MODMESH_BUFFER_FILES
Expand Down
Loading

0 comments on commit 451b4f3

Please sign in to comment.