Skip to content

Commit 26f8014

Browse files
committed
8210283: Support git as an SCM alternative in the build
Reviewed-by: ihse, ehelin
1 parent 21a0458 commit 26f8014

File tree

5 files changed

+55
-19
lines changed

5 files changed

+55
-19
lines changed

Diff for: .gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/build/
2+
/dist/
3+
/.idea/
4+
nbproject/private/
5+
/webrev
6+
/.src-rev
7+
/.jib/
8+
.DS_Store
9+
.metadata/
10+
.recommenders/
11+
test/nashorn/script/external
12+
test/nashorn/lib
13+
NashornProfile.txt
14+
**/JTreport/**
15+
**/JTwork/**

Diff for: make/SourceRevision.gmk

+37-19
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,35 @@ $(eval $(call IncludeCustomExtension, SourceRevision-pre.gmk))
3131
################################################################################
3232
# Keep track of what source revision is used to create the build, by creating
3333
# a tracker file in the output directory. This tracker file is included in the
34-
# image, and can be used to recreate the source revision used.
34+
# source image, and can be used to recreate the source revision used.
3535
#
36-
# We're either building directly from a mercurial forest, and if so, use the
37-
# current revision from mercurial. Otherwise, we are building from a source
38-
# bundle. As a part of creating this source bundle, the current mercurial
39-
# revisions of all repos will be stored in a file in the top dir, which is then
40-
# used when creating the tracker file.
36+
# We're either building directly from an SCM repository, and if so, use the
37+
# current revision from that SCM. Otherwise, we are building from a source
38+
# bundle. As a part of creating this source bundle, the current SCM revisions of
39+
# all repos will be stored in a file in the top dir, which is then used when
40+
# creating the tracker file.
4141

4242
STORED_SOURCE_REVISION := $(TOPDIR)/.src-rev
4343

44-
# Are we using mercurial?
44+
USE_SCM := false
4545
ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), )
46+
USE_SCM := true
47+
SCM_DIR := .hg
48+
ID_COMMAND := $(PRINTF) "hg:%s" "$$($(HG) id -i)"
49+
else ifneq ($(and $(GIT), $(wildcard $(TOPDIR)/.git)), )
50+
USE_SCM := true
51+
SCM_DIR := .git
52+
ID_COMMAND := $(PRINTF) "git:%s%s\n" \
53+
"$$(git log -n1 --format=%H | cut -c1-12)" \
54+
"$$(if test -n "$$(git status --porcelain)"; then printf '+'; fi)"
55+
endif
56+
57+
ifeq ($(USE_SCM), true)
4658

4759
# Verify that the entire forest is consistent
4860
$(foreach repo, $(call FindAllReposRel), \
49-
$(if $(wildcard $(TOPDIR)/$(repo)/.hg),, \
50-
$(error Inconsistent revision control: $(repo) is missing .hg directory)) \
61+
$(if $(wildcard $(TOPDIR)/$(repo)/$(SCM_DIR)),, \
62+
$(error Inconsistent revision control: $(repo) is missing $(SCM_DIR) directory)) \
5163
)
5264

5365
# Replace "." with "_top" and "/" with "-"
@@ -56,7 +68,9 @@ ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), )
5668

5769
################################################################################
5870
# SetupGetRevisionForRepo defines a make rule for creating a file containing
59-
# the name of the repository and the output of "hg id" for that repository.
71+
# the name of the repository and the output of the scm command for that
72+
# repository.
73+
#
6074
# Argument 1 is the relative path to the repository from the top dir.
6175
#
6276
SetupGetRevisionForRepo = $(NamedParamsMacroTemplate)
@@ -66,7 +80,7 @@ ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), )
6680

6781
$$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME): FRC
6882
$$(call MakeDir, $$(@D))
69-
$$(ECHO) $$(strip $1):`$$(HG) id -i --repository $$($1_REPO_PATH)` > $$@
83+
$$(ECHO) $$(strip $1):`$$(CD) $$($1_REPO_PATH) && $$(ID_COMMAND)` > $$@
7084

7185
REPO_REVISIONS += $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME)
7286
endef
@@ -92,23 +106,25 @@ ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), )
92106

93107
$(eval $(call CreateSourceRevisionFile, $(STORED_SOURCE_REVISION)))
94108

95-
hg-store-source-revision: $(STORED_SOURCE_REVISION)
109+
scm-store-source-revision: $(STORED_SOURCE_REVISION)
96110

97111
$(eval $(call CreateSourceRevisionFile, $(SOURCE_REVISION_TRACKER)))
98112

99-
hg-create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
113+
scm-create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
100114

101-
STORE_SOURCE_REVISION_TARGET := hg-store-source-revision
102-
CREATE_SOURCE_REVISION_TRACKER_TARGET := hg-create-source-revision-tracker
115+
STORE_SOURCE_REVISION_TARGET := scm-store-source-revision
116+
CREATE_SOURCE_REVISION_TRACKER_TARGET := scm-create-source-revision-tracker
117+
118+
.PHONY: scm-store-source-revision scm-create-source-revision-tracker
103119

104120
else
105-
# Not using HG
121+
# Not using any SCM
106122

107123
ifneq ($(wildcard $(STORED_SOURCE_REVISION)), )
108124
# We have a stored source revision (.src-rev)
109125

110126
src-store-source-revision:
111-
$(call LogInfo, No mercurial configuration present$(COMMA) not updating .src-rev)
127+
$(call LogInfo, No SCM configuration present$(COMMA) not updating .src-rev)
112128

113129
$(SOURCE_REVISION_TRACKER): $(STORED_SOURCE_REVISION)
114130
$(install-file)
@@ -118,16 +134,18 @@ else
118134
# We don't have a stored source revision. Can't do anything, really.
119135

120136
src-store-source-revision:
121-
$(call LogWarn, Error: No mercurial configuration present$(COMMA) cannot create .src-rev)
137+
$(call LogWarn, Error: No SCM configuration present$(COMMA) cannot create .src-rev)
122138
exit 2
123139

124140
src-create-source-revision-tracker:
125-
$(call LogWarn, Warning: No mercurial configuration present and no .src-rev)
141+
$(call LogWarn, Warning: No SCM configuration present and no .src-rev)
126142
endif
127143

128144
STORE_SOURCE_REVISION_TARGET := src-store-source-revision
129145
CREATE_SOURCE_REVISION_TRACKER_TARGET := src-create-source-revision-tracker
130146

147+
.PHONY: src-store-source-revision src-create-source-revision-tracker
148+
131149
endif
132150

133151
################################################################################

Diff for: make/autoconf/basics.m4

+1
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,7 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
11901190
BASIC_PATH_PROGS(READELF, [greadelf readelf])
11911191
BASIC_PATH_PROGS(DOT, dot)
11921192
BASIC_PATH_PROGS(HG, hg)
1193+
BASIC_PATH_PROGS(GIT, git)
11931194
BASIC_PATH_PROGS(STAT, stat)
11941195
BASIC_PATH_PROGS(TIME, time)
11951196
BASIC_PATH_PROGS(FLOCK, flock)

Diff for: make/autoconf/spec.gmk.in

+1
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ EXPR:=@EXPR@
723723
FILE:=@FILE@
724724
DOT:=@DOT@
725725
HG:=@HG@
726+
GIT:=@GIT@
726727
OBJCOPY:=@OBJCOPY@
727728
SETFILE:=@SETFILE@
728729
XATTR:=@XATTR@

Diff for: make/common/MakeBase.gmk

+1
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ SOURCE_REVISION_TRACKER := $(SUPPORT_OUTPUTDIR)/src-rev/source-revision-tracker
347347
FindAllReposAbs = \
348348
$(strip $(sort $(dir $(filter-out $(TOPDIR)/build/%, $(wildcard \
349349
$(addprefix $(TOPDIR)/, .hg */.hg */*/.hg */*/*/.hg */*/*/*/.hg) \
350+
$(addprefix $(TOPDIR)/, .git */.git */*/.git */*/*/.git */*/*/*/.git) \
350351
)))))
351352

352353
# Locate all hg repositories included in the forest, as relative paths

0 commit comments

Comments
 (0)