mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-30 20:18:08 +00:00
[node.js binding] enable CI for macOS arm64 (#9532)
* nodejs aggr * add dependency * no unzip * fix aggregation * add arm64 for mac * mac arm64 build * fix commandline * add check for multi-CMAKE_OSX_ARCHITECTURES * fix
This commit is contained in:
parent
c1b0f924b7
commit
90555bf96d
4 changed files with 35 additions and 7 deletions
|
|
@ -28,6 +28,17 @@ if(had_error)
|
|||
message(FATAL_ERROR "Failed to find NPM: " ${had_error})
|
||||
endif()
|
||||
|
||||
# setup ARCH
|
||||
if (APPLE AND CMAKE_OSX_ARCHITECTURES_LEN GREATER 1)
|
||||
message(FATAL_ERROR "CMake.js does not support multi-architecture for macOS")
|
||||
endif()
|
||||
if (APPLE AND CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
|
||||
set(NODEJS_BINDING_ARCH arm64)
|
||||
# elseif()
|
||||
else()
|
||||
set(NODEJS_BINDING_ARCH x64)
|
||||
endif()
|
||||
|
||||
if(NOT onnxruntime_ENABLE_STATIC_ANALYSIS)
|
||||
# add custom target
|
||||
add_custom_target(js_npm_ci ALL
|
||||
|
|
@ -42,7 +53,7 @@ add_custom_target(js_common_npm_ci ALL
|
|||
|
||||
add_custom_target(nodejs_binding_wrapper ALL
|
||||
COMMAND ${NPM_CLI} ci
|
||||
COMMAND ${NPM_CLI} run build -- --onnxruntime-build-dir=${CMAKE_CURRENT_BINARY_DIR} --config=${CMAKE_BUILD_TYPE} --arch=x64
|
||||
COMMAND ${NPM_CLI} run build -- --onnxruntime-build-dir=${CMAKE_CURRENT_BINARY_DIR} --config=${CMAKE_BUILD_TYPE} --arch=${NODEJS_BINDING_ARCH}
|
||||
WORKING_DIRECTORY ${JS_NODE_ROOT}
|
||||
COMMENT "Using cmake-js to build OnnxRuntime Node.js binding")
|
||||
add_dependencies(js_common_npm_ci js_npm_ci)
|
||||
|
|
|
|||
|
|
@ -8,20 +8,20 @@ add_compile_definitions(NAPI_VERSION=${napi_build_version})
|
|||
add_compile_definitions(ORT_API_MANUAL_INIT)
|
||||
|
||||
# dist variables
|
||||
execute_process(COMMAND node -e "console.log(process.arch)"
|
||||
OUTPUT_VARIABLE node_arch OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND node -e "console.log(process.platform)"
|
||||
OUTPUT_VARIABLE node_platform OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
file(READ ${CMAKE_SOURCE_DIR}/../../VERSION_NUMBER ort_version)
|
||||
string(STRIP "${ort_version}" ort_version)
|
||||
set(dist_folder "${CMAKE_SOURCE_DIR}/bin/napi-v3/${node_platform}/${node_arch}/")
|
||||
set(dist_folder "${CMAKE_SOURCE_DIR}/bin/napi-v3/${node_platform}/${NODE_ARCH}/")
|
||||
|
||||
# onnxruntime.dll dir
|
||||
if(NOT ONNXRUNTIME_BUILD_DIR)
|
||||
if (WIN32)
|
||||
set(ONNXRUNTIME_BUILD_DIR ${CMAKE_SOURCE_DIR}/../../build/Windows/${CMAKE_BUILD_TYPE})
|
||||
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
||||
set(ONNXRUNTIME_BUILD_DIR ${CMAKE_SOURCE_DIR}/../../build/MacOS/${CMAKE_BUILD_TYPE})
|
||||
else()
|
||||
set(ONNXRUNTIME_BUILD_DIR ${CMAKE_SOURCE_DIR}/../../build/Linux)
|
||||
set(ONNXRUNTIME_BUILD_DIR ${CMAKE_SOURCE_DIR}/../../build/Linux/${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
|
|
|||
|
|
@ -4,18 +4,20 @@
|
|||
import {execSync, spawnSync} from 'child_process';
|
||||
import * as fs from 'fs-extra';
|
||||
import minimist from 'minimist';
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
|
||||
// command line flags
|
||||
const buildArgs = minimist(process.argv.slice(2));
|
||||
|
||||
// --config=Debug|Release|RelWithDebInfo
|
||||
const CONFIG: 'Debug'|'Release'|'RelWithDebInfo' = buildArgs.config || 'RelWithDebInfo';
|
||||
const CONFIG: 'Debug'|'Release'|'RelWithDebInfo' =
|
||||
buildArgs.config || (os.platform() === 'win32' ? 'RelWithDebInfo' : 'Release');
|
||||
if (CONFIG !== 'Debug' && CONFIG !== 'Release' && CONFIG !== 'RelWithDebInfo') {
|
||||
throw new Error(`unrecognized config: ${CONFIG}`);
|
||||
}
|
||||
// --arch=x64|ia32|arm64|arm
|
||||
const ARCH: 'x64'|'ia32'|'arm64'|'arm' = buildArgs.arch || 'x64';
|
||||
const ARCH: 'x64'|'ia32'|'arm64'|'arm' = buildArgs.arch || os.arch();
|
||||
if (ARCH !== 'x64' && ARCH !== 'ia32' && ARCH !== 'arm64' && ARCH !== 'arm') {
|
||||
throw new Error(`unrecognized architecture: ${ARCH}`);
|
||||
}
|
||||
|
|
@ -49,6 +51,11 @@ if (ONNXRUNTIME_BUILD_DIR && typeof ONNXRUNTIME_BUILD_DIR === 'string') {
|
|||
args.push(`--CDONNXRUNTIME_BUILD_DIR=${ONNXRUNTIME_BUILD_DIR}`);
|
||||
}
|
||||
|
||||
// set cross-compile for arm64 on macOS
|
||||
if (os.platform() === 'darwin' && ARCH === 'arm64') {
|
||||
args.push('--CDCMAKE_OSX_ARCHITECTURES=arm64');
|
||||
}
|
||||
|
||||
// launch cmake-js configure
|
||||
const procCmakejs = spawnSync(command, args, {shell: true, stdio: 'inherit', cwd: ROOT_FOLDER});
|
||||
if (procCmakejs.status !== 0) {
|
||||
|
|
|
|||
|
|
@ -173,6 +173,16 @@ jobs:
|
|||
DoNugetPack: 'false'
|
||||
DoEsrp: ${{ parameters.DoEsrp }}
|
||||
|
||||
- template: ../templates/mac-ci.yml
|
||||
parameters:
|
||||
AgentPool : $(AgentPoolMacOS)
|
||||
ArtifactName: 'bin-darwin_arm64'
|
||||
JobName: 'Mac_CI_arm64'
|
||||
BuildCommand: 'python3 $(Build.SourcesDirectory)/tools/ci_build/build.py --build_dir $(Build.BinariesDirectory) --skip_submodule_sync --parallel --build_nodejs --config Release --osx_arch=arm64 --skip_tests'
|
||||
DoNodejsPack : 'true'
|
||||
DoNugetPack: 'false'
|
||||
DoEsrp: ${{ parameters.DoEsrp }}
|
||||
|
||||
- job: 'Linux_CI_x64'
|
||||
workspace:
|
||||
clean: all
|
||||
|
|
|
|||
Loading…
Reference in a new issue