Rework rule CopySetHaikuRevision

* Remove support for VCSs other than git.
* Make the haiku-revision file a regular build target and make sure it
  is built only once.
* Make determine_haiku_revision an actual shell script and simplify
  it a bit.
This commit is contained in:
Ingo Weinhold
2013-08-26 16:38:50 +02:00
parent ce4f367692
commit a1e681690c
2 changed files with 75 additions and 82 deletions
+33 -21
View File
@@ -328,51 +328,63 @@ rule ObjectReferences
} }
} }
rule CopySetHaikuRevision target : source rule CopySetHaikuRevision target : source
{ {
# CopySetHaikuRevision <target> : <source> # CopySetHaikuRevision <target> : <source>
# #
# Copy <source> to <target>, writing the SVN revision of the working root # Copy <source> to <target>, writing the Git revision of the working
# directory into the haiku revision section of <target>. # directory into the haiku revision section of <target>.
# #
# <target> - Output file target. Gristed and located target. # <target> - Output file target. Gristed and located target.
# <source> - ELF object to be copied. Gristed and located target. # <source> - ELF object to be copied. Gristed and located target.
# If existent, make the target depend on the .svn/entries file in the # If existing, make the target depend on the .git/index file in the
# root directory, so it gets updated when the revision changes due to # root directory, so it gets updated when the revision changes due to
# "svn up". # commits or merges.
if [ Glob [ FDirName $(HAIKU_TOP) .svn ] : entries ] { local gitIndex = <haiku-rootdir-git>index ;
local svnEntries = <haiku-rootdir-svn>entries ; local revisionFile = <haiku-rootdir-git>haiku-revision ;
SEARCH on $(svnEntries) = [ FDirName $(HAIKU_TOP) .svn ] ; if ! [ on $(gitIndex) return $(HAIKU_GIT_REVISION_DETERMINED) ] {
Depends $(target) : $(svnEntries) ; if [ Glob [ FDirName $(HAIKU_TOP) .git ] : index ] {
} else if [ Glob [ FDirName $(HAIKU_TOP) .git ] : index ] { HAIKU_GIT_REVISION_DETERMINED on $(gitIndex) = 1 ;
local gitIndex = <haiku-rootdir-git>index ; SEARCH on $(gitIndex) = [ FDirName $(HAIKU_TOP) .git ] ;
SEARCH on $(gitIndex) = [ FDirName $(HAIKU_TOP) .git ] ; MakeLocate $(revisionFile) : $(HAIKU_BUILD_OUTPUT_DIR) ;
Depends $(target) : $(gitIndex) ; Depends $(revisionFile) : $(gitIndex) ;
} else if [ Glob [ FDirName $(HAIKU_TOP) .hg ] : store ] { DetermineHaikuRevision $(revisionFile) : $(gitIndex) ;
local hgStore = <haiku-rootdir-hg>store ; } else {
SEARCH on $(hgStore) = [ FDirName $(HAIKU_TOP) .hg ] ; revisionFile = ;
Depends $(target) : $(hgStore) ; }
} }
PropagateContainerUpdateTargetFlags $(target) : $(source) ; PropagateContainerUpdateTargetFlags $(target) : $(source) ;
Depends $(target) : <build>copyattr <build>set_haiku_revision $(source) ; Depends $(target)
: <build>copyattr <build>set_haiku_revision $(source) $(revisionFile) ;
CopySetHaikuRevision1 $(target) CopySetHaikuRevision1 $(target)
: <build>copyattr <build>set_haiku_revision $(source) ; : <build>copyattr <build>set_haiku_revision $(source) $(revisionFile) ;
} }
actions CopySetHaikuRevision1 actions CopySetHaikuRevision1
{ {
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
. $(HAIKU_TOP)/build/scripts/determine_haiku_revision $(2[1]) --data $(2[3]) $(1) || exit 1
determineHaikuRevision $(HAIKU_TOP) $(HAIKU_BUILD_OUTPUT_DIR)
$(2[1]) --data $(2[3]) $(1) && revision=0
$(2[2]) $(1) ${revision} if [ -n "$(2[4]:E=)" ]; then
revision="`cat $(2[4]:E=)`"
fi
$(2[2]) $(1) "$revision"
} }
actions DetermineHaikuRevision
{
$(HAIKU_TOP)/build/scripts/determine_haiku_revision $(HAIKU_TOP) $(1)
}
rule DataFileToSourceFile sourceFile : dataFile : dataVariable : sizeVariable rule DataFileToSourceFile sourceFile : dataFile : dataVariable : sizeVariable
{ {
sourceFile = [ FGristFiles $(sourceFile) ] ; sourceFile = [ FGristFiles $(sourceFile) ] ;
+42 -61
View File
@@ -1,70 +1,51 @@
#!/bin/sh #!/bin/sh
determineGitRevision() haikuTop=$1
{ revisionFile=$2
haikuTop=$1 haikuBuildOutputDir=`dirname $revisionFile`
haikuBuildOutputDir=$2 lastBuiltRevisionFile=${haikuBuildOutputDir}/last-built-revision
revision=`cat ${haikuBuildOutputDir}/haiku-revision 2>/dev/null` case `uname` in
lastBuiltRevision=`cat ${haikuBuildOutputDir}/last-built-revision \ Darwin)
2>/dev/null` SED=gsed
localRev=`git rev-parse HEAD` ;;
*)
SED=sed
;;
esac
export SED
# only determine the haiku-revision if anything has changed from revision=`cat ${revisionFile} 2>/dev/null`
# last build lastBuiltRevision=`cat $lastBuiltRevisionFile 2>/dev/null`
if [ -z "$revision" -o "$lastBuiltRevision" != "$localRev" ]; then
# the revision we use is the description of HEAD with respect to the
# last reachable hrev-(haiku-revision-)tag
revision=`git describe --dirty --tags --match=hrev*`
if [ -z "$revision" ]; then
# failed to find any hrev tags, use short hash instead
revision=`git rev-parse --short HEAD`
elif echo "$revision" | grep -- '-' >/dev/null; then
# HEAD is not directly a changeset from Haiku's central repo, so we
# add the current branch name as additional info
branchName=`git branch | grep '*' | cut -b 3-`
revision="$revision [$branchName]"
fi
echo $localRev >${haikuBuildOutputDir}/last-built-revision
fi
}
originalDir=`pwd`
cd ${haikuTop}
export LC_ALL=C
determineHaikuRevision() localRev=`git rev-parse HEAD`
{
haikuTop=$1
haikuBuildOutputDir=$2
case `uname` in # only determine the haiku-revision if anything has changed from
Darwin) # last build
SED=gsed if [ -z "$revision" -o "$lastBuiltRevision" != "$localRev" ]; then
;; # the revision we use is the description of HEAD with respect to the
*) # last reachable hrev-(haiku-revision-)tag
SED=sed revision=`git describe --dirty --tags --match=hrev*`
;;
esac
export SED
originalDir=`pwd`
cd ${haikuTop}
export LC_ALL=C
if [ -d .svn ]; then
revision=`svn info 2>/dev/null | grep Revision | awk '{printf $2}'`
elif [ -d .git/svn ]; then
revision=`git svn info 2>/dev/null | grep Revision | awk '{printf $2}'`
elif [ -d .git ]; then
determineGitRevision $haikuTop $haikuBuildOutputDir
elif [ -d .hg ]; then
# Try searching hg log for last svn commit
# Extract from "(svn r12345) ..." line
revision=`(cd ${haikuTop} &&
hg log --no-merges --template "{desc|firstline}\n") 2> /dev/null |
grep --max-count=1 "(svn r" |
$SED -n -e 's,(svn r\(.*\)).*,\1,p'`
fi
if [ -z "$revision" ]; then if [ -z "$revision" ]; then
revision=0 # failed to find any hrev tags, use short hash instead
revision=`git rev-parse --short HEAD`
elif echo "$revision" | grep -- '-' >/dev/null; then
# HEAD is not directly a changeset from Haiku's central repo, so we
# add the current branch name as additional info
branchName=`git branch | grep '*' | cut -b 3-`
revision="$revision [$branchName]"
fi fi
echo $revision >${haikuBuildOutputDir}/haiku-revision fi
cd $originalDir
} cd $originalDir
if [ -z "$revision" ]; then
revision=0
fi
echo $localRev >${lastBuiltRevisionFile}
echo $revision >${revisionFile}