use of com.facebook.buck.step.fs.WriteFileStep in project buck by facebook.
the class JarFattener method writeFatJarInfo.
/**
* @return a {@link Step} that generates the fat jar info resource.
*/
private Step writeFatJarInfo(Path destination, final ImmutableMap<String, String> nativeLibraries) {
ByteSource source = new ByteSource() {
@Override
public InputStream openStream() throws IOException {
FatJar fatJar = new FatJar(FAT_JAR_INNER_JAR, nativeLibraries);
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
try {
fatJar.store(bytes);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
return new ByteArrayInputStream(bytes.toByteArray());
}
};
return new WriteFileStep(getProjectFilesystem(), source, destination, /* executable */
false);
}
use of com.facebook.buck.step.fs.WriteFileStep in project buck by facebook.
the class HaskellPackageRule method getWriteRegistrationFileStep.
private WriteFileStep getWriteRegistrationFileStep(SourcePathResolver resolver, Path registrationFile, Path packageDb) {
Map<String, String> entries = new LinkedHashMap<>();
entries.put("name", packageInfo.getName());
entries.put("version", packageInfo.getVersion());
entries.put("id", packageInfo.getIdentifier());
if (haskellVersion.getMajorVersion() >= 8) {
entries.put("key", packageInfo.getIdentifier());
}
entries.put("exposed", "True");
entries.put("exposed-modules", Joiner.on(' ').join(modules));
Path pkgRoot = getProjectFilesystem().getPath("${pkgroot}");
if (!modules.isEmpty()) {
List<String> importDirs = new ArrayList<>();
for (SourcePath interfaceDir : interfaces) {
Path relInterfaceDir = pkgRoot.resolve(packageDb.getParent().relativize(resolver.getRelativePath(interfaceDir)));
importDirs.add('"' + relInterfaceDir.toString() + '"');
}
entries.put("import-dirs", Joiner.on(", ").join(importDirs));
}
List<String> libDirs = new ArrayList<>();
List<String> libs = new ArrayList<>();
for (SourcePath library : libraries) {
Path relLibPath = pkgRoot.resolve(packageDb.getParent().relativize(resolver.getRelativePath(library)));
libDirs.add('"' + relLibPath.getParent().toString() + '"');
libs.add(MorePaths.stripPathPrefixAndExtension(relLibPath.getFileName(), "lib"));
}
entries.put("library-dirs", Joiner.on(", ").join(libDirs));
// Use extra libraries here, so GHC won't try to find libraries with any extra suffices
// (e.g. lib<name>-ghc7.10.3.dylib).
entries.put("extra-libraries", Joiner.on(", ").join(libs));
entries.put("depends", Joiner.on(", ").join(depPackages.keySet()));
return new WriteFileStep(getProjectFilesystem(), entries.entrySet().stream().map(input -> input.getKey() + ": " + input.getValue()).collect(Collectors.joining(System.lineSeparator())), registrationFile, /* executable */
false);
}
Aggregations