diff --git a/Makefile b/Makefile index 0a6b7c65..b215c9b3 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 82827420..a6540421 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ privileges. Further administration can be done at . ## 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 . ## License diff --git a/src/android/AndroidManifest.xml b/src/android/AndroidManifest.xml new file mode 100644 index 00000000..60427241 --- /dev/null +++ b/src/android/AndroidManifest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/src/android/com/unprompted/tildefriends/MainActivity.java b/src/android/com/unprompted/tildefriends/MainActivity.java new file mode 100644 index 00000000..a593283e --- /dev/null +++ b/src/android/com/unprompted/tildefriends/MainActivity.java @@ -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!"); + } +} diff --git a/src/android/com/unprompted/tildefriends/MainActivity.kt b/src/android/com/unprompted/tildefriends/MainActivity.kt new file mode 100644 index 00000000..d00a6330 --- /dev/null +++ b/src/android/com/unprompted/tildefriends/MainActivity.kt @@ -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"); + } + */ + } +} diff --git a/src/android/res/layout/activity_main.xml b/src/android/res/layout/activity_main.xml new file mode 100644 index 00000000..18d85d6e --- /dev/null +++ b/src/android/res/layout/activity_main.xml @@ -0,0 +1,12 @@ + + + +