summaryrefslogtreecommitdiff
path: root/packages/fcl-res
diff options
context:
space:
mode:
authorsvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-08-12 19:06:20 +0000
committersvenbarth <svenbarth@3ad0048d-3df7-0310-abae-a5850022a9f2>2020-08-12 19:06:20 +0000
commitdb0ccd773bfbaf4295187e2059d7238811e62563 (patch)
tree589ecaa7bd9e3c20ecbf5e00c521ccf1e3dfe572 /packages/fcl-res
parent5c4a032fe7583c663c47310d4b9f1b0a7e94af36 (diff)
downloadfpc-db0ccd773bfbaf4295187e2059d7238811e62563.tar.gz
fcl-res, fpcres: command line switches for include and defines
Reintegrate fpcres-rc branch by Martok git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@46387 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-res')
-rw-r--r--packages/fcl-res/src/rcreader.pp15
-rw-r--r--packages/fcl-res/src/yyinclude.pp12
-rw-r--r--packages/fcl-res/src/yypreproc.pp2
3 files changed, 24 insertions, 5 deletions
diff --git a/packages/fcl-res/src/rcreader.pp b/packages/fcl-res/src/rcreader.pp
index 613510571d..2ad14051ec 100644
--- a/packages/fcl-res/src/rcreader.pp
+++ b/packages/fcl-res/src/rcreader.pp
@@ -30,6 +30,8 @@ type
private
fExtensions : string;
fDescription : string;
+ fRCIncludeDirs: TStringList;
+ fRCDefines: TStringList;
protected
function GetExtensions : string; override;
function GetDescription : string; override;
@@ -39,6 +41,8 @@ type
public
constructor Create; override;
destructor Destroy; override;
+ property RCIncludeDirs: TStringList read fRCIncludeDirs;
+ property RCDefines: TStringList read fRCDefines;
end;
implementation
@@ -81,6 +85,8 @@ begin
end;
procedure TRCResourceReader.ReadRCFile(aResources: TResources; aLocation: String; aStream: TStream);
+var
+ i: Integer;
begin
AssignStream(lexlib.yyinput, aStream);
Reset(lexlib.yyinput);
@@ -90,8 +96,11 @@ begin
SetTextCodePage(lexlib.yyinput, rcparser.opt_code_page);
rcparser.yinclude:= tyinclude.Create;
rcparser.yinclude.WorkDir:= aLocation;
+ rcparser.yinclude.SearchPaths.Assign(fRCIncludeDirs);
rcparser.ypreproc:= typreproc.Create;
rcparser.ypreproc.Defines.Add('RC_INVOKED', '');
+ for i:= 0 to fRCDefines.Count-1 do
+ rcparser.ypreproc.Defines.Items[fRCDefines.Names[i]]:= fRCDefines.ValueFromIndex[i];
rcparser.aktresources:= aResources;
if rcparser.yyparse <> 0 then
raise EReadError.Create('Parse Error');
@@ -106,11 +115,15 @@ constructor TRCResourceReader.Create;
begin
fExtensions:='.rc';
fDescription:='RC script resource reader';
+ fRCDefines:= TStringList.Create;
+ fRCIncludeDirs:= TStringList.Create;
end;
destructor TRCResourceReader.Destroy;
begin
-
+ fRCIncludeDirs.Free;
+ fRCDefines.Free;
+ inherited;
end;
initialization
diff --git a/packages/fcl-res/src/yyinclude.pp b/packages/fcl-res/src/yyinclude.pp
index 9be7fb3ebe..73a928ef0f 100644
--- a/packages/fcl-res/src/yyinclude.pp
+++ b/packages/fcl-res/src/yyinclude.pp
@@ -90,14 +90,20 @@ begin
if FileExists(f) then
Exit(f);
end;
- yyerror('Invalid file not found on search paths: "'+fn+'"');
+ yyerror('Include file not found on search paths: <'+fn+'>');
end
else if (fn[1] = '"') and (fn[length(fn)] = '"') then begin
fn:= copy(fn, 2, Length(fn)-2);
f:= ConcatPaths([WorkDir, fn]);
if FileExists(f) then
Exit(f);
- yyerror('Invalid file not found: "'+fn+'"');
+ if fn = 'windows.h' then begin
+ // treat windows.h as an alias for windres.h
+ f:= ConcatPaths([WorkDir, 'windres.h']);
+ if FileExists(f) then
+ Exit(f);
+ end;
+ yyerror('Include file not found: "'+fn+'"');
end;
end;
yyerror('Invalid include directive: "'+fn+'"');
@@ -105,7 +111,7 @@ end;
constructor tyinclude.Create;
begin
- inherited;
+ inherited Create;
level:= 0;
WorkDir:= GetCurrentDir;
SearchPaths:= TStringList.Create;
diff --git a/packages/fcl-res/src/yypreproc.pp b/packages/fcl-res/src/yypreproc.pp
index 7a07ebe9b8..25574b6cc6 100644
--- a/packages/fcl-res/src/yypreproc.pp
+++ b/packages/fcl-res/src/yypreproc.pp
@@ -27,7 +27,7 @@ var
constructor typreproc.Create;
begin
- inherited;
+ inherited Create;
Defines:= TFPStringHashTable.Create;
level:= 0;
cheadermode:= false;