Skip to content

Commit

Permalink
CLC source/library per target arguments
Browse files Browse the repository at this point in the history
Allow specifying custom folder as compilation target.
While temp can be used for such purpose, it will try to download dsl-compiler also (if not specified).
Since SBT is doing parallel compilation, support custom folders to avoid concurrency issues.

Library parameter for passing in version (eg. currently DSL-JSON passes in custom argument via force).
This way new versions can be used without introducing breaking changes in old versions.

Switch Mono to mcs instead of dmcs (it complains about being obsolete)
  • Loading branch information
zapov committed Dec 12, 2016
1 parent ac4d68b commit a473311
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CommandLineClient/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.dslplatform</groupId>
<artifactId>dsl-clc</artifactId>
<packaging>jar</packaging>
<version>1.8.3</version>
<version>1.8.4</version>
<name>DSL Platform - Compiler Command-Line Client</name>
<url>https://github.com/ngs-doo/dsl-compiler-client</url>
<description>Command line client for interaction with DSL Platform compiler (https://dsl-platform.com)</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public static Either<String> findCompiler(final Context context, final boolean i
}
return Either.fail("Unable to find csc.exe (.NET C# compiler). Add it to path or specify dotnet compile option.");
}
if (Utils.testCommand(context, "dmcs", "Mono", Collections.singletonList("--version"))) {
return Either.success("dmcs");
if (Utils.testCommand(context, "mcs", "Mono", Collections.singletonList("--version"))) {
return Either.success("mcs");
}
return Either.fail("Unable to find dmcs (Mono C# compiler). Add it to path or specify dotnet compile option.");
return Either.fail("Unable to find mcs (Mono C# compiler). Add it to path or specify dotnet compile option.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public static Map<String, String> compile(
final List<String> settings,
final String namespace,
final String version,
final List<File> dsls) throws ExitException {
final List<File> dsls,
final String library) throws ExitException {
final Map<String, String> files = new HashMap<String, String>();
final List<String> arguments = new ArrayList<String>();
arguments.add("target=" + target);
Expand All @@ -48,6 +49,9 @@ public static Map<String, String> compile(
arguments.add("settings=" + o);
}
}
if (library != null && library.length() > 0) {
arguments.add("library=" + library);
}
for (final File f : dsls) {
arguments.add("dsl=" + f.getAbsolutePath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ public Either<Boolean> tryParse(final String name, final String value, final Con
}
context.put("dependency:" + o.value, value);
return Either.success(true);
} else if (("libraries:" + o.value).equalsIgnoreCase(name) || ("library:" + o.value).equalsIgnoreCase(name)) {
if (value == null || value.length() == 0) {
return Either.fail("Target library parameter detected, but it's missing version as argument. Parameter: " + name);
}
context.put("library:" + o.value, value);
return Either.success(true);
} else if (("sources:" + o.value).equalsIgnoreCase(name) || ("source:" + o.value).equalsIgnoreCase(name)) {
if (value == null || value.length() == 0) {
return Either.fail("Target source parameter detected, but it's missing path as argument. Parameter: " + name);
}
final File path = new File(value);
if (path.exists() && !path.isDirectory()) {
return Either.fail("Target source path found, but it's not a directory. Parameter: " + name);
}
context.put("source:" + o.value, value);
return Either.success(true);
}
}
}
Expand Down Expand Up @@ -212,20 +228,39 @@ public void run(final Context context) throws ExitException {
compile(context, targets);
}

private void compile(Context context, List<Option> targets) throws ExitException {
public static String getTargetSourcePath(final Context context, Option target) throws ExitException {
final String custom = context.get("source:" + target.value);
if (custom != null && !custom.isEmpty()) {
final File file = new File(custom, target.name());
try {
if (file.exists()) {
Utils.deletePath(file);
}
return custom;
} catch (IOException e) {
context.error("Unable to clean target source folder: " + file.getAbsolutePath());
context.error(e);
throw new ExitException();
}
}
return TempPath.getTempProjectPath(context).getAbsolutePath();
}

private void compile(final Context context, final List<Option> targets) throws ExitException {
final List<File> dsls = DslPath.getDslPaths(context);
final List<String> settings = Settings.get(context);
final String temp = TempPath.getTempProjectPath(context).getAbsolutePath();
final boolean sourceOnly = Settings.hasSourceOnly(context);
for (final Option t : targets) {
Map<String, String> files =
final String temp = getTargetSourcePath(context, t);
final Map<String, String> files =
DslCompiler.compile(
context,
t.value,
settings,
context.get(Namespace.INSTANCE),
context.get(Version.INSTANCE),
dsls);
dsls,
context.get("library:" + t.value));
try {
for (final Map.Entry<String, String> kv : files.entrySet()) {
final String fullName = t.name() + "/" + kv.getKey() + t.extension;
Expand Down Expand Up @@ -279,6 +314,8 @@ public String getDetailedDescription() {
sb.append("DSL Platform converts DSL model to various target sources which are then locally compiled (if possible).\n\n");
sb.append("Custom output name can be specified with as -java_client=/home/model.jar,revenj=/home/revenj.dll\n\n");
sb.append("Custom dependency path can be specified as -dependencies:java_client=/home/java_libs\n\n");
sb.append("Library version can be passed to DSL Compiler with as -library:revenj.net=1.4.1\n\n");
sb.append("Custom source folder can be specified as -source:java_client=/tmp/java_src\n\n");
sb.append("This option specifies which target sources are available.\n");
sb.append("---------------------------------------------------------\n");
for (final Option o : Option.values()) {
Expand Down

0 comments on commit a473311

Please sign in to comment.