1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-29 12:50:37 +00:00

Fix -o to be relative to _STARTDIR$ when source file is

In 094a8c82 we added the ability to compile a source file relative to
_STARTDIR$ instead of the location of the qb64pe executable. This change
fixes `-o` so that it is also treated as relative to _STARTDIR$ when the
provided source file is.

Note that this is not a real behavior change because if the provided
source file is relative to the qb64pe executable then `-o` will be as
well, which matches the previous behavior. The cases where it is made
relative to _STARTDIR$ all produced errors until 094a8c82 was done, so
there was no previous defined behavior.
This commit is contained in:
Matthew Kilgore 2022-10-01 04:06:20 -04:00
parent 094a8c82b2
commit 21b7d60f44
2 changed files with 25 additions and 3 deletions

View file

@ -379,9 +379,12 @@ DIM SHARED compilelog$
'$INCLUDE:'global\IDEsettings.bas'
DIM OutputIsRelativeToStartDir AS LONG
CMDLineFile = ParseCMDLineArgs$
IF CMDLineFile <> "" AND _FILEEXISTS(_STARTDIR$ + "/" + CMDLineFile) THEN
CMDLineFile = _STARTDIR$ + "/" + CMDLineFile
OutputIsRelativeToStartDir = -1
END IF
IF ConsoleMode THEN
@ -12319,19 +12322,38 @@ IF idemode = 0 AND No_C_Compile_Mode = 0 THEN
path.out$ = getfilepath$(outputfile_cmd$)
f$ = MID$(outputfile_cmd$, LEN(path.out$) + 1)
file$ = RemoveFileExtension$(f$)
IF LEN(path.out$) THEN
IF LEN(path.out$) OR OutputIsRelativeToStartDir THEN
currentdir$ = _CWD$
IF OutputIsRelativeToStartDir THEN
' This CHDIR makes the next CHDIR relative to _STARTDIR$
' We do this if the provided source file was also relative to _STARTDIR$
CHDIR _STARTDIR$
' If there was no provided path then that is the same as the
' output file being directly in _STARTDIR$. Assigning it here
' is perfectly fine and avoids failing the error check below
' with a blank string.
IF LEN(path.out$) = 0 THEN
path.out$ = _STARTDIR$
END IF
END IF
IF _DIREXISTS(path.out$) = 0 THEN
PRINT
PRINT "Can't create output executable - path not found: " + path.out$
IF ConsoleMode THEN SYSTEM 1
END 1
END IF
currentdir$ = _CWD$
CHDIR path.out$
path.out$ = _CWD$
CHDIR currentdir$
IF RIGHT$(path.out$, 1) <> pathsep$ THEN path.out$ = path.out$ + pathsep$
path.exe$ = path.out$
SaveExeWithSource = -1 'Override the global setting if an output file was specified
END IF
END IF

View file

@ -60,7 +60,7 @@ do
cd "./tests/compile_tests/$category"
# -m and -q make sure that we get predictable results
"../../../$QB64" $compilerFlags -m -q -x "$testName.bas" -o "$EXE" 1>"../../../$compileResultOutput"
"../../../$QB64" $compilerFlags -q -m -x "$testName.bas" -o "../../../$EXE" 1>"../../../$compileResultOutput"
ERR=$?
popd >/dev/null