Skip to content
Permalink
Browse files Browse the repository at this point in the history
Look at SOURCE_DATE_EPOCH to support reproducible builds
Based on a patch from Chris Lamb <lamby@debian.org> ,
see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=868790 .
  • Loading branch information
michaliskambi committed Jul 23, 2017
1 parent 2e920b1 commit 35a1983
Showing 1 changed file with 19 additions and 4 deletions.
Expand Up @@ -686,6 +686,24 @@ procedure THelperProcessor.NodeField(const Node: TX3DNodeInformation;
end;
end;

function CopyrightYears: string;
const
YearBegin = '2015-';
var
BuildDate: TDateTime;
SourceDateEpoch: string;
begin
{ Look at SOURCE_DATE_EPOCH to support reproducible builds,
https://wiki.debian.org/ReproducibleBuilds/TimestampsProposal
https://reproducible-builds.org/specs/source-date-epoch/ }
SourceDateEpoch := GetEnvironmentVariable('SOURCE_DATE_EPOCH');
if SourceDateEpoch = '' then
BuildDate := Now
else
BuildDate := UnixToDateTime(StrToInt(SourceDateEpoch));
Result := YearBegin + IntToStr(YearOf(BuildDate));
end;

procedure THelperProcessor.NodeEnd(const Node: TX3DNodeInformation);

procedure GenerateOutput(const OutputInterface, OutputImplementation: string);
Expand All @@ -698,7 +716,7 @@ procedure THelperProcessor.NodeEnd(const Node: TX3DNodeInformation);
StringToFile(OutputFileName,
'{ -*- buffer-read-only: t -*-' + NL +
'' + NL +
' Copyright 2015-' + IntToStr(YearOf(Now)) + ' Michalis Kamburelis.' + NL +
' Copyright ' + CopyrightYears + ' Michalis Kamburelis.' + NL +
'' + NL +
' This file is part of "Castle Game Engine".' + NL +
'' + NL +
Expand Down Expand Up @@ -921,10 +939,7 @@ procedure TTemplateProcessor.NodeEnd(const Node: TX3DNodeInformation);
end;

procedure TTemplateProcessor.ComponentEnd(const ComponentName: string);
var
CopyrightYears: string;
begin
CopyrightYears := IntToStr(YearOf(Now)) + '-' + IntToStr(YearOf(Now));
Writeln(
'{' + NL +
' Copyright ' + CopyrightYears + ' Michalis Kamburelis.' + NL +
Expand Down

0 comments on commit 35a1983

Please sign in to comment.