forked from beeware/mobile-forge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-iOS.sh
executable file
·122 lines (102 loc) · 4.56 KB
/
setup-iOS.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/bash
# set -e
if [ -z "$1" ]; then
echo "usage: $0 <python version>"
echo "e.g.:"
echo
echo " source $0 3.11"
echo
return
fi
PYTHON_VER=$1
CMAKE_VERSION="3.27.4"
if [ -z "$PYTHON_APPLE_SUPPORT" ]; then
echo "PYTHON_APPLE_SUPPORT not defined."
return
fi
if [ ! -d $PYTHON_APPLE_SUPPORT/install ]; then
echo "PYTHON_APPLE_SUPPORT does not point at a valid loation."
return
fi
PYTHON_FOLDER=$(echo `ls -1d $PYTHON_APPLE_SUPPORT/install/macOS/macosx/python-$PYTHON_VER.*` | sort -n -r | head -n1)
PYTHON_VERSION=$(basename $PYTHON_FOLDER | cut -d "-" -f 2)
if [ ! -x $PYTHON_APPLE_SUPPORT/install/macOS/macosx/python-$PYTHON_VERSION/bin/python$PYTHON_VER ]; then
echo "PYTHON_APPLE_SUPPORT does not appear to contain a Python $PYTHON_VERSION macOS binary."
echo $PYTHON_APPLE_SUPPORT/install/macOS/macosx/python-$PYTHON_VERSION/bin/python$PYTHON_VER
return
fi
if [ ! -e $PYTHON_APPLE_SUPPORT/install/iOS/iphoneos.arm64/python-$PYTHON_VERSION/bin/python$PYTHON_VER ]; then
echo "PYTHON_APPLE_SUPPORT does not appear to contain a Python $PYTHON_VERSION iOS ARM64 device binary."
return
fi
if [ ! -e $PYTHON_APPLE_SUPPORT/install/iOS/iphonesimulator.arm64/python-$PYTHON_VERSION/bin/python$PYTHON_VER ]; then
echo "PYTHON_APPLE_SUPPORT does not appear to contain a Python $PYTHON_VERSION iOS ARM64 simulator binary."
return
fi
if [ ! -e $PYTHON_APPLE_SUPPORT/install/iOS/iphonesimulator.x86_64/python-$PYTHON_VERSION/bin/python$PYTHON_VER ]; then
echo "PYTHON_APPLE_SUPPORT does not appear to contain a Python $PYTHON_VERSION iOS x86-64 simulator binary."
return
fi
# Ensure CMake is installed
if ! [ -d "tools/CMake.app" ]; then
if ! [ -f "downloads/cmake-${CMAKE_VERSION}-macos-universal.tar.gz" ]; then
echo "Downloading CMake"
mkdir -p downloads
curl --location "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-macos-universal.tar.gz" --output downloads/cmake-${CMAKE_VERSION}-macos-universal.tar.gz
fi
echo "Installing CMake"
mkdir -p tools
tar -xzf downloads/cmake-${CMAKE_VERSION}-macos-universal.tar.gz
mv cmake-${CMAKE_VERSION}-macos-universal/CMake.app tools
rm -rf cmake-${CMAKE_VERSION}-macos-universal
fi
if [ ! -z "$VIRTUAL_ENV" ]; then
deactivate
fi
if [ ! -d ./venv$PYTHON_VER ]; then
echo "Creating Python $PYTHON_VER virtual environment for build..."
$PYTHON_APPLE_SUPPORT/install/macOS/macosx/python-$PYTHON_VERSION/bin/python$PYTHON_VER -m venv venv$PYTHON_VER
source ./venv$PYTHON_VER/bin/activate
pip install -U pip
pip install -e . wheel
echo "Building platform dependency wheels..."
python -m make_dep_wheels iOS
echo "Python $PYTHON_VERSION environment has been created."
echo
else
echo "Using existing Python $PYTHON_VERSION environment."
source ./venv$PYTHON_VER/bin/activate
fi
# Create wheels for ninja that can be installed in the host environment
if ! [ -f "dist/ninja-1.11.1-py3-none-ios_12_0_iphoneos_arm64.whl" ]; then
echo "Downloading Ninja"
python -m pip wheel --no-deps -w dist ninja==1.11.1
mv dist/ninja-1.11.1-*.whl dist/ninja-1.11.1-py3-none-ios_12_0_iphoneos_arm64.whl
cp dist/ninja-1.11.1-py3-none-ios_12_0_iphoneos_arm64.whl dist/ninja-1.11.1-py3-none-ios_12_0_iphonesimulator_x86_64.whl
cp dist/ninja-1.11.1-py3-none-ios_12_0_iphoneos_arm64.whl dist/ninja-1.11.1-py3-none-ios_12_0_iphonesimulator_arm64.whl
fi
export PATH="$PATH:$PYTHON_APPLE_SUPPORT/support/$PYTHON_VER/iOS/bin:$(pwd)/tools/CMake.app/Contents/bin"
export MOBILE_FORGE_IPHONEOS_ARM64=$PYTHON_APPLE_SUPPORT/install/iOS/iphoneos.arm64/python-$PYTHON_VERSION/bin/python$PYTHON_VER
export MOBILE_FORGE_IPHONESIMULATOR_ARM64=$PYTHON_APPLE_SUPPORT/install/iOS/iphonesimulator.arm64/python-$PYTHON_VERSION/bin/python$PYTHON_VER
export MOBILE_FORGE_IPHONESIMULATOR_X86_64=$PYTHON_APPLE_SUPPORT/install/iOS/iphonesimulator.x86_64/python-$PYTHON_VERSION/bin/python$PYTHON_VER
echo
echo "You can now build packages with forge; e.g.:"
echo
echo "Build all packages for all iOS targets:"
echo " forge iOS"
echo
echo "Build only the non-python packages, for all iOS targets:"
echo " forge iOS -s non-py"
echo
echo "Build all packages needed for a smoke test, for all iOS targets:"
echo " forge iOS -s smoke"
echo
echo "Build lru-dict for all iOS targets:"
echo " forge iOS lru-dict"
echo
echo "Build lru-dict for the ARM64 device target:"
echo " forge iphoneos:arm64 lru-dict"
echo
echo "Build all applicable versions of lru-dict for all iOS targets:"
echo " forge iOS --all-versions lru-dict"
echo