jdk

Форк
0
/
LinkMicrosoft.gmk 
115 строк · 4.8 Кб
1
#
2
# Copyright (c) 2011, 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
################################################################################
27
# This file contains functionality related to linking a native binary;
28
# creating either a dynamic library, a static library or an executable.
29

30
################################################################################
31
define CreateLinkedResultMicrosoft
32
  ifeq ($$($1_TYPE), STATIC_LIBRARY)
33
    $$(eval $$(call CreateStaticLibraryMicrosoft,$1))
34
  else
35
    $$(eval $$(call CreateDynamicLibraryOrExecutableMicrosoft,$1))
36
  endif
37
endef
38

39
################################################################################
40
define CreateStaticLibraryMicrosoft
41
  $1_VARDEPS := $$($1_LIB) $$(LIBFLAGS) $$($1_LIBS) \
42
      $$($1_EXTRA_LIBS)
43
  $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
44
      $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
45

46
  $1_TARGET_DEPS :=  $$($1_ALL_OBJS) $$($1_RES) $$($1_EXTRA_LINK_DEPS) \
47
      $$($1_VARDEPS_FILE)
48

49
  $$($1_TARGET): $$($1_TARGET_DEPS)
50
        ifneq ($$($1_OBJ_FILE_LIST), )
51
	  $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST)))
52
        endif
53
	$$(call LogInfo, Building static library $$($1_BASENAME))
54
	$$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR))
55
	$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_run_lib, \
56
	    $$($1_LIB) -nologo $$(LIBFLAGS) -out:$$($1_TARGET) \
57
	        $$($1_LD_OBJ_ARG) $$($1_RES))
58
endef
59

60
################################################################################
61
define CreateDynamicLibraryOrExecutableMicrosoft
62
  ifeq ($$($1_EMBED_MANIFEST), true)
63
    $1_EXTRA_LDFLAGS += -manifest:embed
64
  endif
65

66
  $1_IMPORT_LIBRARY := $$($1_OBJECT_DIR)/$$($1_NAME).lib
67
  $1_EXTRA_LDFLAGS += "-implib:$$($1_IMPORT_LIBRARY)"
68

69
  ifeq ($$($1_TYPE), LIBRARY)
70
    # To properly trigger downstream dependants of the import library, just as
71
    # for debug files, we must have a recipe in the rule. To avoid rerunning
72
    # the recipe every time have it touch the target. If an import library
73
    # file is deleted by something external, explicitly delete the target to
74
    # trigger a rebuild of both.
75
    ifneq ($$(wildcard $$($1_IMPORT_LIBRARY)), $$($1_IMPORT_LIBRARY))
76
      $$(call LogDebug, Deleting $$($1_BASENAME) because import library is missing)
77
      $$(shell $(RM) $$($1_TARGET))
78
    endif
79
    $$($1_IMPORT_LIBRARY): $$($1_TARGET)
80
	$(TOUCH) $$@
81

82
    $1 += $$($1_IMPORT_LIBRARY)
83
  endif
84

85
  $1_VARDEPS := $$($1_LD) $$($1_SYSROOT_LDFLAGS) $$($1_LDFLAGS) \
86
      $$($1_EXTRA_LDFLAGS) $$($1_LIBS) $$($1_EXTRA_LIBS) $$($1_MT) \
87
      $$($1_MANIFEST_VERSION)
88

89
  $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, \
90
      $$($1_OBJECT_DIR)/$$($1_NOSUFFIX).vardeps)
91

92
  $1_TARGET_DEPS := $$($1_ALL_OBJS) $$($1_RES) $$($1_MANIFEST) \
93
      $$($1_EXTRA_LINK_DEPS) $$($1_VARDEPS_FILE)
94

95
  $$($1_TARGET): $$($1_TARGET_DEPS)
96
        ifneq ($$($1_OBJ_FILE_LIST), )
97
	  $$(eval $$(call ListPathsSafely, $1_ALL_OBJS, $$($1_OBJ_FILE_LIST)))
98
        endif
99
	$$(call LogInfo, Linking $$($1_BASENAME))
100
	$$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR))
101
	$$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_run_ld, \
102
	    $$($1_LD) -nologo $$($1_LDFLAGS) $$($1_EXTRA_LDFLAGS) \
103
	        $$($1_SYSROOT_LDFLAGS) -out:$$($1_TARGET) $$($1_LD_OBJ_ARG) \
104
	        $$($1_RES) $$($1_LIBS) $$($1_EXTRA_LIBS)) \
105
	    | $(GREP) -v "^   Creating library .*\.lib and object .*\.exp" || \
106
	        test "$$$$?" = "1"
107
        ifeq ($(call isBuildOsEnv, windows.wsl2), true)
108
	  $$(CHMOD) +x $$($1_TARGET)
109
        endif
110
        ifneq ($$($1_MANIFEST), )
111
	  $$($1_MT) -nologo -manifest $$($1_MANIFEST) \
112
	      -identity:"$$($1_NAME).exe, version=$$($1_MANIFEST_VERSION)" \
113
	      -outputresource:$$@;#1
114
        endif
115
endef
116

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

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

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

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