use of org.metaborg.spoofax.core.build.SpoofaxCommonPaths in project spoofax by metaborg.
the class LanguageSpecBuilder method initialize.
public void initialize(LanguageSpecBuildInput input) throws MetaborgException {
final SpoofaxCommonPaths paths = new SpoofaxLangSpecCommonPaths(input.languageSpec().location());
try {
paths.srcGenDir().createFolder();
paths.targetMetaborgDir().createFolder();
} catch (FileSystemException e) {
throw new MetaborgException("Initializing directories failed", e);
}
for (IBuildStep buildStep : buildSteps) {
buildStep.execute(LanguageSpecBuildPhase.initialize, input);
}
}
use of org.metaborg.spoofax.core.build.SpoofaxCommonPaths in project spoofax by metaborg.
the class TermFactoryService method getTypesmartContext.
private TypesmartContext getTypesmartContext(ILanguageComponent component) {
TypesmartContext context = mergedTypesmartContexts.get(component);
if (context == null) {
FileObject localContextFile = new SpoofaxCommonPaths(component.location()).strTypesmartExportedFile();
context = TypesmartContext.load(localContextFile, typesmartLogger);
try {
for (ILanguageComponent other : dependencyService.sourceDeps(component)) {
FileObject otherContextFile = new SpoofaxCommonPaths(other.location()).strTypesmartExportedFile();
TypesmartContext otherContext = TypesmartContext.load(otherContextFile, typesmartLogger);
context = context.merge(otherContext);
}
} catch (MissingDependencyException e) {
typesmartLogger.error("Could not load source dependencies of " + component + " to resolve typesmart contexts.", e);
}
mergedTypesmartContexts.put(component, context);
}
return context;
}
use of org.metaborg.spoofax.core.build.SpoofaxCommonPaths in project spoofax by metaborg.
the class LanguageSpecBuilder method clean.
public void clean(LanguageSpecBuildInput input) throws MetaborgException {
final FileObject location = input.languageSpec().location();
logger.debug("Cleaning {}", location);
final SpoofaxCommonPaths paths = new SpoofaxLangSpecCommonPaths(location);
cleanAndLog(paths.srcGenDir());
cleanAndLog(paths.targetDir());
try {
final String path = path(input);
plutoClean(path);
} catch (IOException e) {
throw new MetaborgException("Cleaning Pluto file attributes failed", e);
}
for (IBuildStep buildStep : buildSteps) {
buildStep.execute(LanguageSpecBuildPhase.clean, input);
}
}
use of org.metaborg.spoofax.core.build.SpoofaxCommonPaths in project spoofax by metaborg.
the class LanguageSpecBuilder method compile.
public void compile(LanguageSpecBuildInput input) throws MetaborgException {
logger.debug("Running pre-Java build for {}", input.languageSpec().location());
initPluto();
try {
final String path = path(input);
plutoBuild(GenerateSourcesBuilder.request(generateSourcesBuilderInput(input)), path);
} catch (RequiredBuilderFailed e) {
if (e.getMessage().contains("no rebuild of failing builder")) {
throw new MetaborgException(failingRebuildMessage, e);
} else {
throw new MetaborgException();
}
} catch (RuntimeException e) {
throw e;
} catch (Throwable e) {
throw new MetaborgException(e);
}
final SpoofaxCommonPaths paths = new SpoofaxLangSpecCommonPaths(input.languageSpec().location());
// HACK: compile the main ESV file to make sure that packed.esv file is always available.
final Iterable<FileObject> esvRoots = languagePathService.sourcePaths(input.project(), SpoofaxConstants.LANG_ESV_NAME);
final FileObject mainEsvFile = paths.findEsvMainFile(esvRoots);
try {
if (mainEsvFile != null && mainEsvFile.exists()) {
logger.info("Compiling Main ESV file {}", mainEsvFile);
// @formatter:off
final BuildInput buildInput = new BuildInputBuilder(input.languageSpec()).addSource(mainEsvFile).addTransformGoal(new CompileGoal()).withMessagePrinter(new StreamMessagePrinter(sourceTextService, false, true, logger)).build(dependencyService, languagePathService);
// @formatter:on
final ISpoofaxBuildOutput result = runner.build(buildInput, null, null).schedule().block().result();
if (!result.success()) {
throw new MetaborgException("Compiling Main ESV file failed");
}
}
} catch (FileSystemException e) {
final String message = logger.format("Could not compile ESV file {}", mainEsvFile);
throw new MetaborgException(message, e);
} catch (InterruptedException e) {
// Ignore
}
// HACK: compile the main DS file if available, after generating sources (because ds can depend on Stratego
// strategies), to generate an interpreter.
final Iterable<FileObject> dsRoots = languagePathService.sourcePaths(input.project(), SpoofaxConstants.LANG_DYNSEM_NAME);
final FileObject mainDsFile = paths.findDsMainFile(dsRoots, input.languageSpec().config().strategoName());
try {
if (mainDsFile != null && mainDsFile.exists()) {
if (languageIdentifierService.identify(mainDsFile, input.project()) == null) {
logger.error("Could not identify DynSem main file {}, please add DynSem as a compile dependency", mainDsFile);
}
logger.info("Compiling main DynSem file {}", mainDsFile);
// @formatter:off
final BuildInput buildInput = new BuildInputBuilder(input.languageSpec()).addSource(mainDsFile).addTransformGoal(new EndNamedGoal("Generate interpreter")).withMessagePrinter(new StreamMessagePrinter(sourceTextService, false, true, logger)).build(dependencyService, languagePathService);
// @formatter:on
final ISpoofaxBuildOutput result = runner.build(buildInput, null, null).schedule().block().result();
if (!result.success()) {
logger.error("Compiling main DynSem file {} failed", mainDsFile);
}
}
} catch (FileSystemException e) {
final String message = logger.format("Could not compile DynSem file {}", mainDsFile);
throw new MetaborgException(message, e);
} catch (InterruptedException e) {
// Ignore
}
for (IBuildStep buildStep : buildSteps) {
buildStep.execute(LanguageSpecBuildPhase.compile, input);
}
}
Aggregations