Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified CodeLanguagesContainer.xcframework.zip
Binary file not shown.
4 changes: 4 additions & 0 deletions Sources/CodeEditLanguages/Documentation.docc/Add-Languages.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ In order to add a language to ``CodeEditLanguages`` you need to open the `.xcode
```bash
$ ./build_framework.sh
```
> Note: To run the script, you need to install `jq` by downloading it [here](https://stedolan.github.io/jq/) or with Homebrew using:
> ```bash
> $ brew install jq
> ```

5. Check the output of the script. It should say `Done!` at the end.
![build_framework.sh console output](build-output)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ From time to time the `tree-sitter` languages need to be updated to their latest
```bash
$ ./build_framework.sh
```
> Note: To run the script, you need to install `jq` by downloading it [here](https://stedolan.github.io/jq/) or with Homebrew using:
> ```bash
> $ brew install jq
> ```

> Note: This script automatically removes old artifacts and replaces them with the new ones.

3. Check the console output. It should say `Done!` at the end.
Expand Down
66 changes: 57 additions & 9 deletions build_framework.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# convenience function to print a status message in green
status () {
local GREEN='\033[0;32m'
local NC='\033[0m' # No Color
local NC='\033[0m' # No Color
echo "${GREEN}◆ $1${NC}"
}

Expand Down Expand Up @@ -75,21 +75,69 @@ RESOURCES_PATH="$PWD/Sources/CodeEditLanguages/Resources"
status "Copying language queries to package resources..."
rm -rf "$RESOURCES_PATH"

# find and copy language queries
# find and copy language queries
LIST=$( echo $CHECKOUTS_PATH/tree-* )

OLD_PWD="$PWD"

for lang in $LIST ; do
name=${lang##*/}
mkdir -p $RESOURCES_PATH/$name
highlights=$( find $lang -type f -name "*.scm" )
for highlight in $highlights ; do
highlight_name=${highlight##*/}
cp $highlight $RESOURCES_PATH/$name/$highlight_name
# determine how many targets a given package has
cd $lang

# get package info as JSON
manifest=$(swift package dump-package)

# use jq to get the target path
targets=$(echo $manifest | jq -r '.targets[].path')

# use jq to count number of targets
count=$(echo $manifest | jq '.targets | length')

# Determine if target paths are all '.'
same=1
for target in $targets; do
if [[ $target != "." ]]; then
same=0
break
fi
done

# loop through targets
for target in $targets; do
name=${lang##*/}

# if there is only one target, use name
# otherwise use target
if [[ $count -eq 1 || ($count -ne 1 && $same -eq 1) ]]; then
mkdir -p $RESOURCES_PATH/$name
else
mkdir -p $RESOURCES_PATH/$target
fi

highlights=$( find $lang/$target -type f -name "*.scm" )
for highlight in $highlights ; do
highlight_name=${highlight##*/}

# if there is only one target, use name
# otherwise use target
if [[ $count -eq 1 || ($count -ne 1 && $same -eq 1) ]]; then
cp $highlight $RESOURCES_PATH/$name/$highlight_name
else
cp $highlight $RESOURCES_PATH/$target/$highlight_name
fi
done

# If target paths are all '.', break out of loop
if [[ $same -eq 1 || ($count -ne 1 && $same -eq 1) ]]; then
break
fi
done
done
status "Language queries copied to package resources!"

# cleanup derived derived data
# cleanup derived derived data

cd $OLD_PWD

if [ -d "$PWD/DerivedData" ]; then
status "Cleaning up DerivedData..."
Expand Down