File: TestFilesCompilation.gmk

package info (click to toggle)
openjdk-26 26~32ea-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 841,336 kB
  • sloc: java: 5,732,058; xml: 1,398,183; cpp: 1,348,173; ansic: 488,951; asm: 404,027; objc: 21,152; sh: 14,618; javascript: 12,730; python: 8,352; makefile: 2,524; perl: 357; awk: 351; pascal: 103; exp: 83; sed: 72; jsp: 24
file content (148 lines) | stat: -rw-r--r-- 6,364 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#
# Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.  Oracle designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#

include MakeIncludeStart.gmk
ifeq ($(INCLUDE), true)

################################################################################

include JdkNativeCompilation.gmk

# Setup make rules for creating a set of native test files (libraries or
# executables). This will locate native files matching a certain pattern,
# and compile these into libraries or executables.
#
# Parameter 1 is the name of the rule. This name is used as variable prefix,
# and the targets generated are listed in a variable by that name.
#
# Remaining parameters are named arguments. These include:
#   TYPE Must be either PROGRAM or LIBRARY.
#   SOURCE_DIRS A list of source directories to search
#   OUTPUT_DIR Where to put the resulting files
#   EXCLUDE A list of filenames to exclude from compilation
#   EXTRA_FILES List of extra files not in SOURCE_DIRS
#   CFLAGS List of extra CFLAGS to pass on for each test
#   LDFLAGS List of extra LDFLAGS to pass on for each test
#   LIBS List of extra LIBS to pass on for each test
SetupTestFilesCompilation = $(NamedParamsMacroTemplate)
define SetupTestFilesCompilationBody

  # Check for duplicate base file names. That would have failed later anyhow, but
  # this gives a better error message.
  $1_DUPLICATED_NAMES := $$(call dups, $$(notdir $$($1_FILE_LIST)))
  ifneq ($$($1_DUPLICATED_NAMES), )
    $$(error There are duplicate test file names for $1: $$($1_DUPLICATED_NAMES))
  endif

  # The list to depend on starts out empty
  $1 :=
  ifeq ($$($1_TYPE), LIBRARY)
    $1_PREFIX = lib
    $1_OUTPUT_SUBDIR := lib
    $1_COMPILATION_TYPE := LIBRARY
    $1_LOG_TYPE := library
  else ifeq ($$($1_TYPE), PROGRAM)
    $1_PREFIX = exe
    $1_OUTPUT_SUBDIR := bin
    $1_COMPILATION_TYPE := EXECUTABLE
    $1_LOG_TYPE := executable
    $1_LD_SET_ORIGIN := false
  else
    $$(error Unknown type: $$($1_TYPE))
  endif

  # Locate all files with the matching prefix
  $1_FILE_LIST := \
      $$(call FindFiles, $$($1_SOURCE_DIRS), $$($1_PREFIX)*.c $$($1_PREFIX)*.cpp $$($1_PREFIX)*.m)

  $1_EXCLUDE_PATTERN := $$(addprefix %/, $$($1_EXCLUDE))
  $1_FILTERED_FILE_LIST := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_FILE_LIST))

  $1_BUILD_INFO := $$($1_OUTPUT_DIR)/_$1-build-info.marker

  # Tests are built with internal debug symbols where supported.
  # With Visual Studio or on macosx, we revert to external.
  $1_COPY_DEBUG_SYMBOLS := false
  ifeq ($(TOOLCHAIN_TYPE), microsoft)
    $1_COPY_DEBUG_SYMBOLS := true
  else ifeq ($(call isTargetOs, macosx), true)
    $1_COPY_DEBUG_SYMBOLS := true
  endif

  # Always include common test functionality
  TEST_CFLAGS := -I$(TOPDIR)/test/lib/native

  # Setup a compilation for each and every one of them
  $$(foreach file, $$($1_FILTERED_FILE_LIST), \
    $$(eval name := $$(strip $$(basename $$(notdir $$(file))))) \
    $$(eval unprefixed_name := $$(patsubst $$($1_PREFIX)%, %, $$(name))) \
    $$(eval $$(call SetupJdkNativeCompilation, BUILD_TEST_$$(name), \
        NAME := $$(unprefixed_name), \
        TYPE := $$($1_COMPILATION_TYPE), \
        LINK_TYPE := $(if $$(filter %.cpp, $$(file)), C++, C), \
        EXTRA_HEADER_DIRS := \
            java.base:libjava \
            java.base:libjvm, \
        EXTRA_FILES := $$(file) $$($1_EXTRA_FILES), \
        OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$(name), \
        OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \
        CFLAGS := $$(TEST_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
        CXXFLAGS := $$(TEST_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
        LD_SET_ORIGIN := $$($1_LD_SET_ORIGIN), \
        LDFLAGS := $$($1_LDFLAGS) $$($1_LDFLAGS_$$(name)), \
        DISABLED_WARNINGS_gcc := format undef unused-but-set-variable \
            unused-const-variable unused-function unused-value \
            unused-variable, \
        DISABLED_WARNINGS_clang := format-nonliteral \
            missing-field-initializers sometimes-uninitialized undef \
            unused-but-set-variable unused-function unused-variable, \
        DEFAULT_LIBCXX := false, \
        JDK_LIBS := $$($1_JDK_LIBS_$$(name)), \
        LIBS := $$($1_LIBS) $$($1_LIBS_$$(name)), \
        DEFAULT_VERSIONINFO_RESOURCE := false, \
        OPTIMIZATION := $$(if $$($1_OPTIMIZATION_$$(name)), $$($1_OPTIMIZATION_$$(name)), LOW), \
        COPY_DEBUG_SYMBOLS := $$($1_COPY_DEBUG_SYMBOLS), \
        STRIP_SYMBOLS := $$(if $$($1_STRIP_SYMBOLS_$$(name)), $$($1_STRIP_SYMBOLS_$$(name)), false), \
        BUILD_INFO_LOG_MACRO := LogInfo, \
    )) \
    $$(eval $1 += $$(BUILD_TEST_$$(name)) ) \
    $$(eval $1_BUILD_INFO_DEPS += $$(BUILD_TEST_$$(name)_BUILD_INFO_DEPS)) \
    $$(eval $$(BUILD_TEST_$$(name)_BUILD_INFO): | $$($1_BUILD_INFO)) \
  )

  # Setup rule for printing a summary of all the tests being compiled. On Warn
  # log level, this replaces the individual build info logging done by
  # SetupJdkNativeCompilation.
  $$($1_BUILD_INFO): $$($1_BUILD_INFO_DEPS)
	$$(call LogWarn, $$(strip Creating $$(words $$(filter-out %.vardeps, $$?)) \
	    test $$($1_LOG_TYPE) file(s) for $1))
	$(TOUCH) $$@

endef

################################################################################

endif # include guard
include MakeIncludeEnd.gmk