summaryrefslogtreecommitdiffstats
path: root/solenv/gbuild/CliLibrary.mk
blob: e6af838919255a3c2c3f7aff537731dd226ce0c8 (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
# -*- 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/.
#

# CliLibrary class

gb_CliLibrary_EXT := $(gb_CliAssembly_POLICYEXT)

gb_CliLibrary_CSCFLAGS := \
	-noconfig \
	-nologo \

gb_CliLibrary_CSCFLAGS_DEBUG := \
	-checked+ \
	-define:DEBUG \
	-define:TRACE \

ifeq ($(strip $(debug)),)
ifeq ($(strip $(ENABLE_DBGUTIL)),TRUE)
gb_CliLibrary__get_csflags = $(gb_CliLibrary_CSCFLAGS) $(gb_CliLibrary_CSCFLAGS_DEBUG)
else
gb_CliLibrary__get_csflags = $(gb_CliLibrary_CSCFLAGS) -o
endif
else
gb_CliLibrary__get_csflags = $(gb_CliLibrary_CSCFLAGS) $(gb_CliLibrary_CSCFLAGS_DEBUG) -debug+
endif

gb_CliLibrary__get_source = $(SRCDIR)/$(1).cs
gb_CliLibrary__get_generated_source = $(WORKDIR)/$(1).cs

# csc has silly problems handling files passed on command line
define gb_CliLibrary__command
	csc \
		$(call gb_CliLibrary__get_csflags) \
		$(CLI_CSCFLAGS) \
		-target:library \
		-out:$(1) \
		$(if $(call gb_LinkTarget__symbols_enabled,$(1)),\
			-debug:pdbonly \
			-pdb:$(call gb_LinkTarget__get_pdb_filename,$(WORKDIR)/LinkTarget/Library/$(notdir $(1)))) \
		-keyfile:$(CLI_KEYFILE) \
		-reference:System.dll \
		$(foreach assembly,$(CLI_ASSEMBLIES),-reference:$(assembly)) \
		$(subst /,\,$(CLI_SOURCES)) \


endef

.PHONY : $(call gb_CliLibrary_get_clean_target,%)
$(call gb_CliLibrary_get_clean_target,%) :
	$(call gb_Output_announce,$*,$(false),CSC,3)
	$(call gb_Helper_abbreviate_dirs,\
		rm -f $(call gb_CliLibrary_get_target,$*) \
	)


# Compiles one or more C# source files
#
# gb_CliLibrary_CliLibrary target
define gb_CliLibrary_CliLibrary
$(call gb_CliAssembly_CliAssembly,$(1),$(call gb_CliLibrary_get_target,$(1)))

$(call gb_CliLibrary_get_target,$(1)) : CLI_ASSEMBLIES :=
$(call gb_CliLibrary_get_target,$(1)) : CLI_SOURCES :=
$(call gb_CliLibrary_get_target,$(1)) : CLI_CSCFLAGS :=
$(call gb_CliLibrary_get_target,$(1)) : CLI_KEYFILE :=


$(call gb_CliLibrary_get_target,$(1)) :| $(call gb_CliAssembly_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_CliAssembly_get_clean_target,$(1))

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

$(call gb_CliLibrary_get_target,$(1)) :
	$$(call gb_Output_announce,$(1),$(true),CSC,3)
	$$(call gb_Trace_StartRange,$(1),CSC)
	$$(call gb_CliLibrary__command,$$@,$(1))
	$$(call gb_Trace_EndRange,$(1),CSC)

endef

define gb_CliLibrary_set_configfile
$(call gb_CliAssembly_set_configfile,$(1),$(2),$(3))

endef

define gb_CliLibrary_set_keyfile
$(call gb_CliLibrary_get_target,$(1)) : CLI_KEYFILE := $(2)
$(call gb_CliAssembly_set_keyfile,$(1),$(2))

endef

define gb_CliLibrary_set_policy
$(call gb_CliAssembly_set_policy,$(1),$(2),$(3))

endef

define gb_CliLibrary_use_assembly
$(call gb_CliLibrary_get_target,$(1)) : CLI_ASSEMBLIES += $(call gb_CliLibrary_get_target,$(2))
$(call gb_CliLibrary_get_target,$(1)) : $(call gb_CliLibrary_get_target,$(2))

endef

define gb_CliLibrary_use_assemblies
$(foreach assembly,$(2),$(call gb_CliLibrary_use_assembly,$(1),$(assembly)))

endef

# Add a source file to compile
define gb_CliLibrary_add_csfile
$(call gb_CliLibrary_get_target,$(1)) : CLI_SOURCES += $(call gb_CliLibrary__get_source,$(2))
$(call gb_CliLibrary_get_target,$(1)) : $(call gb_CliLibrary__get_source,$(2))

endef

# Add source files to compile
define gb_CliLibrary_add_csfiles
$(foreach csfile,$(2),$(call gb_CliLibrary_add_csfile,$(1),$(csfile)))

endef

# Add a generated source file to compile
define gb_CliLibrary_add_generated_csfile
$(call gb_CliLibrary_get_target,$(1)) : CLI_SOURCES += $(call gb_CliLibrary__get_generated_source,$(2))
$(call gb_CliLibrary_get_target,$(1)) : $(call gb_CliLibrary__get_generated_source,$(2))

endef

# Add generated source files to compile
define gb_CliLibrary_add_generated_csfiles
$(foreach csfile,$(2),$(call gb_CliLibrary_add_generated_csfile,$(1),$(csfile)))

endef

# Add flags used for compilation
define gb_CliLibrary_add_csflags
$(call gb_CliLibrary_get_target,$(1)) : CLI_CSCFLAGS += $(2)

endef

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