use of com.facebook.buck.rules.macros.LocationMacro in project buck by facebook.
the class CxxGenruleDescription method getMacroHandler.
@Override
protected <A extends Arg> MacroHandler getMacroHandler(BuildTarget buildTarget, ProjectFilesystem filesystem, BuildRuleResolver resolver, TargetGraph targetGraph, A args) {
CxxPlatform cxxPlatform = cxxPlatforms.getRequiredValue(buildTarget);
ImmutableMap.Builder<String, MacroExpander> macros = ImmutableMap.builder();
macros.put("exe", new ExecutableMacroExpander());
macros.put("location", new CxxLocationMacroExpander(cxxPlatform));
macros.put("platform-name", new StringExpander(cxxPlatform.getFlavor().toString()));
macros.put("location-platform", new LocationMacroExpander() {
@Override
protected BuildRule resolve(BuildRuleResolver resolver, LocationMacro input) throws MacroException {
try {
return resolver.requireRule(input.getTarget().withAppendedFlavors(cxxPlatform.getFlavor()));
} catch (NoSuchBuildTargetException e) {
throw new MacroException(e.getHumanReadableErrorMessage());
}
}
});
macros.put("cc", new ToolExpander(cxxPlatform.getCc().resolve(resolver)));
macros.put("cxx", new ToolExpander(cxxPlatform.getCxx().resolve(resolver)));
ImmutableList<String> asflags = cxxPlatform.getAsflags();
ImmutableList<String> cflags = cxxPlatform.getCflags();
ImmutableList<String> cxxflags = cxxPlatform.getCxxflags();
macros.put("cflags", new StringExpander(shquoteJoin(Iterables.concat(cflags, asflags))));
macros.put("cxxflags", new StringExpander(shquoteJoin(Iterables.concat(cxxflags, asflags))));
macros.put("cppflags", new CxxPreprocessorFlagsExpander(cxxPlatform, CxxSource.Type.C));
macros.put("cxxppflags", new CxxPreprocessorFlagsExpander(cxxPlatform, CxxSource.Type.CXX));
macros.put("ld", new ToolExpander(cxxPlatform.getLd().resolve(resolver)));
for (Linker.LinkableDepType depType : Linker.LinkableDepType.values()) {
for (Filter filter : Filter.values()) {
macros.put(String.format("ldflags-%s%s", depType.toString().toLowerCase().replace('_', '-'), filter == Filter.PARAM ? "-filter" : ""), new CxxLinkerFlagsExpander(buildTarget, filesystem, cxxPlatform, depType, args.out, filter));
}
}
return new MacroHandler(macros.build());
}
Aggregations