mirror of
https://gitlab.com/eql/lqml.git
synced 2025-12-06 02:30:38 -08:00
iOS: add cross-compiling (both ECL and Lisp code) for iOS Simulator
This commit is contained in:
parent
0a8859bc37
commit
c81ff001c5
4 changed files with 72 additions and 37 deletions
|
|
@ -62,6 +62,7 @@ Please note:
|
||||||
* using latest Xcode, it may complain about the Legacy Build System; just go to
|
* using latest Xcode, it may complain about the Legacy Build System; just go to
|
||||||
File / Project Settings and select New Build System
|
File / Project Settings and select New Build System
|
||||||
|
|
||||||
The simulator will not work here, because we didn't cross-compile ECL and
|
If you cross-compiled ECL for the simulator, it should work there too, but this
|
||||||
the app code for the simulator.
|
is currently only tested on **Intel**.
|
||||||
|
|
||||||
|
Simulator note: ensure the virtual keyboard is shown, see keys `cmd-k`.
|
||||||
|
|
|
||||||
|
|
@ -5,17 +5,10 @@ source_dir=$script_dir
|
||||||
|
|
||||||
config_options="--disable-shared --disable-c99complex --enable-manual=no --with-cross-config=$source_dir/src/util/iOS-arm64.cross_config"
|
config_options="--disable-shared --disable-c99complex --enable-manual=no --with-cross-config=$source_dir/src/util/iOS-arm64.cross_config"
|
||||||
|
|
||||||
# please note: we need to add -DGC_DISABLE_INCREMENTAL, which will remove a private API call
|
# -DGC_DISABLE_INCREMENTAL removes a private API call (not allowed in iOS)
|
||||||
# from the binary, since those are not allowed in iOS (for security reasons)
|
|
||||||
|
|
||||||
export CFLAGS="-DECL_C_COMPATIBLE_VARIADIC_DISPATCH -DECL_RWLOCK -DGC_DISABLE_INCREMENTAL"
|
export CFLAGS="-DECL_C_COMPATIBLE_VARIADIC_DISPATCH -DECL_RWLOCK -DGC_DISABLE_INCREMENTAL"
|
||||||
|
|
||||||
build_dir="$source_dir/build_ios/"
|
|
||||||
install_prefix="$source_dir/ecl-ios/"
|
|
||||||
|
|
||||||
mkdir -p "$build_dir"
|
|
||||||
mkdir -p "$install_prefix"
|
|
||||||
|
|
||||||
num_simultaneous_jobs=1
|
num_simultaneous_jobs=1
|
||||||
|
|
||||||
select_ios()
|
select_ios()
|
||||||
|
|
@ -35,16 +28,20 @@ select_ios()
|
||||||
|
|
||||||
ios_sdk_dir="$ios_sdks/$ios_sdk"
|
ios_sdk_dir="$ios_sdks/$ios_sdk"
|
||||||
|
|
||||||
echo "*** Selecting platform \"$ios_platform\" and SDK \"$ios_sdk\" for \"$arch\"."
|
echo "*** compiling for \"$ios_platform\" - \"$ios_sdk\" - \"$arch\"."
|
||||||
|
|
||||||
case "$platform_type" in
|
case "$platform_type" in
|
||||||
|
|
||||||
iPhoneOS) config_options_extras=--host=aarch64-apple-darwin
|
iPhoneOS) config_options_extras=--host=aarch64-apple-darwin
|
||||||
sdk_name="iphoneos"
|
sdk_name="iphoneos"
|
||||||
|
build_dir="$source_dir/build_ios/"
|
||||||
|
install_prefix="$source_dir/ecl-ios/"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
iPhoneSimulator) config_options_extras=
|
iPhoneSimulator) config_options_extras=--host="$arch-apple-darwin"
|
||||||
sdk_name="iphonesimulator"
|
sdk_name="iphonesimulator"
|
||||||
|
build_dir="$source_dir/build_ios_sim/"
|
||||||
|
install_prefix="$source_dir/ecl-ios-sim/"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
@ -62,7 +59,6 @@ select_ios()
|
||||||
|
|
||||||
export CXXFLAGS="$CFLAGS"
|
export CXXFLAGS="$CFLAGS"
|
||||||
|
|
||||||
# export LD="ld -arch $arch"
|
|
||||||
export LD="ld"
|
export LD="ld"
|
||||||
export LDFLAGS="-arch $arch -pipe -std=c99 -gdwarf-2 -isysroot $ios_sdk_dir"
|
export LDFLAGS="-arch $arch -pipe -std=c99 -gdwarf-2 -isysroot $ios_sdk_dir"
|
||||||
|
|
||||||
|
|
@ -80,8 +76,6 @@ make_ecl()
|
||||||
{
|
{
|
||||||
cd "$build_dir"
|
cd "$build_dir"
|
||||||
|
|
||||||
# make clean
|
|
||||||
|
|
||||||
make -j $num_simultaneous_jobs || exit 1
|
make -j $num_simultaneous_jobs || exit 1
|
||||||
|
|
||||||
make install
|
make install
|
||||||
|
|
@ -96,11 +90,37 @@ build_one_ios()
|
||||||
|
|
||||||
select_ios "$platform_type" "$arch"
|
select_ios "$platform_type" "$arch"
|
||||||
|
|
||||||
|
mkdir -p "$build_dir"
|
||||||
|
mkdir -p "$install_prefix"
|
||||||
|
|
||||||
configure_ecl
|
configure_ecl
|
||||||
|
|
||||||
make_ecl
|
make_ecl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
universal_binaries()
|
||||||
|
{
|
||||||
|
FILES=`find ecl-ios/lib -type f -name '*.a'`
|
||||||
|
|
||||||
|
for ios in $FILES
|
||||||
|
do
|
||||||
|
echo "processing: $ios"
|
||||||
|
sim="ecl-ios-sim${ios:7}"
|
||||||
|
|
||||||
|
lipo -create "$ios" "$sim" -output "$ios.uni"
|
||||||
|
|
||||||
|
mv "$ios.uni" "$ios"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
export ECL_TO_RUN="../ecl-ios-host/bin/ecl"
|
export ECL_TO_RUN="../ecl-ios-host/bin/ecl"
|
||||||
|
|
||||||
build_one_ios iPhoneOS arm64
|
# pass 'sim' to cross-compile for simulator
|
||||||
|
|
||||||
|
if [ "$1" == "sim" ]; then
|
||||||
|
build_one_ios iPhoneSimulator `uname -m`
|
||||||
|
universal_binaries
|
||||||
|
else
|
||||||
|
build_one_ios iPhoneOS arm64
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,37 +2,36 @@
|
||||||
#
|
#
|
||||||
# they will be read into ECL using (ext:getenv) in order to
|
# they will be read into ECL using (ext:getenv) in order to
|
||||||
# set the C compiler variables
|
# set the C compiler variables
|
||||||
|
#
|
||||||
|
# compiles for both iOS and simulator
|
||||||
|
|
||||||
select_ios()
|
select_ios_and_simulator()
|
||||||
{
|
{
|
||||||
platform_type="$1"
|
arch_sim="`uname -m`"
|
||||||
arch="$2"
|
|
||||||
|
|
||||||
ios_platform="$platform_type.platform"
|
platform_type="iPhoneOS"
|
||||||
|
platform_type_sim="iPhoneSimulator"
|
||||||
|
|
||||||
developer_dir="`xcode-select --print-path`"
|
developer_dir="`xcode-select --print-path`"
|
||||||
platforms_dir="$developer_dir/Platforms"
|
platforms_dir="$developer_dir/Platforms"
|
||||||
|
|
||||||
|
ios_platform="$platform_type.platform"
|
||||||
|
ios_platform_sim="$platform_type_sim.platform"
|
||||||
ios_platform_dir="$platforms_dir/$ios_platform"
|
ios_platform_dir="$platforms_dir/$ios_platform"
|
||||||
|
ios_platform_dir_sim="$platforms_dir/$ios_platform_sim"
|
||||||
ios_sdks="$ios_platform_dir/Developer/SDKs"
|
ios_sdks="$ios_platform_dir/Developer/SDKs"
|
||||||
|
ios_sdks_sim="$ios_platform_dir_sim/Developer/SDKs"
|
||||||
|
|
||||||
sdk_version=`(cd "$ios_sdks"; ls -1d *.sdk |sed -e 's/\.sdk$//' -e 's/^[^0-9\.]*//' |awk 'BEGIN{best = 0.0}($0 + 0.0) > best + 0.0{best = $0;}END{print best}')`
|
sdk_version=`(cd "$ios_sdks"; ls -1d *.sdk |sed -e 's/\.sdk$//' -e 's/^[^0-9\.]*//' |awk 'BEGIN{best = 0.0}($0 + 0.0) > best + 0.0{best = $0;}END{print best}')`
|
||||||
|
sdk_version_sim=`(cd "$ios_sdks_sim"; ls -1d *.sdk |sed -e 's/\.sdk$//' -e 's/^[^0-9\.]*//' |awk 'BEGIN{best = 0.0}($0 + 0.0) > best + 0.0{best = $0;}END{print best}')`
|
||||||
|
|
||||||
ios_sdk="$platform_type$sdk_version.sdk"
|
ios_sdk="$platform_type$sdk_version.sdk"
|
||||||
|
ios_sdk_sim="$platform_type_sim$sdk_version_sim.sdk"
|
||||||
|
|
||||||
ios_sdk_dir="$ios_sdks/$ios_sdk"
|
ios_sdk_dir="$ios_sdks/$ios_sdk"
|
||||||
|
ios_sdk_dir_sim="$ios_sdks_sim/$ios_sdk_sim"
|
||||||
|
|
||||||
echo "*** Selecting platform \"$ios_platform\" and SDK \"$ios_sdk\" for \"$arch\"."
|
echo "*** compiling for \"$ios_platform\" - \"$ios_sdk\" and \"$ios_platform_sim\" - \"$ios_sdk_sim\" ***"
|
||||||
|
|
||||||
case "$platform_type" in
|
|
||||||
|
|
||||||
iPhoneOS) config_options_extras=--host=aarch64-apple-darwin
|
|
||||||
sdk_name="iphoneos"
|
|
||||||
;;
|
|
||||||
|
|
||||||
iPhoneSimulator) config_options_extras=
|
|
||||||
sdk_name="iphonesimulator"
|
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
|
||||||
|
|
||||||
# this needs to be updated when a new Xcode is released
|
# this needs to be updated when a new Xcode is released
|
||||||
iphoneos_version_min="11.0"
|
iphoneos_version_min="11.0"
|
||||||
|
|
@ -40,7 +39,7 @@ select_ios()
|
||||||
export CC="clang"
|
export CC="clang"
|
||||||
export CXX="clang++"
|
export CXX="clang++"
|
||||||
|
|
||||||
export CFLAGS="-arch $arch -miphoneos-version-min=$iphoneos_version_min -isysroot $ios_sdk_dir"
|
export CFLAGS="-arch arm64 -arch $arch_sim -miphoneos-version-min=$iphoneos_version_min -isysroot $ios_sdk_dir -isysroot $ios_sdk_dir_sim"
|
||||||
export CFLAGS="$CFLAGS -pipe -Wno-trigraphs -Wreturn-type -Wunused-variable"
|
export CFLAGS="$CFLAGS -pipe -Wno-trigraphs -Wreturn-type -Wunused-variable"
|
||||||
export CFLAGS="$CFLAGS -fpascal-strings -fasm-blocks -fmessage-length=0 -fvisibility=hidden"
|
export CFLAGS="$CFLAGS -fpascal-strings -fasm-blocks -fmessage-length=0 -fvisibility=hidden"
|
||||||
export CFLAGS="$CFLAGS -O0 -DNO_ASM"
|
export CFLAGS="$CFLAGS -O0 -DNO_ASM"
|
||||||
|
|
@ -48,13 +47,12 @@ select_ios()
|
||||||
export CXXFLAGS="$CFLAGS"
|
export CXXFLAGS="$CFLAGS"
|
||||||
|
|
||||||
export LD="ld"
|
export LD="ld"
|
||||||
export LDFLAGS="-arch $arch -miphoneos-version-min=$iphoneos_version_min -pipe -std=c99 -gdwarf-2 -isysroot $ios_sdk_dir"
|
export LDFLAGS="-arch arm64 -arch $arch_sim -isysroot $ios_sdk_dir -isysroot $ios_sdk_dir_sim -pipe -std=c99 -gdwarf-2"
|
||||||
|
|
||||||
export LIBS="-framework Foundation"
|
export LIBS="-framework Foundation"
|
||||||
}
|
}
|
||||||
|
|
||||||
select_ios "iPhoneOS" "arm64"
|
select_ios_and_simulator
|
||||||
#select_ios "iPhoneSimulator" "x86_64"
|
|
||||||
|
|
||||||
$ECL_IOS/../ecl-ios-host/bin/ecl -norc -shell $1
|
$ECL_IOS/../ecl-ios-host/bin/ecl -norc -shell $1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,3 +41,19 @@ and add the following below that line:
|
||||||
Now you should have your cross-compiled ECL under `~/ecl/ios/ecl-ios/`, and
|
Now you should have your cross-compiled ECL under `~/ecl/ios/ecl-ios/`, and
|
||||||
your host ECL (for cross-compiling) under `~/ecl/ios/ecl-ios-host/`.
|
your host ECL (for cross-compiling) under `~/ecl/ios/ecl-ios-host/`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Build for iOS Simulator (optional)
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
Note: only tested on **Intel**.
|
||||||
|
|
||||||
|
For this to work, you will need to upgrade your **gmp** library to the latest
|
||||||
|
version (tested with gmp 6.2.1). Just substitute it in `src/gmp`.
|
||||||
|
|
||||||
|
* run second script again, passing **sim**
|
||||||
|
```
|
||||||
|
./2-make-ecl-ios.sh sim
|
||||||
|
```
|
||||||
|
This will first compile for the simulator, then combine both versions to
|
||||||
|
universal binaries.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue