From b782fd45f7046a94a617ec8aec76ee5513555924 Mon Sep 17 00:00:00 2001 From: Marcel Hlopko Date: Wed, 16 Nov 2016 15:48:25 +0000 Subject: Simplify Crosstool Build Variables context This cl merges two classes used to hold build variables context into one. Those classes are (previously top-level) jcgd.build.lib.rules.cpp.Variables, and its inner class View. Both represent a collection of build variables and imo it makes sense to merge them to make the code simpler. Also, I cleaned up the build variables api to use primitive strings or instances of VariableValueBuilders, and I've hidden subclasses of VariableValues. Last but not least, I refactored the code to use immutable collections exclusively. That revealed that 'module_files' variable is sometimes registered twice. I want to clean this eventually ([]). -- MOS_MIGRATED_REVID=139329823 --- .../google/devtools/build/lib/rules/cpp/FdoSupport.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java') diff --git a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java index 9e09b0643c..1e37bda60c 100644 --- a/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java +++ b/src/main/java/com/google/devtools/build/lib/rules/cpp/FdoSupport.java @@ -514,8 +514,7 @@ public class FdoSupport { } if (featureConfiguration.isEnabled(CppRuleClasses.FDO_INSTRUMENT)) { - buildVariables.addVariable("fdo_instrument_path", - fdoInstrument.getPathString()); + buildVariables.addStringVariable("fdo_instrument_path", fdoInstrument.getPathString()); } // Optimization phase @@ -530,16 +529,16 @@ public class FdoSupport { builder.addMandatoryInputs(auxiliaryInputs); if (!Iterables.isEmpty(auxiliaryInputs)) { if (featureConfiguration.isEnabled(CppRuleClasses.AUTOFDO)) { - buildVariables.addVariable("fdo_profile_path", - getAutoProfilePath(fdoProfile, fdoRootExecPath).getPathString()); + buildVariables.addStringVariable( + "fdo_profile_path", getAutoProfilePath(fdoProfile, fdoRootExecPath).getPathString()); } if (featureConfiguration.isEnabled(CppRuleClasses.FDO_OPTIMIZE)) { if (fdoMode == FdoMode.LLVM_FDO) { - buildVariables.addVariable("fdo_profile_path", + buildVariables.addStringVariable( + "fdo_profile_path", getLLVMProfilePath(fdoProfile, fdoRootExecPath).getPathString()); } else { - buildVariables.addVariable("fdo_profile_path", - fdoRootExecPath.getPathString()); + buildVariables.addStringVariable("fdo_profile_path", fdoRootExecPath.getPathString()); } } } @@ -698,8 +697,7 @@ public class FdoSupport { CcToolchainFeatures.Variables.Builder buildVariables ) { if (featureConfiguration.isEnabled(CppRuleClasses.FDO_INSTRUMENT)) { - buildVariables.addVariable("fdo_instrument_path", - fdoInstrument.getPathString()); + buildVariables.addStringVariable("fdo_instrument_path", fdoInstrument.getPathString()); } } -- cgit v1.2.3