From 277aed08b29bc056563d0f252e00b1fef9ed5fc3 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 27 Nov 2007 02:16:20 +0000 Subject: [PATCH] windows ide: - create rc files instead of res for version info and manifest - remove no more needed ide resources git-svn-id: trunk@13045 - --- .gitattributes | 2 - ide/main.pp | 4 +- ide/manifest.lrs | 14 --- ide/manifest.res | Bin 796 -> 0 bytes ide/w32manifest.pas | 70 ++++++----- ide/w32versioninfo.pas | 274 +++++++++++++++-------------------------- 6 files changed, 140 insertions(+), 224 deletions(-) delete mode 100644 ide/manifest.lrs delete mode 100644 ide/manifest.res diff --git a/.gitattributes b/.gitattributes index 23b2d23397..d1bab19280 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1963,9 +1963,7 @@ ide/mainintf.pas svneol=native#text/pascal ide/makeresstrdlg.lfm svneol=native#text/plain ide/makeresstrdlg.lrs svneol=native#text/plain ide/makeresstrdlg.pas svneol=native#text/pascal -ide/manifest.lrs svneol=native#text/pascal ide/manifest.rc svneol=native#text/plain -ide/manifest.res -text ide/miscoptions.pas svneol=native#text/pascal ide/msgquickfixes.pas svneol=native#text/plain ide/msgview.lfm svneol=native#text/plain diff --git a/ide/main.pp b/ide/main.pp index e5034c0c6d..dde0ed1f56 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -8399,7 +8399,7 @@ begin // handle versioninfo VersionInfo := Project1.VersionInfo; - Result := VersionInfo.CompileRCFile(Project1.MainFilename, + Result := VersionInfo.CreateRCFile(Project1.MainFilename, MainBuildBoss.GetTargetOS(true)); for Count := 1 to VersionInfo.VersionInfoMessages.Count do @@ -8408,7 +8408,7 @@ begin if Result <> mrOk then exit; // handle manifest - Result := Project1.XPManifest.CompileRCFile(Project1.MainFilename, + Result := Project1.XPManifest.CreateRCFile(Project1.MainFilename, MainBuildBoss.GetTargetOS(true)); for Count := 1 to Project1.XPManifest.Messages.Count do MessagesView.AddMsg(Format(Project1.XPManifest.Messages[Count - 1], diff --git a/ide/manifest.lrs b/ide/manifest.lrs deleted file mode 100644 index 42bce5c0b0..0000000000 --- a/ide/manifest.lrs +++ /dev/null @@ -1,14 +0,0 @@ -LazarusResources.Add('manifest','RES',[ - #0#0#0#0' '#0#0#0#255#255#0#0#255#255#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#220 - +#2#0#0' '#0#0#0#255#255#24#0#255#255#1#0#0#0#0#0'0'#0#25#4#0#0#0#0#0#0#0#0'<' - +'?xml version="1.0" encoding="UTF-8" standalone="yes"?>Your application description here.' - +'' -]); diff --git a/ide/manifest.res b/ide/manifest.res deleted file mode 100644 index 82d429d747e10db32923cad33641609576e51cbe..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 796 zcma)4-EPw`6b^`ofIG{VNKISTRWK!)stKfOfOauJT)NIlYvDh9>}+{g-enwj>zYXu zB9fz%ipJd)8j)7HU2K^7Ez=h+sB)V07GK%~P;vD0g54PK=Vlq3hyAI&&t_ zl>MADBdqEG+s)dI?(d?dw9#xUW%R#M~!8*Q>31SqTNsFe?U zu*6jk$2zVa+;~RLc=iL|F9(0hAIi4w21`<4oSj@a8-vrxk0va$1^+g|rwy^cgyGu# z0?KfC`r&l5T+9~>DZ6>wai)dcCb8XnM*2z6y@nC*$6nSIL&CVWo%_#pPk2)y$P_5Q zrV8*oQO?j_1=TAJTfkBC<1GQR)1RRS&2)a(T;SUFL_ctr)Jo>KYu*WskOP}Od*$>v Na{9=az=vP6`3v)^5Y+$x diff --git a/ide/w32manifest.pas b/ide/w32manifest.pas index b9b4cee69a..4813be3085 100644 --- a/ide/w32manifest.pas +++ b/ide/w32manifest.pas @@ -45,14 +45,14 @@ type FMessages: TStrings; FModified: boolean; FUseManifest: boolean; - resFilename: string; + rcFilename: string; procedure SetUseManifest(const AValue: boolean); procedure SetFileNames(const MainFilename: string); public constructor Create; destructor Destroy; override; - function CompileRCFile(const MainFilename, TargetOS: string): TModalResult; + function CreateRCFile(const MainFilename, TargetOS: string): TModalResult; function CreateManifest: Boolean; function UpdateMainSourceFile(const AFilename: string): TModalResult; @@ -63,13 +63,39 @@ type implementation +const + sManifest: String = + '#define RT_MANIFEST 24'#$D#$A+ + '#define CREATEPROCESS_MANIFEST_RESOURCE_ID 1'#$D#$A+ + '#define ISOLATIONAWARE_MANIFEST_RESOURCE_ID 2'#$D#$A+ + '#define ISOLATIONAWARE_NOSTATICIMPORT_MANIFEST_RESOURCE_ID 3'#$D#$A#$D#$A+ + 'CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST MOVEABLE PURE'#$D#$A+ + '{'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' "Your application description here."'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + ' ""'#$D#$A+ + '}'; + {----------------------------------------------------------------------------- - TProjectXPManifest CompileRCFile + TProjectXPManifest CreateRCFile -----------------------------------------------------------------------------} -function TProjectXPManifest.CompileRCFile(const MainFilename, TargetOS: string): TModalResult; +function TProjectXPManifest.CreateRCFile(const MainFilename, TargetOS: string): TModalResult; begin // in future we will compile manifest from rc, but now we just add our template - Result := mrOk; SetFileNames(MainFilename); if (TargetOS = 'win32') and UseManifest then @@ -81,31 +107,15 @@ end; function TProjectXPManifest.CreateManifest: Boolean; var - Res: TLResource; Stream: TStream; begin - // here will be better to compile res from rc, but we will only extract - // precompiled res from lazarus resource due to error in windres. - - // Error description: - // if we compile manifest by windres then we will not link our project if we - // have other res files before manifest (I tested with version info resource) - // But if we compile that manifest.rc with other resource compiler then we have - // not such errors. So at this moment we decided to extract precompiled res insted - // of have problems with rc compilation and further linking - Result := False; - Res := LazarusResources.Find('manifest'); - if (Res <> nil) and (Res.Value <> '') and (Res.ValueType = 'RES') then - begin - Stream := nil; - try - Stream := TFileStream.Create(resFileName, fmCreate); - Stream.Write(Res.Value[1], length(Res.Value)); - Result := True; - finally - Stream.Free; - end; + try + Stream := TFileStream.Create(rcFileName, fmCreate); + Stream.Write(sManifest[1], length(sManifest)); + Result := True; + finally + Stream.Free; end; end; @@ -130,7 +140,7 @@ begin if ManifestCodeBuf <> nil then begin SetFileNames(AFilename); - Filename:=ExtractFileName(resFileName); + Filename:=ExtractFileName(rcFileName); DebugLn(['TProjectXPManifest.UpdateMainSourceFile ',Filename]); if CodeToolBoss.FindResourceDirective(ManifestCodeBuf, 1, 1, NewCode, NewX, NewY, @@ -163,7 +173,7 @@ end; -----------------------------------------------------------------------------} procedure TProjectXPManifest.SetFileNames(const MainFilename: string); begin - resFilename := ExtractFilePath(MainFilename) + 'manifest.res'; + rcFilename := ExtractFilePath(MainFilename) + 'manifest.rc'; end; constructor TProjectXPManifest.Create; @@ -177,7 +187,5 @@ begin inherited Destroy; end; -initialization - {$i manifest.lrs} end. diff --git a/ide/w32versioninfo.pas b/ide/w32versioninfo.pas index 3220451f5f..7418db4e0a 100644 --- a/ide/w32versioninfo.pas +++ b/ide/w32versioninfo.pas @@ -65,7 +65,6 @@ type FUseVersionInfo: boolean; FVersionNr: integer; rcFilename: string; - resFilename: string; rcInFile: text; rcOutFile: text; rcLine: string; @@ -79,7 +78,6 @@ type procedure RewriteAndSkipRCFile; procedure AppendToRCFile; procedure RewriteRCFile; - function DoTheRealCompile: TModalResult; procedure SetAutoIncrementBuild(const AValue: boolean); procedure SetBuildNr(const AValue: integer); procedure SetCommentsString(const AValue: string); @@ -102,7 +100,7 @@ type public constructor Create; destructor Destroy; override; - function CompileRCFile(const MainFilename, TargetOS: string): TModalResult; + function CreateRCFile(const MainFilename, TargetOS: string): TModalResult; function UpdateMainSourceFile(const AFilename: string): TModalResult; property Modified: boolean read FModified write SetModified; @@ -310,70 +308,49 @@ begin end; {----------------------------------------------------------------------------- - TProjectVersionInfo CompileRCFile + TProjectVersionInfo CreateRCFile -----------------------------------------------------------------------------} -function TProjectVersionInfo.CompileRCFile(const MainFilename, TargetOS: string +function TProjectVersionInfo.CreateRCFile(const MainFilename, TargetOS: string ): TModalResult; begin - Result := mrCancel; - SetFileNames(MainFilename); - if (TargetOS = 'win32') then + Result := mrCancel; + SetFileNames(MainFilename); + if (TargetOS = 'win32') then + begin + // we are building a win32 application + if UseVersionInfo then + begin + // project indicates to use the versioninfo + if AutoIncrementBuild then // project indicate to use autoincrementbuild + BuildNr := BuildNr + 1; + if ProductVersionString = '' then + ProductVersionString := IntToStr(VersionNr) + '.' + + IntToStr(MajorRevNr) + '.' + + IntToStr(MinorRevNr) + '.' + + IntToStr(BuildNr); + if (FileExists(rcFilename)) then // we found an existing .rc file + RewriteRCFile + else begin - { we are building a win32 application } - if UseVersionInfo then - begin - { project indicates to use the versioninfo } - if AutoIncrementBuild then - begin - { project indicate to use autoincrementbuild } - BuildNr := BuildNr + 1; - end; - if ProductVersionString = '' then - ProductVersionString := IntToStr(VersionNr) + '.' + - IntToStr(MajorRevNr) + '.' + - IntToStr(MinorRevNr) + '.' + - IntToStr(BuildNr); - if (FileExists(rcFilename)) then - begin - { we found an existing .rc file } - RewriteRCFile; - end - else - begin - { there is no .rc file } - AssignFile(rcOutFile, rcFilename); - Rewrite(rcOutFile); - AppendToRCFile; - CloseFile(rcOutFile); - end; - { now it's time to do the real compile } - Result := DoTheRealCompile; - if (Result = mrOk) then - begin - { compilation succeeded } - VersionInfoMessages.Clear; - VersionInfoMessages.Add('Resource file ' + rcFilename + - ' has been compiled successfully!'); - end - else - begin - { compilation failed } - VersionInfoMessages.Add('Errors found while compiling ' + - rcFilename); - end; - end - else - begin - { project indicates to not use the versioninfo } - Result := mrOk; - end; - end - else - begin - { on systems other then win32, there is nothing to do, just return - with Result = mrOk } - Result := mrOk; + // there is no .rc file + AssignFile(rcOutFile, rcFilename); + Rewrite(rcOutFile); + AppendToRCFile; + CloseFile(rcOutFile); end; + Result := mrOk; + end + else + begin + // project indicates to not use the versioninfo + Result := mrOk; + end; + end + else + begin + // on systems other then win32, there is nothing to do, just return with Result = mrOk + Result := mrOk; + end; end; {----------------------------------------------------------------------------- @@ -472,64 +449,64 @@ end; -----------------------------------------------------------------------------} procedure TProjectVersionInfo.AppendToRCFile; begin - rcLine := '1 VERSIONINFO'; - WriteLn(rcoutFile, rcLine); - rcLine := 'FILEVERSION ' + IntToStr(VersionNr) + ',' + - IntToStr(MajorRevNr) + ',' + - IntToStr(MinorRevNr) + ',' + - IntToStr(BuildNr); - WriteLn(rcoutFile, rcLine); - rcLine := 'PRODUCTVERSION ' + StringReplace(ProductVersionString, '.', ',', [rfReplaceAll]); - WriteLn(rcoutFile, rcLine); - rcLine := '{'; - WriteLn(rcoutFile, rcLine); - rcLine := ' BLOCK "StringFileInfo"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' {'; - WriteLn(rcoutFile, rcLine); - rcLine := ' BLOCK "' + HexLang + HexCharSet + '"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' {'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "Comments", "' + CommentsString + '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "CompanyName", "' + CompanyString + '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "FileDescription", "' + DescriptionString + '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "FileVersion", "' + IntToStr(VersionNr) + '.' + - IntToStr(MajorRevNr) + '.' + - IntToStr(MinorRevNr) + '.' + - IntToStr(BuildNr) + '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "InternalName", "' + InternalNameString + '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "LegalCopyright", "' + CopyrightString + '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "LegalTrademarks", "' + TrademarksString + '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "OriginalFilename", "' + OriginalFilenameString + '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "ProductName", "' + ProdNameString + '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "ProductVersion", "' + - StringReplace(ProductVersionString, ',', '.', [rfReplaceAll]) + - '\000"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' }'; - WriteLn(rcoutFile, rcLine); - rcLine := ' }'; - WriteLn(rcoutFile, rcLine); - rcLine := ' BLOCK "VarFileInfo"'; - WriteLn(rcoutFile, rcLine); - rcLine := ' {'; - WriteLn(rcoutFile, rcLine); - rcLine := ' VALUE "Translation", 0x' + HexLang + ', 0x' + HexCharSet; - WriteLn(rcoutFile, rcLine); - rcLine := ' }'; - WriteLn(rcoutFile, rcLine); - rcLine := '}'; - WriteLn(rcoutFile, rcLine); + rcLine := '1 VERSIONINFO'; + WriteLn(rcoutFile, rcLine); + rcLine := 'FILEVERSION ' + IntToStr(VersionNr) + ',' + + IntToStr(MajorRevNr) + ',' + + IntToStr(MinorRevNr) + ',' + + IntToStr(BuildNr); + WriteLn(rcoutFile, rcLine); + rcLine := 'PRODUCTVERSION ' + StringReplace(ProductVersionString, '.', ',', [rfReplaceAll]); + WriteLn(rcoutFile, rcLine); + rcLine := '{'; + WriteLn(rcoutFile, rcLine); + rcLine := ' BLOCK "StringFileInfo"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' {'; + WriteLn(rcoutFile, rcLine); + rcLine := ' BLOCK "' + HexLang + HexCharSet + '"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' {'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "Comments", "' + CommentsString + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "CompanyName", "' + CompanyString + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "FileDescription", "' + DescriptionString + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "FileVersion", "' + IntToStr(VersionNr) + '.' + + IntToStr(MajorRevNr) + '.' + + IntToStr(MinorRevNr) + '.' + + IntToStr(BuildNr) + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "InternalName", "' + InternalNameString + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "LegalCopyright", "' + CopyrightString + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "LegalTrademarks", "' + TrademarksString + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "OriginalFilename", "' + OriginalFilenameString + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "ProductName", "' + ProdNameString + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "ProductVersion", "' + + StringReplace(ProductVersionString, ',', '.', [rfReplaceAll]) + + '\000"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' }'; + WriteLn(rcoutFile, rcLine); + rcLine := ' }'; + WriteLn(rcoutFile, rcLine); + rcLine := ' BLOCK "VarFileInfo"'; + WriteLn(rcoutFile, rcLine); + rcLine := ' {'; + WriteLn(rcoutFile, rcLine); + rcLine := ' VALUE "Translation", 0x' + HexLang + ', 0x' + HexCharSet; + WriteLn(rcoutFile, rcLine); + rcLine := ' }'; + WriteLn(rcoutFile, rcLine); + rcLine := '}'; + WriteLn(rcoutFile, rcLine); end; {----------------------------------------------------------------------------- @@ -611,58 +588,6 @@ begin end; end; -{----------------------------------------------------------------------------- - TProjectVersionInfo DoTheRealCompile ------------------------------------------------------------------------------} -function TProjectVersionInfo.DoTheRealCompile: TModalResult; -const READ_BYTES = 2048; -var rcProcess: TProcess; - rcMemStream: TMemoryStream; - rcStringList: TStringList; - BytesRead: longint; - n: longint; -begin - Result := mrCancel; - rcMemStream := TMemoryStream.Create; - BytesRead := 0; - try - rcProcess := TProcess.Create(nil); - rcProcess.CommandLine := 'windres -v ' + rcFilename + ' ' + resFilename; - rcProcess.ShowWindow := swoHIDE; - rcProcess.Options := [poUsePipes, poStdErrToOutput]; - rcProcess.Execute; - while rcProcess.Running do - begin - rcMemStream.SetSize(BytesRead + READ_BYTES); - n := rcProcess.OutPut.Read((rcMemStream.Memory + BytesRead)^, READ_BYTES); - if n > 0 then - begin - inc(BytesRead, n); - end - else - begin - sleep(100); - end; - end; - repeat - rcMemStream.SetSize(BytesRead + READ_BYTES); - n := rcProcess.Output.Read((rcMemStream.Memory + BytesRead)^, READ_BYTES); - if n > 0 then - begin - inc(BytesRead, n); - end; - until n <= 0; - finally - if rcProcess.ExitStatus = 0 then Result := mrOk; - rcProcess.Free; - end; - rcMemStream.SetSize(BytesRead); - rcStringList := TStringList.Create; - rcStringList.LoadFromStream(rcMemStream); - for n := 1 to rcStringList.Count do - VersionInfoMessages.Add(rcStringList[n - 1]); -end; - procedure TProjectVersionInfo.SetAutoIncrementBuild(const AValue: boolean); begin if FAutoIncrementBuild=AValue then exit; @@ -807,7 +732,7 @@ begin VersionInfoCodeBuf:=CodeToolBoss.LoadFile(AFilename,false,false); if VersionInfoCodeBuf=nil then exit; SetFileNames(AFilename); - Filename:=ExtractFileName(resFilename); + Filename:=ExtractFileName(rcFilename); //DebugLn(['TProjectVersionInfo.UpdateMainSourceFile ',Filename,' UseVersionInfo=',UseVersionInfo]); if CodeToolBoss.FindResourceDirective(VersionInfoCodeBuf,1,1, NewCode,NewX,NewY, @@ -843,8 +768,7 @@ end; -----------------------------------------------------------------------------} procedure TProjectVersionInfo.SetFileNames(const MainFilename: string); begin - rcFilename := Copy(MainFilename, 1, Length(MainFilename) - 4) + '.rc'; - resFilename := Copy(MainFilename, 1, Length(MainFilename) - 4) + '.res'; + rcFilename := Copy(MainFilename, 1, Length(MainFilename) - 4) + '.rc'; end; finalization