Skip to content

Commit 87222b0

Browse files
committed
refine the code
1 parent 1b50716 commit 87222b0

File tree

7 files changed

+49
-23
lines changed

7 files changed

+49
-23
lines changed

CMakeLists.txt

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -773,29 +773,7 @@ if(OCOS_ENABLE_C_API)
773773
endif()
774774

775775
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
776-
if(NOT OCOS_ENABLE_STATIC_LIB)
777-
# Emscripten does not support building a shared library with custom ops.
778-
# and backward compatible with the previous version, we silently turn off the shared library build.
779-
set(OCOS_BUILD_SHARED_LIB OFF CACHE INTERNAL "" FORCE)
780-
add_executable(ortcustomops ${_TARGET_LIB_SRC})
781-
set_target_properties(ortcustomops PROPERTIES LINK_FLAGS " \
782-
-s WASM=1 \
783-
-s NO_EXIT_RUNTIME=0 \
784-
-s ALLOW_MEMORY_GROWTH=1 \
785-
-s SAFE_HEAP=0 \
786-
-s MODULARIZE=1 \
787-
-s SAFE_HEAP_LOG=0 \
788-
-s STACK_OVERFLOW_CHECK=0 \
789-
-s EXPORT_ALL=0 \
790-
-s VERBOSE=0 \
791-
--no-entry")
792-
793-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
794-
set_property(TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1")
795-
else()
796-
set_property(TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=0 -s DEMANGLE_SUPPORT=0")
797-
endif()
798-
endif()
776+
include(ext_wasm)
799777
else()
800778
add_library(ortcustomops STATIC ${_TARGET_LIB_SRC})
801779
if (HAS_SDL)

cmake/ext_apple_framework.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin|iOS")
25
message(FATAL_ERROR "Building an Apple framework can only be enabled for MacOS or iOS.")
36
endif()

cmake/ext_java.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
include(FindJava)
25
find_package(Java REQUIRED)
36
include(UseJava)

cmake/ext_ortlib.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
if(_ONNXRUNTIME_EMBEDDED)
25
set(ONNXRUNTIME_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/../include/onnxruntime/core/session)
36
set(ONNXRUNTIME_LIB_DIR "")

cmake/ext_python.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
block(PROPAGATE Python3_FOUND)
25
set(Python3_FIND_REGISTRY NEVER)
36
# if we don't set this to NEVER (or possibly LAST) the builds of the wheel for different python versions will fail

cmake/ext_tests.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
14
if (OCOS_ENABLE_SELECTED_OPLIST)
25
# currently the tests don't handle operator exclusion cleanly.
36
message(FATAL_ERROR "Due to usage of OCOS_ENABLE_SELECTED_OPLIST excluding operators the tests are unable to be built and run")

cmake/ext_wasm.cmake

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) Microsoft Corporation. All rights reserved.
2+
# Licensed under the MIT License.
3+
4+
if(OCOS_ENABLE_STATIC_LIB)
5+
add_library(ortcustomops STATIC ${_TARGET_LIB_SRC})
6+
if (HAS_SDL)
7+
target_compile_options(ortcustomops PRIVATE "/sdl")
8+
endif()
9+
add_library(onnxruntime_extensions ALIAS ortcustomops)
10+
standardize_output_folder(ortcustomops)
11+
else()
12+
# Emscripten does not support building a shared library with custom ops.
13+
# and backward compatible with the previous version, we silently turn off the shared library build.
14+
set(OCOS_BUILD_SHARED_LIB OFF CACHE INTERNAL "" FORCE)
15+
add_executable(ortcustomops ${_TARGET_LIB_SRC})
16+
set_target_properties(ortcustomops PROPERTIES LINK_FLAGS " \
17+
-s WASM=1 \
18+
-s NO_EXIT_RUNTIME=0 \
19+
-s ALLOW_MEMORY_GROWTH=1 \
20+
-s SAFE_HEAP=0 \
21+
-s MODULARIZE=1 \
22+
-s SAFE_HEAP_LOG=0 \
23+
-s STACK_OVERFLOW_CHECK=0 \
24+
-s EXPORT_ALL=0 \
25+
-s VERBOSE=0 \
26+
--no-entry")
27+
28+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
29+
set_property(TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1")
30+
else()
31+
set_property(TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=0 -s DEMANGLE_SUPPORT=0")
32+
endif()
33+
endif()

0 commit comments

Comments
 (0)