-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_cmake.sh
executable file
·50 lines (40 loc) · 1.27 KB
/
build_cmake.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
## Note, toolchain was installed for all users.
## /Users/$USER/Library/Developer/Toolchains/ for local only
# TOOLCHAINLOC='/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-10-30-a.xctoolchain'
dirname=${PWD##*/}
# if dirname exists leave it alone, else return /
dirname=${dirname:-/}
prefix=`echo $dirname | cut -d - -f 1`
export PN="d${prefix}"
REPOROOT=$(git rev-parse --show-toplevel)
BUILDROOT=$REPOROOT/$dirname/build/
SHAREDROOT=$REPOROOT/Shared
# export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw -o - $TOOLCHAINLOC/Info.plist)
export SHARED=$SHAREDROOT
mkdir -p $BUILDROOT
# ## Use CMake compile_commands.json
# ## set(CMAKE_EXPORT_COMPILE_COMMANDS ON) in the file CMakeLists.txt or the flag below
# cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=YES -B $BUILDROOT -G Ninja .
# if cmake --build $BUILDROOT ; then
# cd $BUILDROOT
# ./$PN
# cd $OLDPWD
# fi
## Use Ninja compile_commands.json
cmake -B $BUILDROOT -G Ninja .
if cmake --build $BUILDROOT ; then
cd $BUILDROOT
ninja -t compdb > compile_commands.json
./$PN
cd $OLDPWD
fi
# if swiftc *swift -o $BUILDROOT/$PN ; then
# cd $BUILDROOT
# ./$PN
# cd $OLDPWD
# fi
# if swiftc Banana/*.swift -o $BUILDROOT/$PN ; then
# cd $BUILDROOT
# ./$PN
# cd $OLDPWD
# fi