runnables, prevent additional first line switches to include "-of"

This commit is contained in:
Basile Burg 2016-04-11 06:11:26 +02:00
parent ad19ed1c6b
commit e10c323c74
1 changed files with 15 additions and 14 deletions

View File

@ -1980,9 +1980,10 @@ end;
procedure TCEMainForm.compileRunnable(unittest: boolean = false); procedure TCEMainForm.compileRunnable(unittest: boolean = false);
var var
i: integer; i: integer;
fname: string;
dmdproc: TCEProcess; dmdproc: TCEProcess;
lst: TStringList; lst: TStringList = nil;
fname, firstlineFlags: string; firstLineFlags: string = '';
begin begin
fMsgs.clearByData(fDoc); fMsgs.clearByData(fDoc);
@ -1992,20 +1993,19 @@ begin
firstlineFlags := fDoc.Lines[0]; firstlineFlags := fDoc.Lines[0];
i := firstlineFlags.length; i := firstlineFlags.length;
if ( i > 18) then if (i > 18) and (firstlineFlags.upperCase[1..17] = '#!RUNNABLE-FLAGS:') then
begin begin
if firstlineFlags.upperCase[1..17] = '#!RUNNABLE-FLAGS:' then firstlineFlags := fSymStringExpander.expand(firstlineFlags[18..i]);
firstlineFlags := fSymStringExpander.expand(firstlineFlags[18..i]) lst := TStringList.Create;
else firstlineFlags:= ''; CommandToList(firstlineFlags, lst);
end else firstlineFlags:= ''; for i:= lst.Count-1 downto 0 do
if (lst[i].length > 2) and (lst[i][1..3] = '-of') then
lst.Delete(i);
end;
lst := TStringList.Create;
dmdproc := TCEProcess.Create(nil); dmdproc := TCEProcess.Create(nil);
try try
fMsgs.message('compiling ' + shortenPath(fDoc.fileName, 25), fDoc, amcEdit, amkInf); fMsgs.message('compiling ' + shortenPath(fDoc.fileName, 25), fDoc, amcEdit, amkInf);
if fDoc.fileName.fileExists then if fDoc.fileName.fileExists then
fDoc.save fDoc.save
else else
@ -2025,8 +2025,8 @@ begin
dmdproc.Parameters.Add('-of' + fname + exeExt); dmdproc.Parameters.Add('-of' + fname + exeExt);
dmdproc.Parameters.Add('-J' + fDoc.fileName.extractFilePath); dmdproc.Parameters.Add('-J' + fDoc.fileName.extractFilePath);
dmdproc.Parameters.AddText(fRunnableSw); dmdproc.Parameters.AddText(fRunnableSw);
CommandToList(firstlineFlags, lst); if lst.isNotNil and (lst.Count <> 0) then
dmdproc.Parameters.AddStrings(lst); dmdproc.Parameters.AddStrings(lst);
if unittest then if unittest then
begin begin
dmdproc.Parameters.Add('-main'); dmdproc.Parameters.Add('-main');
@ -2056,7 +2056,8 @@ begin
finally finally
dmdproc.Free; dmdproc.Free;
lst.Free; if lst.isNotNil then
lst.Free;
end; end;
end; end;