Skip to content

Commit

Permalink
in medias res, but icons
Browse files Browse the repository at this point in the history
  • Loading branch information
ixchow committed Nov 12, 2023
1 parent aea4ab0 commit 2212a57
Show file tree
Hide file tree
Showing 11 changed files with 280 additions and 5 deletions.
34 changes: 32 additions & 2 deletions Maekfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ const android_options = {
LINK: [
`${NDK}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++`,
'-target', 'aarch64-linux-android29',
'-shared',
'-Wl,-Bsymbolic', //look for global symbols inside library first
'-Wl,-soname,libgame.so', //specify name of output library (suggested by https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Additional-Required-Arguments )
'-shared',
],
LINKLibs: [], //extra -L and -l flags for linker
};
Expand All @@ -187,7 +187,37 @@ maek.CPP('main.cpp', android_options);
const android_game_objs = game_sources.map((x) => maek.CPP(x, undefined, android_options));
const android_common_objs = common_sources.map((x) => maek.CPP(x, undefined, android_options));

const android_game_so = maek.LINK([...android_game_objs, ...android_common_objs], 'dist-android/libgame.so', android_options);
const android_game_so = maek.LINK([...android_game_objs, ...android_common_objs], 'dist-android/apk/lib/arm64-v8a/libgame.so', android_options);

//quick generic "RULE" for running commands with maek:
// [outFiles] = maek.RULE([outFile0, outFile1, ...], [inFile0, inFile1, ...], command, [desc])
maek.RULE = (outFiles, inFiles, command, desc = "run") => {
const task = async () => {
for (const outFile of outFiles) {
await fsPromises.mkdir(path.dirname(outFile), { recursive: true });
}
await run(command, `${task.label}: ${desc} [${idx} of ${commands.length+1}]`,
async () => {
return {
read:[...inFiles],
written:[...outFiles]
};
}
);
};

task.depends = [...inFiles];
task.label = `RULE {${inFiles.join(", ")}}`;

for (outFile of outFiles) {
if (outFile in maek.tasks) {
throw new Error(`Task ${task.label} purports to create ${outFile}, but ${maek.tasks[outFile].label} already creates that file.`);
}
maek.tasks[outFile] = task;
}
return outFiles;
};


maek.TARGETS = [android_game_so]; //DEBUG

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,6 @@ https://stackoverflow.com/questions/75463480/is-it-possible-to-use-android-ndk-w
https://stackoverflow.com/questions/59504840/create-jni-ndk-apk-only-command-line-without-gradle-ant-or-cmake

https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#Clang


https://stackoverflow.com/questions/64878248/switch-from-aapt-to-aapt2-for-native-app-packaging
81 changes: 81 additions & 0 deletions android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.tchow.game"
android:installLocation="auto"
android:versionCode="1"
android:versionName="1.0">

<uses-sdk
android:minSdkVersion="29"
android:targetSdkVersion="29" />
<!--
Based on the hello_xr AndroidManifest.xml:
Copyright (c) 2017-2023, The Khronos Group Inc.
SPDX-License-Identifier: Apache-2.0
Changes copyright (c) 2023 Jim McCann
-->
<!-- Tell the system this app requires OpenGL ES 3.2. -->
<uses-feature
android:glEsVersion="0x00030002"
android:required="true" />
<!-- Tell the system this app works in either 3dof or 6dof mode -->
<uses-feature
android:name="android.hardware.vr.headtracking"
android:required="false"
android:version="1" />

<!-- Recommended for haptic feedback -->
<uses-permission android:name="android.permission.VIBRATE" />

<!-- If building externally with the OpenXR loader AAR, this would be merged in automatically. -->
<uses-permission android:name="org.khronos.openxr.permission.OPENXR" />
<uses-permission android:name="org.khronos.openxr.permission.OPENXR_SYSTEM" />

<queries>
<!-- to talk to the broker -->
<provider android:authorities="org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker" />

<!-- so client-side code of runtime/layers can talk to their service sides -->
<intent>
<action android:name="org.khronos.openxr.OpenXRRuntimeService" />
</intent>
<intent>
<action android:name="org.khronos.openxr.OpenXRApiLayerService" />
</intent>
</queries>
<!-- end of elements normally merged from the OpenXR loader AAR -->

<application
android:allowBackup="true"
android:hasCode="false"
android:icon="@mipmap/gp-icon"
android:label="@string/app_name"
android:roundIcon="@mipmap/gp-icon">

<!-- The activity is the built-in NativeActivity framework class. -->
<!-- launchMode is set to singleTask because there should never be multiple copies of the app running. -->
<!-- Theme.Black.NoTitleBar.Fullscreen gives solid black instead of a (bad stereoscopic) gradient on app transition. -->
<activity
android:name="android.app.NativeActivity"
android:configChanges="screenSize|screenLayout|orientation|keyboardHidden|keyboard|navigation|uiMode|density"
android:excludeFromRecents="false"
android:launchMode="singleTask"
android:resizeableActivity="false"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:exported="true" >
<!-- Tell NativeActivity the name of the .so -->
<meta-data
android:name="android.app.lib_name"
android:value="game" />
<!-- This filter lets the apk show up as a launchable icon. -->
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="com.oculus.intent.category.VR" />
<category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />
</intent-filter>
</activity>
</application>
</manifest>
11 changes: 11 additions & 0 deletions android/export-icons.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/sh
INKSCAPE=inkscape
BASENAME=gp-icon

mkdir -p mipmap-mdpi mipmap-hdpi mipmap-xhdpi mipmap-xxhdpi mipmap-xxxhdpi

"$INKSCAPE" "$BASENAME.svg" -o "mipmap-mdpi/$BASENAME.png" --export-type=png --export-area-page --export-width=48 --export-height=48 --export-background='#000000' --export-background-opacity=0.0
"$INKSCAPE" "$BASENAME.svg" -o "mipmap-hdpi/$BASENAME.png" --export-type=png --export-area-page --export-width=72 --export-height=72 --export-background='#000000' --export-background-opacity=0.0
"$INKSCAPE" "$BASENAME.svg" -o "mipmap-xhdpi/$BASENAME.png" --export-type=png --export-area-page --export-width=96 --export-height=96 --export-background='#000000' --export-background-opacity=0.0
"$INKSCAPE" "$BASENAME.svg" -o "mipmap-xxhdpi/$BASENAME.png" --export-type=png --export-area-page --export-width=144 --export-height=144 --export-background='#000000' --export-background-opacity=0.0
"$INKSCAPE" "$BASENAME.svg" -o "mipmap-xxxhdpi/$BASENAME.png" --export-type=png --export-area-page --export-width=192 --export-height=192 --export-background='#000000' --export-background-opacity=0.0
Loading

0 comments on commit 2212a57

Please sign in to comment.