This repository has been archived by the owner on Nov 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommon.sh
75 lines (63 loc) · 1.72 KB
/
common.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
name=$1
ROOT=`pwd`
ADDON_ROOT=$ROOT/fcitx5-$name
DESTDIR=$ROOT/build/$name
CACHE_DIR=$ROOT/cache
APP_CONTENTS_PATH="/Library/Input Methods/Fcitx5.app/Contents"
# This is the same with INSTALL_PREFIX of prebuilder
INSTALL_PREFIX=/tmp/fcitx5
mkdir -p $INSTALL_PREFIX
if [[ -z $2 ]]; then
ARCH=`uname -m`
else
ARCH=$2
fi
: "${CMAKE_BUILD_TYPE:=Release}"
install_deps() {
for dep in "$@"; do
file=$dep-$ARCH.tar.bz2
[[ -f $CACHE_DIR/$file ]] || wget -P $CACHE_DIR https://github.com/fcitx-contrib/fcitx5-macos-prebuilder/releases/download/latest/$file
tar xjvf $CACHE_DIR/$file -C $INSTALL_PREFIX
done
}
f5m_configure() {
rm -rf build
PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig cmake -B build -G Ninja \
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DCMAKE_FIND_ROOT_PATH="$APP_CONTENTS_PATH;$INSTALL_PREFIX" \
-DCMAKE_OSX_DEPLOYMENT_TARGET=13 \
-DCMAKE_OSX_ARCHITECTURES=$ARCH "$@"
}
f5m_build() {
cmake --build build
}
f5m_install() {
cmake --install build
DESTDIR=$DESTDIR cmake --install build
for dep in "$@"; do
file=$dep-$ARCH.tar.bz2
tar xjvf $CACHE_DIR/$file -C $DESTDIR$INSTALL_PREFIX --exclude include --exclude lib
done
}
f5m_split_data() {
cd $DESTDIR$INSTALL_PREFIX
rm -rf ../data
mkdir -p ../data
rm -rf share/{icons,metainfo} # useless for macOS
for dir in "include" "share"; do
if [[ -d $dir ]]; then
mv $dir ../data/$dir
fi
done
}
# params: IMs to auto add on plugin install
f5m_make_tarball() {
cd $DESTDIR$INSTALL_PREFIX
python3 $ROOT/generate-descriptor.py "$@"
tar cjvf ../../../$name-$ARCH.tar.bz2 --no-xattrs *
cd ../data
tar cjvf ../../../$name-any.tar.bz2 --no-xattrs *
}
set -x
cd $ADDON_ROOT