Search in sources :

Example 1 with WriteStringTemplateRule

use of com.facebook.buck.rules.WriteStringTemplateRule in project buck by facebook.

the class AbstractLuaScriptStarter method build.

@Override
public SourcePath build() {
    BuildTarget templateTarget = BuildTarget.builder(getBaseParams().getBuildTarget()).addFlavors(InternalFlavor.of("starter-template")).build();
    WriteFile templateRule = getRuleResolver().addToIndex(new WriteFile(getBaseParams().withBuildTarget(templateTarget).copyReplacingDeclaredAndExtraDeps(Suppliers.ofInstance(ImmutableSortedSet.of()), Suppliers.ofInstance(ImmutableSortedSet.of())), getPureStarterTemplate(), BuildTargets.getGenPath(getBaseParams().getProjectFilesystem(), templateTarget, "%s/starter.lua.in"), /* executable */
    false));
    final Tool lua = getLuaConfig().getLua(getRuleResolver());
    WriteStringTemplateRule writeStringTemplateRule = getRuleResolver().addToIndex(WriteStringTemplateRule.from(getBaseParams(), getRuleFinder(), getTarget(), getOutput(), templateRule.getSourcePathToOutput(), ImmutableMap.of("SHEBANG", lua.getCommandPrefix(getPathResolver()).get(0), "MAIN_MODULE", Escaper.escapeAsPythonString(getMainModule()), "MODULES_DIR", getRelativeModulesDir().isPresent() ? Escaper.escapeAsPythonString(getRelativeModulesDir().get().toString()) : "nil", "PY_MODULES_DIR", getRelativePythonModulesDir().isPresent() ? Escaper.escapeAsPythonString(getRelativePythonModulesDir().get().toString()) : "nil", "EXT_SUFFIX", Escaper.escapeAsPythonString(getCxxPlatform().getSharedLibraryExtension())), /* executable */
    true));
    return writeStringTemplateRule.getSourcePathToOutput();
}
Also used : WriteFile(com.facebook.buck.file.WriteFile) BuildTarget(com.facebook.buck.model.BuildTarget) WriteStringTemplateRule(com.facebook.buck.rules.WriteStringTemplateRule) Tool(com.facebook.buck.rules.Tool)

Aggregations

WriteFile (com.facebook.buck.file.WriteFile)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 Tool (com.facebook.buck.rules.Tool)1 WriteStringTemplateRule (com.facebook.buck.rules.WriteStringTemplateRule)1