diff options
author | Marcel Hlopko <hlopko@google.com> | 2016-10-11 15:30:49 +0000 |
---|---|---|
committer | Yue Gan <yueg@google.com> | 2016-10-12 08:55:07 +0000 |
commit | 74b94328db5346e0f6c573731fcbaa85ca751304 (patch) | |
tree | cab3cab9a81aab6bea2016b2567039661f682324 /tools | |
parent | 671045b8fd9cc53d208af6eb38dab5c1fb543545 (diff) |
Move interface so building to action configs
This cl moves the conditional building of interface libraries from LinkCommandLine to action configs and features. It provides link_dynamic_library.sh to keep blaze backwards compatible. The script and related code can be deleted once all crosstools are updated.
RELNOTES: No.
--
MOS_MIGRATED_REVID=135799041
Diffstat (limited to 'tools')
-rw-r--r-- | tools/cpp/BUILD | 5 | ||||
-rw-r--r-- | tools/cpp/BUILD.static | 5 | ||||
-rwxr-xr-x | tools/cpp/link_dynamic_library.sh | 60 |
3 files changed, 70 insertions, 0 deletions
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD index 50d19a855b..a3c8cbe4a4 100644 --- a/tools/cpp/BUILD +++ b/tools/cpp/BUILD @@ -158,3 +158,8 @@ filegroup( name = "srcs", srcs = glob(["**"]) + ["//tools/cpp/test:srcs"], ) + +filegroup( + name = "link_dynamic_library", + srcs = ["link_dynamic_library.sh"], +) diff --git a/tools/cpp/BUILD.static b/tools/cpp/BUILD.static index 32a323ad35..6f52c9d0c7 100644 --- a/tools/cpp/BUILD.static +++ b/tools/cpp/BUILD.static @@ -94,3 +94,8 @@ filegroup( "wrapper/bin/pydir/msvc*", ]), ) + +filegroup( + name = "link_dynamic_library", + srcs = ["link_dynamic_library.sh"], +) diff --git a/tools/cpp/link_dynamic_library.sh b/tools/cpp/link_dynamic_library.sh new file mode 100755 index 0000000000..ae79a80f23 --- /dev/null +++ b/tools/cpp/link_dynamic_library.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# +# Copyright 2016 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# This script handles interface library generation for dynamic library +# link action. +# +# Bazel can be configured to generate external interface library script +# to generate interface libraries in CppLinkAction for dynamic libraries. +# This is not needed on Windows (as the "interface" libraries are +# generated by default). This script therefore handles the cases when +# external script is provided, or when no script should be used. + +set -eu + +E_LINKER_COMMAND_NOT_FOUND=12 +E_INTERFACE_BUILDER_NOT_FOUND=13 + +# Should generate interface library switch (<yes|no>); if the value is "no", +# following 3 args are ignored (but must be present) +GENERATE_INTERFACE_LIBRARY="$1" +# Tool which can generate interface library from dynamic library file +INTERFACE_LIBRARY_BUILDER="$2" +# Dynamic library from which we want to generate interface library +DYNAMIC_LIBRARY="$3" +# Resulting interface library +INTERFACE_LIBRARY="$4" +# The command used to generate the dynamic library +LINKER_COMMAND="$5" + +shift 5 + +if [ ! -e "$LINKER_COMMAND" ]; then + echo "Linker command ($LINKER_COMMAND) not found." 1>&2; + exit "$E_LINKER_COMMAND_NOT_FOUND" +fi + +if [ "no" == "$GENERATE_INTERFACE_LIBRARY" ]; then + INTERFACE_GENERATION=: +else + if [ ! -e "$INTERFACE_LIBRARY_BUILDER" ]; then + echo "Interface library builder ($INTERFACE_LIBRARY_BUILDER) not found." 1>&2; + exit "$E_INTERFACE_BUILDER_NOT_FOUND" + fi + INTERFACE_GENERATION="${INTERFACE_LIBRARY_BUILDER} ${DYNAMIC_LIBRARY} ${INTERFACE_LIBRARY}" +fi + +${LINKER_COMMAND} "$@" && ${INTERFACE_GENERATION} |