mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-06 00:00:22 +00:00
Merge pull request #201 from mkilgore/compile-relative-bas
Fix compiling bas files relative to the CWD
This commit is contained in:
commit
bdcb8f1b4d
|
@ -379,7 +379,13 @@ DIM SHARED compilelog$
|
||||||
|
|
||||||
'$INCLUDE:'global\IDEsettings.bas'
|
'$INCLUDE:'global\IDEsettings.bas'
|
||||||
|
|
||||||
|
DIM OutputIsRelativeToStartDir AS LONG
|
||||||
|
|
||||||
CMDLineFile = ParseCMDLineArgs$
|
CMDLineFile = ParseCMDLineArgs$
|
||||||
|
IF CMDLineFile <> "" AND _FILEEXISTS(_STARTDIR$ + "/" + CMDLineFile) THEN
|
||||||
|
CMDLineFile = _STARTDIR$ + "/" + CMDLineFile
|
||||||
|
OutputIsRelativeToStartDir = -1
|
||||||
|
END IF
|
||||||
|
|
||||||
IF ConsoleMode THEN
|
IF ConsoleMode THEN
|
||||||
_DEST _CONSOLE
|
_DEST _CONSOLE
|
||||||
|
@ -12316,19 +12322,38 @@ IF idemode = 0 AND No_C_Compile_Mode = 0 THEN
|
||||||
path.out$ = getfilepath$(outputfile_cmd$)
|
path.out$ = getfilepath$(outputfile_cmd$)
|
||||||
f$ = MID$(outputfile_cmd$, LEN(path.out$) + 1)
|
f$ = MID$(outputfile_cmd$, LEN(path.out$) + 1)
|
||||||
file$ = RemoveFileExtension$(f$)
|
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
|
IF _DIREXISTS(path.out$) = 0 THEN
|
||||||
PRINT
|
PRINT
|
||||||
PRINT "Can't create output executable - path not found: " + path.out$
|
PRINT "Can't create output executable - path not found: " + path.out$
|
||||||
IF ConsoleMode THEN SYSTEM 1
|
IF ConsoleMode THEN SYSTEM 1
|
||||||
END 1
|
END 1
|
||||||
END IF
|
END IF
|
||||||
currentdir$ = _CWD$
|
|
||||||
CHDIR path.out$
|
CHDIR path.out$
|
||||||
path.out$ = _CWD$
|
path.out$ = _CWD$
|
||||||
CHDIR currentdir$
|
CHDIR currentdir$
|
||||||
|
|
||||||
IF RIGHT$(path.out$, 1) <> pathsep$ THEN path.out$ = path.out$ + pathsep$
|
IF RIGHT$(path.out$, 1) <> pathsep$ THEN path.out$ = path.out$ + pathsep$
|
||||||
path.exe$ = path.out$
|
path.exe$ = path.out$
|
||||||
|
|
||||||
SaveExeWithSource = -1 'Override the global setting if an output file was specified
|
SaveExeWithSource = -1 'Override the global setting if an output file was specified
|
||||||
END IF
|
END IF
|
||||||
END IF
|
END IF
|
||||||
|
|
|
@ -56,9 +56,14 @@ do
|
||||||
compilerFlags=$(cat "./tests/compile_tests/$category/$testName.flags")
|
compilerFlags=$(cat "./tests/compile_tests/$category/$testName.flags")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
pushd . >/dev/null
|
||||||
|
cd "./tests/compile_tests/$category"
|
||||||
|
|
||||||
# -m and -q make sure that we get predictable results
|
# -m and -q make sure that we get predictable results
|
||||||
"$QB64" $compilerFlags -m -q -x "./tests/compile_tests/$category/$testName.bas" -o "$EXE" 1>"$compileResultOutput"
|
"../../../$QB64" $compilerFlags -q -m -x "$testName.bas" -o "../../../$EXE" 1>"../../../$compileResultOutput"
|
||||||
ERR=$?
|
ERR=$?
|
||||||
|
|
||||||
|
popd >/dev/null
|
||||||
cp_if_exists ./internal/temp/compilelog.txt "$RESULTS_DIR/$category-$testName-compilelog.txt"
|
cp_if_exists ./internal/temp/compilelog.txt "$RESULTS_DIR/$category-$testName-compilelog.txt"
|
||||||
|
|
||||||
if [ "$testType" == "success" ]; then
|
if [ "$testType" == "success" ]; then
|
||||||
|
|
2
tests/compile_tests/extra/include_extra.bi
Normal file
2
tests/compile_tests/extra/include_extra.bi
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
|
||||||
|
PRINT "include_extra.bi was included!"
|
12
tests/compile_tests/extra/include_extra_include.bi
Normal file
12
tests/compile_tests/extra/include_extra_include.bi
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
' Include a file relative to the location of this file (which itself is included from elsewhere)
|
||||||
|
|
||||||
|
' Both relative formats should work
|
||||||
|
|
||||||
|
'$include:'./include_extra_target.bi'
|
||||||
|
'$include:'include_extra_target.bi'
|
||||||
|
|
||||||
|
' Absolute position relative to the compiler should work too
|
||||||
|
|
||||||
|
'$include:'./tests/compile_tests/extra/include_extra_target.bi'
|
||||||
|
'$include:'tests/compile_tests/extra/include_extra_target.bi'
|
4
tests/compile_tests/extra/include_extra_target.bi
Normal file
4
tests/compile_tests/extra/include_extra_target.bi
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
includeCount = includeCount + 1
|
||||||
|
|
||||||
|
PRINT "include_extra_target.bi was included! Include count:"; includeCount
|
|
@ -0,0 +1,10 @@
|
||||||
|
$CONSOLE:ONLY
|
||||||
|
|
||||||
|
' This include path is relative to the location of QB64-PE
|
||||||
|
|
||||||
|
' Both relative path formats should work
|
||||||
|
|
||||||
|
'$include:'./tests/compile_tests/extra/include_extra.bi'
|
||||||
|
'$include:'tests/compile_tests/extra/include_extra.bi'
|
||||||
|
|
||||||
|
SYSTEM
|
|
@ -0,0 +1,2 @@
|
||||||
|
include_extra.bi was included!
|
||||||
|
include_extra.bi was included!
|
12
tests/compile_tests/include_paths/include_multiple.bas
Normal file
12
tests/compile_tests/include_paths/include_multiple.bas
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
$CONSOLE:ONLY
|
||||||
|
|
||||||
|
' Include a file that itself includes another file. It does so in a relative
|
||||||
|
' fashion
|
||||||
|
|
||||||
|
Dim includeCount As Long
|
||||||
|
|
||||||
|
'$include:'../extra/include_extra_include.bi'
|
||||||
|
'$include:'./tests/compile_tests/extra/include_extra_include.bi'
|
||||||
|
'$include:'tests/compile_tests/extra/include_extra_include.bi'
|
||||||
|
|
||||||
|
SYSTEM
|
12
tests/compile_tests/include_paths/include_multiple.output
Normal file
12
tests/compile_tests/include_paths/include_multiple.output
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
include_extra_target.bi was included! Include count: 1
|
||||||
|
include_extra_target.bi was included! Include count: 2
|
||||||
|
include_extra_target.bi was included! Include count: 3
|
||||||
|
include_extra_target.bi was included! Include count: 4
|
||||||
|
include_extra_target.bi was included! Include count: 5
|
||||||
|
include_extra_target.bi was included! Include count: 6
|
||||||
|
include_extra_target.bi was included! Include count: 7
|
||||||
|
include_extra_target.bi was included! Include count: 8
|
||||||
|
include_extra_target.bi was included! Include count: 9
|
||||||
|
include_extra_target.bi was included! Include count: 10
|
||||||
|
include_extra_target.bi was included! Include count: 11
|
||||||
|
include_extra_target.bi was included! Include count: 12
|
7
tests/compile_tests/include_paths/include_relative.bas
Normal file
7
tests/compile_tests/include_paths/include_relative.bas
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
$CONSOLE:ONLY
|
||||||
|
|
||||||
|
' This include path is specified relative to the location of the current source file
|
||||||
|
|
||||||
|
'$include:'../extra/include_extra.bi'
|
||||||
|
|
||||||
|
SYSTEM
|
|
@ -0,0 +1 @@
|
||||||
|
include_extra.bi was included!
|
Loading…
Reference in a new issue