|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# All rights reserved. |
| 3 | +# |
| 4 | +# This source code is licensed under the BSD-style license found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | + |
| 7 | +# Please this file formatted by running: |
| 8 | +# ~~~ |
| 9 | +# cmake-format -i CMakeLists.txt |
| 10 | +# ~~~ |
| 11 | + |
| 12 | +set(MODELS_DIR ${CMAKE_CURRENT_BINARY_DIR}/models/) |
| 13 | + |
| 14 | +add_custom_command( |
| 15 | + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/models/add_mul.pte |
| 16 | + ${CMAKE_CURRENT_BINARY_DIR}/models/add.pte |
| 17 | + COMMAND ${CMAKE_COMMAND} -E make_directory "${MODELS_DIR}" |
| 18 | + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../.. |
| 19 | + COMMAND python3 -m examples.portable.scripts.export --model_name="add_mul" |
| 20 | + --output_dir="${MODELS_DIR}" |
| 21 | + COMMAND python3 -m examples.portable.scripts.export --model_name="add" |
| 22 | + --output_dir="${MODELS_DIR}" |
| 23 | +) |
| 24 | + |
| 25 | +add_custom_target( |
| 26 | + executorch_wasm_test_models DEPENDS ${MODELS_DIR}/add_mul.pte |
| 27 | + ${MODELS_DIR}/add.pte |
| 28 | +) |
| 29 | + |
| 30 | +add_custom_command( |
| 31 | + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/package.json |
| 32 | + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/package.json |
| 33 | + ${CMAKE_CURRENT_BINARY_DIR}/package.json |
| 34 | + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/package.json |
| 35 | + COMMENT "Copying package.json to build output directory" |
| 36 | +) |
| 37 | + |
| 38 | +add_custom_target( |
| 39 | + executorch_wasm_test_package_json |
| 40 | + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/package.json |
| 41 | +) |
| 42 | + |
| 43 | +add_executable(executorch_wasm_tests) |
| 44 | +target_link_libraries(executorch_wasm_tests PUBLIC executorch_wasm) |
| 45 | +target_link_options( |
| 46 | + executorch_wasm_tests |
| 47 | + PUBLIC |
| 48 | + --embed-file |
| 49 | + "${MODELS_DIR}@/" |
| 50 | + --post-js |
| 51 | + ${CMAKE_CURRENT_SOURCE_DIR}/unittests.js |
| 52 | + -sASSERTIONS=2 |
| 53 | +) |
| 54 | +set_target_properties( |
| 55 | + executorch_wasm_tests PROPERTIES OUTPUT_NAME "executorch_wasm.test" |
| 56 | +) |
| 57 | +set_property( |
| 58 | + TARGET executorch_wasm_tests |
| 59 | + APPEND |
| 60 | + PROPERTY LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/unittests.js |
| 61 | +) |
| 62 | +add_dependencies( |
| 63 | + executorch_wasm_tests executorch_wasm_test_models |
| 64 | + executorch_wasm_test_package_json |
| 65 | +) |
0 commit comments