11#! /usr/bin/env sh
22
3+ # This script builds the CodeLanguagesContainer.xcframework
4+ #
5+ # Just call it from the root of the project
6+ # $ ./build_framework.sh
7+ #
8+ # If you need debug output, set the --debug flag
9+ # $ ./build_framework.sh --debug
10+ #
11+ # Created by: Lukas Pistrol on 29.10.2022
12+
13+ # convenience function to print a status message in green
14+ status () {
15+ local GREEN=' \033[0;32m'
16+ local NC=' \033[0m' # No Color
17+ echo " ${GREEN} ◆ $1 ${NC} "
18+ }
19+
20+ # If --debug set -quiet flag and redirect output to /dev/null
21+ if [ " $1 " = " --debug" ]; then
22+ QUIET_FLAG=" "
23+ QUIET_OUTPUT=/dev/stdout
24+ else
25+ QUIET_FLAG=" -quiet"
26+ QUIET_OUTPUT=/dev/null
27+ fi
28+
29+ # Set pipefail to make sure that the script fails if any of the commands fail
330set -euo pipefail
431
532# build the framework project `CodeLanguages-Container`
33+ status " Clean Building CodeLanguages-Container.xcodeproj..."
634xcodebuild \
735 -project CodeLanguages-Container/CodeLanguages-Container.xcodeproj \
836 -scheme CodeLanguages-Container \
937 -destination " platform=macOS" \
1038 -derivedDataPath DerivedData \
1139 -configuration Release \
12- -quiet clean build
40+ $QUIET_FLAG clean build & > $QUIET_OUTPUT
41+ status " Build complete!"
1342
1443# set path variables
1544PRODUCTS_PATH=" $PWD /DerivedData/Build/Products/Release"
@@ -19,39 +48,45 @@ OUTPUT_PATH="CodeLanguagesContainer.xcframework"
1948# remove previous generated files
2049rm -rf " $OUTPUT_PATH "
2150rm " $OUTPUT_PATH " .zip
51+ status " Removed previous generated files!"
2252
2353# build the binary framework
54+ status " Creating CodeLanguagesContainer.xcframework..."
2455xcodebuild \
2556 -create-xcframework \
2657 -framework " $FRAMEWORK_PATH " \
27- -output " $OUTPUT_PATH "
58+ -output " $OUTPUT_PATH " & > $QUIET_OUTPUT
2859
2960# zip the xcframework
61+ status " Zipping CodeLanguagesContainer.xcframework..."
3062zip -r -q " $OUTPUT_PATH " .zip " $OUTPUT_PATH "
3163
3264# remove the unzipped xcframework
3365rm -rf " $OUTPUT_PATH "
3466
67+ status " CodeLanguagesContainer.xcframework.zip created!"
68+
3569# copy language queries to package resources
3670# set path variables
3771CHECKOUTS_PATH=" $PWD /DerivedData/SourcePackages/checkouts"
3872RESOURCES_PATH=" $PWD /Sources/CodeEditLanguages/Resources"
3973
4074# remove previous copied files
75+ status " Copying language queries to package resources..."
4176rm -rf " $RESOURCES_PATH "
4277
4378# find and copy language queries
4479LIST=$( echo $CHECKOUTS_PATH /tree-* )
4580
4681for lang in $LIST ; do
4782 name=${lang##*/ }
48- echo " Copying queries: $name "
4983 mkdir -p $RESOURCES_PATH /$name
5084 highlights=$( find $lang -type f -name " *.scm" )
5185 for highlight in $highlights ; do
5286 highlight_name=${highlight##*/ }
5387 cp $highlight $RESOURCES_PATH /$name /$highlight_name
5488 done
5589done
90+ status " Language queries copied to package resources!"
5691
57- echo " Done!"
92+ status " Done!"
0 commit comments