-
Notifications
You must be signed in to change notification settings - Fork 700
JavaScript bindings for module API #12571
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
Changes from 30 commits
e6c7666
b322cb8
43561d7
d19c6b4
4b0e1af
a21942d
7d15296
5378272
0701996
f3e3d54
160f15f
bbc46df
79d2769
be9c771
a838685
9c2b93b
e63961c
bfbbfc5
b274dae
7de34b9
4aab20f
da58ab2
cfa3d4c
fb5ae68
f4e7144
aa48efb
6f38b89
5cfbc1d
c72e574
1040b15
7926335
3345fe9
f3ba749
f806259
ddbc698
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| # Please this file formatted by running: | ||
| # ~~~ | ||
| # cmake-format -i CMakeLists.txt | ||
| # ~~~ | ||
|
|
||
| cmake_minimum_required(VERSION 3.29) | ||
|
|
||
| project(executorch_wasm) | ||
|
|
||
| if(NOT CMAKE_CXX_STANDARD) | ||
| set(CMAKE_CXX_STANDARD 17) | ||
| endif() | ||
|
|
||
| if(NOT EMSCRIPTEN) | ||
| message(FATAL_ERROR "Emscripten is required to build this target") | ||
| endif() | ||
|
|
||
| # Source root directory for executorch. | ||
| if(NOT EXECUTORCH_ROOT) | ||
| set(EXECUTORCH_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/../..) | ||
| endif() | ||
|
|
||
| include(${EXECUTORCH_ROOT}/tools/cmake/Utils.cmake) | ||
| set(_common_compile_options -Wno-deprecated-declarations -fPIC -Wall -Werror) | ||
| set(_common_include_directories ${EXECUTORCH_ROOT}/..) | ||
|
|
||
| set(link_libraries) | ||
| list( | ||
| APPEND | ||
| link_libraries | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should follow the naming convention with a prepending |
||
| embind | ||
| executorch_core | ||
| extension_data_loader | ||
| portable_ops_lib | ||
| extension_module_static | ||
| extension_tensor | ||
| extension_runner_util | ||
| ) | ||
|
|
||
| add_library(executorch_wasm OBJECT wasm_bindings.cpp) | ||
|
|
||
| target_compile_options(executorch_wasm PUBLIC ${_common_compile_options}) | ||
| target_include_directories( | ||
| executorch_wasm PUBLIC ${_common_include_directories} | ||
| ) | ||
| target_link_libraries(executorch_wasm PUBLIC ${link_libraries}) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should there be a default target_link_options for emscripten? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The link options used for the unit tests are specific for that target. I don't think there are link options that would be widely applicable for this. |
||
| if(EXECUTORCH_BUILD_WASM_TESTS) | ||
| add_subdirectory(test) | ||
| endif() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| # All rights reserved. | ||
| # | ||
| # This source code is licensed under the BSD-style license found in the | ||
| # LICENSE file in the root directory of this source tree. | ||
|
|
||
| # Please this file formatted by running: | ||
| # ~~~ | ||
| # cmake-format -i CMakeLists.txt | ||
| # ~~~ | ||
|
|
||
| set(MODELS_DIR ${CMAKE_CURRENT_BINARY_DIR}/models/) | ||
|
|
||
| add_custom_command( | ||
| OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/models/add_mul.pte | ||
| ${CMAKE_CURRENT_BINARY_DIR}/models/add.pte | ||
| COMMAND ${CMAKE_COMMAND} -E make_directory "${MODELS_DIR}" | ||
| WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. | ||
| COMMAND python3 -m examples.portable.scripts.export --model_name="add_mul" | ||
| --output_dir="${MODELS_DIR}" | ||
| COMMAND python3 -m examples.portable.scripts.export --model_name="add" | ||
| --output_dir="${MODELS_DIR}" | ||
| ) | ||
|
|
||
| add_custom_target( | ||
| executorch_wasm_test_models DEPENDS ${MODELS_DIR}/add_mul.pte | ||
| ${MODELS_DIR}/add.pte | ||
| ) | ||
|
|
||
| add_custom_command( | ||
| OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/package.json | ||
| COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/package.json | ||
| ${CMAKE_CURRENT_BINARY_DIR}/package.json | ||
| DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/package.json | ||
| COMMENT "Copying package.json to build output directory" | ||
| ) | ||
|
|
||
| add_custom_target( | ||
| executorch_wasm_test_package_json | ||
| DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/package.json | ||
| ) | ||
|
|
||
| add_executable(executorch_wasm_tests) | ||
| target_link_libraries(executorch_wasm_tests PUBLIC executorch_wasm) | ||
| target_link_options( | ||
| executorch_wasm_tests PUBLIC --embed-file "${MODELS_DIR}@/" --post-js | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/unittests.js | ||
| ) | ||
| set_target_properties( | ||
| executorch_wasm_tests PROPERTIES OUTPUT_NAME "executorch_wasm.test" | ||
| ) | ||
| set_property( | ||
| TARGET executorch_wasm_tests | ||
| APPEND | ||
| PROPERTY LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/unittests.js | ||
| ) | ||
| add_dependencies( | ||
| executorch_wasm_tests executorch_wasm_test_models | ||
| executorch_wasm_test_package_json | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "scripts": { | ||
| "test": "jest" | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this directory belongs to a new project so should delete this.