| #!/bin/bash |
| |
| CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| VSCODE_EXT_DIR="$CURRENT_DIR/../vscode-language-fidl" |
| |
| # Fetch fidl{c, format} prebuilts from CIPD |
| cipd ensure -ensure-file $CURRENT_DIR/sdk_ensure_file.txt -root $CURRENT_DIR/sdk/ |
| |
| # Copy the prebuilts to the extension's bin/ directory |
| mkdir -p $VSCODE_EXT_DIR/bin/linux |
| cp $CURRENT_DIR/sdk/linux/tools/fidlc $VSCODE_EXT_DIR/bin/linux/fidlc |
| cp $CURRENT_DIR/sdk/linux/tools/fidl-format $VSCODE_EXT_DIR/bin/linux/fidl-format |
| mkdir -p $VSCODE_EXT_DIR/bin/mac |
| cp $CURRENT_DIR/sdk/mac/tools/fidlc $VSCODE_EXT_DIR/bin/mac/fidlc |
| cp $CURRENT_DIR/sdk/mac/tools/fidl-format $VSCODE_EXT_DIR/bin/mac/fidl-format |
| |
| # Add write permissions to the files from the SDK so they can be updated in the |
| # future without sudo |
| chmod +w $VSCODE_EXT_DIR/bin/linux/fidlc |
| chmod +w $VSCODE_EXT_DIR/bin/linux/fidl-format |
| chmod +w $VSCODE_EXT_DIR/bin/mac/fidlc |
| chmod +w $VSCODE_EXT_DIR/bin/mac/fidl-format |
| |
| # Cross-compile the language server into the extension's bin/ directory |
| env GOOS=linux GOARCH=amd64 go build -o $VSCODE_EXT_DIR/bin/linux/server $CURRENT_DIR/main.go |
| env GOOS=darwin GOARCH=amd64 go build -o $VSCODE_EXT_DIR/bin/mac/server $CURRENT_DIR/main.go |
| |
| # Build the extension |
| npm --prefix $VSCODE_EXT_DIR install && npm --prefix $VSCODE_EXT_DIR run compile |