summaryrefslogtreecommitdiff
path: root/solenv/gbuild/CliLibrary.mk
blob: ef56488643f7496649556ccd6262953d7c8510cd (plain)
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

# CliSignTarget class

define gb_CliSignTarget__command
$(call gb_Output_announce,$(1),$(true),SN ,4)
$(call gb_Helper_abbreviate_dirs,\
	$(GNUCOPY) $(CLI_SIGN_LIBRARY) $(1).tmp && \
	sn -R $(1).tmp $(CLI_SIGN_KEYFILE) && \
	mv $(1).tmp $(1) \
)
endef

$(dir $(call gb_CliSignTarget_get_target,%)).dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

$(dir $(call gb_CliSignTarget_get_target,%))%/.dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

$(call gb_CliSignTarget_get_target,%) :
	$(call gb_CliSignTarget__command,$@,$*,$<)

$(call gb_CliSignTarget_get_external_target,%) :
	touch $@

.PHONY : $(call gb_CliSignTarget_get_clean_target,%)
$(call gb_CliSignTarget_get_clean_target,%) :
	$(call gb_Output_announce,$*,$(false),SN ,4)
	$(call gb_Helper_abbreviate_dirs,\
		rm -rf $(call gb_CliSignTarget_get_target,$*) \
			 $(call gb_CliSignTarget_get_external_target,$*) \
	)

# Sign a native assembly.
#
# gb_CliSignTarget_CliSignTarget assembly
define gb_CliSignTarget_CliSignTarget
$(call gb_CliSignTarget_get_target,$(1)) : CLI_SIGN_KEYFILE :=
$(call gb_CliSignTarget_get_target,$(1)) : CLI_SIGN_LIBRARY := $(2)

$(call gb_CliSignTarget_get_external_target,$(1)) :| $(dir $(call gb_CliSignTarget_get_target,$(1))).dir
$(call gb_CliSignTarget_get_target,$(1)) :| $(dir $(call gb_CliSignTarget_get_target,$(1))).dir

endef

# Set the sign key file for the assembly.
#
# The file is given by complete path.
# 
# gb_CliSignTarget_set_keyfile assembly keyfile
define gb_CliSignTarget_set_keyfile
$(call gb_CliSignTarget_get_target,$(1)) : CLI_SIGN_KEYFILE := $(2)
$(call gb_CliSignTarget_get_target,$(1)) : $(2)

endef

# Use another assembly for compilation.
#
# gb_CliSignTarget_use_assembly assembly dep
define gb_CliSignTarget_use_assembly
$(call gb_CliSignTarget_get_external_target,$(1)) : $(call gb_CliAssemblyTarget_get_target,$(2))

endef

# Use other assemblies for compilation.
#
# gb_CliSignTarget_use_assemblies assembly dep(s)
define gb_CliSignTarget_use_assemblies
$(foreach assembly,$(2),$(call gb_CliSignTarget_use_assembly,$(1),$(assembly)))

endef

# CliLibrary class

# Handles creation of a CLI assembly from C++ sources.

# platform defined
#  gb_CliLibrary_LIBS
#  gb_CliLibrary_CliLibrary_platform
#  gb_CliLibrary_get_dll
#  gb_CliLibrary_add_delayload_dll
#  gb_CliLibrary_set_link_keyfile

gb_CliLibrary_PLATFORM_DEFAULT := x86

$(dir $(call gb_CliLibrary_get_target,%)).dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

$(dir $(call gb_CliLibrary_get_target,%))%/.dir :
	$(if $(wildcard $(dir $@)),,mkdir -p $(dir $@))

$(call gb_CliLibrary_get_target,%) :
	touch $@

.PHONY : $(call gb_CliLibrary_get_clean_target,%)
$(call gb_CliLibrary_get_clean_target,%) :
	rm -f $(call gb_CliLibrary_get_target,$*)

gb_CliLibrary_get_linktargetname = CliLibrary/$(1)

# Create a CLI assembly from C++ sources.
#
# gb_CliLibrary assembly
define gb_CliLibrary_CliLibrary
$(call gb_CliLibrary__CliLibrary_impl,$(1),$(call gb_CliLibrary_get_linktargetname,$(1)))

endef

define gb_CliLibrary__CliLibrary_impl
$(call gb_LinkTarget_LinkTarget,$(2),CliLibrary_$(1))
$(call gb_CliSignTarget_CliSignTarget,$(1),$(call gb_CliLibrary_get_dll,$(1)))
$(call gb_CliAssemblyTarget_CliAssemblyTarget,$(1),$(call gb_CliSignTarget_get_target,$(1)))

$(call gb_LinkTarget_set_targettype,$(2),CliLibrary)
$(call gb_LinkTarget_add_defs,$(2),gb_CliLibrary_DEFS)
$(call gb_LinkTarget_add_libs,$(2),gb_CliLibrary_LIBS)

$(call gb_CliLibrary_CliLibrary_platform,$(1),$(2),$(call gb_CliLibrary_get_dll,$(1)))

$(call gb_CliSignTarget_set_keyfile,$(1),$(gb_CliAssemblyTarget_KEYFILE_DEFAULT))
$(call gb_CliAssemblyTarget_set_platform,$(1),$(gb_CliLibrary_PLATFORM_DEFAULT))

$(call gb_CliSignTarget_get_target,$(1)) : $(call gb_LinkTarget_get_target,$(2))
$(call gb_CliLibrary_get_target,$(1)) : $(call gb_CliSignTarget_get_target,$(1))
$(call gb_CliLibrary_get_target,$(1)) : $(call gb_CliAssemblyTarget_get_target,$(1))
$(call gb_CliLibrary_get_target,$(1)) :| $(dir $(call gb_CliLibrary_get_target,$(1))).dir

$(call gb_CliLibrary_get_clean_target,$(1)) : $(call gb_LinkTarget_get_clean_target,$(1))
$(call gb_CliLibrary_get_clean_target,$(1)) : $(call gb_CliSignTarget_get_clean_target,$(1))
$(call gb_CliLibrary_get_clean_target,$(1)) : $(call gb_CliAssemblyTarget_get_clean_target,$(1))

$$(eval $$(call gb_Module_register_target,$(call gb_CliLibrary_get_target,$(1)),$(call gb_CliLibrary_get_clean_target,$(1))))

endef

# Set the configuration file for the assembly.
#
# The file is given by complete path.
# 
# gb_CliLibrary_set_configfile assembly configfile
define gb_CliLibrary_set_configfile
$(call gb_CliAssemblyTarget_set_configfile,$(1),$(2))

endef

# Set the sign key file for the assembly.
#
# The file is given by complete path.
# 
# gb_CliLibrary_set_keyfile assembly keyfile
define gb_CliLibrary_set_keyfile
$(call gb_CliSignTarget_set_keyfile,$(1),$(2))
$(call gb_CliAssemblyTarget_set_keyfile,$(1),$(2))
$(call gb_CliLibrary_set_link_keyfile,$(1),$(2))

endef

# Set the platform of the assembly.
# TODO is this really needed?
#
# gb_CliLibrary_set_platform assembly platform
define gb_CliLibrary_set_platform
$(call gb_CliAssemblyTarget_set_platform,$(1),$(2))

endef

# Set the policy file for the assembly.
#
# The file is given by complete path.
#
# gb_CliLibrary_set_policy assembly policyfile version
define gb_CliLibrary_set_policy
$(call gb_CliAssemblyTarget_set_policy,$(1),$(2),$(3))

endef

# Use another assembly for compilation.
#
# gb_CliLibrary_use_assembly assembly dep
define gb_CliLibrary_use_assembly
$(call gb_CliSignTarget_use_assembly,$(1),$(2))

endef

# Use other assemblies for compilation.
#
# gb_CliLibrary_use_assemblies assembly dep(s)
define gb_CliLibrary_use_assemblies
$(call gb_CliSignTarget_use_assemblies,$(call gb_CliLibrary_get_linktargetname,$(1)),$(2))

endef

# Use a public UNO API library.
#
# E.g., cppu, sal.
#
# gb_CliLibrary_use_api_library assembly library
define gb_CliLibrary_use_api_library
$(call gb_LinkTarget_use_library,$(call gb_CliLibrary_get_linktargetname,$(1)),$(2))
$(call gb_CliLibrary_add_delayload_dll,$(1),$(2))

endef

# Use public UNO API libraries.
#
# E.g., cppu, sal.
#
# gb_CliLibrary_use_api_libraries assembly library
define gb_CliLibrary_use_api_libraries
$(foreach library,$(2),$(call gb_CliLibrary_use_api_library,$(1),$(library)))

endef

# straight forwards to LinkTarget

define gb_CliLibrary_use_internal_bootstrap_api
$(call gb_Library_use_internal_bootstrap_api,$(call gb_CliLibrary_get_linktargetname,$(1)),$(2))

endef

define gb_CliLibrary_use_packages
$(call gb_Library_use_packages,$(call gb_CliLibrary_get_linktargetname,$(1)),$(2))

endef

define gb_CliLibrary_add_exception_objects
$(call gb_Library_add_exception_objects,$(call gb_CliLibrary_get_linktargetname,$(1)),$(2))

endef

define gb_CliLibrary_add_generated_exception_objects
$(call gb_Library_add_generated_exception_objects,$(call gb_CliLibrary_get_linktargetname,$(1)),$(2))

endef

# vim: set noet sw=4 ts=4: