52 lines
2.2 KiB
Bash
52 lines
2.2 KiB
Bash
# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
|
|
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
|
|
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
|
|
|
|
# The prepare function is executed in the root of the temp directory
|
|
# This function is used for putting downloaded files to the correct location or applying patches
|
|
prepare() {
|
|
cd "$BPM_SOURCE"/crates/cli
|
|
cargo fetch --locked --target "$(rustc --print host-tuple)"
|
|
}
|
|
|
|
# The build function is executed in the source directory
|
|
# This function is used to compile the source code
|
|
build() {
|
|
# Build library
|
|
cmake -B build -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON
|
|
cmake --build build
|
|
|
|
# Build command-line interface
|
|
cd "$BPM_SOURCE"/crates/cli
|
|
cargo build --release --locked --offline
|
|
|
|
# Build shell completions
|
|
for completion in bash elvish fish nushell zsh; do
|
|
cargo run --frozen --release -- complete --shell $completion > $completion-completions
|
|
done
|
|
}
|
|
|
|
# Function for packaging the main tree sitter library
|
|
package_tree-sitter() {
|
|
DESTDIR="$BPM_OUTPUT" cmake --install build
|
|
|
|
# Install package license
|
|
install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/tree-sitter/LICENSE
|
|
}
|
|
|
|
# Function for packaging the tree sitter cli tools
|
|
package_tree-sitter-cli() {
|
|
install -D "$BPM_SOURCE"/target/release/tree-sitter "$BPM_OUTPUT"/usr/bin/tree-sitter
|
|
|
|
# Install shell completions
|
|
cd crates/cli
|
|
install -Dm644 bash-completions "$BPM_OUTPUT"/usr/share/bash-completion/completions/tree-sitter
|
|
install -Dm644 elvish-completions "$BPM_OUTPUT"/usr/share/elvish/lib/tree-sitter.elv
|
|
install -Dm644 fish-completions "$BPM_OUTPUT"/usr/share/fish/vendor_completions.d/tree-sitter.fish
|
|
install -Dm644 nushell-completions "$BPM_OUTPUT"/usr/share/nushell/vendor/autoload/tree-sitter.nu
|
|
install -Dm644 zsh-completions "$BPM_OUTPUT"/usr/share/zsh/site-functions/_tree-sitter
|
|
|
|
# Install package license
|
|
install -Dm644 "$BPM_SOURCE"/LICENSE "$BPM_OUTPUT"/usr/share/licenses/tree-sitter/LICENSE
|
|
}
|