Skip to content

Commit 24e993b

Browse files
author
Sayan Shaw
committed
Merge branch 'main' of https://github.com/microsoft/onnxruntime-extensions into sayanshaw/python-decoder-api
2 parents df62cc8 + f3f6caa commit 24e993b

File tree

8 files changed

+71
-33
lines changed

8 files changed

+71
-33
lines changed

.pipelines/ci.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -748,13 +748,24 @@ stages:
748748
- script: |
749749
bash ./build.sh \
750750
-DCMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
751+
-DOCOS_ENABLE_STATIC_LIB=OFF \
751752
-DOCOS_ENABLE_SPM_TOKENIZER=ON \
752-
-DOCOS_BUILD_PYTHON=OFF \
753-
-DOCOS_ENABLE_CV2=OFF \
753+
-DOCOS_BUILD_PYTHON=OFF \
754754
-DOCOS_ENABLE_VISION=OFF \
755-
-DOCOS_ENABLE_CTEST=OFF
756-
displayName: build the customop library with onnxruntime
757-
# TODO add unittest for webassembly
755+
-DOCOS_ENABLE_CTEST=OFF \
756+
-DOCOS_ENABLE_C_API=ON
757+
displayName: build ort-extensions as an executable
758+
759+
- script: |
760+
bash ./build.sh \
761+
-DCMAKE_TOOLCHAIN_FILE=$(Build.BinariesDirectory)/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake \
762+
-DOCOS_ENABLE_STATIC_LIB=ON \
763+
-DOCOS_ENABLE_SPM_TOKENIZER=ON \
764+
-DOCOS_BUILD_PYTHON=OFF \
765+
-DOCOS_ENABLE_VISION=OFF \
766+
-DOCOS_ENABLE_CTEST=OFF \
767+
-DOCOS_ENABLE_C_API=ON
768+
displayName: build ort-extensions as a static library
758769
759770
- stage: AndroidBuilds
760771
dependsOn: []

CMakeLists.txt

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ include(CMakeDependentOption)
5454

5555
set(_ORTX_STANDALONE_PROJECT OFF)
5656
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
57-
set(_ORTX_STANDALONE_PROJECT ON)
57+
set(_ORTX_STANDALONE_PROJECT ON)
58+
endif()
59+
60+
set(_ORTX_SHARED_BUILD_SUPPORTED ON)
61+
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
62+
set(_ORTX_SHARED_BUILD_SUPPORTED OFF)
5863
endif()
5964

6065
option(CC_OPTIMIZE "Allow compiler optimizations, Set to OFF to disable" ON)
@@ -78,11 +83,11 @@ option(OCOS_ENABLE_VISION "Enable the operators in `operators/vision`" ON)
7883
option(OCOS_ENABLE_AUDIO "Enable the operators for audio processing" ON)
7984
option(OCOS_ENABLE_AZURE "Enable the operators for azure execution provider" OFF)
8085

81-
option(OCOS_ENABLE_STATIC_LIB "Enable generating static library" OFF)
86+
option(OCOS_ENABLE_STATIC_LIB "Enable generating static library" OFF) # only for WebAssembly
8287
option(OCOS_ENABLE_SELECTED_OPLIST "Enable including the selected_ops tool file" OFF)
8388
option(OCOS_ENABLE_C_API "Enable building the C API" OFF)
8489

85-
option(OCOS_BUILD_SHARED_LIB "Enable building the dynamic library" ON)
90+
option(OCOS_BUILD_SHARED_LIB "Enable building the dynamic library" ${_ORTX_SHARED_BUILD_SUPPORTED})
8691
option(OCOS_BUILD_PYTHON "Enable building the Python package" OFF)
8792
option(OCOS_BUILD_JAVA "Enable building the Java package" OFF)
8893
option(OCOS_BUILD_ANDROID "Enable building the Android package" OFF)
@@ -629,7 +634,7 @@ if(OCOS_ENABLE_TF_STRING)
629634

630635
if(OCOS_ENABLE_RE2_REGEX)
631636
target_include_directories(noexcep_operators PUBLIC ${googlere2_SOURCE_DIR})
632-
target_link_libraries(noexcep_operators PRIVATE re2)
637+
target_link_libraries(noexcep_operators PRIVATE re2::re2)
633638
endif()
634639
endif()
635640

@@ -773,30 +778,7 @@ if(OCOS_ENABLE_C_API)
773778
endif()
774779

775780
if(CMAKE_SYSTEM_NAME STREQUAL "Emscripten")
776-
if(OCOS_ENABLE_STATIC_LIB)
777-
message(FATAL_ERROR "Emscripten build does not support building a static library.")
778-
endif()
779-
# Emscripten does not support building a shared library with custom ops.
780-
# and backward compatible with the previous version, we silently turn off the shared library build.
781-
set(OCOS_BUILD_SHARED_LIB OFF CACHE INTERNAL "" FORCE)
782-
add_executable(ortcustomops ${_TARGET_LIB_SRC})
783-
set_target_properties(ortcustomops PROPERTIES LINK_FLAGS " \
784-
-s WASM=1 \
785-
-s NO_EXIT_RUNTIME=0 \
786-
-s ALLOW_MEMORY_GROWTH=1 \
787-
-s SAFE_HEAP=0 \
788-
-s MODULARIZE=1 \
789-
-s SAFE_HEAP_LOG=0 \
790-
-s STACK_OVERFLOW_CHECK=0 \
791-
-s EXPORT_ALL=0 \
792-
-s VERBOSE=0 \
793-
--no-entry")
794-
795-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
796-
set_property(TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1")
797-
else()
798-
set_property(TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=0 -s DEMANGLE_SUPPORT=0")
799-
endif()
781+
include(ext_wasm)
800782
else()
801783
add_library(ortcustomops STATIC ${_TARGET_LIB_SRC})
802784
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: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
add_executable(ortcustomops ${_TARGET_LIB_SRC})
13+
set_target_properties(ortcustomops PROPERTIES LINK_FLAGS " \
14+
-s WASM=1 \
15+
-s NO_EXIT_RUNTIME=0 \
16+
-s ALLOW_MEMORY_GROWTH=1 \
17+
-s SAFE_HEAP=0 \
18+
-s MODULARIZE=1 \
19+
-s SAFE_HEAP_LOG=0 \
20+
-s STACK_OVERFLOW_CHECK=0 \
21+
-s EXPORT_ALL=0 \
22+
-s VERBOSE=0 \
23+
--no-entry")
24+
25+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
26+
set_property(TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=1 -s DEMANGLE_SUPPORT=1")
27+
else()
28+
set_property(TARGET ortcustomops APPEND_STRING PROPERTY LINK_FLAGS " -s ASSERTIONS=0 -s DEMANGLE_SUPPORT=0")
29+
endif()
30+
endif()

0 commit comments

Comments
 (0)