# -*- 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/.
#
##############################
# DotnetLibrary Target Class #
##############################
####### Constant Strings #########
gb_DotnetLibrary__CONFIG_RELEASE := -c Release
gb_DotnetLibrary__CONFIG_DEBUG := -c Debug
####### Helper Functions #########
define gb_DotnetLibrary__get_build_config
$(if $(or \
$(filter TRUE,$(strip $(debug))), \
$(filter TRUE,$(strip $(ENABLE_DBGUTIL))) \
), \
$(gb_DotnetLibrary__CONFIG_DEBUG), \
$(gb_DotnetLibrary__CONFIG_RELEASE))
endef
define gb_DotnetLibrary__escape_quotes
$(strip $(subst ",\",$(1)))
endef
####### Build and Clean Targets #########
.PHONY : $(call gb_DotnetLibrary_get_clean_target,%)
$(call gb_DotnetLibrary_get_clean_target,%) :
$(call gb_Output_announce,$*,$(false),NET,4)
$(call gb_Helper_abbreviate_dirs,\
rm -rf $(call gb_DotnetLibrary_get_target,$*))
$(call gb_DotnetLibrary_get_target,%) :
$(call gb_Output_announce,$*,$(true),NET,4)
$(call gb_Trace_StartRange,$*,NET)
$(call gb_Helper_abbreviate_dirs,\
mkdir -p $(call gb_DotnetLibrary_get_workdir,$*) && \
P=$(DOTNET_PROJECT_FILE) && \
echo "" > $$P && \
echo "" >> $$P && \
echo "$(DOTNET_PROPERTY_ELEMENTS)" >> $$P && \
echo "" >> $$P && \
echo "" >> $$P && \
echo "$(DOTNET_ITEM_ELEMENTS)" >> $$P && \
echo "" >> $$P && \
echo "" >> $$P && \
dotnet build $$P $(DOTNET_BUILD_FLAGS) \
-o $(call gb_DotnetLibrary_get_workdir,$*) \
> $@.log 2>&1 || \
(echo \
&& cat $@.log \
&& echo \
&& echo "A library failed to build. To retry the build, use:" \
&& echo " make DotnetLibrary_$*" \
&& echo "cd into the module directory to run the build faster" \
&& echo \
&& false) && \
touch $@)
$(call gb_Trace_EndRange,$*,NET)
####### Library Target Constructors #########
define gb_DotnetLibrary__common_ctor
$(call gb_DotnetLibrary_get_target,$(1)) : DOTNET_BUILD_FLAGS := $(strip $(call gb_DotnetLibrary__get_build_config))
$(call gb_DotnetLibrary_get_target,$(1)) : DOTNET_PROPERTY_ELEMENTS := netstandard20
$(call gb_DotnetLibrary_get_target,$(1)) : DOTNET_ITEM_ELEMENTS :=
$(call gb_DotnetLibrary_get_target,$(1)) : DOTNET_PROJECT_FILE := $(call gb_DotnetLibrary_get_workdir,$(1))/$(1).$(2)
$(eval $(call gb_Module_register_target, \
$(call gb_DotnetLibrary_get_target,$(1)), \
$(call gb_DotnetLibrary_get_clean_target,$(1))))
$(call gb_Helper_make_userfriendly_targets,$(1),DotnetLibrary)
endef
# Generates one csproj file from given inputs and builds it
# call gb_DotnetLibrary_CsLibrary,targetname
define gb_DotnetLibrary_CsLibrary
$(call gb_DotnetLibrary__common_ctor,$(1),csproj)
endef
# Generates one fsproj file from given inputs and builds it
# call gb_DotnetLibrary_FsLibrary,targetname
define gb_DotnetLibrary_FsLibrary
$(call gb_DotnetLibrary__common_ctor,$(1),fsproj)
endef
# Generates one vbproj file from given inputs and builds it
# call gb_DotnetLibrary_VbLibrary,targetname
define gb_DotnetLibrary_VbLibrary
$(call gb_DotnetLibrary__common_ctor,$(1),vbproj)
endef
####### Target Property Setters #########
# Add flags used for compilation
# call gb_DotnetLibrary_add_build_flags,target,flags
define gb_DotnetLibrary_add_build_flags
$(call gb_DotnetLibrary_get_target,$(1)) : DOTNET_BUILD_FLAGS += $(2)
endef
# Add elements to the project file
# call gb_DotnetLibrary_add_properties,target,properties
define gb_DotnetLibrary_add_properties
$(call gb_DotnetLibrary_get_target,$(1)) : DOTNET_PROPERTY_ELEMENTS += $(strip $(call gb_DotnetLibrary__escape_quotes,$(2)))
endef
# Add elements to the project file
# call gb_DotnetLibrary_add_items,target,items
define gb_DotnetLibrary_add_items
$(call gb_DotnetLibrary_get_target,$(1)) : DOTNET_ITEM_ELEMENTS += $(strip $(call gb_DotnetLibrary__escape_quotes,$(2)))
endef
# Add one source file to the project file
# This adds it to the project, and makes it a build dependency
# so the library is rebuilt if the source changes
# call gb_DotnetLibrary_add_source,target,basedir,source
define gb_DotnetLibrary_add_source
$(call gb_DotnetLibrary_get_target,$(1)) : $(strip $(2))/$(strip $(3))
$(call gb_DotnetLibrary_add_items,$(1),)
endef
# Add source files to the project file
# This adds them to the project, and makes it them build dependency
# so the library is rebuilt if the sources change
# call gb_DotnetLibrary_add_sources,target,basedir,sources
define gb_DotnetLibrary_add_sources
$(foreach source,$(3),$(call gb_DotnetLibrary_add_source,$(1),$(2),$(source)))
endef
# Add one generated source file to the project file,
# This is not marked as makefile build dependency,
# so the library is NOT rebuilt if this source changes
# Useful for things like source globs supported by .net projects
# call gb_DotnetLibrary_add_generated_source,target,basedir,source
define gb_DotnetLibrary_add_generated_source
$(call gb_DotnetLibrary_add_items,$(1),)
endef
# Add generated source files to the project file,
# These are not marked as makefile build dependencies,
# so the library is NOT rebuilt if these sources change
# Useful for things like source globs supported by .net projects
# call gb_DotnetLibrary_add_generated_sources,target,basedir,sources
define gb_DotnetLibrary_add_generated_sources
$(foreach source,$(3),$(call gb_DotnetLibrary_add_generated_source,$(1),$(2),$(source)))
endef
# Link to a DotnetLibrary_CsLibrary target
# call gb_DotnetLibrary_link_cs_library,target,library
define gb_DotnetLibrary_link_cs_library
$(call gb_DotnetLibrary_get_target,$(1)) : $(call gb_DotnetLibrary_get_target,$(strip $(2)))
$(call gb_DotnetLibrary_add_items,$(1),)
endef
# Link to a DotnetLibrary_FsLibrary target
# call gb_DotnetLibrary_link_fs_library,target,library
define gb_DotnetLibrary_link_fs_library
$(call gb_DotnetLibrary_get_target,$(1)) : $(call gb_DotnetLibrary_get_target,$(strip $(2)))
$(call gb_DotnetLibrary_add_items,$(1),)
endef
# Link to a DotnetLibrary_VbLibrary target
# call gb_DotnetLibrary_link_vb_library,target,library
define gb_DotnetLibrary_link_vb_library
$(call gb_DotnetLibrary_get_target,$(1)) : $(call gb_DotnetLibrary_get_target,$(strip $(2)))
$(call gb_DotnetLibrary_add_items,$(1),)
endef
# vim: set noet sw=4 ts=4: