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

chores #833

Merged
merged 26 commits into from
Jun 28, 2024
Merged
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
6 changes: 5 additions & 1 deletion .github/workflows/manifold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ jobs:
timeout-minutes: 30
runs-on: ubuntu-22.04
if: github.event.pull_request.draft == false
strategy:
matrix:
exception: [ON, OFF]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to build WASM with exceptions off? Maybe better to test one of the nix builds since they're fast?

Copy link
Contributor

@fire fire Jun 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If testing generally exceptions off is the test. then it could be linux.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fire I think your earlier comment mentioned you do build WASM with exceptions off - that requires special CMake instructions which I was considering removing since JS is generally exceptions-based. But if WASM sans exceptions is actually useful to someone, then @pca006132 has it set up properly now. Do you build for WASM without exceptions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would expect to build Godot Engine WASM without exceptions since the Godot Engine editor and Godot Engine game templates build without exceptions in the default configuration on all platforms.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Okay, let's leave it as is in this PR then.

steps:
- name: Install dependencies
run: |
Expand All @@ -128,7 +131,7 @@ jobs:
source ./emsdk/emsdk_env.sh
mkdir build
cd build
emcmake cmake -DCMAKE_BUILD_TYPE=Release .. && emmake make
emcmake cmake -DCMAKE_BUILD_TYPE=Release -DMANIFOLD_EXCEPTIONS=${{matrix.exception}} .. && emmake make
- name: Test WASM
run: |
cd build/test
Expand All @@ -142,6 +145,7 @@ jobs:
cp ../manifold.* ./dist/
- name: Upload WASM files
uses: actions/upload-artifact@v4
if: matrix.exception == 'ON'
with:
name: wasm
path: bindings/wasm/examples/dist/
Expand Down
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ option(MANIFOLD_DEBUG "Enable debug tracing/timing" OFF)
option(MANIFOLD_PYBIND "Build python bindings" OFF)
option(MANIFOLD_CBIND "Build C (FFI) bindings" ON)
option(MANIFOLD_JSBIND "Build js binding" ${EMSCRIPTEN})
option(MANIFOLD_EXCEPTIONS "Build manifold with exception enabled" ON)
option(BUILD_SHARED_LIBS "Build shared library" ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -59,8 +60,13 @@ endif()

if(EMSCRIPTEN)
message("Building for Emscripten")
set(MANIFOLD_FLAGS -fexceptions -D_LIBCUDACXX_HAS_THREAD_API_EXTERNAL -D_LIBCUDACXX_HAS_THREAD_API_CUDA)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sALLOW_MEMORY_GROWTH=1 -fexceptions -sDISABLE_EXCEPTION_CATCHING=0")
if(MANIFOLD_EXCEPTIONS)
set(MANIFOLD_FLAGS -fexceptions -D_LIBCUDACXX_HAS_THREAD_API_EXTERNAL -D_LIBCUDACXX_HAS_THREAD_API_CUDA)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sALLOW_MEMORY_GROWTH=1 -fexceptions -sDISABLE_EXCEPTION_CATCHING=0")
else()
set(MANIFOLD_FLAGS -D_LIBCUDACXX_HAS_THREAD_API_EXTERNAL -D_LIBCUDACXX_HAS_THREAD_API_CUDA)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -sALLOW_MEMORY_GROWTH=1")
endif()
set(MANIFOLD_PYBIND OFF)
set(BUILD_SHARED_LIBS OFF)
endif()
Expand All @@ -86,10 +92,10 @@ if (MSVC)
set(MANIFOLD_FLAGS ${MANIFOLD_FLAGS} /DNOMINMAX /bigobj)
else()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(WARNING_FLAGS -Werror -Wall -Wno-sign-compare -Wno-unused -Wno-array-bounds
set(WARNING_FLAGS -Werror -Wall -Wno-unused -Wno-array-bounds
-Wno-stringop-overflow -Wno-alloc-size-larger-than)
else()
set(WARNING_FLAGS -Werror -Wall -Wno-sign-compare -Wno-unused)
set(WARNING_FLAGS -Werror -Wall -Wno-unused)
endif()
set(MANIFOLD_FLAGS ${MANIFOLD_FLAGS} ${WARNING_FLAGS})
endif()
Expand Down
6 changes: 3 additions & 3 deletions bindings/c/conv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,23 +227,23 @@ glm::vec4 from_c(ManifoldVec4 v) { return glm::vec4(v.x, v.y, v.z, v.w); }

std::vector<glm::vec3> vector_of_vec_array(ManifoldVec3 *vs, size_t length) {
auto vec = std::vector<glm::vec3>();
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
vec.push_back(from_c(vs[i]));
}
return vec;
}

std::vector<glm::ivec3> vector_of_vec_array(ManifoldIVec3 *vs, size_t length) {
auto vec = std::vector<glm::ivec3>();
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
vec.push_back(from_c(vs[i]));
}
return vec;
}

std::vector<glm::vec4> vector_of_vec_array(ManifoldVec4 *vs, size_t length) {
auto vec = std::vector<glm::vec4>();
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
vec.push_back(from_c(vs[i]));
}
return vec;
Expand Down
2 changes: 1 addition & 1 deletion bindings/c/include/conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ std::vector<glm::vec4> vector_of_vec_array(ManifoldVec4 *vs, size_t length);
template <typename T>
std::vector<T> vector_of_array(T *ts, size_t length) {
auto vec = std::vector<T>();
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
vec.push_back(ts[i]);
}
return vec;
Expand Down
4 changes: 2 additions & 2 deletions bindings/c/include/manifoldc.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ ManifoldManifold *manifold_sphere(void *mem, float radius,
int circular_segments);
ManifoldManifold *manifold_of_meshgl(void *mem, ManifoldMeshGL *mesh);
ManifoldManifold *manifold_smooth(void *mem, ManifoldMeshGL *mesh,
int *half_edges, float *smoothness,
int n_idxs);
size_t *half_edges, float *smoothness,
size_t n_idxs);
ManifoldManifold *manifold_extrude(void *mem, ManifoldPolygons *cs,
float height, int slices,
float twist_degrees, float scale_x,
Expand Down
13 changes: 6 additions & 7 deletions bindings/c/manifoldc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern "C" {
ManifoldSimplePolygon *manifold_simple_polygon(void *mem, ManifoldVec2 *ps,
size_t length) {
auto vec = new (mem) std::vector<glm::vec2>;
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
vec->push_back({ps[i].x, ps[i].y});
}
return to_c(vec);
Expand All @@ -68,7 +68,7 @@ ManifoldPolygons *manifold_polygons(void *mem, ManifoldSimplePolygon **ps,
size_t length) {
auto vec = new (mem) std::vector<SimplePolygon>;
auto polys = reinterpret_cast<SimplePolygon **>(ps);
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
vec->push_back(*polys[i]);
}
return to_c(vec);
Expand Down Expand Up @@ -215,7 +215,7 @@ ManifoldManifold *manifold_batch_hull(void *mem, ManifoldManifoldVec *ms) {
ManifoldManifold *manifold_hull_pts(void *mem, ManifoldVec3 *ps,
size_t length) {
std::vector<glm::vec3> vec(length);
for (int i = 0; i < length; ++i) {
for (size_t i = 0; i < length; ++i) {
vec[i] = {ps[i].x, ps[i].y, ps[i].z};
}
auto hulled = Manifold::Hull(vec);
Expand Down Expand Up @@ -366,10 +366,10 @@ ManifoldMeshGL *manifold_meshgl_w_tangents(void *mem, float *vert_props,
}

ManifoldManifold *manifold_smooth(void *mem, ManifoldMeshGL *mesh,
int *half_edges, float *smoothness,
int n_edges) {
size_t *half_edges, float *smoothness,
size_t n_edges) {
auto smooth = std::vector<Smoothness>();
for (int i = 0; i < n_edges; ++i) {
for (size_t i = 0; i < n_edges; ++i) {
smooth.push_back({half_edges[i], smoothness[i]});
}
auto m = Manifold::Smooth(*from_c(mesh), smooth);
Expand All @@ -391,7 +391,6 @@ ManifoldManifold *manifold_extrude(void *mem, ManifoldPolygons *cs,
}

ManifoldManifold *manifold_revolve(void *mem, ManifoldPolygons *cs,

int circular_segments) {
auto m = Manifold::Revolve(*from_c(cs), circular_segments);
return to_c(new (mem) Manifold(m));
Expand Down
Loading
Loading