jdk

Форк
0
/
TestFilesCompilation.gmk 
142 строки · 5.8 Кб
1
#
2
# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
3
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
#
5
# This code is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License version 2 only, as
7
# published by the Free Software Foundation.  Oracle designates this
8
# particular file as subject to the "Classpath" exception as provided
9
# by Oracle in the LICENSE file that accompanied this code.
10
#
11
# This code is distributed in the hope that it will be useful, but WITHOUT
12
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
# version 2 for more details (a copy is included in the LICENSE file that
15
# accompanied this code).
16
#
17
# You should have received a copy of the GNU General Public License version
18
# 2 along with this work; if not, write to the Free Software Foundation,
19
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
#
21
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
# or visit www.oracle.com if you need additional information or have any
23
# questions.
24
#
25

26
ifndef _TEST_FILES_COMPILATION_GMK
27
_TEST_FILES_COMPILATION_GMK := 1
28

29
ifeq (,$(_MAKEBASE_GMK))
30
  $(error You must include MakeBase.gmk prior to including TestFilesCompilation.gmk)
31
endif
32

33

34
include JdkNativeCompilation.gmk
35

36
# Setup make rules for creating a set of native test files (libraries or
37
# executables). This will locate native files matching a certain pattern,
38
# and compile these into libraries or executables.
39
#
40
# Parameter 1 is the name of the rule. This name is used as variable prefix,
41
# and the targets generated are listed in a variable by that name.
42
#
43
# Remaining parameters are named arguments. These include:
44
#   TYPE Must be either PROGRAM or LIBRARY.
45
#   SOURCE_DIRS A list of source directories to search
46
#   OUTPUT_DIR Where to put the resulting files
47
#   EXCLUDE A list of filenames to exclude from compilation
48
#   EXTRA_FILES List of extra files not in SOURCE_DIRS
49
SetupTestFilesCompilation = $(NamedParamsMacroTemplate)
50
define SetupTestFilesCompilationBody
51

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

59
  # The list to depend on starts out empty
60
  $1 :=
61
  ifeq ($$($1_TYPE), LIBRARY)
62
    $1_PREFIX = lib
63
    $1_OUTPUT_SUBDIR := lib
64
    $1_COMPILATION_TYPE := LIBRARY
65
    $1_LOG_TYPE := library
66
  else ifeq ($$($1_TYPE), PROGRAM)
67
    $1_PREFIX = exe
68
    $1_OUTPUT_SUBDIR := bin
69
    $1_COMPILATION_TYPE := EXECUTABLE
70
    $1_LOG_TYPE := executable
71
    $1_LD_SET_ORIGIN := false
72
  else
73
    $$(error Unknown type: $$($1_TYPE))
74
  endif
75

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

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

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

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

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

97
  # Setup a compilation for each and every one of them
98
  $$(foreach file, $$($1_FILTERED_FILE_LIST),\
99
    $$(eval name := $$(strip $$(basename $$(notdir $$(file))))) \
100
    $$(eval unprefixed_name := $$(patsubst $$($1_PREFIX)%, %, $$(name))) \
101
    $$(eval $$(call SetupJdkNativeCompilation, BUILD_TEST_$$(name), \
102
        NAME := $$(unprefixed_name), \
103
        TYPE := $$($1_COMPILATION_TYPE), \
104
        LINK_TYPE := $(if $$(filter %.cpp, $$(file)), C++, C), \
105
        EXTRA_HEADER_DIRS := \
106
            java.base:libjava \
107
            java.base:libjvm, \
108
        EXTRA_FILES := $$(file) $$($1_EXTRA_FILES), \
109
        OBJECT_DIR := $$($1_OUTPUT_DIR)/support/$$(name), \
110
        OUTPUT_DIR := $$($1_OUTPUT_DIR)/$$($1_OUTPUT_SUBDIR), \
111
        CFLAGS := $$(TEST_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
112
        CXXFLAGS := $$(TEST_CFLAGS) $$($1_CFLAGS) $$($1_CFLAGS_$$(name)), \
113
        LD_SET_ORIGIN := $$($1_LD_SET_ORIGIN), \
114
        LDFLAGS := $$($1_LDFLAGS_$$(name)), \
115
        DISABLED_WARNINGS_gcc := format undef unused-function unused-value, \
116
        DISABLED_WARNINGS_clang := undef format-nonliteral \
117
            missing-field-initializers sometimes-uninitialized, \
118
        DEFAULT_LIBCXX := false, \
119
        JDK_LIBS := $$($1_JDK_LIBS_$$(name)), \
120
        LIBS := $$($1_LIBS_$$(name)), \
121
        DEFAULT_VERSIONINFO_RESOURCE := false, \
122
        OPTIMIZATION := $$(if $$($1_OPTIMIZATION_$$(name)),$$($1_OPTIMIZATION_$$(name)),LOW), \
123
        COPY_DEBUG_SYMBOLS := $$($1_COPY_DEBUG_SYMBOLS), \
124
        STRIP_SYMBOLS := $$(if $$($1_STRIP_SYMBOLS_$$(name)),$$($1_STRIP_SYMBOLS_$$(name)),false), \
125
        BUILD_INFO_LOG_MACRO := LogInfo, \
126
    )) \
127
    $$(eval $1 += $$(BUILD_TEST_$$(name)) ) \
128
    $$(eval $1_BUILD_INFO_DEPS += $$(BUILD_TEST_$$(name)_BUILD_INFO_DEPS)) \
129
    $$(eval $$(BUILD_TEST_$$(name)_BUILD_INFO): | $$($1_BUILD_INFO)) \
130
  )
131

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

140
endef
141

142
endif # _TEST_FILES_COMPILATION_GMK
143

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.