forked from haxpor/aseprite-macos-buildsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aseprite.sh
executable file
·187 lines (156 loc) · 5.23 KB
/
aseprite.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/bash
#
# Script to automate building latest release of Aseprite (it can be release or beta build)
# This is for macOS build version.
POSTFIXPATH_SDKROOT=Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk
CCPATH_TOOLCHAIN=Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
CXXPATH_TOOLCHAIN=Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
SDK_ROOT=`xcode-select -p`
TARGET="/Applications"
# temporary value for returned value from function
TEMP_RET=""
# find value of target param --xxx if there's any, if not then TEMP_RET will still be empty "", else it will contain value from finding
# param 1 - parameter key name
# param 2 - program list of param, usually is $@
# return 1 if it found, and TEMP_RET is set, otherwise return 0. TEMP_RET will be always set to "" (empty) at the beginning of this function.
function findValueOfParam() {
# set empty to temporary return variable first
TEMP_RET=""
count=$#
argv=($@)
for (( i=1; i<count; i++ )); do
if [ ${argv[i]} = "$1" ]; then
TEMP_RET=${argv[i+1]}
return 0
fi
done
return 1
}
# check if there's any input parameters
if [ $(($# % 2)) -ne 0 ]; then
echo "Missing some parameter value"
exit 1
fi
# set the input argument
if [ "$#" -ne 0 ]; then
# if only one parameter
findValueOfParam "--sdk-root" $@
if [ $? -eq 0 ]; then
# orvewrite set sdk-root
SDK_ROOT=$TEMP_RET
# set to xcode-select as well
sudo xcode-select -s "$SDK_ROOT"
echo "Set SDK_ROOT to $SDK_ROOT"
fi
findValueOfParam "--target" $@
if [ $? -eq 0 ]; then
# orvewrite set sdk-root
TARGET=$TEMP_RET
echo "Set TARGET to $TARGET"
fi
fi
# check if aseprite directory exists, so we has no need to clone from repository again
if [ ! -d aseprite ]; then
git clone --recursive https://github.com/aseprite/aseprite.git
fi
# change to aseprite directory
cd aseprite
# checkout master branch
git checkout master
# clear the current dirty state of git repository
git reset --hard
git clean -fd
# fetch all the update down
git fetch --all
git pull
git submodule update --init --recursive
# compile skia
cd ..
# check to create deps directory if not exist
if [ ! -d deps ]; then
mkdir deps
fi
cd deps
# check if depot_tools is already cloned
if [ ! -d depot_tools ]; then
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
fi
# check if skia is already cloned
if [ ! -d skia ]; then
git clone https://github.com/aseprite/skia.git
fi
# clear the dirty state of both repositories
cd depot_tools
git reset --hard
git clean -fd
git fetch --all
git pull
# change dir back
cd ../
cd skia
git reset --hard
git clean -fd
git fetch --all
git pull
# change dir back
cd ../
# continue the operation
export PATH="${PWD}/depot_tools:${PATH}"
cd skia
# get proper skia's branch to compile
SKIA_BRANCH=$(curl "https://raw.githubusercontent.com/aseprite/aseprite/master/INSTALL.md" | grep "aseprite-m[0-9][0-9]" | sed -n '1p' | perl -n -e '/(aseprite-m\d\d)/ && print $1')
git checkout $SKIA_BRANCH
python tools/git-sync-deps
gn gen out/Release-x64 --args="is_debug=false is_official_build=true skia_use_system_expat=false skia_use_system_icu=false skia_use_system_libjpeg_turbo=false skia_use_system_libpng=false skia_use_system_libwebp=false skia_use_system_zlib=false skia_use_sfntly=false skia_use_freetype=true skia_use_harfbuzz=true skia_pdf_subset_harfbuzz=true skia_use_system_freetype2=false skia_use_system_harfbuzz=false target_cpu=\"x64\" extra_cflags=[\"-stdlib=libc++\", \"-mmacosx-version-min=10.9\"] extra_cflags_cc=[\"-frtti\"]"
ninja -C out/Release-x64 skia modules
cd ../../
# compile aseprite
cd aseprite
# create build dir (if needed)
if [ ! -d build ]; then
mkdir build
fi
cd build
# prepare environment variables
export CC="$SDK_ROOT/$CCPATH_TOOLCHAIN"
export CXX="$SDK_ROOT/$CXXPATH_TOOLCHAIN"
# checkout the latest tag (release or beta)
git checkout `git describe --tags`
cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_OSX_ARCHITECTURES=x86_64 \
-DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 \
-DCMAKE_OSX_SYSROOT="$SDK_ROOT/$POSTFIXPATH_SDKROOT" \
-DLAF_OS_BACKEND=skia \
-DSKIA_DIR="${PWD}/../../deps/skia" \
-DSKIA_LIBRARY_DIR="${PWD}/../../deps/skia/out/Release-x64" \
-DSKIA_LIBRARY="${PWD}/../../deps/skia/out/Release-x64/libskia.a" \
-G Ninja \
.. && \
ninja aseprite # when finish, build file will be at aseprite/build/bin
# if everything went fine then do final operations
if [ $? -eq 0 ]; then
# remove existing Aseprite if installed
if [ -d "$TARGET/Aseprite" ]; then
rm -rf "$TARGET/Aseprite"
fi
# move result to default ~/Applications
mv bin "$TARGET/Aseprite"
# check to create target directory
if [ -d "$TARGET/Aseprite.app" ]; then
# if found then copy all the contents of our template .app instead
# this is to avoid risking removing any user' files the app might created
echo "Target Aseprite.app directory found, copying contents of template .app to target location instead"
# copy application bundle to result
cp -Rp ../../Aseprite.app/* "$TARGET/Aseprite.app/"
echo "All done"
else
# if not, then just copy the whole template .app directory to target
echo "Copying template .app to target location"
# copy application bundle to result
cp -Rp ../../Aseprite.app "$TARGET/Aseprite.app"
echo "All done"
fi
else
echo "Something went wrong"
fi