Search in sources :

Example 1 with ElixirCompilerOptions

use of org.elixir_lang.jps.model.ElixirCompilerOptions in project intellij-elixir by KronicDeth.

the class MixBuilder method build.

@Override
public void build(@NotNull ElixirTarget target, @NotNull DirtyFilesHolder<ElixirSourceRootDescriptor, ElixirTarget> holder, @NotNull BuildOutputConsumer outputConsumer, @NotNull CompileContext context) throws ProjectBuildException, IOException {
    if (!holder.hasDirtyFiles() && !holder.hasRemovedFiles())
        return;
    JpsModule module = target.getModule();
    JpsProject project = module.getProject();
    ElixirCompilerOptions compilerOptions = JpsElixirCompilerOptionsExtension.getOrCreateExtension(project).getOptions();
    if (!compilerOptions.myUseMixCompiler)
        return;
    String mixPath = getMixExecutablePath(project);
    if (mixPath == null) {
        String errorMessage = "Mix path is not set.";
        context.processMessage(new CompilerMessage(NAME, BuildMessage.Kind.ERROR, errorMessage));
        throw new ProjectBuildException(errorMessage);
    }
    JpsSdk<JpsDummyElement> sdk = ElixirTargetBuilderUtil.getSdk(context, module);
    String elixirPath = JpsElixirSdkType.getScriptInterpreterExecutable(sdk.getHomePath()).getAbsolutePath();
    for (String contentRootUrl : module.getContentRootsList().getUrls()) {
        String contentRootPath = new URL(contentRootUrl).getPath();
        File contentRootDir = new File(contentRootPath);
        File mixConfigFile = new File(contentRootDir, MIX_CONFIG_FILE_NAME);
        if (!mixConfigFile.exists())
            continue;
        runMix(elixirPath, mixPath, contentRootPath, compilerOptions.myAttachDebugInfoEnabled, context);
    }
}
Also used : ProjectBuildException(org.jetbrains.jps.incremental.ProjectBuildException) JpsModule(org.jetbrains.jps.model.module.JpsModule) CompilerMessage(org.jetbrains.jps.incremental.messages.CompilerMessage) JpsProject(org.jetbrains.jps.model.JpsProject) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) ElixirCompilerOptions(org.elixir_lang.jps.model.ElixirCompilerOptions) File(java.io.File) URL(java.net.URL)

Example 2 with ElixirCompilerOptions

use of org.elixir_lang.jps.model.ElixirCompilerOptions in project intellij-elixir by KronicDeth.

the class ElixirBuilder method build.

@Override
public void build(@NotNull ElixirTarget target, @NotNull DirtyFilesHolder<ElixirSourceRootDescriptor, ElixirTarget> holder, @NotNull BuildOutputConsumer outputConsumer, @NotNull CompileContext context) throws ProjectBuildException, IOException {
    LOG.info(target.getPresentableName());
    final Set<File> filesToCompile = new THashSet<File>(FileUtil.FILE_HASHING_STRATEGY);
    holder.processDirtyFiles(new FileProcessor<ElixirSourceRootDescriptor, ElixirTarget>() {

        @Override
        public boolean apply(ElixirTarget target, File file, ElixirSourceRootDescriptor root) throws IOException {
            boolean isAcceptFile = target.isTests() ? ELIXIR_TEST_SOURCE_FILTER.accept(file) : ELIXIR_SOURCE_FILTER.accept(file);
            if (isAcceptFile && ourCompilableModuleTypes.contains(target.getModule().getModuleType())) {
                filesToCompile.add(file);
            }
            return true;
        }
    });
    if (filesToCompile.isEmpty() && !holder.hasRemovedFiles())
        return;
    JpsModule module = target.getModule();
    JpsProject project = module.getProject();
    ElixirCompilerOptions compilerOptions = JpsElixirCompilerOptionsExtension.getOrCreateExtension(project).getOptions();
    if (compilerOptions.myUseMixCompiler) {
        doBuildWithMix(target, context, module, compilerOptions);
    } else {
        // elixirc can not compile tests now.
        if (!target.isTests()) {
            doBuildWithElixirc(target, context, module, compilerOptions, filesToCompile);
        }
    }
}
Also used : JpsProject(org.jetbrains.jps.model.JpsProject) IOException(java.io.IOException) ElixirCompilerOptions(org.elixir_lang.jps.model.ElixirCompilerOptions) File(java.io.File) THashSet(gnu.trove.THashSet)

Aggregations

File (java.io.File)2 ElixirCompilerOptions (org.elixir_lang.jps.model.ElixirCompilerOptions)2 JpsProject (org.jetbrains.jps.model.JpsProject)2 THashSet (gnu.trove.THashSet)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ProjectBuildException (org.jetbrains.jps.incremental.ProjectBuildException)1 CompilerMessage (org.jetbrains.jps.incremental.messages.CompilerMessage)1 JpsDummyElement (org.jetbrains.jps.model.JpsDummyElement)1 JpsModule (org.jetbrains.jps.model.module.JpsModule)1