paths are now always relative

This commit is contained in:
Irmen de Jong 2021-10-16 02:43:22 +02:00
parent 0f80897c50
commit 06defd0cb0
7 changed files with 9 additions and 8 deletions

View File

@ -85,7 +85,7 @@ private fun compileMain(args: Array<String>): Boolean {
for (importedFile in allImportedFiles) {
print(" ")
println(importedFile)
val watchDir = importedFile.parent ?: Path.of(".")
val watchDir = importedFile.parent ?: Path.of("")
watchDir.register(watchservice, StandardWatchEventKinds.ENTRY_MODIFY)
}
println("[${LocalDateTime.now().withNano(0)}] Waiting for file changes.")

View File

@ -1343,8 +1343,8 @@ $repeatLabel lda $counterVar
val sourcePath = Path(stmt.definingModule.source.pathString())
val includedPath = sourcePath.resolveSibling(includedName)
val pathForAssembler = outputDir // #54: 64tass needs the path *relative to the .asm file*
.absolute() // avoid IllegalArgumentExc due to non-absolute path .relativize(absolute path)
.relativize(includedPath)
.toAbsolutePath()
.relativize(includedPath.toAbsolutePath())
.normalize() // avoid assembler warnings (-Wportable; only some, not all)
.toString().replace('\\', '/')
out(" .binary \"$pathForAssembler\" $offset $length")

View File

@ -79,7 +79,7 @@ locallabel:
val errors = ErrorReporter()
val options = CompilationOptions(OutputType.RAW, LauncherType.NONE, ZeropageType.FULL, emptyList(), false, true, C64Target)
val zp = C64MachineDefinition.C64Zeropage(options)
val asmgen = AsmGen(program, errors, zp, options, C64Target, Path.of("."))
val asmgen = AsmGen(program, errors, zp, options, C64Target, Path.of(""))
return asmgen
}

View File

@ -43,7 +43,7 @@ object Prog8Parser {
}
private class ParsedModule(source: SourceCode) :
Module(mutableListOf(), Position(source.origin, 1, 0, 0), source)
Module(mutableListOf(), Position(source.pathString(), 1, 0, 0), source)
{
/**

View File

@ -65,6 +65,7 @@ sealed class SourceCode {
* filename prefix to designate library files that will be retreived from internal resources rather than disk
*/
const val libraryFilePrefix = "library:"
val curdir: Path = Path.of(".").toAbsolutePath()
}
/**
@ -102,7 +103,7 @@ sealed class SourceCode {
}
override val isFromResources = false
override val origin = normalized.absolutePathString()
override val origin = curdir.relativize(normalized.toAbsolutePath()).normalize().toString()
override fun getCharStream(): CharStream = CharStreams.fromPath(normalized)
}

View File

@ -3,7 +3,7 @@ TODO
For next compiler release
^^^^^^^^^^^^^^^^^^^^^^^^^
fix github issue #64 about inconsistent absolute path usage
re-test https://github.com/irmen/prog8/pull/54 on windows
Blocked by Commander-x16 v39 release

View File

@ -35,7 +35,7 @@ class RequestParser : Take {
slowCodegenWarnings = true,
compilationTarget = "c64",
sourceDirs = emptyList(),
outputDir = Path.of(".")
outputDir = Path.of("")
)
return RsJson(Jsonding())
}