Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions INSTALL-android.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,44 @@ mkdir -p ~/android/toolchain
cd ~/android/toolchain

tar -xf ~/Downloads/android-sdk_r24.1.2-linux.tgz
7z x ~/Downloads/android-ndk-r10d-linux-x86_64.bin
7z x ~/Downloads/android-ndk-r10e-linux-x86_64.bin
````

Update the SDK:

android-sdk-linuxl/tools/android update sdk --no-ui
android-sdk-linux/tools/android update sdk --no-ui

### Setting up the ARM toolchain

Create a standalone toolchain (this simplifies setting up the build environment):

````bash
android-ndk-r10d/build/tools/make-standalone-toolchain.sh \
--toolchain=arm-linux-androideabi-clang3.4 \
android-ndk-r10e/build/tools/make-standalone-toolchain.sh \
--toolchain=arm-linux-androideabi-clang3.5 \
--platform=android-8 \
--install-dir=~/android/toolchain/standalone
--install-dir=${HOME}/android/toolchain/standalone
````

By default, the Android toolchain uses the `gold` linker. However, this doesn't work for compiling LiveCode, so it's necessary to change the default linker to `ld.bfd` by replacing the `ld` symlink:

````bash
rm standalone/bin/arm-linux-androideabi-ld
ln -s standalone/bin/arm-linux-androideabi-ld.bfd \
ln -s arm-linux-androideabi-ld.bfd \
standalone/bin/arm-linux-androideabi-ld
````

Add a couple of symlinks to allow the engine configuration script to find the Android toolchain:

````bash
ln -s android-ndk-r10e android-ndk
ln -s android-sdk-linux android-sdk
````

## Configuring LiveCode

### Build environment

The Android build expects a large number of environment variables to be set. If the environment variables aren't set, the build process will attempt to guess sensible defaults.
The Android build expects a large number of environment variables to be set. If the environment variables aren't set, the build process will attempt to guess sensible defaults. If you've set up the directory structure as described above, the make command should detect everything automatically and these variables shouldn't be necessary.

The following script will set up the environment variables correctly. You may need to edit it depending on where your JDK and ARM toolchain are installed:

Expand Down
80 changes: 74 additions & 6 deletions config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ fi
# If no output type specified, guess from platform:
if test -z "$FORMATS"; then
case ${OS} in
linux|android) FORMATS="make" ;;
# Always use Linux-style makefiles for Android as the Android toolchain
# is more Linux-y than Darwin-y
linux|android) FORMATS="make-linux" ;;
mac|ios) FORMATS="xcode" ;;
win) FORMATS="msvs" ;;
esac
Expand Down Expand Up @@ -259,22 +261,87 @@ if test -z "$TARGET_ARCH"; then
fi

# Android default settings and tools
ANDROID_BUILD_TOOLS=${ANDROID_BUILD_TOOLS:-22.0.1}
ANDROID_JAVA_SDK=${ANDROID_JAVA_SDK:-${JAVA_SDK:-/usr/lib/jvm/java-7-openjdk-amd64}}
ANDROID_NDK_VERSION=${ANDROID_NDK_VERSION:-r10d}
ANDROID_NDK=${ANDROID_NDK:-${HOME}/Workspace/android-ndk-${ANDROID_NDK_VERSION}}
ANDROID_PLATFORM=${ANDROID_PLATFORM:-android-8}
ANDROID_SDK=${ANDROID_SDK:-${HOME}/Workspace/android-sdk-linux}

ANDROID_TOOLCHAIN=${ANDROID_TOOLCHAIN:-${HOME}/android-armv6-standalone/bin/arm-linux-androideabi-}
# Attempt to locate an Android NDK
if [ -z "${ANDROID_NDK}" ] ; then
# Try the symlink we suggest in INSTALL-android.md
if [ -d "${HOME}/android/toolchain/android-ndk" ] ; then
ANDROID_NDK="${HOME}/android/toolchain/android-ndk"
else
if [ "${OS}" = "android" ] ; then
echo >&2 "Error: Android NDK not found (set \$ANDROID_NDK)"
exit 1
fi
fi
fi

# Attempt to locate an Android SDK
if [ -z "${ANDROID_SDK}" ] ; then
# Try the symlink we suggest in INSTALL-android.md
if [ -d "${HOME}/android/toolchain/android-sdk" ] ; then
ANDROID_SDK="${HOME}/android/toolchain/android-sdk"
else
if [ "${OS}" = "android" ] ; then
echo >&2 "Error: Android SDK not found (set \$ANDROID_SDK)"
exit 1
fi
fi
fi

# Attempt to guess the Android build tools version
if [ -z "${ANDROID_BUILD_TOOLS}" ] ; then
# Check for a sub-folder in the appropriate place
# Possibly fragile - are there ever multiple sub-folders?
if [ ! "$(echo \"${ANDROID_SDK}/build-tools/\"*)" = "${ANDROID_SDK}/build-tools/*" ] ; then
ANDROID_BUILD_TOOLS=$(basename $(echo "${ANDROID_SDK}/build-tools/"*))
else
if [ "${OS}" = "android" ] ; then
echo >&2 "Error: Android build tools not found (set \$ANDROID_BUILD_TOOLS)"
exit 1
fi
fi
fi

if [ -z "${ANDROID_TOOLCHAIN}" ] ; then
# Try the folder we suggest in INSTALL-android.md
if [ -d "${HOME}/android/toolchain/standalone" ] ; then
ANDROID_TOOLCHAIN="${HOME}/android/toolchain/standalone/bin/arm-linux-androideabi-"
else
if [ "${OS}" = "android" ] ; then
echo >&2 "Error: Android toolchain not found (set \$ANDROID_TOOLCHAIN)"
exit 1
fi
fi
fi

ANDROID_AR=${AR:-${ANDROID_TOOLCHAIN}ar}
ANDROID_CC=${CC:-${ANDROID_TOOLCHAIN}clang -target arm-linux-androideabi -march=armv6 -integrated-as}
ANDROID_CXX=${CXX:-${ANDROID_TOOLCHAIN}clang -target arm-linux-androideabi -march=armv6 -integrated-as}
ANDROID_LINK=${LINK:-${ANDROID_TOOLCHAIN}clang -target arm-linux-androideabi -march=armv6 -integrated-as}
ANDROID_OBJCOPY=${OBJCOPY:-${ANDROID_TOOLCHAIN}objcopy}
ANDROID_OBJDUMP=${OBJDUMP:-${ANDROID_TOOLCHAIN}objdump}
ANDROID_STRIP=${STRIP:-${ANDROID_TOOLCHAIN}strip}

if [ -z "${JAVA_SDK}" ] ; then
# Utility used to locate Java on OSX systems
if [ -x /usr/libexec/java_home ] ; then
ANDROID_JAVA_SDK="$(/usr/libexec/java_home)"
elif [ -d /usr/lib/jvm/default ] ; then
ANDROID_JAVA_SDK=/usr/lib/jvm/default
elif [ -d /usr/lib/jvm/default-jvm ] ; then
ANDROID_JAVA_SDK=/usr/lib/jvm/default-jvm
else
if [ "${OS}" = "android" ] ; then
echo >&2 "Error: no Java SDK found - set \$JAVA_SDK"
exit 1
fi
fi
else
ANDROID_JAVA_SDK="${JAVA_SDK}"
fi


################################################################
# Invoke gyp
Expand Down Expand Up @@ -304,6 +371,7 @@ case ${OS} in
export CXX="${ANDROID_CXX}"
export LINK="${ANDROID_LINK}"
export OBJCOPY="${ANDROID_OBJCOPY}"
export OBJDUMP="${ANDROID_OBJDUMP}"
export STRIP="${ANDROID_STRIP}"
invoke_gyp $basic_args "-DOS=${OS}" "-Dtarget_arch=${TARGET_ARCH}" \
-Dcross_compile=1 \
Expand Down
7 changes: 6 additions & 1 deletion config/android.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

'variables':
{
'java_sdk_path%': '<!(echo ${JAVA_SDK:-/usr/lib/jvm/java-6-openjdk-amd64})',
'java_sdk_path%': '<!(echo ${JAVA_SDK})',
'android_sdk_path%': '<!(echo ${ANDROID_SDK})',
'android_ndk_path%': '<!(echo ${ANDROID_NDK})',
'android_platform%': '<!(echo ${ANDROID_PLATFORM})',
Expand All @@ -22,6 +22,11 @@
'java_classpath': '<(android_sdk_path)/platforms/<(android_platform)/android.jar',

'output_dir': '../android-<(target_arch)-bin',

# Capture the values of some build tool environment vars
'objcopy': '<!(echo ${OBJCOPY:-objcopy})',
'objdump': '<!(echo ${OBJDUMP:-objdump})',
'strip': '<!(echo ${STRIP:-strip})',
},

'target_defaults':
Expand Down
9 changes: 9 additions & 0 deletions config/debug_syms.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
],

'extract-debug-symbols_path': '../tools/extract-debug-symbols.sh',

# These tools are only used for Linux and Android targets
'objcopy%': '',
'objdump%': '',
'strip%': '',
},

'actions':
Expand All @@ -33,6 +38,10 @@

'action':
[
'env',
'OBJCOPY=<(objcopy)',
'OBJDUMP=<(objdump)',
'STRIP=<(strip)',
'<(extract-debug-symbols_path)',
'<(OS)',
'>(debug_info_suffix)',
Expand Down
5 changes: 5 additions & 0 deletions config/linux.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
'variables':
{
'output_dir': '../linux-<(target_arch)-bin',

# Capture the values of some build tool environment vars
'objcopy': '<!(echo ${OBJCOPY:-objcopy})',
'objdump': '<!(echo ${OBJDUMP:-objdump})',
'strip': '<!(echo ${STRIP:-strip})',
},

'target_defaults':
Expand Down
39 changes: 28 additions & 11 deletions engine/app-bundle-template.gypi
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
{
'type': 'executable',
'mac_bundle': 1,

'mac_bundle_resources':
'conditions':
[
'rsrc/LiveCode-Community.rsrc',
'rsrc/English.lproj/Localisation.strings',
'rsrc/LiveCodeDoc.icns',
'rsrc/LiveCode.icns',
],
[
'OS == "mac" or OS == "ios"',
{
'target_conditions':
[
[
'_type != "none"',
{
'mac_bundle': 1,
},
],
],

'mac_bundle_resources':
[
'rsrc/LiveCode-Community.rsrc',
'rsrc/English.lproj/Localisation.strings',
'rsrc/LiveCodeDoc.icns',
'rsrc/LiveCode.icns',
],

'xcode_settings':
{
'INFOPLIST_FILE': '<(app_plist)',
},
'xcode_settings':
{
'INFOPLIST_FILE': '<(app_plist)',
},
}
],
],
}
11 changes: 9 additions & 2 deletions gyp/pylib/gyp/generator/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,18 @@ def CalculateGeneratorInputInfo(params):
quiet_cmd_alink_thin = AR($(TOOLSET)) $@
cmd_alink_thin = rm -f $@ && $(AR.$(TOOLSET)) crsT $@ $(filter %.o,$^)

# Figure out the correct --start-group and --end-group commands (not needed for
# the MacOS linker)
ifeq ($(shell uname),Linux)
opt_start_group := -Wl,--start-group
opt_end_group := -Wl,--end-group
endif

# Due to circular dependencies between libraries :(, we wrap the
# special "figure out circular dependencies" flags around the entire
# input list during linking.
quiet_cmd_link = LINK($(TOOLSET)) $@
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ -Wl,--start-group $(LD_INPUTS) -Wl,--end-group $(LIBS)
cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(opt_start_group) $(LD_INPUTS) $(opt_end_group) $(LIBS)

# We support two kinds of shared objects (.so):
# 1) shared_library, which is just bundling together many dependent libraries
Expand All @@ -164,7 +171,7 @@ def CalculateGeneratorInputInfo(params):
cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--whole-archive $(LD_INPUTS) -Wl,--no-whole-archive $(LIBS)

quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ -Wl,--start-group $(filter-out FORCE_DO_CMD, $^) -Wl,--end-group $(LIBS)
cmd_solink_module = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -Wl,-soname=$(@F) -o $@ $(opt_start_group) $(filter-out FORCE_DO_CMD, $^) $(opt_end_group) $(LIBS)
"""

LINK_COMMANDS_MAC = """\
Expand Down