|
@@ -487,6 +487,7 @@ type
|
|
procedure AddUsedUnit(aFile: TPas2jsCompilerFile);
|
|
procedure AddUsedUnit(aFile: TPas2jsCompilerFile);
|
|
|
|
|
|
function DirectoryExists(const Filename: string): boolean;
|
|
function DirectoryExists(const Filename: string): boolean;
|
|
|
|
+ function ExpandFileName(const Filename: string): string;
|
|
public
|
|
public
|
|
property CompilerExe: string read FCompilerExe write SetCompilerExe;
|
|
property CompilerExe: string read FCompilerExe write SetCompilerExe;
|
|
property ConditionEvaluator: TCondDirectiveEvaluator read FConditionEval;
|
|
property ConditionEvaluator: TCondDirectiveEvaluator read FConditionEval;
|
|
@@ -2598,7 +2599,7 @@ end;
|
|
procedure TPas2jsCompiler.SetCompilerExe(AValue: string);
|
|
procedure TPas2jsCompiler.SetCompilerExe(AValue: string);
|
|
begin
|
|
begin
|
|
if AValue<>'' then
|
|
if AValue<>'' then
|
|
- AValue:=ExpandFileNameUTF8(AValue,FileCache.BaseDirectory);
|
|
|
|
|
|
+ AValue:=ExpandFileName(AValue);
|
|
if FCompilerExe=AValue then Exit;
|
|
if FCompilerExe=AValue then Exit;
|
|
FCompilerExe:=AValue;
|
|
FCompilerExe:=AValue;
|
|
end;
|
|
end;
|
|
@@ -2933,7 +2934,7 @@ procedure TPas2jsCompiler.LoadDefaultConfig;
|
|
begin
|
|
begin
|
|
Result:=false;
|
|
Result:=false;
|
|
if aFilename='' then exit;
|
|
if aFilename='' then exit;
|
|
- aFilename:=ExpandFileNameUTF8(aFilename,FileCache.BaseDirectory);
|
|
|
|
|
|
+ aFilename:=ExpandFileName(aFilename);
|
|
if ShowTriedUsedFiles then
|
|
if ShowTriedUsedFiles then
|
|
Log.LogMsgIgnoreFilter(nConfigFileSearch,[aFilename]);
|
|
Log.LogMsgIgnoreFilter(nConfigFileSearch,[aFilename]);
|
|
if not DirectoryCache.FileExists(aFilename) then exit;
|
|
if not DirectoryCache.FileExists(aFilename) then exit;
|
|
@@ -3251,6 +3252,7 @@ begin
|
|
end;
|
|
end;
|
|
'o':
|
|
'o':
|
|
begin
|
|
begin
|
|
|
|
+ // -Jo<flag>
|
|
Identifier:=String(p);
|
|
Identifier:=String(p);
|
|
if Identifier='' then
|
|
if Identifier='' then
|
|
ParamFatal('missing value of -Jo option');
|
|
ParamFatal('missing value of -Jo option');
|
|
@@ -3314,7 +3316,16 @@ begin
|
|
'o': // output file, main JavaScript file
|
|
'o': // output file, main JavaScript file
|
|
begin
|
|
begin
|
|
inc(p);
|
|
inc(p);
|
|
- FileCache.MainJSFile:=String(p);
|
|
|
|
|
|
+ aFilename:=String(p);
|
|
|
|
+ if aFilename='' then
|
|
|
|
+ ParamFatal('invalid empty output file (-o)')
|
|
|
|
+ else if aFilename='..' then
|
|
|
|
+ ParamFatal('invalid output file (-o) "'+aFilename+'"')
|
|
|
|
+ else if aFilename='.' then
|
|
|
|
+ // ok, stdout
|
|
|
|
+ else
|
|
|
|
+ aFilename:=ExpandFileName(aFilename);
|
|
|
|
+ FileCache.MainJSFile:=aFilename;
|
|
end;
|
|
end;
|
|
'O': // optimizations
|
|
'O': // optimizations
|
|
begin
|
|
begin
|
|
@@ -3428,7 +3439,7 @@ begin
|
|
aFilename:=copy(Param,2,length(Param));
|
|
aFilename:=copy(Param,2,length(Param));
|
|
if aFilename='' then
|
|
if aFilename='' then
|
|
ParamFatal('invalid config file at param position '+IntToStr(i));
|
|
ParamFatal('invalid config file at param position '+IntToStr(i));
|
|
- aFilename:=ExpandFileNameUTF8(aFilename,FileCache.BaseDirectory);
|
|
|
|
|
|
+ aFilename:=ExpandFileName(aFilename);
|
|
if not DirectoryCache.FileExists(aFilename) then
|
|
if not DirectoryCache.FileExists(aFilename) then
|
|
ParamFatal('config file not found: "'+copy(Param,2,length(Param))+'"');
|
|
ParamFatal('config file not found: "'+copy(Param,2,length(Param))+'"');
|
|
LoadConfig(aFilename);
|
|
LoadConfig(aFilename);
|
|
@@ -3441,7 +3452,7 @@ begin
|
|
CfgSyntaxError('invalid parameter');
|
|
CfgSyntaxError('invalid parameter');
|
|
if FileCache.MainSrcFile<>'' then
|
|
if FileCache.MainSrcFile<>'' then
|
|
ParamFatal('Only one Pascal file is supported, but got "'+FileCache.MainSrcFile+'" and "'+Param+'".');
|
|
ParamFatal('Only one Pascal file is supported, but got "'+FileCache.MainSrcFile+'" and "'+Param+'".');
|
|
- aFilename:=ExpandFileNameUTF8(Param,FileCache.BaseDirectory);
|
|
|
|
|
|
+ aFilename:=ExpandFileName(Param);
|
|
FileCache.MainSrcFile:=aFilename;
|
|
FileCache.MainSrcFile:=aFilename;
|
|
end;
|
|
end;
|
|
end;
|
|
end;
|
|
@@ -4275,7 +4286,7 @@ begin
|
|
Terminate(ExitCodeFileNotFound);
|
|
Terminate(ExitCodeFileNotFound);
|
|
end;
|
|
end;
|
|
|
|
|
|
- UnitFilename:=ExpandFileNameUTF8(UnitFilename,FileCache.BaseDirectory);
|
|
|
|
|
|
+ UnitFilename:=ExpandFileName(UnitFilename);
|
|
if DirectoryCache.DirectoryExists(UnitFilename) then
|
|
if DirectoryCache.DirectoryExists(UnitFilename) then
|
|
begin
|
|
begin
|
|
Log.LogMsg(nFileIsFolder,[QuoteStr(UnitFilename)]);
|
|
Log.LogMsg(nFileIsFolder,[QuoteStr(UnitFilename)]);
|
|
@@ -4356,5 +4367,10 @@ begin
|
|
Result:=FileCache.DirectoryCache.DirectoryExists(Filename);
|
|
Result:=FileCache.DirectoryCache.DirectoryExists(Filename);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+function TPas2jsCompiler.ExpandFileName(const Filename: string): string;
|
|
|
|
+begin
|
|
|
|
+ Result:=ExpandFileNameUTF8(Filename,FileCache.BaseDirectory);
|
|
|
|
+end;
|
|
|
|
+
|
|
end.
|
|
end.
|
|
|
|
|