Skip to content

Commit 1f8fb48

Browse files
committed
add iOS arm64_simulator arch and tvOS x86_64_simulator arch
1 parent 902f228 commit 1f8fb48

File tree

11 files changed

+114
-53
lines changed

11 files changed

+114
-53
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This is a cross compilation file from OSX (M1) to arm64
2+
# Apple keeps changing the location and names of files so
3+
# these might not work for you. Use the googels and xcrun.
4+
# https://mesonbuild.com/Reference-tables.html#cpu-families
5+
6+
[binaries]
7+
c = 'clang'
8+
cpp = 'clang++'
9+
objc = 'clang'
10+
objcpp = 'clang++'
11+
ar = 'ar'
12+
strip = 'strip'
13+
14+
[built-in options]
15+
c_args = ['-arch', 'arm64', '-mios-simulator-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
16+
cpp_args = ['-arch', 'arm64', '-mios-simulator-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
17+
c_link_args = ['-arch', 'arm64', '-mios-simulator-version-min=9.0', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
18+
cpp_link_args = ['-arch', 'arm64', '-mios-simulator-version-min=9.0', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
19+
objc_args = ['-arch', 'arm64', '-mios-simulator-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
20+
objcpp_args = ['-arch', 'arm64', '-mios-simulator-version-min=9.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk']
21+
22+
[properties]
23+
root = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer'
24+
has_function_printf = true
25+
has_function_hfkerhisadf = false
26+
27+
[host_machine]
28+
system = 'darwin'
29+
cpu_family = 'aarch64'
30+
cpu = 'aarch64'
31+
endian = 'little'

apple/compile-cfgs/meson-crossfiles/arm64-ios.meson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ has_function_hfkerhisadf = false
2626
[host_machine]
2727
system = 'darwin'
2828
cpu_family = 'aarch64'
29-
cpu = 'arm64'
29+
cpu = 'aarch64'
3030
endian = 'little'

apple/compile-cfgs/meson-crossfiles/arm64-macos.meson

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ has_function_hfkerhisadf = false
2525

2626
[host_machine]
2727
system = 'darwin'
28-
cpu_family = 'arm64'
29-
cpu = 'arm64'
28+
cpu_family = 'aarch64'
29+
cpu = 'aarch64'
3030
endian = 'little'

apple/compile-cfgs/meson-crossfiles/arm64-tvos-simulator.meson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ has_function_hfkerhisadf = false
2626
[host_machine]
2727
system = 'darwin'
2828
cpu_family = 'aarch64'
29-
cpu = 'arm64'
29+
cpu = 'aarch64'
3030
endian = 'little'

apple/compile-cfgs/meson-crossfiles/arm64-tvos.meson

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ has_function_hfkerhisadf = false
2626
[host_machine]
2727
system = 'darwin'
2828
cpu_family = 'aarch64'
29-
cpu = 'arm64'
29+
cpu = 'aarch64'
3030
endian = 'little'
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# This is a cross compilation file from OSX (x86_64) to M1
2+
# Apple keeps changing the location and names of files so
3+
# these might not work for you. Use the googels and xcrun.
4+
5+
[binaries]
6+
c = 'clang'
7+
cpp = 'clang++'
8+
objc = 'clang'
9+
objcpp = 'clang++'
10+
ar = 'ar'
11+
strip = 'strip'
12+
13+
[built-in options]
14+
c_args = ['-arch', 'x86_64', '-mtvos-simulator-version-min=12.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk']
15+
cpp_args = ['-arch', 'x86_64', '-mtvos-simulator-version-min=12.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk']
16+
c_link_args = ['-arch', 'x86_64', '-mtvos-simulator-version-min=12.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk']
17+
cpp_link_args = ['-arch', 'x86_64', '-mtvos-simulator-version-min=12.0', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk']
18+
objc_args = ['-arch', 'x86_64', '-mtvos-simulator-version-min=12.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk']
19+
objcpp_args = ['-arch', 'x86_64', '-mtvos-simulator-version-min=12.0', '-fembed-bitcode', '-Os', '-isysroot', '/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk']
20+
21+
[properties]
22+
root = '/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer'
23+
has_function_printf = true
24+
has_function_hfkerhisadf = false
25+
26+
[host_machine]
27+
system = 'darwin'
28+
cpu_family = 'x86_64'
29+
cpu = 'x86_64'
30+
endian = 'little'

apple/do-compile/any.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,29 @@ do_lipo_all() {
7878

7979
for arch in $archs; do
8080

81-
local ARCH_INC_DIR="$XC_PRODUCT_ROOT/$LIB_NAME-$arch/include"
81+
local inc_src_dir="$XC_PRODUCT_ROOT/$LIB_NAME-$arch/include"
8282
if [[ $arch == *simulator ]];then
83-
local UNI_DIR="$XC_UNI_SIM_PROD_DIR"
83+
local uni_dir="$XC_UNI_SIM_PROD_DIR"
8484
else
85-
local UNI_DIR="$XC_UNI_PROD_DIR"
85+
local uni_dir="$XC_UNI_PROD_DIR"
8686
fi
8787

88-
local ARCH_OUT_DIR="$UNI_DIR/$LIB_NAME/include"
88+
local inc_dst_dir="$uni_dir/$LIB_NAME/include"
8989

90-
if [[ -d "$ARCH_INC_DIR" && ! -d "$ARCH_OUT_DIR" ]]; then
91-
echo "copy include dir to $ARCH_OUT_DIR"
92-
cp -R "$ARCH_INC_DIR" "$ARCH_OUT_DIR"
90+
if [[ -d "$inc_src_dir" ]]; then
91+
echo "copy include dir to $inc_dst_dir"
92+
cp -R "$inc_src_dir" "$inc_dst_dir"
9393

94-
local ARCH_PC_DIR="$XC_PRODUCT_ROOT/$LIB_NAME-$arch/lib/pkgconfig"
95-
if ls ${ARCH_PC_DIR}/*.pc >/dev/null 2>&1;then
96-
local UNI_PC_DIR="$UNI_DIR/$LIB_NAME/lib/pkgconfig/"
97-
mkdir -p "$UNI_PC_DIR"
98-
echo "copy pkgconfig file to $UNI_PC_DIR"
99-
cp ${ARCH_PC_DIR}/*.pc "$UNI_PC_DIR"
94+
local pc_src_dir="$XC_PRODUCT_ROOT/$LIB_NAME-$arch/lib/pkgconfig"
95+
if ls ${pc_src_dir}/*.pc >/dev/null 2>&1;then
96+
local pc_dst_dir="$uni_dir/$LIB_NAME/lib/pkgconfig/"
97+
mkdir -p "$pc_dst_dir"
98+
echo "copy pkgconfig file to $pc_dst_dir"
99+
cp ${pc_src_dir}/*.pc "$pc_dst_dir"
100100
#fix prefix path
101-
p="$UNI_DIR/$LIB_NAME"
101+
p="$uni_dir/$LIB_NAME"
102102
escaped_p=$(echo $p | sed 's/\//\\\//g')
103-
sed -i "" "s/^prefix=.*/prefix=$escaped_p/" "$UNI_PC_DIR/"*.pc
103+
sed -i "" "s/^prefix=.*/prefix=$escaped_p/" "$pc_dst_dir/"*.pc
104104
fi
105105
fi
106106
done

apple/do-compile/freetype.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ echo "XC_DEBUG:$XC_DEBUG"
3333
echo "===check env end==="
3434

3535
# prepare build config
36-
CFG_FLAGS="--prefix=$XC_BUILD_PREFIX --default-library static -Dpng=disabled"
36+
CFG_FLAGS="--prefix=$XC_BUILD_PREFIX --default-library static -Dpng=disabled -Dharfbuzz=disabled"
3737

3838
if [[ "$BUILD_OPT" == "debug" ]]; then
3939
CFG_FLAGS="$CFG_FLAGS --buildtype=debug"

apple/do-compile/harfbuzz.sh

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,34 @@ env_assert "XC_THREAD"
3535
echo "XC_DEBUG:$XC_DEBUG"
3636
echo "===check env end==="
3737
# prepare build config
38-
CFG_FLAGS="--prefix=$XC_BUILD_PREFIX --default-library static"
38+
CFG_FLAGS="--prefix=$XC_BUILD_PREFIX --default-library static -Ddocs=disabled -Dcairo=disabled -Dchafa=disabled -Dtests=disabled"
3939

4040
if [[ "$BUILD_OPT" == "debug" ]]; then
4141
CFG_FLAGS="$CFG_FLAGS --buildtype=debug"
4242
else
4343
CFG_FLAGS="$CFG_FLAGS --buildtype=release"
4444
fi
4545

46-
MY_PKG_CONFIG_LIBDIR=''
47-
# with freetype
48-
if [[ -f "${XC_PRODUCT_ROOT}/freetype-$XC_ARCH/lib/pkgconfig/freetype2.pc" || -f "${XC_PRODUCT_ROOT}/universal/freetype/lib/pkgconfig/freetype2.pc" ]]; then
46+
echo "----------------------"
47+
echo "[*] check freetype"
48+
49+
pkg-config --libs freetype2
50+
51+
pkg-config --libs freetype2 --silence-errors >/dev/null && enable_freetype2=1
52+
53+
if [[ $enable_freetype2 ]];then
4954
echo "[*] --enable-freetype"
50-
if [[ -n "$MY_PKG_CONFIG_LIBDIR" ]]; then
51-
MY_PKG_CONFIG_LIBDIR="$MY_PKG_CONFIG_LIBDIR:"
52-
fi
53-
54-
if [[ -f "${XC_PRODUCT_ROOT}/freetype-$XC_ARCH/lib/pkgconfig/freetype2.pc" ]]; then
55-
MY_PKG_CONFIG_LIBDIR="${MY_PKG_CONFIG_LIBDIR}${XC_PRODUCT_ROOT}/freetype-$XC_ARCH/lib/pkgconfig"
56-
else
57-
MY_PKG_CONFIG_LIBDIR="${MY_PKG_CONFIG_LIBDIR}${XC_PRODUCT_ROOT}/universal/freetype/lib/pkgconfig"
58-
fi
55+
CFG_FLAGS="$CFG_FLAGS -Dfreetype=enabled"
5956
else
6057
echo "[*] --disable-freetype"
61-
fi
62-
63-
if [[ -n "$MY_PKG_CONFIG_LIBDIR" ]]; then
64-
export PKG_CONFIG_LIBDIR="$MY_PKG_CONFIG_LIBDIR"
58+
CFG_FLAGS="$CFG_FLAGS -Dfreetype=disabled"
6559
fi
6660

6761
cd $XC_BUILD_SOURCE
6862
export CC="$XCRUN_CC"
6963
export CXX="$XCRUN_CXX"
7064

7165
if [[ $(uname -m) != "$XC_ARCH" || "$XC_FORCE_CROSS" ]]; then
72-
export PKG_CONFIG=$(which pkg-config)
7366
if [[ $XC_IS_SIMULATOR != 1 ]]; then
7467
echo "[*] cross compile, on $(uname -m) compile $XC_PLAT $XC_ARCH."
7568
CFG_FLAGS="$CFG_FLAGS --cross-file $THIS_DIR/../compile-cfgs/meson-crossfiles/$XC_ARCH-$XC_PLAT.meson"
@@ -83,7 +76,6 @@ echo "----------------------"
8376
echo "[*] compile $LIB_NAME"
8477
echo "CC: $XCRUN_CC"
8578
echo "CFG_FLAGS: $CFG_FLAGS"
86-
echo "PKG_CONFIG_LIBDIR: $MY_PKG_CONFIG_LIBDIR"
8779
echo "----------------------"
8880
echo
8981

@@ -92,12 +84,12 @@ if [[ -d $build ]]; then
9284
rm -rf $build
9385
fi
9486

95-
meson setup $build $CFG_FLAGS 1>/dev/null
96-
97-
cd $build
9887
# show all configure
9988
# https://mesonbuild.com/Build-options.html
100-
# meson configure
101-
meson configure -Ddocs=disabled -Dcairo=disabled -Dchafa=disabled -Dfreetype=enabled -Dtests=disabled
102-
meson compile
103-
meson install 1>/dev/null
89+
meson setup $build $CFG_FLAGS
90+
91+
cd $build
92+
93+
echo "compile"
94+
95+
meson compile && meson install

apple/init-env.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ function init_plat_env() {
6161

6262
if [[ "$XC_PLAT" == 'ios' ]]; then
6363
export XC_OTHER_CFLAGS="-fembed-bitcode"
64-
ALL_ARCHS="arm64 x86_64_simulator"
64+
ALL_ARCHS="arm64 arm64_simulator x86_64_simulator"
6565
elif [[ "$XC_PLAT" == 'macos' ]]; then
6666
export XC_OTHER_CFLAGS=""
6767
ALL_ARCHS="x86_64 arm64"
6868
elif [[ "$XC_PLAT" == 'tvos' ]]; then
6969
export XC_OTHER_CFLAGS=''
70-
ALL_ARCHS="arm64 arm64_simulator"
70+
ALL_ARCHS="arm64 arm64_simulator x86_64_simulator"
7171
fi
7272

7373
if [[ -z "$XC_ALL_ARCHS" ]];then
@@ -139,7 +139,7 @@ function init_arch_env () {
139139

140140
if [[ "$XC_PLAT" == 'ios' ]]; then
141141
case $_XC_ARCH in
142-
'x86_64_simulator')
142+
*_simulator)
143143
export XCRUN_PLATFORM='iPhoneSimulator'
144144
export XC_DEPLOYMENT_TARGET='-mios-simulator-version-min=11.0'
145145
export XC_IS_SIMULATOR=1
@@ -148,14 +148,18 @@ function init_arch_env () {
148148
export XCRUN_PLATFORM='iPhoneOS'
149149
export XC_DEPLOYMENT_TARGET='-miphoneos-version-min=11.0'
150150
;;
151+
*)
152+
echo "wrong arch:$_XC_ARCH for $XC_PLAT"
153+
exit 1
154+
;;
151155
esac
152156
elif [[ "$XC_PLAT" == 'macos' ]]; then
153157
export XCRUN_PLATFORM='MacOSX'
154158
export MACOSX_DEPLOYMENT_TARGET=10.11
155159
export XC_DEPLOYMENT_TARGET="-mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET"
156160
elif [[ "$XC_PLAT" == 'tvos' ]]; then
157161
case $_XC_ARCH in
158-
'arm64_simulator')
162+
*_simulator)
159163
export XCRUN_PLATFORM='AppleTVSimulator'
160164
export XC_DEPLOYMENT_TARGET="-mtvos-simulator-version-min=12.0"
161165
export XC_IS_SIMULATOR=1
@@ -164,6 +168,10 @@ function init_arch_env () {
164168
export XCRUN_PLATFORM='AppleTVOS'
165169
export XC_DEPLOYMENT_TARGET="-mtvos-version-min=12.0"
166170
;;
171+
*)
172+
echo "wrong arch:$_XC_ARCH for $XC_PLAT"
173+
exit 1
174+
;;
167175
esac
168176
fi
169177

0 commit comments

Comments
 (0)