1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2025-02-08 12:30:58 +00:00

Moved some KC-files to stdlib. Added option for multiple include paths.

This commit is contained in:
jespergravgaard 2018-08-31 22:52:10 +02:00
parent 7f29a344ae
commit 17ad45d453
13 changed files with 12 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import picocli.CommandLine;
import java.io.*; import java.io.*;
import java.nio.file.*; import java.nio.file.*;
import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import static junit.framework.TestCase.fail; import static junit.framework.TestCase.fail;
@ -19,7 +20,7 @@ public class KickC implements Callable<Void> {
private Path kcFile = null; private Path kcFile = null;
@CommandLine.Option(names = {"-I", "-libdir" }, description = "Path to a library folder, where the compiler looks for included files.") @CommandLine.Option(names = {"-I", "-libdir" }, description = "Path to a library folder, where the compiler looks for included files.")
private Path libDir = null; private List<Path> libDirs = null;
@CommandLine.Option(names = {"-o"}, description = "Name of the output file. By default it is the same as the input file with extension .asm") @CommandLine.Option(names = {"-o"}, description = "Name of the output file. By default it is the same as the input file with extension .asm")
private String asmFileName = null; private String asmFileName = null;
@ -46,9 +47,11 @@ public class KickC implements Callable<Void> {
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
compiler.addImportPath("."); compiler.addImportPath(".");
if(libDir != null) { if(libDirs != null) {
for(Path libDir : libDirs) {
compiler.addImportPath(libDir.toString()); compiler.addImportPath(libDir.toString());
} }
}
String fileBaseName = getFileBaseName(kcFile); String fileBaseName = getFileBaseName(kcFile);

View File

@ -25,13 +25,13 @@ import static org.junit.Assert.assertTrue;
*/ */
public class TestPrograms { public class TestPrograms {
ReferenceHelper helper; String stdlibPath = "src/main/kc/stdlib";
String testPath = "src/test/java/dk/camelot64/kickc/test/kc";
ReferenceHelper helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
String testPath;
public TestPrograms() { public TestPrograms() {
testPath = "src/test/java/dk/camelot64/kickc/test/kc";
helper = new ReferenceHelper("dk/camelot64/kickc/test/ref/");
} }
@BeforeClass @BeforeClass
@ -1003,6 +1003,7 @@ public class TestPrograms {
private void testFile(String fileName) throws IOException, URISyntaxException { private void testFile(String fileName) throws IOException, URISyntaxException {
System.out.println("Testing output for " + fileName); System.out.println("Testing output for " + fileName);
Compiler compiler = new Compiler(); Compiler compiler = new Compiler();
compiler.addImportPath(stdlibPath);
compiler.addImportPath(testPath); compiler.addImportPath(testPath);
Program program = compiler.compile(fileName); Program program = compiler.compile(fileName);

View File

@ -1,4 +1,4 @@
// Simple outines for working with memory // Simple routines for working with memory
// Fill some memory with a value // Fill some memory with a value
void fill(byte* start, word size, byte val) { void fill(byte* start, word size, byte val) {