make/common/TestFilesCompilation.gmk
author erikj
Tue, 05 Dec 2017 23:14:35 +0100
changeset 48069 a358ebcfacfb
parent 41260 4f71f07b30d1
child 49070 d7859531621b
permissions -rw-r--r--
8192771: Boot JDK jar tool used to construct the modular JAR for java.jnlp Reviewed-by: ihse, psandoz, mchung
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29156
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
     1
#
41260
4f71f07b30d1 8150736: Excessive disk space used by build system
erikj
parents: 40613
diff changeset
     2
# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
29156
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
     3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
     4
#
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
     5
# This code is free software; you can redistribute it and/or modify it
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
     6
# under the terms of the GNU General Public License version 2 only, as
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
     7
# published by the Free Software Foundation.  Oracle designates this
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
     8
# particular file as subject to the "Classpath" exception as provided
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
     9
# by Oracle in the LICENSE file that accompanied this code.
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    10
#
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    11
# This code is distributed in the hope that it will be useful, but WITHOUT
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    14
# version 2 for more details (a copy is included in the LICENSE file that
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    15
# accompanied this code).
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    16
#
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    17
# You should have received a copy of the GNU General Public License version
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    18
# 2 along with this work; if not, write to the Free Software Foundation,
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    20
#
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    22
# or visit www.oracle.com if you need additional information or have any
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    23
# questions.
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    24
#
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    25
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    26
ifndef _TEST_FILES_COMPILATION_GMK
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    27
_TEST_FILES_COMPILATION_GMK := 1
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    28
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    29
ifeq (,$(_MAKEBASE_GMK))
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    30
  $(error You must include MakeBase.gmk prior to including TestFilesCompilation.gmk)
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    31
endif
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    32
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    33
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    34
include NativeCompilation.gmk
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    35
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    36
# Setup make rules for creating a set of native test files (libraries or
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    37
# executables). This will locate native files matching a certain pattern,
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    38
# and compile these into libraries or executables.
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    39
#
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    40
# Parameter 1 is the name of the rule. This name is used as variable prefix,
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    41
# and the targets generated are listed in a variable by that name.
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    42
#
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    43
# Remaining parameters are named arguments. These include:
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    44
#   TYPE Must be either PROGRAM or LIBRARY.
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    45
#   SOURCE_DIRS A list of source directories to search
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    46
#   OUTPUT_DIR Where to put the resulting files
29312
f3f859137ce6 8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents: 29305
diff changeset
    47
SetupTestFilesCompilation = $(NamedParamsMacroTemplate)
f3f859137ce6 8074988: Reduce boilerplate in Setup* macro definitions
erikj
parents: 29305
diff changeset
    48
define SetupTestFilesCompilationBody
29156
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    49
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    50
  # Check for duplicate base file names. That would have failed later anyhow, but
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    51
  # this gives a better error message.
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    52
  $1_DUPLICATED_NAMES := $$(call dups, $$(notdir $$($1_FILE_LIST)))
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    53
  ifneq ($$($1_DUPLICATED_NAMES), )
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    54
    $$(error There are duplicate test file names for $1: $$($1_DUPLICATED_NAMES))
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    55
  endif
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    56
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    57
  # The list to depend on starts out empty
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    58
  $1 :=
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    59
  ifeq ($$($1_TYPE), LIBRARY)
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    60
    $1_PREFIX = lib
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    61
    $1_OUTPUT_SUBDIR := lib
29305
4ddc6faf7842 8073021: add native code coverage target into makefiles
erikj
parents: 29156
diff changeset
    62
    $1_CFLAGS := $(CFLAGS_TESTLIB) $(CFLAGS_WARNINGS_ARE_ERRORS)
4ddc6faf7842 8073021: add native code coverage target into makefiles
erikj
parents: 29156
diff changeset
    63
    $1_LDFLAGS := $(LDFLAGS_TESTLIB) $(call SET_SHARED_LIBRARY_ORIGIN)
29156
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    64
  else ifeq ($$($1_TYPE), PROGRAM)
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    65
    $1_PREFIX = exe
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    66
    $1_OUTPUT_SUBDIR := bin
29305
4ddc6faf7842 8073021: add native code coverage target into makefiles
erikj
parents: 29156
diff changeset
    67
    $1_CFLAGS := $(CFLAGS_TESTEXE) $(CFLAGS_WARNINGS_ARE_ERRORS)
4ddc6faf7842 8073021: add native code coverage target into makefiles
erikj
parents: 29156
diff changeset
    68
    $1_LDFLAGS := $(LDFLAGS_TESTEXE)
29156
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    69
  else
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    70
    $$(error Unknown type: $$($1_TYPE))
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    71
  endif
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    72
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    73
  # Locate all files with the matching prefix
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    74
  $1_FILE_LIST := \
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    75
      $$(shell $$(FIND) $$($1_SOURCE_DIRS) -type f -name "$$($1_PREFIX)*.c")
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    76
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    77
  # Setup a compilation for each and every one of them
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    78
  $$(foreach file, $$($1_FILE_LIST),\
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    79
    $$(eval name := $$(strip $$(patsubst $$($1_PREFIX)%, %, $$(basename $$(notdir $$(file)))))) \
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    80
    $$(eval $$(call SetupNativeCompilation, BUILD_TEST_$$(name), \
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    81
        $$($1_TYPE) := $$(name), \
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    82
        SRC := $$(patsubst %/,%,$$(dir $$(file))), \
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    83
        INCLUDE_FILES := $$(notdir $$(file)), \
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    84
        OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$($1_PREFIX)$$(name), \
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    85
        OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    86
        LANG := C, \
31220
8a9b0fe3f23c 8081471: Allow SetupTestFilesCompilation to set LDFLAGS for individual tests
ihse
parents: 29312
diff changeset
    87
        CFLAGS := $$($1_CFLAGS) $$($1_CFLAGS_$$($1_PREFIX)$$(name)), \
8a9b0fe3f23c 8081471: Allow SetupTestFilesCompilation to set LDFLAGS for individual tests
ihse
parents: 29312
diff changeset
    88
        LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$($1_PREFIX)$$(name)), \
40613
0140daccc66f 8164297: Jtreg test exeinvoke fails to link on Ubuntu
erikj
parents: 35032
diff changeset
    89
        LIBS := $$($1_LIBS_$$($1_PREFIX)$$(name)), \
29156
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    90
        OPTIMIZATION := LOW, \
41260
4f71f07b30d1 8150736: Excessive disk space used by build system
erikj
parents: 40613
diff changeset
    91
        COPY_DEBUG_SYMBOLS := false, \
4f71f07b30d1 8150736: Excessive disk space used by build system
erikj
parents: 40613
diff changeset
    92
        STRIP_SYMBOLS := false, \
35032
c2f315819691 8145596: Enable debug symbols for all libraries
ihse
parents: 32462
diff changeset
    93
    )) \
29156
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    94
    $$(eval $1 += $$(BUILD_TEST_$$(name)) )  \
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    95
  )
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    96
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    97
endef
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    98
bd932374081c 8072842: Add support for building native JTReg tests
ihse
parents:
diff changeset
    99
endif # _TEST_FILES_COMPILATION_GMK