make/common/ZipArchive.gmk
author lana
Tue, 15 Mar 2016 13:48:18 -0700
changeset 36505 17460b0304f4
parent 29312 f3f859137ce6
child 41658 14de1ab85d25
permissions -rw-r--r--
Added tag jdk-9+110 for changeset 428cc83bfc1e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     1
#
27592
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
     2
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     4
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    10
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    15
# accompanied this code).
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    16
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    20
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    23
# questions.
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    24
#
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    25
27592
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    26
ifndef _ZIP_ARCHIVE_GMK
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    27
_ZIP_ARCHIVE_GMK := 1
25854
98ce0879ab4c 8054834: Modular Source Code
chegar
parents: 24080
diff changeset
    28
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    29
ifeq (,$(_MAKEBASE_GMK))
27592
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    30
  $(error You must include MakeBase.gmk prior to including ZipArchive.gmk)
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    31
endif
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    32
27592
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    33
# Setup make rules for creating a zip archive.
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    34
#
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    35
# Parameter 1 is the name of the rule. This name is used as variable prefix,
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    36
# and the targets generated are listed in a variable by that name.
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    37
#
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    38
# Remaining parameters are named arguments. These include:
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    39
#   SRC
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    40
#   ZIP
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    41
#   INCLUDES
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    42
#   INCLUDE_FILES
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    43
#   EXCLUDES
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    44
#   EXCLUDE_FILES
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    45
#   SUFFIXES
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    46
#   EXTRA_DEPS
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
    47
#   ZIP_OPTIONS extra options to pass to zip
29312
f3f859137ce6 8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents: 27602
diff changeset
    48
SetupZipArchive = $(NamedParamsMacroTemplate)
f3f859137ce6 8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents: 27602
diff changeset
    49
define SetupZipArchiveBody
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    50
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    51
  # To avoid running find over too large sets of files, which causes make to crash
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    52
  # on some configurations (cygwin), use INCLUDES and INCLUDE_FILES to build a set
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    53
  # of directories to run find in, if available.
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    54
  ifneq ($$($1_INCLUDES)$$($1_INCLUDE_FILES),)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    55
    $1_FIND_LIST := $$(wildcard $$(foreach i,$$($1_SRC), \
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    56
        $$(addprefix $$i/,$$($1_INCLUDES) $$($1_INCLUDE_FILES))))
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    57
  else
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    58
    $1_FIND_LIST := $$($1_SRC)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    59
  endif
18422
8443ba629f9d 8016605: New files dont apear in src.zip
erikj
parents: 16583
diff changeset
    60
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    61
  # Find all files in the source tree.
20645
6170a286f879 8025869: make docs doesn't regenerate docs correctly after changing API doc comments in jaxp sources
erikj
parents: 20364
diff changeset
    62
  $1_ALL_SRCS := $$(call not-containing,_the.,$$(call CacheFind,$$($1_FIND_LIST)))
6170a286f879 8025869: make docs doesn't regenerate docs correctly after changing API doc comments in jaxp sources
erikj
parents: 20364
diff changeset
    63
6170a286f879 8025869: make docs doesn't regenerate docs correctly after changing API doc comments in jaxp sources
erikj
parents: 20364
diff changeset
    64
  # Filter on suffixes if set
6170a286f879 8025869: make docs doesn't regenerate docs correctly after changing API doc comments in jaxp sources
erikj
parents: 20364
diff changeset
    65
  ifneq ($$($1_SUFFIXES),)
6170a286f879 8025869: make docs doesn't regenerate docs correctly after changing API doc comments in jaxp sources
erikj
parents: 20364
diff changeset
    66
    $1_ALL_SRCS := $$(filter $$(addprefix %, $$($1_SUFFIXES)), $$($1_ALL_SRCS))
6170a286f879 8025869: make docs doesn't regenerate docs correctly after changing API doc comments in jaxp sources
erikj
parents: 20364
diff changeset
    67
  endif
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    68
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    69
  ifneq ($$($1_INCLUDES),)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    70
    ifneq ($$($1_SUFFIXES),)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    71
      $1_ZIP_INCLUDES := $$(foreach s,$$($1_SUFFIXES), \
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    72
          $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$$s$(DQUOTE),$$($1_INCLUDES))))
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    73
    else
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    74
      $1_ZIP_INCLUDES := $$(addprefix -i$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_INCLUDES)))
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    75
    endif
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    76
  endif
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    77
  ifneq ($$($1_INCLUDE_FILES),)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    78
    $1_ZIP_INCLUDES += $$(addprefix -i$(SPACE),$$($1_INCLUDE_FILES))
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    79
  endif
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    80
  ifneq ($$($1_EXCLUDES),)
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
    81
    $1_ZIP_EXCLUDES := $$(addprefix -x$(SPACE)$(DQUOTE),$$(addsuffix /*$(DQUOTE),$$($1_EXCLUDES)))
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    82
    $1_SRC_EXCLUDES := $$(foreach i,$$($1_SRC),$$(addprefix $$i/,$$(addsuffix /%,$$($1_EXCLUDES))))
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    83
    $1_ALL_SRCS := $$(filter-out $$($1_SRC_EXCLUDES),$$($1_ALL_SRCS))
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    84
  endif
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
    85
  ifneq ($$($1_EXCLUDE_FILES),)
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
    86
    # Cannot precompute ZIP_EXCLUDE_FILES as it is dependent on which src root is being
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
    87
    # zipped at the moment.
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
    88
    $1_SRC_EXCLUDE_FILES := $$(addprefix %, $$($1_EXCLUDE_FILES)) $$($1_EXCLUDE_FILES)
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
    89
    $1_ALL_SRCS := $$(filter-out $$($1_SRC_EXCLUDE_FILES), $$($1_ALL_SRCS))
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
    90
  endif
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    91
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    92
  # Use a slightly shorter name for logging, but with enough path to identify this zip.
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    93
  $1_NAME:=$$(subst $$(OUTPUT_ROOT)/,,$$($1_ZIP))
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
    94
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    95
  # Now $1_ALL_SRCS should contain all sources that are going to be put into the zip.
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    96
  # I.e. the zip -i and -x options should match the filtering done in the makefile.
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    97
  # Explicitly excluded files can be given with absolute path. The patsubst solution
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    98
  # isn't perfect but the likelyhood of an absolute path to match something in a src
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
    99
  # dir is very small.
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
   100
  # If zip has nothing to do, it returns 12 and would fail the build. Check for 12
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
   101
  # and only fail if it's not.
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
   102
  $$($1_ZIP) : $$($1_ALL_SRCS) $$($1_EXTRA_DEPS)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
   103
	$(MKDIR) -p $$(@D)
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
   104
	$(ECHO) Updating $$($1_NAME)
27602
chegar
parents: 27560 27592
diff changeset
   105
	$$(foreach i,$$($1_SRC),(cd $$i && $(ZIP) -qru $$($1_ZIP_OPTIONS) $$@ . $$($1_ZIP_INCLUDES) \
27560
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
   106
	    $$($1_ZIP_EXCLUDES) -x \*_the.\* \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
   107
	    $$(addprefix -x$(SPACE), $$(patsubst $$i/%,%, $$($1_EXCLUDE_FILES))) \
adc258b13e2c 8049367: Modular Run-Time Images
chegar
parents: 26671
diff changeset
   108
	    || test "$$$$?" = "12" )$$(NEWLINE)) true
20363
fa7663fc5d50 8001931: The new build system whitespace cleanup
ihse
parents: 20273
diff changeset
   109
	$(TOUCH) $$@
22480
d1be923b168a 8026773: Failing compilation in Corba does not fail the build
erikj
parents: 22469
diff changeset
   110
d1be923b168a 8026773: Failing compilation in Corba does not fail the build
erikj
parents: 22469
diff changeset
   111
  # Add zip to target list
d1be923b168a 8026773: Failing compilation in Corba does not fail the build
erikj
parents: 22469
diff changeset
   112
  $1 += $$($1_ZIP)
12258
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   113
endef
6ec26f6cc53e 7074397: Build infrastructure changes (makefile re-write)
ohair
parents:
diff changeset
   114
27592
af7df0dd5ff7 8065911: Introduce EvalDebugWrapper for all Setup* macros
ihse
parents: 27591
diff changeset
   115
endif # _ZIP_ARCHIVE_GMK