From c71316d3f6de862f99a1363d5f03ac04412a73f4 Mon Sep 17 00:00:00 2001 From: dbabkin Date: Tue, 29 May 2018 01:59:29 -0700 Subject: Add CcSysrootAliasRule RELNOTES:none PiperOrigin-RevId: 198364550 --- .../build/lib/analysis/mock/MOCK_CROSSTOOL | 10 ++-- .../build/lib/rules/cpp/CcLibcTopAliasTest.java | 54 ++++++++++++++++++++++ 2 files changed, 59 insertions(+), 5 deletions(-) create mode 100644 src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibcTopAliasTest.java (limited to 'src/test/java/com') diff --git a/src/test/java/com/google/devtools/build/lib/analysis/mock/MOCK_CROSSTOOL b/src/test/java/com/google/devtools/build/lib/analysis/mock/MOCK_CROSSTOOL index eca8122d38..dc49dcb0de 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/mock/MOCK_CROSSTOOL +++ b/src/test/java/com/google/devtools/build/lib/analysis/mock/MOCK_CROSSTOOL @@ -36,7 +36,7 @@ default_toolchain { toolchain { abi_version: "local" abi_libc_version: "local" - builtin_sysroot: "" + builtin_sysroot: "/test/" compiler: "compiler" host_system_name: "local" needsPic: true @@ -181,7 +181,7 @@ toolchain { needsPic: true supports_fission: true - builtin_sysroot: "" + builtin_sysroot: "/usr/grte/v1" cxx_flag: "-std=c++0x" linker_flag: "-lstdc++" cxx_builtin_include_directory: "/usr/lib/gcc/" @@ -296,7 +296,7 @@ toolchain { needsPic: false - builtin_sysroot: "" + builtin_sysroot: "/usr/grte/v1" cxx_flag: "-std=c++0x" linker_flag: "-lstdc++" cxx_builtin_include_directory: "/usr/include" @@ -447,7 +447,7 @@ toolchain { tool_path { name: "objdump" path: "C:/msys64/mingw64/bin/objdump" } tool_path { name: "strip" path: "C:/msys64/mingw64/bin/strip" } - builtin_sysroot: "" + builtin_sysroot: "/usr/grte/v1" cxx_flag: "-std=c++0x" cxx_builtin_include_directory: "C:/msys64/mingw64/x86_64-w64-mingw32/include" objcopy_embed_flag: "-I" @@ -536,7 +536,7 @@ toolchain { toolchain { abi_version: "local" abi_libc_version: "local" - builtin_sysroot: "" + builtin_sysroot: "/usr/grte/v1" compiler: "windows_msys64" host_system_name: "local" needsPic: false diff --git a/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibcTopAliasTest.java b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibcTopAliasTest.java new file mode 100644 index 0000000000..eeb6a9dddd --- /dev/null +++ b/src/test/java/com/google/devtools/build/lib/rules/cpp/CcLibcTopAliasTest.java @@ -0,0 +1,54 @@ +// Copyright 2018 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. + +package com.google.devtools.build.lib.rules.cpp; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.devtools.build.lib.analysis.ConfiguredTarget; +import com.google.devtools.build.lib.analysis.util.BuildViewTestCase; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for cc_libc_top_alias rule. */ +@RunWith(JUnit4.class) +public class CcLibcTopAliasTest extends BuildViewTestCase { + + @Test + public void testCcLibcTopAlias() throws Exception { + scratch.file("a/BUILD", "cc_libc_top_alias(name='current_cc_libc_top')"); + + ConfiguredTarget target = getConfiguredTarget("//a:current_cc_libc_top"); + + assertThat(target.getLabel().toString()).isEqualTo("//a:current_cc_libc_top"); + } + + + @Test + public void testCcLibcTopAliasWithGrteTopArgument() throws Exception { + scratch.file("a/BUILD", "cc_libc_top_alias(name='current_cc_libc_top')"); + scratch.file("b/BUILD", + "filegroup(", + " name = 'everything',", + " srcs = []", + ")"); + //value of this property replaced to :everything in {@code LibcTopLabelConverter} + useConfiguration("--grte_top=//b:some_string"); + + ConfiguredTarget target = getConfiguredTarget("//a:current_cc_libc_top"); + + assertThat(target.getLabel().toString()).isEqualTo("//b:everything"); + } +} -- cgit v1.2.3