mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-07 19:10:25 +00:00
Command line improvements.
- Add -e for compiling with OPTION _EXPLICIT activated from the command line - even if the source file doesn't have the directive. - Add -o for specifying a different output executable file name. - More flexible syntax, as switches can come after the file name, making the following acceptable: qb64 filename.bas -x -e -o myprog.exe
This commit is contained in:
parent
46e13e9d1e
commit
bad8133d16
|
@ -3,5 +3,5 @@ DIM SHARED BuildNum AS STRING
|
||||||
Version$ = "1.000"
|
Version$ = "1.000"
|
||||||
'BuildNum format is YYYYMMDD/id, where id is a ever-increasing
|
'BuildNum format is YYYYMMDD/id, where id is a ever-increasing
|
||||||
'integer. If you make a change, update the date and increase the id!
|
'integer. If you make a change, update the date and increase the id!
|
||||||
BuildNum$ = "20160630/30"
|
BuildNum$ = "20160702/31"
|
||||||
|
|
||||||
|
|
|
@ -278,6 +278,10 @@ DIM SHARED ideerrorline AS LONG 'set by qb64-error(...) to the line number it wo
|
||||||
DIM SHARED idemessage AS STRING 'set by qb64-error(...) to the error message to be reported, this
|
DIM SHARED idemessage AS STRING 'set by qb64-error(...) to the error message to be reported, this
|
||||||
'is later passed to the ide in message #8
|
'is later passed to the ide in message #8
|
||||||
|
|
||||||
|
DIM SHARED optionexplicit AS _BYTE
|
||||||
|
DIM SHARED optionexplicit_cmd AS _BYTE
|
||||||
|
DIM SHARED outputfile_cmd$
|
||||||
|
|
||||||
'$INCLUDE:'global\IDEsettings.bas'
|
'$INCLUDE:'global\IDEsettings.bas'
|
||||||
|
|
||||||
CMDLineFile = ParseCMDLineArgs$
|
CMDLineFile = ParseCMDLineArgs$
|
||||||
|
@ -707,7 +711,6 @@ DIM SHARED cleanupstringprocessingcall AS STRING
|
||||||
DIM SHARED recompile AS INTEGER 'forces recompilation
|
DIM SHARED recompile AS INTEGER 'forces recompilation
|
||||||
'COMMON SHARED cmemlist() AS INTEGER
|
'COMMON SHARED cmemlist() AS INTEGER
|
||||||
DIM SHARED optionbase AS INTEGER
|
DIM SHARED optionbase AS INTEGER
|
||||||
DIM SHARED optionexplicit AS _BYTE
|
|
||||||
|
|
||||||
DIM SHARED addmetastatic AS INTEGER
|
DIM SHARED addmetastatic AS INTEGER
|
||||||
DIM SHARED addmetadynamic AS INTEGER
|
DIM SHARED addmetadynamic AS INTEGER
|
||||||
|
@ -1162,7 +1165,7 @@ path.source$ = getfilepath$(sourcefile$)
|
||||||
IF LEN(path.source$) THEN
|
IF LEN(path.source$) THEN
|
||||||
IF _DIREXISTS(path.source$) = 0 THEN
|
IF _DIREXISTS(path.source$) = 0 THEN
|
||||||
PRINT
|
PRINT
|
||||||
PRINT "CANNOT LOCATE SOURCE FILE:" + sourcefile$
|
PRINT "CANNOT LOCATE SOURCE FILE: " + sourcefile$
|
||||||
IF ConsoleMode THEN SYSTEM 1
|
IF ConsoleMode THEN SYSTEM 1
|
||||||
END 1
|
END 1
|
||||||
END IF
|
END IF
|
||||||
|
@ -1429,7 +1432,7 @@ addmetastatic = 0
|
||||||
addmetadynamic = 0
|
addmetadynamic = 0
|
||||||
DynamicMode = 0
|
DynamicMode = 0
|
||||||
optionbase = 0
|
optionbase = 0
|
||||||
optionexplicit = 0
|
optionexplicit = 0: IF optionexplicit_cmd = -1 AND NoIDEMode = 1 THEN optionexplicit = -1
|
||||||
DataOffset = 0
|
DataOffset = 0
|
||||||
statementn = 0
|
statementn = 0
|
||||||
qberrorhappened = 0: qberrorcode = 0: qberrorline = 0
|
qberrorhappened = 0: qberrorcode = 0: qberrorline = 0
|
||||||
|
@ -9612,7 +9615,7 @@ DO
|
||||||
layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$
|
layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$
|
||||||
GOTO finishedline
|
GOTO finishedline
|
||||||
CASE "_EXPLICIT"
|
CASE "_EXPLICIT"
|
||||||
IF optionexplicit = -1 THEN a$ = "Duplicate OPTION _EXPLICIT": GOTO errmes
|
IF optionexplicit = -1 AND NoIDEMode = 0 THEN a$ = "Duplicate OPTION _EXPLICIT": GOTO errmes
|
||||||
IF LEN(layout$) THEN a$ = "OPTION _EXPLICIT must come before any other statement": GOTO errmes
|
IF LEN(layout$) THEN a$ = "OPTION _EXPLICIT must come before any other statement": GOTO errmes
|
||||||
IF linenumber > 1 AND opex_comments = 0 THEN a$ = "OPTION _EXPLICIT must come before any other statement": GOTO errmes
|
IF linenumber > 1 AND opex_comments = 0 THEN a$ = "OPTION _EXPLICIT must come before any other statement": GOTO errmes
|
||||||
optionexplicit = -1
|
optionexplicit = -1
|
||||||
|
@ -11359,6 +11362,27 @@ IF idemode = 0 AND No_C_Compile_Mode = 0 THEN
|
||||||
ELSE
|
ELSE
|
||||||
PRINT "COMPILING C++ CODE INTO EXE..."
|
PRINT "COMPILING C++ CODE INTO EXE..."
|
||||||
END IF
|
END IF
|
||||||
|
IF LEN(outputfile_cmd$) THEN
|
||||||
|
'resolve relative path for output file
|
||||||
|
path.out$ = getfilepath$(outputfile_cmd$)
|
||||||
|
f$ = MID$(outputfile_cmd$, LEN(path.out$) + 1)
|
||||||
|
file$ = RemoveFileExtension$(f$)
|
||||||
|
IF LEN(path.out$) THEN
|
||||||
|
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
|
||||||
IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN
|
IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN
|
||||||
E = 0
|
E = 0
|
||||||
ON ERROR GOTO qberror_test
|
ON ERROR GOTO qberror_test
|
||||||
|
@ -12149,7 +12173,7 @@ IF os$ = "LNX" THEN
|
||||||
|
|
||||||
IF INSTR(_OS$, "[MACOSX]") THEN
|
IF INSTR(_OS$, "[MACOSX]") THEN
|
||||||
ff = FREEFILE
|
ff = FREEFILE
|
||||||
IF path.exe$ = "./" OR LEFT$(path.exe$, 2) = ".." THEN path.exe$ = ""
|
IF path.exe$ = "./" OR path.exe$ = "../../" OR path.exe$ = "..\..\" THEN path.exe$ = ""
|
||||||
OPEN path.exe$ + file$ + extension$ + "_start.command" FOR OUTPUT AS #ff
|
OPEN path.exe$ + file$ + extension$ + "_start.command" FOR OUTPUT AS #ff
|
||||||
PRINT #ff, "cd " + CHR$(34) + "$(dirname " + CHR$(34) + "$0" + CHR$(34) + ")" + CHR$(34);
|
PRINT #ff, "cd " + CHR$(34) + "$(dirname " + CHR$(34) + "$0" + CHR$(34) + ")" + CHR$(34);
|
||||||
PRINT #ff, CHR$(10);
|
PRINT #ff, CHR$(10);
|
||||||
|
@ -12168,7 +12192,7 @@ IF os$ = "LNX" THEN
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
IF No_C_Compile_Mode THEN compfailed = 0: GOTO No_C_Compile
|
IF No_C_Compile_Mode THEN compfailed = 0: GOTO No_C_Compile
|
||||||
IF LEFT$(path.exe$, 2) = ".." THEN path.exe$ = ""
|
IF path.exe$ = "../../" OR path.exe$ = "..\..\" THEN path.exe$ = ""
|
||||||
IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN compfailed = 0 ELSE compfailed = 1 'detect compilation failure
|
IF _FILEEXISTS(path.exe$ + file$ + extension$) THEN compfailed = 0 ELSE compfailed = 1 'detect compilation failure
|
||||||
|
|
||||||
IF compfailed THEN
|
IF compfailed THEN
|
||||||
|
@ -12270,16 +12294,13 @@ FUNCTION ParseCMDLineArgs$ ()
|
||||||
'Recall that COMMAND$ is a concatenation of argv[] elements, so we don't have
|
'Recall that COMMAND$ is a concatenation of argv[] elements, so we don't have
|
||||||
'to worry about more than one space between things (unless they used quotes,
|
'to worry about more than one space between things (unless they used quotes,
|
||||||
'in which case they're simply asking for trouble).
|
'in which case they're simply asking for trouble).
|
||||||
cmdline$ = LTRIM$(RTRIM$(COMMAND$))
|
FOR i = 1 TO _COMMANDCOUNT
|
||||||
tpos = 1
|
token$ = COMMAND$(i)
|
||||||
DO
|
SELECT CASE LCASE$(LEFT$(token$, 2))
|
||||||
token$ = MID$(cmdline$, tpos, 2) '))
|
|
||||||
SELECT CASE token$
|
|
||||||
CASE "-s" 'Settings
|
CASE "-s" 'Settings
|
||||||
token$ = MID$(cmdline$, tpos)
|
|
||||||
_DEST _CONSOLE
|
_DEST _CONSOLE
|
||||||
PRINT "QB64 COMPILER V" + Version$
|
PRINT "QB64 COMPILER V" + Version$
|
||||||
SELECT CASE token$
|
SELECT CASE LCASE$(token$)
|
||||||
CASE "-s"
|
CASE "-s"
|
||||||
PRINT "debuginfo = ";
|
PRINT "debuginfo = ";
|
||||||
IF idedebuginfo THEN PRINT "TRUE" ELSE PRINT "FALSE"
|
IF idedebuginfo THEN PRINT "TRUE" ELSE PRINT "FALSE"
|
||||||
|
@ -12360,6 +12381,8 @@ FUNCTION ParseCMDLineArgs$ ()
|
||||||
Cloud = 1
|
Cloud = 1
|
||||||
ConsoleMode = 1 'Implies -x
|
ConsoleMode = 1 'Implies -x
|
||||||
NoIDEMode = 1 'Imples -c
|
NoIDEMode = 1 'Imples -c
|
||||||
|
CASE "-e" 'Option Explicit
|
||||||
|
optionexplicit_cmd = -1
|
||||||
CASE "-z" 'Not compiling C code
|
CASE "-z" 'Not compiling C code
|
||||||
No_C_Compile_Mode = 1
|
No_C_Compile_Mode = 1
|
||||||
ConsoleMode = 1 'Implies -x
|
ConsoleMode = 1 'Implies -x
|
||||||
|
@ -12369,16 +12392,14 @@ FUNCTION ParseCMDLineArgs$ ()
|
||||||
NoIDEMode = 1 'Implies -c
|
NoIDEMode = 1 'Implies -c
|
||||||
CASE "-c" 'Compile instead of edit
|
CASE "-c" 'Compile instead of edit
|
||||||
NoIDEMode = 1
|
NoIDEMode = 1
|
||||||
CASE "--" 'Signifies the end of options; the rest of the line is a filename (allows compilation of -crapfile.bas and -xtreme.bas etc.)
|
CASE "-o" 'Specify an output file
|
||||||
tpos = tpos + 3 'Do it manually here
|
IF LEN(COMMAND$(i + 1)) > 0 THEN outputfile_cmd$ = COMMAND$(i + 1): i = i + 1
|
||||||
EXIT DO
|
|
||||||
CASE ELSE 'Something we don't recognise, assume it's a filename
|
CASE ELSE 'Something we don't recognise, assume it's a filename
|
||||||
EXIT DO
|
PassedFileName$ = token$
|
||||||
END SELECT
|
END SELECT
|
||||||
tpos = tpos + 3
|
NEXT i
|
||||||
LOOP
|
|
||||||
'tpos should now point to the filename (the rest of the command line). This means options *must* come before the file.
|
IF LEN(PassedFileName$) THEN ParseCMDLineArgs$ = PassedFileName$
|
||||||
ParseCMDLineArgs$ = MID$(cmdline$, tpos)
|
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
FUNCTION Type2MemTypeValue (t1)
|
FUNCTION Type2MemTypeValue (t1)
|
||||||
|
|
Loading…
Reference in a new issue