summaryrefslogtreecommitdiff
path: root/refreshexecutableunit.pas
diff options
context:
space:
mode:
Diffstat (limited to 'refreshexecutableunit.pas')
-rw-r--r--refreshexecutableunit.pas74
1 files changed, 59 insertions, 15 deletions
diff --git a/refreshexecutableunit.pas b/refreshexecutableunit.pas
index 50da0a7..1984738 100644
--- a/refreshexecutableunit.pas
+++ b/refreshexecutableunit.pas
@@ -5,23 +5,46 @@ unit refreshexecutableunit;
interface
uses
- Classes, SysUtils;
+ Classes, SysUtils, lowlevelunit;
-procedure refreshExecutable(myDir: string);
+procedure refreshExecutable(dirs: tStringArray); // dirs[0] = Verzeichnis des Hauptprogramms, dirs[1] = Verzeichnis dieser Unit
+function sourceSha512Sum(dir: string): string;
+function binarySha512Sum(index: longint): string; inline;
implementation
-uses baseunix, systemunit, process, lowLevelUnit;
+uses baseunix, systemunit, process;
-procedure refreshExecutable(myDir: string);
+{$INCLUDE refreshexecutableunit_sums.inc}
+
+procedure refreshExecutable(dirs: tStringArray);
var
tmpDir,output,summeEins: string;
- args: array of string;
+ args: tStringArray;
+ i: longint;
+ f: textfile;
begin
output:='';
+
+ fileMode:=fmOpenWrite;
+
+ assignfile(f,dirs[1]+'refreshexecutableunit_sums.inc');
+ rewrite(f);
+ writeln(f,'const');
+ writeln(f,' sha512sums: array[0..1] of string = (');
+ for i:=0 to length(dirs)-1 do begin
+ write(f,' '''+sourceSha512Sum(dirs[i])+'''');
+ if i=length(dirs)-1 then
+ writeln(f)
+ else
+ writeln(f,',');
+ end;
+ writeln(f,' );');
+ closefile(f);
+
tmpDir:=mkTemp('-d /tmp/fpc.XXXXXX');
mkdir(tmpDir+'/lib');
- setlength(args,15);
+ setlength(args,13+length(dirs));
args[0]:='-MObjFPC';
args[1]:='-Scghi';
args[2]:='-Cg';
@@ -32,16 +55,17 @@ begin
args[7]:='-l';
args[8]:='-vewnhibq';
args[9]:='-Fi'+tmpDir+'/lib';
- args[10]:='-Fu../units';
- args[11]:='-Fu.';
- args[12]:='-FU'+tmpDir+'/lib';
- args[13]:=myDir+extractFileName(paramstr(0));
- if fileexists(args[13]+'.lpr') then
- args[13]:=args[13]+'.lpr'
+ args[10]:='-FU'+tmpDir+'/lib';
+ args[11]:=dirs[0]+extractFileName(paramstr(0));
+ if fileexists(args[11]+'.lpr') then
+ args[11]:=args[11]+'.lpr'
else
- args[13]:=args[13]+'.pas';
- args[14]:='-o'+tmpDir+'/output';
- if runCommandInDir(myDir,'fpc',args,output) then begin
+ args[11]:=args[11]+'.pas';
+ args[12]:='-o'+tmpDir+'/output';
+ for i:=0 to length(dirs)-1 do
+ args[13+i]:='-Fu'+dirs[i];
+
+ if runCommandInDir(dirs[0],'fpc',args,output) then begin
setlength(args,2);
args[0]:=tmpDir+'/output';
args[1]:=paramstr(0);
@@ -70,5 +94,25 @@ begin
setlength(args,0);
end;
+function sourceSha512Sum(dir: string): string;
+var
+ args: tStringArray;
+begin
+ result:='';
+ setlength(args,3);
+ args[0]:='describe';
+ args[1]:='--always';
+ args[2]:='--abbrev=0';
+ if runCommandInDir(dir,'git',args,result) then
+ result:=trim(result)
+ else
+ result:='ungültig';
+end;
+
+function binarySha512Sum(index: longint): string;
+begin
+ result:=sha512sums[index];
+end;
+
end.