Skip to content

Commit ac26555

Browse files
authored
Create a macos-arm64 preset (#10768)
### Summary * Create the base for a macos-arm64 preset — bigger migration in future diffs * Create an Apple CI job to test builds ### Test plan CI + ``` $ cmake --preset macos-arm64 -- Loading build preset: /Users/jathu/executorch/tools/cmake/preset/macos-arm64.cmake -- --- Configurated Options --- -- EXECUTORCH_BUILD_PRESET_FILE : /Users/jathu/executorch/tools/cmake/preset/macos-arm64.cmake -- EXECUTORCH_ENABLE_LOGGING : ON -- EXECUTORCH_BUILD_COREML : ON -- --------------------------- $ cmake --build cmake-out --parallel ``` cc @larryliu0820
1 parent d25ce54 commit ac26555

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

.github/workflows/build-presets.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,20 @@ on:
1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}-${{ github.event_name == 'workflow_dispatch' }}-${{ github.event_name == 'schedule' }}
1313
cancel-in-progress: true
14+
15+
jobs:
16+
apple:
17+
uses: pytorch/test-infra/.github/workflows/macos_job.yml@main
18+
strategy:
19+
matrix:
20+
preset: [macos-arm64]
21+
with:
22+
job-name: build
23+
runner: macos-latest-xlarge
24+
python-version: 3.12
25+
submodules: recursive
26+
script: |
27+
set -eux
28+
${CONDA_RUN} ./install_requirements.sh > /dev/null
29+
${CONDA_RUN} cmake --preset ${{ matrix.preset }}
30+
${CONDA_RUN} cmake --build cmake-out --parallel

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ project(executorch)
4848
# MARK: - Start EXECUTORCH_H12025_BUILD_MIGRATION --------------------------------------------------
4949

5050
include(${PROJECT_SOURCE_DIR}/tools/cmake/common/preset.cmake)
51+
52+
load_build_preset()
5153
include(${PROJECT_SOURCE_DIR}/tools/cmake/preset/default.cmake)
5254

5355
# Print all the configs that were called with announce_configured_options.

CMakePresets.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"version": 10,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 31,
6+
"patch": 0
7+
},
8+
"$comment": "On-device AI across mobile, embedded and edge for PyTorch.",
9+
"configurePresets": [
10+
{
11+
"name": "common",
12+
"hidden": true,
13+
"binaryDir": "${sourceDir}/cmake-out",
14+
"generator": "Unix Makefiles"
15+
},
16+
{
17+
"name": "macos-arm64",
18+
"inherits": ["common"],
19+
"generator": "Xcode",
20+
"cacheVariables": {
21+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/third-party/ios-cmake/ios.toolchain.cmake",
22+
"EXECUTORCH_BUILD_PRESET_FILE": "${sourceDir}/tools/cmake/preset/macos-arm64.cmake",
23+
"PLATFORM": "MAC_ARM64",
24+
"DEPLOYMENT_TARGET": "10.15"
25+
},
26+
"condition": {
27+
"lhs": "${hostSystemName}",
28+
"type": "equals",
29+
"rhs": "Darwin"
30+
}
31+
}
32+
]
33+
}

tools/cmake/Utils.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,11 @@ function(resolve_python_executable)
313313
python
314314
PARENT_SCOPE
315315
)
316+
elseif(DEFINED ENV{VIRTUAL_ENV})
317+
set(PYTHON_EXECUTABLE
318+
$ENV{VIRTUAL_ENV}/bin/python3
319+
PARENT_SCOPE
320+
)
316321
else()
317322
set(PYTHON_EXECUTABLE
318323
python3

tools/cmake/common/preset.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,14 @@ macro(set_overridable_option NAME VALUE)
9191

9292
set(${NAME} ${VALUE} CACHE STRING "")
9393
endmacro()
94+
95+
# Detemine the build preset and load it.
96+
macro(load_build_preset)
97+
if(DEFINED EXECUTORCH_BUILD_PRESET_FILE)
98+
announce_configured_options(EXECUTORCH_BUILD_PRESET_FILE)
99+
message(STATUS "Loading build preset: ${EXECUTORCH_BUILD_PRESET_FILE}")
100+
include(${EXECUTORCH_BUILD_PRESET_FILE})
101+
endif()
102+
# For now, just continue if the preset file is not set. In the future, we will
103+
# try to determine a preset file.
104+
endmacro()

0 commit comments

Comments
 (0)