Skip to content

Commit

Permalink
Tools to add version configuration information (based on git-describe)
Browse files Browse the repository at this point in the history
to HLL::Compiler objects.
  • Loading branch information
pmichaud committed May 31, 2011
1 parent 8dd1944 commit 3599a33
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
1 change: 1 addition & 0 deletions VERSION
@@ -0,0 +1 @@
2011.05
1 change: 1 addition & 0 deletions src/NQP/Compiler.pm
Expand Up @@ -7,6 +7,7 @@ sub MAIN(@ARGS) {
$nqpcomp.language('nqp');
$nqpcomp.parsegrammar(NQP::Grammar);
$nqpcomp.parseactions(NQP::Actions);
hll-config($nqpcomp.config);

# Add extra command line options.
my @clo := $nqpcomp.commandline_options();
Expand Down
6 changes: 4 additions & 2 deletions tools/build/Makefile.in
Expand Up @@ -300,7 +300,8 @@ $(STAGE1)/$(P6REGEX_PBC): $(STAGE0_PBCS) $(STAGE1)/$(HLL_PBC) $(STAGE1)/$(CORE_S

$(STAGE1)/$(NQP_PBC): $(STAGE0_PBCS) $(STAGE1)/$(P6REGEX_PBC) $(STAGE1)/$(CORE_SETTING_PBC) $(NQP_SOURCES)
$(MKPATH) $(STAGE1)/gen
$(PERL) tools/build/gen-cat.pl $(NQP_SOURCES) > $(STAGE1)/$(NQP_COMBINED)
$(PERL) tools/build/gen-version.pl >src/gen/nqp-config.pm
$(PERL) tools/build/gen-cat.pl $(NQP_SOURCES) src/gen/nqp-config.pm > $(STAGE1)/$(NQP_COMBINED)
$(PARROT) --library=$(STAGE0) $(STAGE0)/$(NQP_PBC) \
--target=pir --output=$(STAGE1)/$(NQP_COMBINED_PIR) \
--module-path=$(STAGE1) --setting-path=$(STAGE1) $(STAGE1)/$(NQP_COMBINED)
Expand Down Expand Up @@ -356,7 +357,8 @@ $(STAGE2)/$(P6REGEX_PBC): $(STAGE1_PBCS) $(STAGE2)/$(HLL_PBC) $(P6REGEX_SOURCES)

$(STAGE2)/$(NQP_PBC): $(STAGE0_PBCS) $(STAGE2)/$(P6REGEX_PBC) $(NQP_SOURCES)
$(MKPATH) $(STAGE1)/gen
$(PERL) tools/build/gen-cat.pl $(NQP_SOURCES) > $(STAGE2)/$(NQP_COMBINED)
$(PERL) tools/build/gen-version.pl >src/gen/nqp-config.pm
$(PERL) tools/build/gen-cat.pl $(NQP_SOURCES) src/gen/nqp-config.pm > $(STAGE2)/$(NQP_COMBINED)
$(PARROT) --library=$(STAGE1) $(STAGE1)/$(NQP_PBC) \
--target=pir --output=$(STAGE2)/$(NQP_COMBINED_PIR) \
--module-path=$(STAGE2) --setting-path=$(STAGE2) $(STAGE2)/$(NQP_COMBINED)
Expand Down
32 changes: 32 additions & 0 deletions tools/build/gen-version.pl
@@ -0,0 +1,32 @@
#! perl

=head1 TITLE
gen-version.l -- script to generate version information for HLL compilers
=cut

use POSIX 'strftime';

open(my $fh, '<', 'VERSION') or die $!;
my $VERSION = <$fh>;
close($fh);

if (-d '.git' && open(my $GIT, '-|', "git describe --tags")) {
$VERSION = <$GIT>;
close($GIT);
}

chomp $VERSION;

my $builddate = strftime('%Y-%m-%dT%H:%M:%SZ', gmtime);

print <<"END_VERSION";
sub hll-config(\$config) {
\$config<version> := '$VERSION';
\$config<build-date> := '$builddate';
}
END_VERSION

0;

0 comments on commit 3599a33

Please sign in to comment.