Skip to content

Commit 146533b

Browse files
csmartdaltoncsmartdalton
andcommitted
Add an android_api option for premake
Instead of hardcoding android21, make this option configurable. Diffs= d5a774b4b4 Add an android_api option for premake (#8892) Co-authored-by: Chris Dalton <99840794+csmartdalton@users.noreply.github.com>
1 parent 3c52115 commit 146533b

File tree

3 files changed

+32
-71
lines changed

3 files changed

+32
-71
lines changed

.rive_head

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5328d573c738f9d597ab7dab14ef328b7d91b149
1+
d5a774b4b46a147fd72e3ffd9dc730ab313d4a13

build/build_rive.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,6 @@ if [[ "$1" = "rebuild" ]]; then
111111
fi
112112
else
113113
# New build. Parse arguments into premake options.
114-
RIVE_PREMAKE_FILE="${RIVE_PREMAKE_FILE:-./premake5.lua}"
115-
if [ ! -f "$RIVE_PREMAKE_FILE" ]; then
116-
echo "Premake file "$RIVE_PREMAKE_FILE" not found"
117-
exit -1
118-
fi
119114

120115
# Only use default arguments if RIVE_PREMAKE_ARGS is unset (not just empty).
121116
if [ -z "${RIVE_PREMAKE_ARGS+null_detector_string}" ]; then
@@ -132,9 +127,10 @@ else
132127
RIVE_ARCH="${RIVE_ARCH:-universal}" # The simulator requires universal builds.
133128
;;
134129
"android") RIVE_OS="${RIVE_OS:-android}" ;;
135-
"arm") RIVE_ARCH="${RIVE_ARCH:-arm}" ;;
136130
"arm64") RIVE_ARCH="${RIVE_ARCH:-arm64}" ;;
131+
"arm") RIVE_ARCH="${RIVE_ARCH:-arm}" ;;
137132
"x64") RIVE_ARCH="${RIVE_ARCH:-x64}" ;;
133+
"x86") RIVE_ARCH="${RIVE_ARCH:-x86}" ;;
138134
"universal") RIVE_ARCH="${RIVE_ARCH:-universal}" ;;
139135
"wasm") RIVE_ARCH="${RIVE_ARCH:-wasm}" ;;
140136
"ninja") RIVE_BUILD_SYSTEM="${RIVE_BUILD_SYSTEM:-ninja}" ;;
@@ -181,7 +177,7 @@ else
181177
RIVE_BUILD_SYSTEM="${RIVE_BUILD_SYSTEM:-gmake2}"
182178
fi
183179

184-
RIVE_PREMAKE_ARGS="$RIVE_BUILD_SYSTEM --file=$RIVE_PREMAKE_FILE --config=$RIVE_CONFIG --out=$RIVE_OUT $RIVE_PREMAKE_ARGS"
180+
RIVE_PREMAKE_ARGS="$RIVE_BUILD_SYSTEM --config=$RIVE_CONFIG --out=$RIVE_OUT $RIVE_PREMAKE_ARGS"
185181
if [ ! -z "$RIVE_OS" ]; then RIVE_PREMAKE_ARGS="$RIVE_PREMAKE_ARGS --os=$RIVE_OS"; fi
186182
if [ ! -z "$RIVE_VARIANT" ]; then RIVE_PREMAKE_ARGS="$RIVE_PREMAKE_ARGS --variant=$RIVE_VARIANT"; fi
187183
if [ ! -z "$RIVE_ARCH" ]; then RIVE_PREMAKE_ARGS="$RIVE_PREMAKE_ARGS --arch=$RIVE_ARCH"; fi

build/rive_build_config.lua

Lines changed: 28 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,12 @@ newoption({
6161
default = 'host',
6262
})
6363

64+
newoption({
65+
trigger = 'android_api',
66+
description = 'Target Android API version number',
67+
default = '21',
68+
})
69+
6470
newoption({
6571
trigger = 'variant',
6672
value = 'type',
@@ -361,6 +367,14 @@ if _OPTIONS['os'] == 'android' then
361367
ndk_toolchain = ndk_toolchain .. '/linux-x86_64'
362368
end
363369

370+
local android_base_targets = {
371+
arm64 = 'aarch64-linux-android',
372+
arm = 'armv7a-linux-androideabi',
373+
x64 = 'x86_64-linux-android',
374+
x86 = 'i686-linux-android',
375+
}
376+
local android_target = android_base_targets[_OPTIONS['arch']] .. _OPTIONS['android_api']
377+
364378
-- clone the clang toolset into a custom one called "android_ndk".
365379
premake.tools.android_ndk = {}
366380
for k, v in pairs(premake.tools.clang) do
@@ -369,16 +383,20 @@ if _OPTIONS['os'] == 'android' then
369383

370384
-- update the android_ndk toolset to use the appropriate binaries.
371385
local android_ndk_tools = {
372-
cc = ndk_toolchain .. '/bin/clang',
373-
cxx = ndk_toolchain .. '/bin/clang++',
386+
cc = ndk_toolchain .. '/bin/' .. android_target .. '-clang',
387+
cxx = ndk_toolchain .. '/bin/' .. android_target .. '-clang++',
374388
ar = ndk_toolchain .. '/bin/llvm-ar',
375389
}
376390
function premake.tools.android_ndk.gettoolname(cfg, tool)
377391
return android_ndk_tools[tool]
378392
end
379393

380-
valid_cc_tools = premake.action._list['gmake2'].valid_tools['cc']
381-
valid_cc_tools[#valid_cc_tools + 1] = 'android_ndk'
394+
-- suppress "** Warning: Unsupported toolset 'android_ndk'".
395+
local premake_valid_tools = premake.action._list[_ACTION].valid_tools
396+
if premake_valid_tools ~= nil then
397+
premake_valid_tools['cc'][#premake_valid_tools['cc'] + 1] = 'android_ndk'
398+
end
399+
382400
toolset('android_ndk')
383401

384402
buildoptions({
@@ -404,62 +422,6 @@ if _OPTIONS['os'] == 'android' then
404422
'-static-libstdc++',
405423
})
406424

407-
filter({ 'options:arch=x86', 'options:not for_unreal' })
408-
do
409-
architecture('x86')
410-
buildoptions({ '--target=i686-none-linux-android21' })
411-
linkoptions({ '--target=i686-none-linux-android21' })
412-
end
413-
414-
filter({ 'options:arch=x86', 'options:for_unreal' })
415-
do
416-
architecture('x86')
417-
buildoptions({ '--target=i686-none-linux-android31' })
418-
linkoptions({ '--target=i686-none-linux-android31' })
419-
end
420-
421-
filter({ 'options:arch=x64', 'options:not for_unreal' })
422-
do
423-
architecture('x64')
424-
buildoptions({ '--target=x86_64-none-linux-android21' })
425-
linkoptions({ '--target=x86_64-none-linux-android21' })
426-
end
427-
428-
filter({ 'options:arch=x64', 'options:for_unreal' })
429-
do
430-
architecture('x64')
431-
buildoptions({ '--target=x86_64-none-linux-android31' })
432-
linkoptions({ '--target=x86_64-none-linux-android31' })
433-
end
434-
435-
filter({ 'options:arch=arm', 'options:not for_unreal' })
436-
do
437-
architecture('arm')
438-
buildoptions({ '--target=armv7a-none-linux-android21' })
439-
linkoptions({ '--target=armv7a-none-linux-android21' })
440-
end
441-
442-
filter({ 'options:arch=arm', 'options:for_unreal' })
443-
do
444-
architecture('arm')
445-
buildoptions({ '--target=armv7a-none-linux-android31' })
446-
linkoptions({ '--target=armv7a-none-linux-android31' })
447-
end
448-
449-
filter({ 'options:arch=arm64', 'options:not for_unreal' })
450-
do
451-
architecture('arm64')
452-
buildoptions({ '--target=aarch64-none-linux-android21' })
453-
linkoptions({ '--target=aarch64-none-linux-android21' })
454-
end
455-
456-
filter({ 'options:arch=arm64', 'options:for_unreal' })
457-
do
458-
architecture('arm64')
459-
buildoptions({ '--target=aarch64-none-linux-android31' })
460-
linkoptions({ '--target=aarch64-none-linux-android31' })
461-
end
462-
463425
filter({})
464426
end
465427

@@ -664,10 +626,13 @@ if _OPTIONS['arch'] == 'wasm' or _OPTIONS['arch'] == 'js' then
664626
return emsdk_tools[tool]
665627
end
666628

667-
system('emscripten')
629+
-- suppress "** Warning: Unsupported toolset 'emsdk'".
630+
local premake_valid_tools = premake.action._list[_ACTION].valid_tools
631+
if premake_valid_tools ~= nil then
632+
premake_valid_tools['cc'][#premake_valid_tools['cc'] + 1] = 'emsdk'
633+
end
668634

669-
valid_cc_tools = premake.action._list['gmake2'].valid_tools['cc']
670-
valid_cc_tools[#valid_cc_tools + 1] = 'emsdk'
635+
system('emscripten')
671636
toolset('emsdk')
672637

673638
linkoptions({ '-sALLOW_MEMORY_GROWTH=1', '-sDYNAMIC_EXECUTION=0' })

0 commit comments

Comments
 (0)