Branch libreoffice-5-0-4
[LibreOffice.git] / solenv / gbuild / CliLibrary.mk
blob8c863a72e05ae0378de5fa3770bb0c92778dc20d
1 # -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
3 # This file is part of the LibreOffice project.
5 # This Source Code Form is subject to the terms of the Mozilla Public
6 # License, v. 2.0. If a copy of the MPL was not distributed with this
7 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # CliLibrary class
12 gb_CliLibrary_EXT := $(gb_CliAssembly_POLICYEXT)
14 gb_CliLibrary_CSCFLAGS := \
15 -noconfig \
16 -nologo \
18 gb_CliLibrary_CSCFLAGS_DEBUG := \
19 -checked+ \
20 -define:DEBUG \
21 -define:TRACE \
23 ifeq ($(strip $(debug)),)
24 ifeq ($(strip $(ENABLE_DBGUTIL)),TRUE)
25 gb_CliLibrary__get_csflags = $(gb_CliLibrary_CSCFLAGS) $(gb_CliLibrary_CSCFLAGS_DEBUG)
26 else
27 gb_CliLibrary__get_csflags = $(gb_CliLibrary_CSCFLAGS) -o
28 endif
29 else
30 gb_CliLibrary__get_csflags = $(gb_CliLibrary_CSCFLAGS) $(gb_CliLibrary_CSCFLAGS_DEBUG) -debug+
31 endif
33 gb_CliLibrary__get_source = $(SRCDIR)/$(1).cs
34 gb_CliLibrary__get_generated_source = $(WORKDIR)/$(1).cs
36 # csc has silly problems handling files passed on command line
37 define gb_CliLibrary__command
38 $(call gb_Output_announce,$(2),$(true),CSC,3)
39 csc \
40 $(call gb_CliLibrary__get_csflags) \
41 $(CLI_CSCFLAGS) \
42 -target:library \
43 -out:$(1) \
44 -keyfile:$(CLI_KEYFILE) \
45 -reference:System.dll \
46 $(foreach assembly,$(CLI_ASSEMBLIES),-reference:$(assembly)) \
47 $(subst /,\,$(CLI_SOURCES)) \
50 endef
52 .PHONY : $(call gb_CliLibrary_get_clean_target,%)
53 $(call gb_CliLibrary_get_clean_target,%) :
54 $(call gb_Output_announce,$*,$(false),CSC,3)
55 $(call gb_Helper_abbreviate_dirs,\
56 rm -f $(call gb_CliLibrary_get_target,$*) \
60 # Compiles one or more C# source files
62 # gb_CliLibrary_CliLibrary target
63 define gb_CliLibrary_CliLibrary
64 $(call gb_CliAssembly_CliAssembly,$(1),$(call gb_CliLibrary_get_target,$(1)))
66 $(call gb_CliLibrary_get_target,$(1)) : CLI_ASSEMBLIES :=
67 $(call gb_CliLibrary_get_target,$(1)) : CLI_SOURCES :=
68 $(call gb_CliLibrary_get_target,$(1)) : CLI_CSCFLAGS :=
69 $(call gb_CliLibrary_get_target,$(1)) : CLI_KEYFILE :=
72 $(call gb_CliLibrary_get_target,$(1)) :| $(call gb_CliAssembly_get_target,$(1))
73 $(call gb_CliLibrary_get_target,$(1)) :| $(dir $(call gb_CliLibrary_get_target,$(1))).dir
74 $(call gb_CliLibrary_get_clean_target,$(1)) : $(call gb_CliAssembly_get_clean_target,$(1))
76 $$(eval $$(call gb_Module_register_target,$(call gb_CliLibrary_get_target,$(1)),$(call gb_CliLibrary_get_clean_target,$(1))))
77 $(call gb_Helper_make_userfriendly_targets,$(1),CliLibrary)
79 $(call gb_CliLibrary_get_target,$(1)) :
80 $$(call gb_CliLibrary__command,$$@,$(1))
82 endef
84 define gb_CliLibrary_set_configfile
85 $(call gb_CliAssembly_set_configfile,$(1),$(2))
87 endef
89 define gb_CliLibrary_set_keyfile
90 $(call gb_CliLibrary_get_target,$(1)) : CLI_KEYFILE := $(2)
91 $(call gb_CliAssembly_set_keyfile,$(1),$(2))
93 endef
95 define gb_CliLibrary_set_policy
96 $(call gb_CliAssembly_set_policy,$(1),$(2),$(3))
98 endef
100 define gb_CliLibrary_use_assembly
101 $(call gb_CliLibrary_get_target,$(1)) : CLI_ASSEMBLIES += $(call gb_CliLibrary_get_target,$(2))
102 $(call gb_CliLibrary_get_target,$(1)) : $(call gb_CliLibrary_get_target,$(2))
104 endef
106 define gb_CliLibrary_use_assemblies
107 $(foreach assembly,$(2),$(call gb_CliLibrary_use_assembly,$(1),$(assembly)))
109 endef
111 # Add a source file to compile
112 define gb_CliLibrary_add_csfile
113 $(call gb_CliLibrary_get_target,$(1)) : CLI_SOURCES += $(call gb_CliLibrary__get_source,$(2))
114 $(call gb_CliLibrary_get_target,$(1)) : $(call gb_CliLibrary__get_source,$(2))
116 endef
118 # Add source files to compile
119 define gb_CliLibrary_add_csfiles
120 $(foreach csfile,$(2),$(call gb_CliLibrary_add_csfile,$(1),$(csfile)))
122 endef
124 # Add a generated source file to compile
125 define gb_CliLibrary_add_generated_csfile
126 $(call gb_CliLibrary_get_target,$(1)) : CLI_SOURCES += $(call gb_CliLibrary__get_generated_source,$(2))
127 $(call gb_CliLibrary_get_target,$(1)) : $(call gb_CliLibrary__get_generated_source,$(2))
129 endef
131 # Add generated source files to compile
132 define gb_CliLibrary_add_generated_csfiles
133 $(foreach csfile,$(2),$(call gb_CliLibrary_add_generated_csfile,$(1),$(csfile)))
135 endef
137 # Add flags used for compilation
138 define gb_CliLibrary_add_csflags
139 $(call gb_CliLibrary_get_target,$(1)) : CLI_CSCFLAGS += $(2)
141 endef
143 # vim: set noet sw=4 ts=4: