Skip to content

Commit 9cc7d3a

Browse files
Update sysroot variables
1 parent fe960bb commit 9cc7d3a

File tree

3 files changed

+20
-30
lines changed

3 files changed

+20
-30
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,32 +49,29 @@ jobs:
4949
with:
5050
dotnet-version: 8.0.x
5151

52+
- name: Setup Android SDK
53+
uses: android-actions/setup-android@v3
54+
5255
- name: Set Version Suffix
5356
shell: bash
5457
run: |
5558
if [ '${{ github.event.inputs.use-auto-generated-version }}' != 'false' ]; then
5659
echo "BuildVersionSuffix=build.$(git rev-list --count HEAD)" >> $GITHUB_ENV
5760
fi
5861
59-
- name: Setup IOS SDK
62+
- name: Set IOS SDK Variables
6063
if: matrix.os == 'macos-latest'
6164
shell: bash
6265
run: |
63-
echo "IOS_SDK=$(xcrun --sdk iphoneos --show-sdk-path)" >> $GITHUB_ENV
64-
echo "IOS_SIMULATOR_SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)" >> $GITHUB_ENV
65-
66-
- name: Setup Android NDK
67-
if: matrix.os == 'macos-latest'
68-
uses: nttld/setup-ndk@v1
69-
with:
70-
ndk-version: r25c
71-
link-to-sdk: true
66+
echo "IOS_SDK_SYSROOT=$(xcrun --sdk iphoneos --show-sdk-path)" >> $GITHUB_ENV
67+
echo "IOS_SIMULATOR_SDK_SYSROOT=$(xcrun --sdk iphonesimulator --show-sdk-path)" >> $GITHUB_ENV
7268
73-
- name: Set Android NDK variables
69+
- name: Set Android NDK Variables
7470
if: matrix.os == 'macos-latest'
7571
shell: bash
7672
run: |
77-
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
73+
echo "ANDROID_NDK=$(find "$ANDROID_SDK_ROOT/ndk/" -mindepth 1 -maxdepth 1 -type d | sort | head -n 1)" >> $GITHUB_ENV
74+
echo "ANDROID_NDK_SYSROOT=$ANDROID_NDK/toolchains/llvm/prebuilt/darwin-x86_64/sysroot" >> $GITHUB_ENV
7875
7976
- name: Restore Dependencies
8077
shell: bash

Box2D.NET.Native/Box2D.NET.Native.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<Import Project="$(NuGetPackageRoot)/microsoft.net.runtime.emscripten.3.1.56.cache.$(HostRuntime)/9.0.5/Sdk/Sdk.props"/>
5252

5353
<PropertyGroup>
54-
<EMSCRIPTEN_CACHE Condition="$(EMSCRIPTEN_CACHE) == ''" >$(WasmCachePath)</EMSCRIPTEN_CACHE>
54+
<EMSCRIPTEN_CACHE_SYSROOT Condition="$(EMSCRIPTEN_CACHE_SYSROOT) == ''" >$(WasmCachePath)sysroot</EMSCRIPTEN_CACHE_SYSROOT>
5555
</PropertyGroup>
5656

5757
<!-- Determine mapping between dotnet RID and zig targets -->
@@ -109,37 +109,37 @@
109109
<When Condition="$(RuntimeIdentifier) == 'iossimulator-x64'">
110110
<PropertyGroup>
111111
<ZigIdentifier>x86_64-ios-simulator</ZigIdentifier>
112-
<ZigArgs>--sysroot "$(IOS_SIMULATOR_SDK)"</ZigArgs>
112+
<ZigArgs>--sysroot "$(IOS_SIMULATOR_SDK_SYSROOT)"</ZigArgs>
113113
</PropertyGroup>
114114
</When>
115115
<When Condition="$(RuntimeIdentifier) == 'iossimulator-arm64'">
116116
<PropertyGroup>
117117
<ZigIdentifier>aarch64-ios-simulator</ZigIdentifier>
118-
<ZigArgs>--sysroot "$(IOS_SIMULATOR_SDK)"</ZigArgs>
118+
<ZigArgs>--sysroot "$(IOS_SIMULATOR_SDK_SYSROOT)"</ZigArgs>
119119
</PropertyGroup>
120120
</When>
121121
<When Condition="$(RuntimeIdentifier) == 'ios-arm64'">
122122
<PropertyGroup>
123123
<ZigIdentifier>aarch64-ios</ZigIdentifier>
124-
<ZigArgs>--sysroot "$(IOS_SDK)"</ZigArgs>
124+
<ZigArgs>--sysroot "$(IOS_SDK_SYSROOT)"</ZigArgs>
125125
</PropertyGroup>
126126
</When>
127127
<When Condition="$(RuntimeIdentifier) == 'browser-wasm'">
128128
<PropertyGroup>
129129
<ZigIdentifier>wasm32-emscripten</ZigIdentifier>
130-
<ZigArgs>--sysroot "$(EMSCRIPTEN_CACHE)"</ZigArgs>
130+
<ZigArgs>--sysroot "$(EMSCRIPTEN_CACHE_SYSROOT)"</ZigArgs>
131131
</PropertyGroup>
132132
</When>
133133
<When Condition="$(RuntimeIdentifier) == 'android-arm64'">
134134
<PropertyGroup>
135135
<ZigIdentifier>aarch64-linux-android</ZigIdentifier>
136-
<ZigArgs>--sysroot "$(ANDROID_NDK_HOME)"</ZigArgs>
136+
<ZigArgs>--sysroot "$(ANDROID_NDK_SYSROOT)"</ZigArgs>
137137
</PropertyGroup>
138138
</When>
139139
<When Condition="$(RuntimeIdentifier) == 'android-x64'">
140140
<PropertyGroup>
141141
<ZigIdentifier>x86_64-linux-android</ZigIdentifier>
142-
<ZigArgs>--sysroot "$(ANDROID_NDK_HOME)"</ZigArgs>
142+
<ZigArgs>--sysroot "$(ANDROID_NDK_SYSROOT)"</ZigArgs>
143143
</PropertyGroup>
144144
</When>
145145
<Otherwise>

Box2D.NET.Native/build.zig

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,24 +96,17 @@ pub fn compile(b: *Build, options: BuildOptions) !void {
9696
@panic("A --sysroot path to an Android NDK needs to be provided when compiling for Android.");
9797
}
9898

99-
const host_tuple = switch (builtin.target.os.tag) {
100-
.linux => "linux-x86_64",
101-
.windows => "windows-x86_64",
102-
.macos => "darwin-x86_64",
103-
else => @panic("unsupported host OS"),
104-
};
105-
10699
const triple = switch (options.target.result.cpu.arch) {
107100
.aarch64 => "aarch64-linux-android",
108101
.x86_64 => "x86_64-linux-android",
109102
else => @panic("Unsupported Android architecture"),
110103
};
104+
111105
const android_api_level: []const u8 = "21";
112106

113-
const android_sysroot = b.pathJoin(&.{ b.sysroot.?, "/toolchains/llvm/prebuilt/", host_tuple, "/sysroot" });
114-
const android_lib_path = b.pathJoin(&.{ "/usr/lib/", triple, android_api_level });
115-
const android_include_path = b.pathJoin(&.{ android_sysroot, "/usr/include" });
116-
const android_system_include_path = b.pathJoin(&.{ android_sysroot, "/usr/include/", triple });
107+
const android_lib_path = b.pathJoin(&.{ b.sysroot.?, "/usr/lib/", triple, android_api_level });
108+
const android_include_path = b.pathJoin(&.{ b.sysroot.?, "/usr/include" });
109+
const android_system_include_path = b.pathJoin(&.{ b.sysroot.?, "/usr/include/", triple });
117110

118111
lib.addLibraryPath(.{ .cwd_relative = android_lib_path });
119112

0 commit comments

Comments
 (0)