Skip to content

Commit

Permalink
eliminate make_patchnum.sh, and make the build process use make_patch…
Browse files Browse the repository at this point in the history
…num.pl instead
  • Loading branch information
demerphq committed Jan 4, 2009
1 parent 12d7e04 commit eb5c076
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 177 deletions.
5 changes: 2 additions & 3 deletions MANIFEST
Expand Up @@ -3170,9 +3170,8 @@ makedepend.SH Precursor to makedepend
makedir.SH Precursor to makedir
Makefile.micro microperl Makefile
Makefile.SH A script that generates Makefile
make_patchnum.com DCL script to generate .patchnum file on VMS (should be rewritten to create git_version.h)
make_patchnum.sh Script to generate git_version.h and lib/Config_git.pl files
make_patchnum.pl Script to generate git_Version.h and lib/Config_git.pl files for all OS'es (experimental)
make_patchnum.com DCL script to generate .patchnum file on VMS (should be replaced by make_patchnum.pl)
make_patchnum.pl Script to generate git_Version.h and lib/Config_git.pl files for all OS'es
malloc.c A version of malloc you might not want
malloc_ctl.h A version of malloc you might not want
MANIFEST This list of files
Expand Down
9 changes: 4 additions & 5 deletions Makefile.SH
Expand Up @@ -406,7 +406,7 @@ esac
## In the following dollars and backticks do not need the extra backslash.
$spitshell >>$Makefile <<'!NO!SUBS!'
private = preplibrary $(CONFIGPM) $(CONFIGPOD) lib/ExtUtils/Miniperl.pm
private = preplibrary $(CONFIGPM) $(CONFIGPOD) make_patchnum lib/ExtUtils/Miniperl.pm
# Files to be built with variable substitution before miniperl
# is available.
Expand Down Expand Up @@ -525,7 +525,7 @@ splintfiles = $(c1)
.c.s:
$(CCCMDSRC) -S $*.c
all: $(FIRSTMAKEFILE) miniperl$(EXE_EXT) miniperl make_patchnum extra.pods $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
all: $(FIRSTMAKEFILE) miniperl$(EXE_EXT) miniperl extra.pods $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
@echo " ";
@echo " Everything is up to date. Type '$(MAKE) test' to run test suite."
Expand All @@ -541,8 +541,7 @@ sperl.i: perl.c $(h)
.PHONY: all translators utilities make_patchnum
make_patchnum:
sh $(shellflags) make_patchnum.sh || $(MAKE) miniperl
$(LDLIBPTH) $(RUN) ./miniperl -Ilib make_patchnum.pl || $(MAKE) miniperl
git_version.h: stock_git_version.h
cp stock_git_version.h git_version.h
Expand Down Expand Up @@ -1333,7 +1332,7 @@ _test_prep: unpack_files
test_prep_pre: preplibrary utilities $(nonxs_ext)
test_prep: make_patchnum test_prep_pre miniperl$(EXE_EXT) $(unidatafiles) perl$(EXE_EXT) $(dynamic_ext) $(TEST_PERL_DLL)
test_prep: test_prep_pre miniperl$(EXE_EXT) $(unidatafiles) perl$(EXE_EXT) $(dynamic_ext) $(TEST_PERL_DLL)
PERL=./perl $(MAKE) _test_prep
_test_tty:
Expand Down
110 changes: 59 additions & 51 deletions make_patchnum.pl
Expand Up @@ -60,30 +60,49 @@ sub write_file {

sub backtick {
my $command = shift;
my $result = `$command`;
chomp $result;
return $result;
if (wantarray) {
my @result= `$command`;
chomp @result;
return @result;
} else {
my $result= `$command`;
$result="" if ! defined $result;
chomp $result;
return $result;
}
}

my $existing_patchnum = read_file('.patchnum');
my $existing_config = read_file('lib/Config_git.pl');
my $existing_unpushed = read_file('unpushed.h');
sub write_files {
my %content= map { /WARNING: '([^']+)'/ || die "Bad mojo!"; $1 => $_ } @_;
my @files= sort keys %content;
my $files= join " and ", map { "'$_'" } @files;
foreach my $file (@files) {
if (read_file($file) ne $content{$file}) {
print "Updating $files\n";
write_file($_,$content{$_}) for @files;
return 1;
}
}
print "Reusing $files\n";
return 0;
}

my $unpushed_commits = '/*no-op*/';
my ($read, $branch, $snapshot_created, $commit_id, $describe);
my ($changed, $extra_info, $commit_title, $new_patchnum);
if (my $patch_file= read_file('.patch')) {
($branch, $snapshot_created, $commit_id, $describe) = split /\s+/, $patchfile;
my ($read, $branch, $snapshot_created, $commit_id, $describe)= ("") x 5;
my ($changed, $extra_info, $commit_title, $new_patchnum, $status)= ("") x 5;
if (my $patch_file= read_file(".patch")) {
($branch, $snapshot_created, $commit_id, $describe) = split /\s+/, $patch_file;
$extra_info = "git_snapshot_date='$snapshot_created'";
$commit_title = "Snapshot of:";
}
elsif (-d path_to('.git')) {
# git branch | awk 'BEGIN{ORS=""} /\*/ { print $2 }'
$branch = join "", map { (split /\s/, $_)[1] }
grep {/\*/} split /\n/, backtick('git branch');
my $remote;
($branch) = map { /\* ([^(]\S*)/ ? $1 : () } backtick('git branch');
my ($remote,$merge);
if (length $branch) {
$remote = backtick("git config branch.$branch.remote");
$merge= backtick("git config branch.$branch.merge");
$merge =~ s!^refs/heads/!!;
$remote= backtick("git config branch.$branch.remote");
}
$commit_id = backtick("git rev-parse HEAD");
$describe = backtick("git describe");
Expand All @@ -94,44 +113,45 @@ sub backtick {
# git cherry $remote/$branch | awk 'BEGIN{ORS=","} /\+/ {print $2}' | sed -e 's/,$//'
my $unpushed_commit_list =
join ",", map { (split /\s/, $_)[1] }
grep {/\+/} split /\n/, backtick("git cherry $remote/$branch");
grep {/\+/} backtick("git cherry $remote/$merge");
# git cherry $remote/$branch | awk 'BEGIN{ORS="\t\\\\\n"} /\+/ {print ",\"" $2 "\""}'
$unpushed_commits =
join "", map { ',"'.(split /\s/, $_)[1].'"'."\t\\\n" }
grep {/\+/} split /\n/, backtick("git cherry $remote/$branch");
join "", map { ',"'.(split /\s/, $_)[1]."\"\t\\\n" }
grep {/\+/} backtick("git cherry $remote/$merge");
if (length $unpushed_commits) {
$commit_title = "Local Commit:";
my $ancestor = backtick("git rev-parse $remote/$branch");
my $ancestor = backtick("git rev-parse $remote/$merge");
$extra_info = "$extra_info
git_ancestor='$ancestor'
git_remote_branch='$remote/$merge'
git_unpushed='$unpushed_commit_list'";
}
}
if (length $changed) {
if ($changed) {
$changed = 'true';
$commit_title = "Derived from:";
$new_patchnum = "$new_patchnum
status: uncommitted-changes";
}
if (not length $commit_title) {
$commit_title = "Commit id:";
$status='"uncommitted-changes"'
} else {
$status='/*clean-working-directory*/'
}
$commit_title ||= "Commit id:";
}

my $new_unpushed =<<"EOFTEXT";
/*********************************************************************
* WARNING: unpushed.h is automatically generated by make_patchnum.pl *
* DO NOT EDIT DIRECTLY - edit make_patchnum.pl instead *
*********************************************************************/
#define PERL_GIT_UNPUSHED_COMMITS $unpushed_commits
/*leave-this-comment*/
EOFTEXT

my $new_config =<<"EOFDATA";
#################################################################
# WARNING: lib/Config_git.pl is generated by make_patchnum.pl #
# DO NOT EDIT DIRECTLY - edit make_patchnum.pl instead #
#################################################################
# we extract the filename out of the warning header, so dont mess with that
exit(write_files(<<"EOF_HEADER", <<"EOF_CONFIG"));
/**************************************************************************
* WARNING: 'git_version.h' is automatically generated by make_patchnum.pl
* DO NOT EDIT DIRECTLY - edit make_patchnum.pl instead
***************************************************************************/
#define PERL_GIT_UNCOMMITTED_CHANGES $status
#define PERL_PATCHNUM "$describe"
#define PERL_GIT_UNPUSHED_COMMITS\t\t\\
$unpushed_commits/*leave-this-comment*/
EOF_HEADER
######################################################################
# WARNING: 'lib/Config_git.pl' is generated by make_patchnum.pl
# DO NOT EDIT DIRECTLY - edit make_patchnum.pl instead
######################################################################
\$Config::Git_Data=<<'ENDOFGIT';
git_commit_id='$commit_id'
git_describe='$describe'
Expand All @@ -140,17 +160,5 @@ sub backtick {
git_commit_id_title='$commit_title'
$extra_info
ENDOFGIT
EOFDATA

# only update the files if necessary, other build product depends on these files
if (( $existing_patchnum ne $new_patchnum ) || ( $existing_config ne $new_config ) || ( $existing_unpushed ne $new_unpushed )) {
print "Updating .patchnum and lib/Config_git.pl\n";
write_file('.patchnum', $new_patchnum);
write_file('lib/Config_git.pl', $new_config);
write_file('unpushed.h', $new_unpushed);
}
else {
print "Reusing .patchnum and lib/Config_git.pl\n"
}

EOF_CONFIG
# ex: set ts=4 sts=4 et ft=perl:
105 changes: 0 additions & 105 deletions make_patchnum.sh

This file was deleted.

14 changes: 2 additions & 12 deletions patchlevel.h
Expand Up @@ -117,20 +117,10 @@ hunk.

#if !defined(PERL_PATCHLEVEL_H_IMPLICIT) && !defined(LOCAL_PATCH_COUNT)
#include "git_version.h"
#if !defined(PERL_GIT_UNPUSHED_COMMITS)
#define PERL_GIT_UNPUSHED_COMMITS_PATCH /* no-op */
#else
#define PERL_GIT_UNPUSHED_COMMITS_PATCH PERL_GIT_UNPUSHED_COMMITS
#endif
#if !defined(PERL_GIT_UNCOMMITTED_CHANGES)
#define PERL_GIT_UNCOMMITTED_CHANGES_PATCH /*no op*/
#else
#define PERL_GIT_UNCOMMITTED_CHANGES_PATCH , STRINGIFY(PERL_GIT_UNCOMMITTED_CHANGES)
#endif
static const char * const local_patches[] = {
NULL
PERL_GIT_UNPUSHED_COMMITS_PATCH /* do not remove this line */
PERL_GIT_UNCOMMITTED_CHANGES_PATCH /* do not remove this line */
PERL_GIT_UNPUSHED_COMMITS /* do not remove this line */
PERL_GIT_UNCOMMITTED_CHANGES /* do not remove this line */
,NULL
};

Expand Down
2 changes: 1 addition & 1 deletion stock_git_version.h
Expand Up @@ -3,5 +3,5 @@
* DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead
****************************************************************************/
#define PERL_PATCHNUM UNKOWN
#define PERL_GIT_UNCOMMITTED_CHANGES UNKNOWN
#define PERL_GIT_UNCOMMITTED_CHANGES ,"UNKNOWN"
#define PERL_GIT_UNPUSHED_COMMITS /*leave-this-comment*/

0 comments on commit eb5c076

Please sign in to comment.