Minimal build support for an android app. Written while the power was out.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4199 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2023-03-04 19:10:05 +00:00
parent 262b0e5e52
commit 28d73f5b37
6 changed files with 98 additions and 7 deletions

View File

@ -20,9 +20,12 @@ CFLAGS += \
-g
LDFLAGS += -Wl,--gc-sections
NDK_PATH := /usr/lib/android-sdk/ndk-bundle
NDK_API_VERSION := 30
NDK_TARGET_TRIPLE := aarch64-linux-android
ANDROID_SDK ?= /usr/lib/android-sdk
ANDROID_BUILD_TOOLS := $(ANDROID_SDK)/build-tools/29.0.3
ANDROID_PLATFORM := $(ANDROID_SDK)/platforms/android-23
ANDROID_NDK ?= /usr/lib/android-sdk/ndk-bundle
ANDROID_NDK_API_VERSION := 30
ANDROID_NDK_TARGET_TRIPLE := aarch64-linux-android
debug windebug androiddebug: CFLAGS += -Og
debug release androidrelease: LDFLAGS += -rdynamic
@ -38,14 +41,14 @@ windebug winrelease: LDFLAGS += \
-static \
-lm \
-Ldeps/openssl/mingw64/lib
androiddebug androidrelease: CC = $(NDK_PATH)/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
androiddebug androidrelease: CC = $(ANDROID_NDK)/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
androiddebug androidrelease: AS = $(CC)
androiddebug androidrelease: CFLAGS += \
-target $(NDK_TARGET_TRIPLE)$(NDK_API_VERSION) \
-target $(ANDROID_NDK_TARGET_TRIPLE)$(ANDROID_NDK_API_VERSION) \
-Ideps/openssl/android/arm64-v8a/usr/local/include \
-Wno-unknown-warning-option
androiddebug androidrelease: LDFLAGS += \
-target $(NDK_TARGET_TRIPLE)$(NDK_API_VERSION) \
-target $(ANDROID_NDK_TARGET_TRIPLE)$(ANDROID_NDK_API_VERSION) \
-Ldeps/openssl/android/arm64-v8a/usr/local/lib
ifeq ($(UNAME_M),x86_64)
@ -360,6 +363,33 @@ endef
$(foreach build_type,$(BUILD_TYPES),$(eval $(call build_rules,$(build_type))))
# Android support.
out/gen/com/unprompted/tildefriends/R.java: $(wildcard src/android/res/layout/*) src/android/AndroidManifest.xml
@mkdir -p $(dir $@)
@echo [aapt] R.java
@$(ANDROID_BUILD_TOOLS)/aapt package -f -m -J out/gen/ -S src/android/res/ -M src/android/AndroidManifest.xml -I $(ANDROID_PLATFORM)/android.jar
JAVA_FILES := out/gen/com/unprompted/tildefriends/R.java $(wildcard src/android/com/unprompted/tildefriends/*.java)
CLASS_FILES := $(foreach src,$(JAVA_FILES),out/classes/com/unprompted/tildefriends/$(notdir $(src:.java=.class)))
$(CLASS_FILES) &: $(JAVA_FILES)
@echo [javac] $(CLASS_FILES)
@javac --release 9 -classpath $(ANDROID_PLATFORM)/android.jar -d out/classes $(JAVA_FILES)
out/apk/classes.dex: $(CLASS_FILES)
@mkdir -p $(dir $@)
@echo [dx] $@
@$(ANDROID_BUILD_TOOLS)/dx --dex --output=$@ out/classes/
out/TildeFriends.unsigned.apk: out/apk/classes.dex
@mkdir -p $(dir $@)
@echo [aapt] $@
@$(ANDROID_BUILD_TOOLS)/aapt package -f -M src/android/AndroidManifest.xml -S src/android/res/ -I $(ANDROID_PLATFORM)/android.jar -F $@ out/apk/
out/TildeFriends.apk: out/TildeFriends.unsigned.apk
@echo [apksigner] $(notdir $@)
@$(ANDROID_BUILD_TOOLS)/apksigner sign --ks keystore.jks --ks-key-alias androidKey --ks-pass pass:android --key-pass pass:android --out $@ $<
clean:
rm -rf $(BUILD_DIR)
.PHONY: clean

View File

@ -28,7 +28,7 @@ privileges. Further administration can be done at
<http://localhost:12345/~core/admin/`>.
## Documentation
There are the very beginnings of developer documentation in `apps/cory/docs/`
There are the very beginnings of developer documentation in `apps/docs/`
that can be read in-place or at <http://localhost:12345/~core/docs/>.
## License

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.unprompted.tildefriends"
versionCode="1"
versionName="0.0.4">
<uses-sdk android:minSdkVersion="16"/>
<application android:label="Tilde Friends">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,15 @@
package com.unprompted.tildefriends;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
TextView text = (TextView)findViewById(R.id.my_text);
text.setText("Hello, world!");
}
}

View File

@ -0,0 +1,19 @@
package com.unprompted.tildefriends
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
companion object {
/*
init {
System.loadLibrary("tildefriends");
}
*/
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/my_text"/>
</LinearLayout>