1#!/bin/bash 2# 3# Sample script demonstrating custom C++ toolchain selection: handles 4# the command that translates a cc_library's .cc (source file) into .o (object 5# file). 6 7echo "$0: running sample cc_library compiler (produces .o output)." 8 9# https://docs.bazel.build/versions/master/cc-toolchain-config-reference.html 10# defines fancier ways to generate custom command lines. This script just shows 11# the default, which looks like: 12# 13# examples/custom_toolchain/sample_compiler <various compiler flags> -o bazel-out/x86-fastbuild/bin/examples/custom_toolchain/_objs/buildme/buildme.o. 14 15# The .o is the last parameter. 16OBJECT_FILE=${@: -1} 17# Swap out .o for .d to get expected .d (source dependency output). 18DOTD_FILE=${OBJECT_FILE%?}d 19 20echo "$0: sample .o output" > $OBJECT_FILE 21echo "sample .d output ($0)" > $DOTD_FILE 22