Skip to content

Commit

Permalink
Merge pull request elalish#157 from elalish/organize2
Browse files Browse the repository at this point in the history
Reorganize Directories
  • Loading branch information
elalish committed Jul 20, 2022
2 parents 3705da3 + fd0a488 commit 38e9901
Show file tree
Hide file tree
Showing 73 changed files with 175 additions and 224 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/check_format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: clang-format
run: ./clang-format.sh
- uses: DoozyX/clang-format-lint-action@v0.14
with:
source: '.'
exclude: '*/third_party'
extensions: 'h,cpp'
clangFormatVersion: 12

12 changes: 6 additions & 6 deletions .github/workflows/manifold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Build ${{matrix.backend}}
run: |
# patch assimp
patch third_party/assimp/code/CMakeLists.txt < assimp.diff
patch test/third_party/assimp/code/CMakeLists.txt < assimp.diff
git apply thrust.diff
mkdir build
cd build
Expand All @@ -41,11 +41,11 @@ jobs:
# note that the test for CUDA backend does not really test CUDA, as we
# don't have CUDA GPU on GitHub Action
run: |
export PYTHONPATH=$PYTHONPATH:$(pwd)/build/tools
export PYTHONPATH=$PYTHONPATH:$(pwd)/build/bindings/python
cd build/test
./manifold_test
cd ../../
python3 test/python/run_all.py
python3 bindings/python/examples/run_all.py
- name: Coverage Report
# only do code coverage for default sequential backend, it seems that TBB
# backend will cause failure
Expand All @@ -60,7 +60,7 @@ jobs:
cd ../
lcov --capture --directory . --output-file ./code_coverage_test.info
lcov --add-tracefile ./code_coverage_init.info --add-tracefile ./code_coverage_test.info --output-file ./code_coverage_total.info
lcov --remove ./code_coverage_total.info '/usr/*' '*/third_party/*' '*/test/*' '*/tools/*' --output-file ./code_coverage.info
lcov --remove ./code_coverage_total.info '/usr/*' '*/third_party/*' '*/test/*' '*/extras/*' '*/bindings/*' --output-file ./code_coverage.info
- uses: codecov/codecov-action@v2
if: matrix.parallel_backend == 'NONE' && matrix.cuda_support == 'OFF'
with:
Expand Down Expand Up @@ -91,7 +91,7 @@ jobs:
run: |
source ./emsdk/emsdk_env.sh
# patch assimp
patch third_party/assimp/code/CMakeLists.txt < assimp.diff
patch test/third_party/assimp/code/CMakeLists.txt < assimp.diff
git apply thrust.diff
mkdir build
cd build
Expand All @@ -116,7 +116,7 @@ jobs:
- uses: jwlawson/actions-setup-cmake@v1.12
- name: Patch assimp
shell: bash
run: patch third_party/assimp/code/CMakeLists.txt < assimp.diff
run: patch test/third_party/assimp/code/CMakeLists.txt < assimp.diff
- uses: ilammy/msvc-dev-cmd@v1
- name: Install CUDA
if: matrix.backend == 'CUDA'
Expand Down
10 changes: 5 additions & 5 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[submodule "third_party/assimp"]
path = third_party/assimp
path = test/third_party/assimp
url = https://github.com/assimp/assimp
[submodule "third_party/thrust"]
path = third_party/thrust
path = src/third_party/thrust
url = https://github.com/NVIDIA/thrust
[submodule "third_party/glm"]
path = third_party/glm
path = src/third_party/glm
url = https://github.com/g-truc/glm
[submodule "third_party/google_test"]
path = third_party/google_test
path = test/third_party/google_test
url = https://github.com/google/googletest.git
[submodule "third_party/pybind11"]
path = third_party/pybind11
path = bindings/python/third_party/pybind11
url = https://github.com/pybind/pybind11
branch = stable
24 changes: 8 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ option(BUILD_TEST_CGAL off)

option(BUILD_SHARED_LIBS off)
set(ASSIMP_INC_DIR
${PROJECT_SOURCE_DIR}/third_party/assimp/include
${CMAKE_BINARY_DIR}/third_party/assimp/include)
set(GLM_INC_DIR ${PROJECT_SOURCE_DIR}/third_party/glm)
set(PYBIND11_DIR ${PROJECT_SOURCE_DIR}/third_party/pybind11)
${PROJECT_SOURCE_DIR}/test/third_party/assimp/include
${CMAKE_BINARY_DIR}/test/third_party/assimp/include)
set(GLM_INC_DIR ${PROJECT_SOURCE_DIR}/src/third_party/glm)
set(PYBIND11_DIR ${PROJECT_SOURCE_DIR}/bindings/python/third_party/pybind11)

option(ASSIMP_FAST_BUILD "build ASSIMP just for tests" ON)

Expand All @@ -39,7 +39,7 @@ if(ASSIMP_FAST_BUILD)
endforeach()
endif()

set(THRUST_INC_DIR ${PROJECT_SOURCE_DIR}/third_party/thrust)
set(THRUST_INC_DIR ${PROJECT_SOURCE_DIR}/src/third_party/thrust)

if(MANIFOLD_USE_CUDA)
enable_language(CUDA)
Expand Down Expand Up @@ -70,16 +70,8 @@ if(CODE_COVERAGE AND NOT MSVC)
add_link_options("-coverage")
endif()

add_subdirectory(utilities)
add_subdirectory(third_party)
add_subdirectory(collider)
add_subdirectory(polygon)
add_subdirectory(manifold)
add_subdirectory(meshIO)
add_subdirectory(src)
add_subdirectory(samples)
add_subdirectory(test)
add_subdirectory(tools)

if(EMSCRIPTEN)
add_subdirectory(wasm)
endif()
add_subdirectory(extras)
add_subdirectory(bindings)
6 changes: 3 additions & 3 deletions assimp.diff
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
diff a/third_party/assimp/code/CMakeLists.txt b/third_party/assimp/code/CMakeLists.txt
--- a/third_party/assimp/code/CMakeLists.txt
+++ b/third_party/assimp/code/CMakeLists.txt
diff a/test/third_party/assimp/code/CMakeLists.txt b/test/third_party/assimp/code/CMakeLists.txt
--- a/test/third_party/assimp/code/CMakeLists.txt
+++ b/test/third_party/assimp/code/CMakeLists.txt
@@ -1176,13 +1176,6 @@ ADD_LIBRARY(assimp::assimp ALIAS assimp)

TARGET_USE_COMMON_OUTPUT_DIRECTORY(assimp)
Expand Down
8 changes: 8 additions & 0 deletions bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

if(NOT EMSCRIPTEN)
add_subdirectory(python)
endif()

if(EMSCRIPTEN)
add_subdirectory(wasm)
endif()
10 changes: 10 additions & 0 deletions bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
project(python)

add_subdirectory(third_party)
pybind11_add_module(pymanifold pymanifold.cpp)
target_link_libraries(pymanifold PRIVATE manifold meshIO)
target_compile_options(pymanifold PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(pymanifold PUBLIC cxx_std_14)
target_include_directories(pymanifold
PRIVATE ${PYBIND11_DIR}/include
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions bindings/python/third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(pybind11)
4 changes: 2 additions & 2 deletions wasm/CMakeLists.txt → bindings/wasm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
project (wasm)
project(wasm)

add_executable(manifoldjs bindings.cpp)
target_link_libraries(manifoldjs manifold)
target_compile_options(manifoldjs PRIVATE ${MANIFOLD_FLAGS} -fexceptions)
target_link_options(manifoldjs PUBLIC --bind)
target_compile_features(manifoldjs PUBLIC cxx_std_14)
set_target_properties(manifoldjs PROPERTIES OUTPUT_NAME "manifold")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/index.html DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/examples/index.html DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
57 changes: 57 additions & 0 deletions bindings/wasm/bindings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#include <emscripten/bind.h>

using namespace emscripten;

#include <manifold.h>

using namespace manifold;

Manifold Union(Manifold& a, Manifold& b) { return a + b; }
void Add(Manifold& a, Manifold& b) { a += b; }

Manifold Difference(Manifold& a, Manifold& b) { return a - b; }
void Subtract(Manifold& a, Manifold& b) { a -= b; }

Manifold Intersection(Manifold& a, Manifold& b) { return a ^ b; }
void Intersect(Manifold& a, Manifold& b) { a ^= b; }

EMSCRIPTEN_BINDINGS(whatever) {
value_object<glm::ivec3>("ivec3")
.field("0", &glm::ivec3::x)
.field("1", &glm::ivec3::y)
.field("2", &glm::ivec3::z);

register_vector<glm::ivec3>("Vector_ivec3");

value_object<glm::vec3>("vec3")
.field("x", &glm::vec3::x)
.field("y", &glm::vec3::y)
.field("z", &glm::vec3::z);

register_vector<glm::vec3>("Vector_vec3");

value_object<glm::vec4>("vec4")
.field("x", &glm::vec4::x)
.field("y", &glm::vec4::y)
.field("z", &glm::vec4::z)
.field("w", &glm::vec4::w);

register_vector<glm::vec4>("Vector_vec4");

value_object<Mesh>("Mesh")
.field("vertPos", &Mesh::vertPos)
.field("triVerts", &Mesh::triVerts)
.field("vertNormal", &Mesh::vertNormal)
.field("halfedgeTangent", &Mesh::halfedgeTangent);

class_<Manifold>("Manifold")
.constructor<Mesh>()
.function("Add", &Add)
.function("Subtract", &Subtract)
.function("Intersect", &Intersect)
.function("GetMesh", &Manifold::GetMesh);

function("Union", &Union);
function("Difference", &Difference);
function("Intersection", &Intersection);
}
File renamed without changes.
9 changes: 0 additions & 9 deletions clang-format.sh

This file was deleted.

1 change: 1 addition & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set -x

DEPLOYABLE_STATIC_FILES=( \
samples/models \
bindings/wasm/examples \
)

PACKAGE_ROOT=`pwd`
Expand Down
25 changes: 25 additions & 0 deletions extras/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
project(extras)

add_executable(perfTest perf_test.cpp)
target_link_libraries(perfTest manifold)

target_compile_options(perfTest PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(perfTest PUBLIC cxx_std_14)

if(BUILD_TEST_CGAL)
add_executable(perfTestCGAL perf_test_cgal.cpp)
find_package(CGAL REQUIRED COMPONENTS Core)
target_compile_definitions(perfTestCGAL PRIVATE CGAL_USE_GMPXX)

# target_compile_definitions(perfTestCGAL PRIVATE CGAL_DEBUG)
target_link_libraries(perfTestCGAL manifold CGAL::CGAL CGAL::CGAL_Core)

target_compile_options(perfTestCGAL PRIVATE ${MANIFOLD_FLAGS})
target_compile_features(perfTestCGAL PUBLIC cxx_std_14)
endif()

# add_executable(playground playground.cpp)
# target_link_libraries(playground manifold meshIO samples)

# target_compile_options(playground PRIVATE ${MANIFOLD_FLAGS})
# target_compile_features(playground PUBLIC cxx_std_14)
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 7 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,15 @@
cd test
./manifold_test
cd ../../
PYTHONPATH=$PYTHONPATH:$(pwd)/build/tools python3 test/python/run_all.py
PYTHONPATH=$PYTHONPATH:$(pwd)/build/bindings/python python3 bindings/python/examples/run_all.py
cd build
'';
installPhase = ''
mkdir -p $out
cp manifold/libmanifold.a $out/
cp meshIO/libmeshIO.a $out/
cp tools/loadMesh $out
cp tools/perfTest $out
cp tools/pymanifold* $out
cp src/manifold/libmanifold.a $out/
cp test/meshIO/libmeshIO.a $out/
cp extras/perfTest $out
cp bindings/python/pymanifold* $out
'';
};
parallelBackends = [
Expand Down Expand Up @@ -115,8 +114,8 @@
'';
installPhase = ''
mkdir -p $out
cp {tools,wasm}/*.js $out/
cp {tools,wasm}/*.wasm $out/
cp {extras,wasm}/*.js $out/
cp {extras,wasm}/*.wasm $out/
'';
};
};
Expand Down
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_subdirectory(third_party)
add_subdirectory(utilities)
add_subdirectory(collider)
add_subdirectory(polygon)
add_subdirectory(manifold)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_subdirectory(graphlite)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 13 additions & 9 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
project (manifold_test)
project(manifold_test)

add_subdirectory(third_party)
add_subdirectory(meshIO)

enable_testing()

file(GLOB_RECURSE SOURCE_FILES CONFIGURE_DEPENDS *.cpp)
set(SOURCE_FILES polygon_test.cpp mesh_test.cpp samples_test.cpp test_main.cpp)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} polygon GTest::GTest manifold meshIO samples)

Expand All @@ -12,17 +15,18 @@ target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)
add_test(test_all ${PROJECT_NAME})

file(COPY data DESTINATION . FILES_MATCHING PATTERN "*.ply")

if(EMSCRIPTEN)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS
"-s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1 --preload-file data --bind")
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS
"-s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1 --preload-file data --bind")
else()
endif()

if(APPLE)
# All executables that link to CUDA need this. If you ever get
# "CUDA driver version is insufficient for CUDA runtime version",
# this is probably what's missing.
# All executables that link to CUDA need this. If you ever get
# "CUDA driver version is insufficient for CUDA runtime version",
# this is probably what's missing.
set_property(TARGET ${PROJECT_NAME}
PROPERTY
BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
PROPERTY
BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
6 changes: 3 additions & 3 deletions meshIO/CMakeLists.txt → test/meshIO/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
project (meshIO)
project(meshIO)

add_library(${PROJECT_NAME} src/meshIO.cpp)

target_include_directories( ${PROJECT_NAME}
target_include_directories(${PROJECT_NAME}
PUBLIC ${PROJECT_SOURCE_DIR}/include ${ASSIMP_INC_DIR}
)

target_link_libraries( ${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME}
PUBLIC utilities
PRIVATE assimp
)
Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 38e9901

Please sign in to comment.