-
-
Notifications
You must be signed in to change notification settings - Fork 466
Expand file tree
/
Copy pathgenerate.sh
More file actions
executable file
·67 lines (58 loc) · 2.12 KB
/
generate.sh
File metadata and controls
executable file
·67 lines (58 loc) · 2.12 KB
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
#!/bin/bash
cd "$(dirname "$0")"
source ./script/setup.sh
export XCODEGEN_AEROSPACE_CODE_SIGN_IDENTITY="aerospace-codesign-certificate"
build_version="0.0.0-SNAPSHOT"
generate_xcodeproj=1
generate_cmd_help=1
generate_shell_parser=1
generate_git_hash=0
while test $# -gt 0; do
case $1 in
--build-version) build_version="$2"; shift 2 ;;
--codesign-identity) XCODEGEN_AEROSPACE_CODE_SIGN_IDENTITY="$2"; shift 2 ;;
--generate-git-hash) generate_git_hash=1; shift 1;;
--ignore-cmd-help) generate_cmd_help=0; shift 1 ;;
--ignore-xcodeproj) generate_xcodeproj=0; shift 1 ;;
--ignore-shell-parser) generate_shell_parser=0; shift 1 ;;
*) echo "Unknown option $1"; exit 1 ;;
esac
done
if test $generate_shell_parser = 1; then
./generate-shell-parser.sh
fi
if test $generate_cmd_help = 1; then
# It takes 300ms for the script to complete
./script/generate-cmd-help.sh
fi
cat > Sources/Common/versionGenerated.swift <<EOF
// FILE IS GENERATED BY generate.sh
public let aeroSpaceAppVersion = "$build_version"
EOF
entries() {
for file in docs/aerospace-*.adoc; do
if grep -q 'exec-and-forget' <<< $file; then
continue
fi
subcommand=$(basename $file | sed 's/^aerospace-//' | sed 's/\.adoc$//')
desc="$(grep :manpurpose: "$file" | sed -E 's/:manpurpose: //')"
echo " [\" $subcommand\", \"$desc\"],"
done
}
cat <<EOF > ./Sources/Cli/subcommandDescriptionsGenerated.swift
// FILE IS GENERATED FROM docs/aerospace-*.adoc files
// TO REGENERATE THE FILE RUN generate.sh
let subcommandDescriptions = [
$(entries)
]
EOF
cat <<EOF > ./Sources/Common/gitHashGenerated.swift
// FILE IS GENERATED BY generate.sh
public let gitHash = "$(if test $generate_git_hash = 0; then echo "SNAPSHOT"; else git rev-parse HEAD; fi)"
public let gitShortHash = "$(if test $generate_git_hash = 0; then echo "SNAPSHOT"; else git rev-parse --short HEAD; fi)"
EOF
if test $generate_xcodeproj = 1; then
export XCODEGEN_AEROSPACE_VERSION=$build_version
./script/install-dep.sh --xcodegen
./.deps/xcodegen/xcodegen # https://github.com/yonaskolb/XcodeGen
fi