2
0
Fork 0
mirror of https://github.com/bazelbuild/rules_cc synced 2024-11-27 20:43:26 +00:00
rules_cc/examples/custom_toolchain/sample_linker

24 lines
783 B
Bash
Executable file

#!/bin/bash
#
# Sample script demonstrating custom C++ toolchain selection: handles
# the command that translates a cc_library's .o (object file) into
# .a (archive).
echo "$0: running sample cc_library linker (produces .a output)."
# https://docs.bazel.build/versions/master/cc-toolchain-config-reference.html
# defines fancier ways to generate custom command lines. This script just shows
# the default, which looks like:
#
# examples/custom_toolchain/sample_linker @bazel-out/x86-fastbuild/bin/examples/custom_toolchain/libbuildme.a-2.params.
# Get "@bazel-out/.../libbuildme.a-2.params".
PARAMS_FILE=${@: -1}
# Remove the "@" prefix.
OUTFILE=${PARAMS_FILE#?}
# Replace "libbuildme.a-2.params" with "libbuildme.a".
OUTFILE=${OUTFILE%-*}
echo "$0: sample output" > $OUTFILE