aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/shedlang/compiler/ShedCompiler.java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2024-03-24 14:10:30 +0000
committerMichael Williamson <mike@zwobble.org>2024-03-24 14:10:30 +0000
commit04cf66d6b53121998b33889a5495aaef3925cdfd (patch)
tree71f827e2486627eb794c3f5b62e74ccab349d5ec /src/main/java/org/shedlang/compiler/ShedCompiler.java
parentcb44def5d662e9ec15cf1d97d735c6deb129c302 (diff)
Use profiles when compiling
Diffstat (limited to 'src/main/java/org/shedlang/compiler/ShedCompiler.java')
-rw-r--r--src/main/java/org/shedlang/compiler/ShedCompiler.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/main/java/org/shedlang/compiler/ShedCompiler.java b/src/main/java/org/shedlang/compiler/ShedCompiler.java
index 1f04c0fa..45c189bf 100644
--- a/src/main/java/org/shedlang/compiler/ShedCompiler.java
+++ b/src/main/java/org/shedlang/compiler/ShedCompiler.java
@@ -4,6 +4,7 @@ import org.shedlang.compiler.ast.untyped.UntypedNamespaceNode;
import org.shedlang.compiler.backends.Backend;
import org.shedlang.compiler.backends.paths.TargetDir;
import org.shedlang.compiler.config.ConfigChecker;
+import org.shedlang.compiler.config.ProfileConfig;
import org.shedlang.compiler.config.ProjectConfig;
import org.shedlang.compiler.parser.Parser;
import org.shedlang.compiler.shid.ShidCodeGen;
@@ -21,10 +22,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.StreamSupport;
import static org.shedlang.compiler.parser.Tokeniser.tokenise;
@@ -34,7 +32,7 @@ public class ShedCompiler {
public void compile(
Path projectRoot,
Backend backend,
- String profileName
+ Optional<String> profileName
) throws IOException, InterruptedException {
var config = ProjectConfig.read(projectRoot);
@@ -75,12 +73,19 @@ public class ShedCompiler {
ConfigChecker.configCheck(config, typeInfos);
+ var profileConfig = profileName.map(config::profile)
+ .orElse(ProfileConfig.DEFAULT);
+
backend.compile(
config,
- profileName,
+ profileConfig,
namespaces,
typeInfos,
- new TargetDir(config.targetDir().resolve(backend.targetName()))
+ new TargetDir(
+ config.targetDir()
+ .resolve(backend.targetName())
+ .resolve(profileConfig.name())
+ )
);
}