diff options
author | 2016-09-08 10:46:29 +0000 | |
---|---|---|
committer | 2016-09-08 13:11:44 +0000 | |
commit | 74e818dd08c2dc081604b9f8dd288750a04d48ef (patch) | |
tree | b3ca06c574cd58a9a5f5c2edbe079eedc2e122cf /src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java | |
parent | e15f917d865c61be237a8c92fcced32d48f57836 (diff) |
Updates to MockCcSupport in preparation for open sourcing more CC tests.
--
MOS_MIGRATED_REVID=132538491
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java b/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java index b2eb70f0b0..2c5dc2ae32 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java +++ b/src/test/java/com/google/devtools/build/lib/packages/util/MockCcSupport.java @@ -343,6 +343,49 @@ public abstract class MockCcSupport { return TextFormat.printToString(builder.build()); } + public static String addOptionalDefaultCoptsToCrosstool(String original) + throws TextFormat.ParseException { + CrosstoolConfig.CrosstoolRelease.Builder builder = + CrosstoolConfig.CrosstoolRelease.newBuilder(); + TextFormat.merge(original, builder); + for (CrosstoolConfig.CToolchain.Builder toolchain : builder.getToolchainBuilderList()) { + CrosstoolConfig.CToolchain.OptionalFlag.Builder defaultTrue = + CrosstoolConfig.CToolchain.OptionalFlag.newBuilder(); + defaultTrue.setDefaultSettingName("crosstool_default_true"); + defaultTrue.addFlag("-DDEFAULT_TRUE"); + toolchain.addOptionalCompilerFlag(defaultTrue.build()); + CrosstoolConfig.CToolchain.OptionalFlag.Builder defaultFalse = + CrosstoolConfig.CToolchain.OptionalFlag.newBuilder(); + defaultFalse.setDefaultSettingName("crosstool_default_false"); + defaultFalse.addFlag("-DDEFAULT_FALSE"); + toolchain.addOptionalCompilerFlag(defaultFalse.build()); + } + + CrosstoolConfig.CrosstoolRelease.DefaultSetting.Builder defaultTrue = + CrosstoolConfig.CrosstoolRelease.DefaultSetting.newBuilder(); + defaultTrue.setName("crosstool_default_true"); + defaultTrue.setDefaultValue(true); + builder.addDefaultSetting(defaultTrue.build()); + CrosstoolConfig.CrosstoolRelease.DefaultSetting.Builder defaultFalse = + CrosstoolConfig.CrosstoolRelease.DefaultSetting.newBuilder(); + defaultFalse.setName("crosstool_default_false"); + defaultFalse.setDefaultValue(false); + builder.addDefaultSetting(defaultFalse.build()); + + return TextFormat.printToString(builder.build()); + } + + public static String addLibcLabelToCrosstool(String original, String label) + throws TextFormat.ParseException { + CrosstoolConfig.CrosstoolRelease.Builder builder = + CrosstoolConfig.CrosstoolRelease.newBuilder(); + TextFormat.merge(original, builder); + for (CrosstoolConfig.CToolchain.Builder toolchain : builder.getToolchainBuilderList()) { + toolchain.setDefaultGrteTop(label); + } + return TextFormat.printToString(builder.build()); + } + public abstract Predicate<String> labelNameFilter(); /** @@ -382,8 +425,7 @@ public abstract class MockCcSupport { /** * Create a crosstool package. For integration tests, it actually links in a working crosstool, - * for all other tests, it only creates a dummy package, with a working CROSSTOOL file. The code - * here matches the declarations in {@link CrosstoolTestHelper}. + * for all other tests, it only creates a dummy package, with a working CROSSTOOL file. * * <p>If <code>addEmbeddedRuntimes</code> is true, it also adds filegroups for the embedded * runtimes. @@ -506,6 +548,8 @@ public abstract class MockCcSupport { public abstract String readCrosstoolFile() throws IOException; + public abstract String getMockLibcPath(); + protected abstract ImmutableList<String> getCrosstoolArchs(); protected abstract String[] getRealFilesystemTools(String crosstoolTop); |