Added no-stdlib and -Xfriend-paths compile options

This commit is contained in:
Erik C. Thauvin 2023-11-08 22:12:34 -08:00
parent 04fd7fe037
commit 51d046a2f7
4 changed files with 31 additions and 5 deletions

1
examples/.idea/.name generated Normal file
View file

@ -0,0 +1 @@
bld-koltin-examples

View file

@ -198,7 +198,8 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
executeBuildSources( executeBuildSources(
compileMainClasspath(), compileMainClasspath(),
sources(mainSourceFiles(), mainSourceDirectories()), sources(mainSourceFiles(), mainSourceDirectories()),
buildMainDirectory()); buildMainDirectory(),
null);
} }
/** /**
@ -207,8 +208,9 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
* @param classpath the classpath list used for the compilation * @param classpath the classpath list used for the compilation
* @param sources the source files to compile * @param sources the source files to compile
* @param destination the destination directory * @param destination the destination directory
* @param friendPaths the output directory for friendly modules
*/ */
protected void executeBuildSources(Collection<String> classpath, Collection<File> sources, File destination) protected void executeBuildSources(Collection<String> classpath, Collection<File> sources, File destination, File friendPaths)
throws IOException { throws IOException {
if (sources.isEmpty() || destination == null) { if (sources.isEmpty() || destination == null) {
return; return;
@ -225,8 +227,11 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
args.add("-d"); args.add("-d");
args.add(destination.getAbsolutePath()); args.add(destination.getAbsolutePath());
args.add("-no-reflect"); // friend-path
args.add("-no-stdlib"); if (friendPaths != null) {
args.add("-Xfriend-paths");
args.add(friendPaths.getAbsolutePath());
}
// options // options
if (compileOptions_ != null) { if (compileOptions_ != null) {
@ -254,7 +259,7 @@ public class CompileKotlinOperation extends AbstractOperation<CompileKotlinOpera
executeBuildSources( executeBuildSources(
compileTestClasspath(), compileTestClasspath(),
sources(testSourceFiles(), testSourceDirectories()), sources(testSourceFiles(), testSourceDirectories()),
buildTestDirectory()); buildTestDirectory(), buildMainDirectory());
} }
/** /**

View file

@ -45,6 +45,7 @@ public class CompileKotlinOptions {
private String moduleName_; private String moduleName_;
private boolean noJdk_; private boolean noJdk_;
private boolean noReflect_; private boolean noReflect_;
private boolean noStdLib_ = true;
private boolean noWarn_; private boolean noWarn_;
private String path_; private String path_;
private boolean progressive_; private boolean progressive_;
@ -177,6 +178,11 @@ public class CompileKotlinOptions {
args.add("-no-reflect"); args.add("-no-reflect");
} }
// no-std-lib
if (noStdLib_) {
args.add("-no-stdlib");
}
// no-warn // no-warn
if (noWarn_) { if (noWarn_) {
args.add("-no-warn"); args.add("-no-warn");
@ -398,6 +404,18 @@ public class CompileKotlinOptions {
return this; return this;
} }
/**
* Don't automatically include the Kotlin/JVM stdlib ({@code kotlin-stdlib.jar}) and Kotlin reflection
* ({@code kotlin-reflect.jar}) into the classpath.
*
* @param noStdLib {@code true} or {@code false}
* @return this class instance
*/
public CompileKotlinOptions noStdLib(boolean noStdLib) {
noStdLib_ = noStdLib;
return this;
}
/** /**
* Suppress the compiler from displaying warnings during compilation. * Suppress the compiler from displaying warnings during compilation.
* *

View file

@ -31,6 +31,7 @@ class CompileKotlinOptionsTest {
var args = new CompileKotlinOptions() var args = new CompileKotlinOptions()
.argFile(List.of("arg1.txt", "arg2.txt")) .argFile(List.of("arg1.txt", "arg2.txt"))
.classpath(List.of("path1", "path2")) .classpath(List.of("path1", "path2"))
.noStdLib(false)
.optIn(List.of("opt1", "opt2")) .optIn(List.of("opt1", "opt2"))
.options(List.of("-foo", "-bar")) .options(List.of("-foo", "-bar"))
.scriptTemplates(List.of("temp1", "temp2")) .scriptTemplates(List.of("temp1", "temp2"))
@ -92,6 +93,7 @@ class CompileKotlinOptionsTest {
"-module-name", "module", "-module-name", "module",
"-no-jdk", "-no-jdk",
"-no-reflect", "-no-reflect",
"-no-stdlib",
"-no-warn", "-no-warn",
"-opt-in", "opt1", "-opt-in", "opt1",
"-opt-in", "opt2", "-opt-in", "opt2",