Skip to content

Interactive Fiction Interpreter Cross Compile Android - using the CMake NDK build system - Example app Thunderfall

Notifications You must be signed in to change notification settings

WakeRealityDev/IFTerpCrossCompileAndroidCMake

Repository files navigation

IFTerpCrossCompileAndroidCMake

This is a newer alternate to the https://github.com/WakeRealityDev/IFTerpCrossCompileAndroid project that uses gcc and Android.mk.

This project uses clang and CMake system with integrated Android Studio 2.3.3 compilation of the NDK code.

This example app is also known as Thunderfall.

Based on Hello JNI

Hello JNI is an Android sample that uses JNI to call C code from a Android Java Activity.

This sample uses the new Android Studio CMake plugin with C++ support.

Pre-requisites

  • Android Studio 2.3.3+ with NDK bundle.

Getting Started

Tested on Ubuntu 17.04 x86 system, latest Google Android NDK from Android Studio as of 2017-08-07. Bash is not required, you could manually run the commands inside of the checkout_terps_and_glk.sh script. These basic steps should work on Linux, OS X, Windows, etc - as long as you have the Android NDK properly installed and some way to download the IF interpreter and RemGlk.

  1. Checkout this project from GitHub.com
  2. $ chmod +x checkout_terps_and_glk.sh
  3. $ ./checkout_terps_and_glk.sh
  4. Launch Android Studio and open the project.

RemGlk + Glulxe source code are not in this project and the bash script will download them intot he proper folder.

You will not need to run ndk-build, the C code build should be automatically performed by the gradle system of Android Studio.

Resulting APK

The APK built with this project should have two binary files in the libs directory (example, arm-v7a CPU):

lib_app_glulxe.so 228kB
libhello-jni.so 9kB

The libhello-jni.so is part of the Google Sample and isn't relevant to the Interactive Fiction code, but it was left in to show the inherited orgins of the code and CMake compilation system.

The important thing to understand is that lib_app_glulxe.so is actualy not a dynamic library but instead an stand-alone executable binary for the Android device. It is only named ".so" to be packaged into the APK - it is not the proper extension for the file given it's stand-alone executable binary format.

If you unzip the APK and extract the lib_app_glulxe.so, you should be able to test it directly as an Android exectuable app:

$ adb push lib_app_glulxe.so /data/local/tmp
$ adb shell
  Now on Android shell it can be executed directly:
  $ cd /data/local/tmp
  $ chmod +x lib_app_glulxe.so
  $ ./lib_app_glulxe.so

At this point you should be able to send JSON to stdin to interface with the RemGlk that is on top of Glulxe interpreter.

Beyond Hello JNI

The commit history of this project will show how a library named :fictionengines was introduced and the NDK code moved into the library.

A sample story is now included in the app, and a basic Activity that can render the RemGlk JSON is now included, borrowed from the Thunderstrike app. This app is now named Thunderfall.

License for the original Hello JNI

Copyright 2015 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

Interactive Fiction Interpreter Cross Compile Android - using the CMake NDK build system - Example app Thunderfall

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published