diff --git a/docs/api/command-line.md b/docs/api/command-line.md index 8626481f..c7d83f0b 100644 --- a/docs/api/command-line.md +++ b/docs/api/command-line.md @@ -36,6 +36,9 @@ When searching for modules, the directory containing the file currently being co When searching for platform definitions, the current working directory is also searched. If not given, the compiler will try to detect the default include directory. If given, then the compiler will NOT try to detect the default include directory and you will have to add it to the list yourself. + +* `-i ` – Add a directory to the include directories. +Unlike `-I`, this does not replace the default include directory and allows using directories with semicolons in their names. * `-t ` – Target platform. It is loaded from an `.ini` file found in any of the include directories. See also [this document](target-platforms.md). diff --git a/src/main/scala/millfork/Main.scala b/src/main/scala/millfork/Main.scala index 500d8440..ca91bbe0 100644 --- a/src/main/scala/millfork/Main.scala +++ b/src/main/scala/millfork/Main.scala @@ -189,10 +189,10 @@ object Main { log.debug(s"Failed to find the default include path: $err") case Right(path) => log.debug(s"Automatically detected include path: $path") - return c.copy(includePath = List(path)) + return c.copy(includePath = List(path) ++ c.extraIncludePath) } } - c + c.copy(includePath = c.includePath ++ c.extraIncludePath) } private def assembleForMos(c: Context, platform: Platform, options: CompilationOptions): AssemblerOutput = { @@ -348,6 +348,10 @@ object Main { c.copy(includePath = c.includePath ++ n) }.description("Include paths for modules. If not given, the default path is used: " + getDefaultIncludePath.fold(identity, identity)) + parameter("-i", "--add-include-dir").repeatable().placeholder("").action { (path, c) => + c.copy(extraIncludePath = c.extraIncludePath :+ path) + }.description("Add a directory to include paths.") + parameter("-r", "--run").placeholder("").action { (p, c) => assertNone(c.runFileName, "Run program already defined") c.copy(runFileName = Some(p))