eliminate .patchnum and related infrastrcuture from *nix based build process
authorYves Orton <demerphq@gmail.com>
Sun, 4 Jan 2009 15:48:27 +0000 (16:48 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sat, 11 Apr 2009 15:42:49 +0000 (16:42 +0100)
Rename the old "unpushed.h" to "git_version.h" and make it hold the defines that used to come from cflags magic

(cherry picked from commit dcff826f70bf3f64ced085d87d733c26aacda219)

.gitignore
MANIFEST
Makefile.SH
cflags.SH
make_patchnum.sh
patchlevel.h

index 362fc7a..0c34456 100644 (file)
@@ -3,9 +3,8 @@
 # ignore local .config files
 .config
 # these are generated by make_patchnum.sh from git or from a .patchfile
-.patchnum
 .sha1
-unpushed.h
+git_version.h
 
 # ignore bug*.pl
 bug*.pl
index 835abd1..e90a38e 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -3164,8 +3164,9 @@ 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
-make_patchnum.sh               Script to generate .patchnum file
+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)
 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
index 32e98e0..4225c9e 100644 (file)
@@ -525,7 +525,7 @@ splintfiles = $(c1)
 .c.s:
        $(CCCMDSRC) -S $*.c
 
-all: $(FIRSTMAKEFILE) make_patchnum miniperl$(EXE_EXT) extra.pods $(private) $(unidatafiles) $(public) $(dynamic_ext) $(nonxs_ext) extras.make
+all: $(FIRSTMAKEFILE) make_patchnum 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."
 
@@ -543,8 +543,11 @@ sperl.i: perl.c $(h)
 make_patchnum:
        sh $(shellflags) make_patchnum.sh
 
-# make sure that we recompile perl.c if .patchnum changes
-perl$(OBJ_EXT): .patchnum unpushed.h
+git_version.h:
+       sh $(shellflags) make_patchnum.sh
+
+# make sure that we recompile perl.c if the git version changes
+perl$(OBJ_EXT): git_version.h
 
 translators:   miniperl$(EXE_EXT) $(CONFIGPM) FORCE
        @echo " "; echo "       Making x2p stuff"; cd x2p; $(LDLIBPTH) $(MAKE) all
@@ -1222,9 +1225,8 @@ _tidy:
        -cd pod; $(LDLIBPTH) $(MAKE) clean
        -cd utils; $(LDLIBPTH) $(MAKE) clean
        -cd x2p; $(LDLIBPTH) $(MAKE) clean
-       -rm .patchnum
        -rm lib/Config_git.pl
-       -rm unpushed.h
+       -rm git_version.h
        -@for x in $(DYNALOADER) $(dynamic_ext) $(static_ext) $(nonxs_ext) ; do \
        $(LDLIBPTH) sh ext/util/make_ext clean $$x MAKE=$(MAKE) ; \
        done
index 80b50b1..ef1c8b5 100755 (executable)
--- a/cflags.SH
+++ b/cflags.SH
@@ -213,6 +213,8 @@ warn="$warn"
 stdflags="$stdflags"
 # Extra extra.
 extra="$extra"
+# what do executables look like?
+_exe="$_exe"
 
 !GROK!THIS!
 
@@ -296,14 +298,7 @@ for file do
     op) ;;
     opmini) ;;
     pad) ;;
-    perl) 
-        if [ -f .patchnum -a -n "`awk 'BEGIN{ORS=""} /describe:/ {print $1}' .patchnum`" ] ; then
-                ccflags="-DPERL_PATCHNUM=`awk 'BEGIN{ORS=""} /describe:/ {print $2}' .patchnum` $ccflags"
-        fi
-       if [ -f .patchnum -a -n "`awk 'BEGIN{ORS=""} /status:/ {print $2}' .patchnum`" ] ; then
-                ccflags="-DPERL_GIT_UNCOMMITTED_CHANGES=`awk 'BEGIN{ORS=""} /status:/ {print $2}' .patchnum` $ccflags"
-       fi
-        ;;
+    perl) ;;
     perlapi) ;;
     perlmain) ;;
     perly) ;;
index 2d3f093..9a8982f 100644 (file)
@@ -8,34 +8,40 @@
 #   lib/Config_git.pl # holds some special configure settings related to git
 #   unpushed.h        # header file used by patchlevel.h to store unpushed commits
 
-existing_patchnum=`cat .patchnum 2>/dev/null`
-existing_config=`cat lib/Config_git.pl 2>/dev/null`
-existing_unpushed=`cat unpushed.h 2>/dev/null`
+config_file="lib/Config_git.pl"
+header_file="git_version.h"
+patch_file=".patch"
+
+git_dir=`git rev-parse --git-dir 2>/dev/null`
+existing_config=`cat $config_file 2>/dev/null`
+existing_header=`cat $header_file 2>/dev/null`
 
 unpushed_commits='/*no-op*/'
-if [ -s ".patch" ] ; then
+if [ -s $patch_file ] ; then
        # this is the minimal expectation for the 
        read branch snapshot_created commit_id describe < .patch
        changed=""
        extra_info="git_snapshot_date='$snapshot_created'"
        commit_title='Snapshot of:'
-elif [ -d ".git" ]; then
-       branch=`git branch | awk 'BEGIN{ORS=""} /\*/ { print $2 }'`
+elif [ -n "$git_dir" ]; then
+       branch=`git branch | awk 'BEGIN{ORS=""} /^\* [^(]/ { print $2 }'`
        test -n "$branch" && remote=`git config branch.$branch.remote`
+       test -n "$branch" && merge=`git config branch.$branch.merge | sed s,refs/heads/,,`
        commit_id=`git rev-parse HEAD`
        changed=`git diff-index --name-only HEAD`
        describe=`git describe --tags`
        commit_created=`git log -1 --pretty='format:%ci'`
        extra_info="git_commit_date='$commit_created'"
-       if [ -n "$branch" ] && [ -n "$remote" ]; then
-               unpushed_commit_list=`git cherry $remote/$branch | awk 'BEGIN{ORS=","} /\+/ {print $2}' | sed -e 's/,$//'`
-               unpushed_commits=`git cherry $remote/$branch | awk 'BEGIN{ORS="\t\\\\\n"} /\+/ {print ",\"" $2 "\""}'`
+       if [ -n "$merge" ] && [ -n "$remote" ]; then
+               unpushed_commit_list=`git cherry $remote/$merge | awk 'BEGIN{ORS=","} /\+/ {print $2}' | sed -e 's/,$//'`
+               unpushed_commits=`git cherry $remote/$merge | awk 'BEGIN{ORS="\t\\\\\n"} /\+/ {print ",\"" $2 "\""}'`
 
                if [ -n "$unpushed_commits" ]; then
                        commit_title="Local Commit:"
-                       ancestor=`git rev-parse $remote/$branch`
+                       ancestor=`git rev-parse $remote/$merge`
                        extra_info="$extra_info
 git_ancestor='$ancestor'
+git_remote_branch='$remote/$merge'
 git_unpushed='$unpushed_commit_list'"
                fi
                        
@@ -52,29 +58,31 @@ SNDOGS
 fi
 
 # Set up defaults for various values
-new_patchnum="describe: $describe"
 if [ -n "$changed" ]; then
        changed="true"
        commit_title="Derived from:"
-       new_patchnum="$new_patchnum
-status: uncommitted-changes"
+       status="#define PERL_GIT_UNCOMMITTED_CHANGES uncommitted-changes"
+else
+       status="/* clean working directory */"
 fi
 test -z "$commit_title" && commit_title='Commit id:'
 
-new_unpushed=`cat <<EOFTEXT
-/*********************************************************************
-* WARNING: unpushed.h is automatically generated by make_patchnum.sh *
-*          DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead      *
-*********************************************************************/
+new_header=`cat <<EOFTEXT
+/***************************************************************************
+* WARNING: $header_file is automatically generated by make_patchnum.sh 
+*          DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead      
+****************************************************************************/
+#define PERL_PATCHNUM $describe
+$status
 #define PERL_GIT_UNPUSHED_COMMITS       $unpushed_commits
 /*leave-this-comment*/
 EOFTEXT
 `
 new_config=`cat <<EOFDATA
-#################################################################
-# WARNING: lib/Config_git.pl is generated by make_patchnum.sh   #
-#          DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead #
-#################################################################
+#######################################################################
+# WARNING: $config_file is generated by make_patchnum.sh   
+#          DO NOT EDIT DIRECTLY - edit make_patchnum.sh instead 
+#######################################################################
 \\$Config::Git_Data=<<'ENDOFGIT';
 git_commit_id='$commit_id'
 git_describe='$describe'
@@ -86,12 +94,11 @@ ENDOFGIT
 EOFDATA
 `
 # only update the files if necessary, other build product depends on these files
-if [ "$existing_patchnum" != "$new_patchnum" ] || [ "$new_config" != "$existing_config" ] || [ "$existing_unpushed" != "$new_unpushed" ]; then
-       echo "Updating .patchnum and lib/Config_git.pl"
-       echo "$new_patchnum" > .patchnum
-       echo "$new_config" > lib/Config_git.pl
-       echo "$new_unpushed" > unpushed.h
+if [ "$new_config" != "$existing_config" ] || [ "$existing_header" != "$new_header" ]; then
+       echo "Updating $header_file and $config_file"
+       echo "$new_config" > $config_file
+       echo "$new_header" > $header_file
 else
-       echo "Reusing .patchnum and lib/Config_git.pl"
+       echo "Reusing $header_file and $config_file"
 fi
 
index 805320d..771f0e3 100644 (file)
@@ -116,7 +116,7 @@ hunk.
  */
 
 #if !defined(PERL_PATCHLEVEL_H_IMPLICIT) && !defined(LOCAL_PATCH_COUNT)
-#include "unpushed.h"
+#include "git_version.h"
 #if !defined(PERL_GIT_UNPUSHED_COMMITS)
 #define PERL_GIT_UNPUSHED_COMMITS_PATCH /* no-op */
 #else