1#!/bin/bash 2# 3# Copyright 2015 The Bazel Authors. All rights reserved. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17# Ship the environment to the C++ action 18# 19set -eu 20 21OUTPUT= 22 23function parse_option() { 24 local -r opt="$1" 25 if [[ "${OUTPUT}" = "1" ]]; then 26 OUTPUT=$opt 27 elif [[ "$opt" = "-o" ]]; then 28 # output is coming 29 OUTPUT=1 30 fi 31} 32 33# let parse the option list 34for i in "$@"; do 35 if [[ "$i" = @* && -r "${i:1}" ]]; then 36 while IFS= read -r opt 37 do 38 parse_option "$opt" 39 done < "${i:1}" || exit 1 40 else 41 parse_option "$i" 42 fi 43done 44 45# Set-up the environment 46%{env} 47 48# Call the C++ compiler 49%{cc} "$@" 50 51# Generate an empty file if header processing succeeded. 52if [[ "${OUTPUT}" == *.h.processed ]]; then 53 echo -n > "${OUTPUT}" 54fi 55