Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .idea/aws.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

463 changes: 463 additions & 0 deletions .idea/dbnavigator.xml

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .idea/emacs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file modified .idea/icon.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/jpa-buddy.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/markdown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/misc.xml1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ dependencies {

version = "${version}.$buildNumber"
allprojects {
repositories { mavenCentral() }
repositories {
mavenLocal()
mavenCentral()
}
apply plugin: 'java'
sourceCompatibility = javaVersion
targetCompatibility = javaTargetVersion
Expand All @@ -31,6 +34,7 @@ allprojects {
apply plugin: 'org.jetbrains.intellij'
intellij {
version = ideaVersion
type.set("IC")
plugins = ['copyright', 'java']
downloadSources = Boolean.valueOf(sources)
sameSinceUntilBuild = Boolean.valueOf(isEAP)
Expand Down Expand Up @@ -67,6 +71,7 @@ allprojects {
}

repositories {
mavenLocal()
jcenter()
flatDir {
dirs 'libs'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ version = 0.11
ideaVersion = 2023.2
javaVersion = 17
javaTargetVersion = 17
buildNumber = SNAPSHOT
buildNumber = X
sources = true
isEAP = false
localIdePath =
Expand Down
11 changes: 10 additions & 1 deletion jps-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
jar.archiveFileName = "jps-plugin.jar"
jar.archiveName = "jps-plugin.jar"

repositories {
mavenLocal()
mavenCentral()
}

dependencies {
implementation group: 'com.github.metadave', name: 'etp', version: '0.7'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package org.intellij.erlang.jps.builder;

import java.io.*;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

import com.intellij.openapi.util.io.FileUtil;
import com.metadave.etp.ETP;
import com.metadave.etp.rep.*;
import org.jetbrains.jps.incremental.CompileContext;
import org.jetbrains.jps.incremental.messages.BuildMessage;
import org.jetbrains.jps.incremental.messages.CompilerMessage;

/**
* Takes original xxx.app.src file decodes it using ETP library, and adds modules and registred sections
* if they are not already present.
*/
public class AppFileConverter {
private File appConfigSrc;
private ETPTuple appConfigterms;
private CompileContext context;
public AppFileConverter(CompileContext context, File appConfigSrc, File outputDir) {
this.context=context;
this.appConfigSrc=appConfigSrc;
try {
appConfigterms = (ETPTuple)ETP.parse(new FileInputStream(appConfigSrc));
if(!"application".equals(((ETPAtom)(appConfigterms.getValue(0))).getValue()))
throw new ParseException("Unexpected file format - missing application",0);
List<ETPTerm<?>> list=((ETPList)(appConfigterms.getValue(2))).getValue();
HashSet<String> s = new HashSet<>();
for(ETPTerm<?> etpTerm : list) {
String name = ((ETPAtom)(((ETPTuple)etpTerm).getValue(0))).getValue();
s.add(name);
}
if(!s.contains("registered")) {
list.add(new ETPTuple(new ETPAtom("registered"),new ETPList(new ArrayList<ETPTerm<?>>())));
}
if(!s.contains("modules")) {
String[] names = outputDir.list(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.endsWith("beam");
}
});
ArrayList<ETPTerm<?>> modules = new ArrayList<ETPTerm<?>>();
for(int i=0;i<names.length;i++) {
modules.add(new ETPAtom(names[i].substring(0,names[i].length()-5)));
}
list.add(new ETPTuple(new ETPAtom("modules"),new ETPList(modules)));
}
}
catch (Exception e) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
e.printStackTrace(pw);
context.processMessage(new CompilerMessage(ErlangBuilder.NAME, BuildMessage.Kind.INFO, "Failed to parse "+appConfigSrc+" app src file : "+e.getLocalizedMessage()+","+sw.toString()));
appConfigterms = null;
}
}

public void writeToFile(File appConfigDst) throws IOException {
if(appConfigterms!=null)
try(FileWriter fw=new FileWriter(appConfigDst)) {
fw.write(appConfigterms.toString());
fw.write(".");
} catch(Exception e) {
context.processMessage(new CompilerMessage(ErlangBuilder.NAME, BuildMessage.Kind.INFO, "Failed to write "+appConfigDst+" : "+e.getLocalizedMessage()));
appConfigterms=null;
}
if(appConfigterms==null) {
FileUtil.copy(appConfigSrc, appConfigDst);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ protected File getDirtyElement(@NotNull File file) {
for (File appConfigSrc : appConfigFiles) {
for (File outputDir : outputDirectories) {
File appConfigDst = getDestinationAppConfig(outputDir, appConfigSrc.getName());
FileUtil.copy(appConfigSrc, appConfigDst);
reportMessage(context, String.format("Copy %s to %s", ErlangBuilderUtil.getPath(appConfigSrc), ErlangBuilderUtil.getPath(outputDir)));
LOG.warn("Using AppFileConverter to generate app file");
new AppFileConverter(context, appConfigSrc, outputDir).writeToFile(appConfigDst);
reportMessage(context, String.format("Copy AppFileConverter %s to %s", ErlangBuilderUtil.getPath(appConfigSrc), ErlangBuilderUtil.getPath(outputDir)));
outputConsumer.registerOutputFile(appConfigDst, Collections.singletonList(ErlangBuilderUtil.getPath(appConfigSrc)));
}
}
Expand Down Expand Up @@ -283,10 +284,14 @@ private static void addParseTransforms(@NotNull GeneralCommandLine commandLine,
@Nullable JpsModule module) {
JpsErlangModuleExtension extension = JpsErlangModuleExtension.getExtension(module);
List<String> parseTransforms = extension != null ? extension.getParseTransforms() : Collections.emptyList();
List<String> flags = extension != null ? extension.getExtraFlags() : Collections.emptyList();
if (parseTransforms.isEmpty()) return;
for (String ptModule : parseTransforms) {
commandLine.addParameter("+{parse_transform, " + ptModule + "}");
}
for (String ptModule : flags) {
commandLine.addParameter(ptModule);
}
}

private static void addCodePath(@NotNull GeneralCommandLine commandLine,
Expand Down
Loading