make/SourceRevision.gmk
author dpochepk
Tue, 20 Dec 2016 17:35:20 +0300
changeset 42898 af1346a135ce
parent 42284 38f8784217d0
child 42848 27ad8b2418f7
permissions -rw-r--r--
8170886: compiler/ciReplay/TestSAServer.java intermittently throws NumberFormatException Reviewed-by: thartmann
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
     1
#
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
     2
# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
     4
#
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    10
#
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    15
# accompanied this code).
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    16
#
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    20
#
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    23
# questions.
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    24
#
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    25
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    26
default: all
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    27
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    28
include $(SPEC)
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    29
include MakeBase.gmk
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    30
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    31
################################################################################
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    32
# Keep track of what source revision is used to create the build, by creating
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    33
# a tracker file in the output directory. This tracker file is included in the
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    34
# image, and can be used to recreate the source revision used.
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    35
#
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    36
# We're either building directly from a mercurial forest, and if so, use the
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    37
# current revision from mercurial. Otherwise, we are building from a source
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    38
# bundle. As a part of creating this source bundle, the current mercurial
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    39
# revisions of all repos will be stored in a file in the top dir, which is then
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    40
# used when creating the tracker file.
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    41
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    42
STORED_SOURCE_REVISION := $(TOPDIR)/.src-rev
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    43
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    44
# Are we using mercurial?
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    45
ifneq ($(and $(HG), $(wildcard $(TOPDIR)/.hg)), )
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    46
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    47
  # Verify that the entire forest is consistent
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    48
  $(foreach repo, $(call FindAllReposRel), \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    49
    $(if $(wildcard $(TOPDIR)/$(repo)/.hg),, \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    50
        $(error Inconsistent revision control: $(repo) is missing .hg directory)) \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    51
  )
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    52
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    53
  # Replace "." with "_top" and "/" with "-"
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    54
  MakeFilenameFromRepo = \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    55
      $(strip $(subst .,top, $(subst /,-, $1)))
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    56
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    57
  ################################################################################
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    58
  # SetupGetRevisionForRepo defines a make rule for creating a file containing
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    59
  # the name of the repository and the output of "hg id" for that repository.
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    60
  # Argument 1 is the relative path to the repository from the top dir.
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    61
  #
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    62
  SetupGetRevisionForRepo = $(NamedParamsMacroTemplate)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    63
  define SetupGetRevisionForRepoBody
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    64
    $1_REPO_PATH :=  $$(TOPDIR)/$$(strip $1)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    65
    $1_FILENAME := $$(call MakeFilenameFromRepo, $1)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    66
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    67
    $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME): FRC
42283
eb9bd075b879 8170385: JDK-8031567 broke source bundles
ihse
parents: 42282
diff changeset
    68
	$$(call MakeDir, $$(@D))
eb9bd075b879 8170385: JDK-8031567 broke source bundles
ihse
parents: 42282
diff changeset
    69
	$$(ECHO) $$(strip $1):`$$(HG) id -i --repository $$($1_REPO_PATH)` > $$@
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    70
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    71
    REPO_REVISIONS += $$(SUPPORT_OUTPUTDIR)/src-rev/$$($1_FILENAME)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    72
  endef
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    73
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    74
  # Setup rules for all repos. This makes sure all the "hg id" calls are made
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    75
  # in parallel.
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    76
  $(foreach repo, $(call FindAllReposRel), \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    77
    $(eval $(call SetupGetRevisionForRepo, $(repo))) \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    78
  )
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    79
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    80
  # Create a complete source revision output file from all repos
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    81
  # Param 1: The output file
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    82
  define CreateSourceRevisionFile
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    83
    $1: $$(REPO_REVISIONS)
42283
eb9bd075b879 8170385: JDK-8031567 broke source bundles
ihse
parents: 42282
diff changeset
    84
	$$(call MakeDir, $$(@D))
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    85
	$$(ECHO) `$$(CAT) $$(REPO_REVISIONS)` > $$@.tmp
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    86
	if [ ! -f $$@ ] || [ "`$$(CAT) $$@`" != "`$$(CAT) $$@.tmp`" ]; then \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    87
	  $$(MV) $$@.tmp $$@ ; \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    88
	else \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    89
	  $$(RM) $$@.tmp ; \
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    90
	fi
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    91
  endef
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    92
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    93
  $(eval $(call CreateSourceRevisionFile, $(STORED_SOURCE_REVISION)))
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    94
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    95
  store-source-revision: $(STORED_SOURCE_REVISION)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    96
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    97
  $(eval $(call CreateSourceRevisionFile, $(SOURCE_REVISION_TRACKER)))
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    98
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
    99
  create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   100
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   101
else
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   102
  # Not using HG
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   103
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   104
  ifneq ($(wildcard $(STORED_SOURCE_REVISION)), )
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   105
    # We have a stored source revision (.src-rev)
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
   106
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   107
    store-source-revision:
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   108
	$(call LogWarn, Warning: No mercurial configuration present, not updating .src-rev)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   109
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   110
    $(SOURCE_REVISION_TRACKER): $(STORED_SOURCE_REVISION)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   111
	$(install-file)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   112
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   113
    create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   114
  else
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   115
    # We don't have a stored source revision. Can't do anything, really.
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
   116
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   117
    store-source-revision:
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   118
	$(call LogWarn, Error: No mercurial configuration present, cannot create .src-rev)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   119
	exit 2
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
   120
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   121
    create-source-revision-tracker:
42284
38f8784217d0 8170392: JDK-8031567 broke builds from source bundles
erikj
parents: 42283
diff changeset
   122
	$(call LogWarn, Warning: No mercurial configuration present and no .src-rev)
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   123
  endif
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
   124
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   125
endif
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   126
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   127
all: store-source-revision create-source-revision-tracker
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   128
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   129
FRC: # Force target
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   130
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   131
.PHONY: all store-source-revision create-source-revision-tracker