2015-02-27 10:56:57 +00:00
|
|
|
#
|
2024-02-27 11:14:11 +00:00
|
|
|
# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
2015-02-27 10:56:57 +00:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
|
|
|
ifndef _TEST_FILES_COMPILATION_GMK
|
|
|
|
_TEST_FILES_COMPILATION_GMK := 1
|
|
|
|
|
2024-09-03 15:31:09 +00:00
|
|
|
ifeq ($(_MAKEBASE_GMK), )
|
2015-02-27 10:56:57 +00:00
|
|
|
$(error You must include MakeBase.gmk prior to including TestFilesCompilation.gmk)
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2024-04-05 08:37:41 +00:00
|
|
|
include JdkNativeCompilation.gmk
|
2015-02-27 10:56:57 +00:00
|
|
|
|
|
|
|
# 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
|
2018-03-15 18:33:04 +00:00
|
|
|
# EXCLUDE A list of filenames to exclude from compilation
|
2023-01-25 16:18:29 +00:00
|
|
|
# EXTRA_FILES List of extra files not in SOURCE_DIRS
|
2015-03-12 11:13:23 +00:00
|
|
|
SetupTestFilesCompilation = $(NamedParamsMacroTemplate)
|
|
|
|
define SetupTestFilesCompilationBody
|
2015-02-27 10:56:57 +00:00
|
|
|
|
|
|
|
# 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
|
2018-02-28 20:16:11 +00:00
|
|
|
$1_COMPILATION_TYPE := LIBRARY
|
2023-01-23 20:51:13 +00:00
|
|
|
$1_LOG_TYPE := library
|
2015-02-27 10:56:57 +00:00
|
|
|
else ifeq ($$($1_TYPE), PROGRAM)
|
|
|
|
$1_PREFIX = exe
|
|
|
|
$1_OUTPUT_SUBDIR := bin
|
2018-02-28 20:16:11 +00:00
|
|
|
$1_COMPILATION_TYPE := EXECUTABLE
|
2023-01-23 20:51:13 +00:00
|
|
|
$1_LOG_TYPE := executable
|
2024-04-05 08:37:41 +00:00
|
|
|
$1_LD_SET_ORIGIN := false
|
2015-02-27 10:56:57 +00:00
|
|
|
else
|
|
|
|
$$(error Unknown type: $$($1_TYPE))
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Locate all files with the matching prefix
|
|
|
|
$1_FILE_LIST := \
|
2021-02-03 16:20:16 +00:00
|
|
|
$$(call FindFiles, $$($1_SOURCE_DIRS), $$($1_PREFIX)*.c $$($1_PREFIX)*.cpp $$($1_PREFIX)*.m)
|
2015-02-27 10:56:57 +00:00
|
|
|
|
2018-03-15 18:33:04 +00:00
|
|
|
$1_EXCLUDE_PATTERN := $$(addprefix %/, $$($1_EXCLUDE))
|
|
|
|
$1_FILTERED_FILE_LIST := $$(filter-out $$($1_EXCLUDE_PATTERN), $$($1_FILE_LIST))
|
|
|
|
|
2023-01-23 20:51:13 +00:00
|
|
|
$1_BUILD_INFO := $$($1_OUTPUT_DIR)/_$1-build-info.marker
|
|
|
|
|
2023-09-12 20:17:52 +00:00
|
|
|
# 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
|
|
|
|
|
2024-04-05 08:37:41 +00:00
|
|
|
# Always include common test functionality
|
|
|
|
TEST_CFLAGS := -I$(TOPDIR)/test/lib/native
|
|
|
|
|
2015-02-27 10:56:57 +00:00
|
|
|
# Setup a compilation for each and every one of them
|
2024-09-03 15:31:09 +00:00
|
|
|
$$(foreach file, $$($1_FILTERED_FILE_LIST), \
|
2018-03-15 18:33:04 +00:00
|
|
|
$$(eval name := $$(strip $$(basename $$(notdir $$(file))))) \
|
|
|
|
$$(eval unprefixed_name := $$(patsubst $$($1_PREFIX)%, %, $$(name))) \
|
2024-04-05 08:37:41 +00:00
|
|
|
$$(eval $$(call SetupJdkNativeCompilation, BUILD_TEST_$$(name), \
|
2018-03-15 18:33:04 +00:00
|
|
|
NAME := $$(unprefixed_name), \
|
2018-02-28 20:16:11 +00:00
|
|
|
TYPE := $$($1_COMPILATION_TYPE), \
|
2024-02-27 11:14:11 +00:00
|
|
|
LINK_TYPE := $(if $$(filter %.cpp, $$(file)), C++, C), \
|
2024-04-11 09:40:12 +00:00
|
|
|
EXTRA_HEADER_DIRS := \
|
|
|
|
java.base:libjava \
|
|
|
|
java.base:libjvm, \
|
2023-01-25 16:18:29 +00:00
|
|
|
EXTRA_FILES := $$(file) $$($1_EXTRA_FILES), \
|
2018-03-15 18:33:04 +00:00
|
|
|
OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$(name), \
|
2015-02-27 10:56:57 +00:00
|
|
|
OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \
|
2024-04-05 08:37:41 +00:00
|
|
|
CFLAGS := $$(TEST_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
|
|
|
|
CXXFLAGS := $$(TEST_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
|
|
|
|
LD_SET_ORIGIN := $$($1_LD_SET_ORIGIN), \
|
2024-04-11 09:40:12 +00:00
|
|
|
LDFLAGS := $$($1_LDFLAGS_$$(name)), \
|
2024-08-29 07:29:12 +00:00
|
|
|
DISABLED_WARNINGS_gcc := format undef unused-but-set-variable \
|
|
|
|
unused-const-variable unused-function unused-value \
|
|
|
|
unused-variable, \
|
2024-08-30 16:43:16 +00:00
|
|
|
DISABLED_WARNINGS_clang := format-nonliteral \
|
|
|
|
missing-field-initializers sometimes-uninitialized undef \
|
|
|
|
unused-but-set-variable unused-function unused-variable, \
|
2024-04-05 08:37:41 +00:00
|
|
|
DEFAULT_LIBCXX := false, \
|
2024-04-11 09:40:12 +00:00
|
|
|
JDK_LIBS := $$($1_JDK_LIBS_$$(name)), \
|
2018-03-15 18:33:04 +00:00
|
|
|
LIBS := $$($1_LIBS_$$(name)), \
|
2024-04-05 08:37:41 +00:00
|
|
|
DEFAULT_VERSIONINFO_RESOURCE := false, \
|
2024-09-03 15:31:09 +00:00
|
|
|
OPTIMIZATION := $$(if $$($1_OPTIMIZATION_$$(name)), $$($1_OPTIMIZATION_$$(name)), LOW), \
|
2023-09-12 20:17:52 +00:00
|
|
|
COPY_DEBUG_SYMBOLS := $$($1_COPY_DEBUG_SYMBOLS), \
|
2024-09-03 15:31:09 +00:00
|
|
|
STRIP_SYMBOLS := $$(if $$($1_STRIP_SYMBOLS_$$(name)), $$($1_STRIP_SYMBOLS_$$(name)), false), \
|
2023-01-23 20:51:13 +00:00
|
|
|
BUILD_INFO_LOG_MACRO := LogInfo, \
|
2016-01-20 08:53:52 +00:00
|
|
|
)) \
|
2023-01-23 20:51:13 +00:00
|
|
|
$$(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)) \
|
2015-02-27 10:56:57 +00:00
|
|
|
)
|
|
|
|
|
2023-01-23 20:51:13 +00:00
|
|
|
# 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
|
2024-04-05 08:37:41 +00:00
|
|
|
# SetupJdkNativeCompilation.
|
2023-01-23 20:51:13 +00:00
|
|
|
$$($1_BUILD_INFO): $$($1_BUILD_INFO_DEPS)
|
|
|
|
$$(call LogWarn, $$(strip Creating $$(words $$(filter-out %.vardeps, $$?)) \
|
|
|
|
test $$($1_LOG_TYPE) file(s) for $1))
|
|
|
|
$(TOUCH) $$@
|
|
|
|
|
2015-02-27 10:56:57 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
endif # _TEST_FILES_COMPILATION_GMK
|