make/SourceRevision.gmk
author mbaesken
Wed, 05 Sep 2018 12:48:51 +0200
changeset 51645 c5f700de5450
parent 51553 867acd5a4140
child 51676 5a1be00ea4f6
permissions -rw-r--r--
8209942: [epsilon] range function for EpsilonTLABElasticity causes compiler warning Reviewed-by: shade, simonis Contributed-by: ralf.schmelter@sap.com
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
#
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
     2
# Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
39110
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
include $(SPEC)
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    27
include MakeBase.gmk
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
    28
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
    29
$(eval $(call IncludeCustomExtension, SourceRevision-pre.gmk))
47217
72e3ae9a25eb 8187444: Forest Consolidation: Make build work
erikj
parents: 42848
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
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
    95
  hg-store-source-revision: $(STORED_SOURCE_REVISION)
42282
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
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
    99
  hg-create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   100
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   101
  STORE_SOURCE_REVISION_TARGET := hg-store-source-revision
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   102
  CREATE_SOURCE_REVISION_TRACKER_TARGET := hg-create-source-revision-tracker
42282
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
else
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   105
  # Not using HG
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   106
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   107
  ifneq ($(wildcard $(STORED_SOURCE_REVISION)), )
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   108
    # We have a stored source revision (.src-rev)
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
   109
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   110
    src-store-source-revision:
42848
27ad8b2418f7 8170741: Enable uploading of built artifacts through Jib
erikj
parents: 42284
diff changeset
   111
	$(call LogInfo, No mercurial configuration present$(COMMA) not updating .src-rev)
42282
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
    $(SOURCE_REVISION_TRACKER): $(STORED_SOURCE_REVISION)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   114
	$(install-file)
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   115
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   116
    src-create-source-revision-tracker: $(SOURCE_REVISION_TRACKER)
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   117
  else
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   118
    # 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
   119
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   120
    src-store-source-revision:
42848
27ad8b2418f7 8170741: Enable uploading of built artifacts through Jib
erikj
parents: 42284
diff changeset
   121
	$(call LogWarn, Error: No mercurial configuration present$(COMMA) cannot create .src-rev)
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   122
	exit 2
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
   123
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   124
    src-create-source-revision-tracker:
42284
38f8784217d0 8170392: JDK-8031567 broke builds from source bundles
erikj
parents: 42283
diff changeset
   125
	$(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
   126
  endif
39110
712f29ba8708 8136771: Implement the license-swap logic as a make target
erikj
parents:
diff changeset
   127
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   128
  STORE_SOURCE_REVISION_TARGET := src-store-source-revision
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   129
  CREATE_SOURCE_REVISION_TRACKER_TARGET := src-create-source-revision-tracker
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   130
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   131
endif
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   132
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   133
################################################################################
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   134
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   135
$(eval $(call IncludeCustomExtension, SourceRevision-post.gmk))
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   136
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   137
################################################################################
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   138
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   139
store-source-revision: $(STORE_SOURCE_REVISION_TARGET)
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   140
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   141
create-source-revision-tracker: $(CREATE_SOURCE_REVISION_TRACKER_TARGET)
42282
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   142
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   143
FRC: # Force target
faf3b6722c44 8031567: Better model for storing source revision information
ihse
parents: 39110
diff changeset
   144
51553
867acd5a4140 8210008: custom extension for make/SourceRevision.gmk
twisti
parents: 47314
diff changeset
   145
.PHONY: store-source-revision create-source-revision-tracker