Let mods customize app constants

Mainly via meson_options.txt.
This commit is contained in:
Tamás Bálint Misius
2022-12-17 13:53:37 +01:00
parent 2140d6db4b
commit 59f89f9a46
25 changed files with 123 additions and 99 deletions

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.powdertoy.tpt"
package="@APPID@"
android:versionCode="1"
android:versionName="1.0"
android:installLocation="auto"

View File

@@ -1,4 +1,4 @@
package uk.co.powdertoy.tpt;
package @APPID@;
import org.libsdl.app.SDLActivity;

View File

@@ -32,12 +32,14 @@ if tpt_arch == 'aarch64':
if tpt_arch == 'x86_64':
android_arch = 'x86_64'
sha_packaged_name = 'libpowder.so'
manifest_path = os.path.join(build_dir, manifest_xml)
sha_path = os.path.join(build_dir, sha_name)
unaligned_path = os.path.join(build_dir, unaligned_name)
private_dir = os.path.join(build_dir, private_name)
arch_dir = os.path.join(private_dir, 'lib', android_arch)
sha_lib_path = os.path.join(arch_dir, sha_name)
sha_lib_path = os.path.join(arch_dir, sha_packaged_name)
flat_dir = os.path.join(private_dir, 'flat')
if os.path.exists(arch_dir):
@@ -79,7 +81,7 @@ if subprocess.run([
aapt,
'add',
unaligned_path,
os.path.join('lib', android_arch, sha_name),
os.path.join('lib', android_arch, sha_packaged_name),
], cwd = private_dir).returncode:
sys.exit(1)

View File

@@ -1,6 +1,12 @@
android_manifest_xml = files('AndroidManifest.xml')
powder_jar_sources = files(
'uk/co/powdertoy/tpt/PowderActivity.java',
android_manifest_xml = configure_file(
input: 'AndroidManifest.template.xml',
output: 'AndroidManifest.xml',
configuration: conf_data,
)
powder_jar_sources = configure_file(
input: 'PowderActivity.template.java',
output: 'PowderActivity.java',
configuration: conf_data,
)
subdir('res')
@@ -12,7 +18,7 @@ android_keystore = get_option('android_keystore')
sdl_jar = tpt_libs.get_variable('sdl_jar')
powder_jar = custom_target(
'powder-jar',
output: 'powder.jar',
output: app_exe + '.jar',
command: [
python3,
files('powder-jar.py'),
@@ -31,7 +37,7 @@ powder_jar = custom_target(
)
unaligned_apk = custom_target(
'build-apk',
output: 'powder.unaligned.apk',
output: app_exe + '.unaligned.apk',
input: powder_sha,
command: [
python3,
@@ -55,7 +61,7 @@ unaligned_apk = custom_target(
)
unsigned_apk = custom_target(
'align-apk',
output: 'powder.unsigned.apk',
output: app_exe + '.unsigned.apk',
input: unaligned_apk,
command: [
python3,
@@ -68,7 +74,7 @@ unsigned_apk = custom_target(
)
signed_apk = custom_target(
'sign-apk',
output: 'powder.apk',
output: app_exe + '.apk',
input: unsigned_apk,
command: [
python3,
@@ -94,6 +100,6 @@ if adb.found()
input: [ signed_apk, install_apk ],
build_always_stale: true,
output: 'run-apk',
command: [ python3, files('run-apk.py'), adb, meson.project_build_root(), '@OUTPUT@', '@INPUT0@' ],
command: [ python3, files('run-apk.py'), adb, meson.project_build_root(), '@OUTPUT@', '@INPUT0@', app_id ],
)
endif

View File

@@ -1,6 +1,7 @@
android_resources = files(
'mipmap-mdpi/ic_launcher.png',
'values/colors.xml',
'values/strings.xml',
'values/styles.xml',
)
subdir('values')

View File

@@ -0,0 +1,5 @@
android_resources += configure_file(
input: 'strings.template.xml',
output: 'strings.xml',
configuration: conf_data,
)

View File

@@ -0,0 +1,3 @@
<resources>
<string name="app_name">@APPNAME@</string>
</resources>

View File

@@ -1,3 +0,0 @@
<resources>
<string name="app_name">The Powder Toy</string>
</resources>

View File

@@ -9,6 +9,7 @@ import sys
build_dir,
phony,
apk_name,
app_id,
) = sys.argv
apk_path = os.path.join(build_dir, apk_name)
@@ -19,6 +20,6 @@ if subprocess.run([
'am',
'start',
'--activity-clear-top',
'-n', 'uk.co.powdertoy.tpt/.PowderActivity',
'-n', app_id + '/.PowderActivity',
]).returncode:
sys.exit(1)