officecfg/CustomTarget_registry.mk         |    3 ++-
 postprocess/CustomTarget_components.mk     |    9 +++------
 postprocess/CustomTarget_registry.mk       |    5 ++---
 solenv/gbuild/HelpTarget.mk                |    2 +-
 solenv/gbuild/LinkTarget.mk                |   12 +++++-------
 solenv/gbuild/Package.mk                   |    3 +--
 solenv/gbuild/Tempfile.mk                  |   24 ------------------------
 solenv/gbuild/gbuild.mk                    |    5 ++++-
 static/CustomTarget_emscripten_fs_image.mk |    5 ++---
 9 files changed, 20 insertions(+), 48 deletions(-)

New commits:
commit 8b87e29c987c599058a70f6a2e0259a2a4100f04
Author:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
AuthorDate: Sat Dec 10 15:57:36 2022 +0100
Commit:     Christian Lohmaier <lohmaier+libreoff...@googlemail.com>
CommitDate: Tue Dec 13 15:05:43 2022 +0000

    use $(file …) directly instead of gb_var2file when not used as intermediate
    
    i.e. when the temporary file is not uses as a responsefile for another
    command, but instead the point of running gb_var2file is to have that
    file as a result in the end.
    
    also move the helper into the main gbuild.mk and remove Tempfile.mk
    
    Change-Id: I79382bef5d7e8a155ba6a8e0750c6a17da42eb37
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143912
    Tested-by: Jenkins
    Reviewed-by: Christian Lohmaier <lohmaier+libreoff...@googlemail.com>

diff --git a/officecfg/CustomTarget_registry.mk 
b/officecfg/CustomTarget_registry.mk
index 5c1048cd8521..55548e1ffe89 100644
--- a/officecfg/CustomTarget_registry.mk
+++ b/officecfg/CustomTarget_registry.mk
@@ -24,7 +24,8 @@ $(call 
gb_CustomTarget_get_workdir,officecfg/registry)/officecfg/officecfg_qa_al
                $(SRCDIR)/officecfg/files.mk
        $(call gb_Output_announce,officecfg_qa_allheaders.hxx,$(true),CAT,1)
        $(call gb_Trace_StartRange,officecfg_qa_allheaders.hxx,CAT)
-       mv $(call gb_var2file,$(shell mkdir -p $(dir $@) && cat /dev/null 
>$@.tmp && echo $@.tmp),$(foreach file,$(officecfg_XCSFILES),$(call 
officecfg_geninclude,$(file)))) $@
+       $(shell mkdir -p $(dir $@))
+       $(file >$@,$(foreach file,$(officecfg_XCSFILES),$(call 
officecfg_geninclude,$(file))))
        $(call gb_Trace_EndRange,officecfg_qa_allheaders.hxx,CAT)
 
 # pass the stem as space separated path elements and get a set of 
--stringparam ns<level> <element> in return
diff --git a/postprocess/CustomTarget_components.mk 
b/postprocess/CustomTarget_components.mk
index e193d2ce37c5..67969396fe3d 100644
--- a/postprocess/CustomTarget_components.mk
+++ b/postprocess/CustomTarget_components.mk
@@ -29,18 +29,15 @@ $(postprocess_WORKDIR)/services_componentfiles.list: \
     $(foreach comp,$(gb_ComponentTarget__ALLCOMPONENTS),$(call 
gb_ComponentTarget_get_target,$(comp))) \
     | $(postprocess_WORKDIR)/.dir
        $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,2)
-       TEMPFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)), \
-            $(foreach comp,$(sort $(gb_ComponentTarget__ALLCOMPONENTS)),$(call 
gb_ComponentTarget_get_target,$(comp))$(gb_NEWLINE))) && \
-            mv $$TEMPFILE $@
+       $(file >$@,$(foreach comp,$(sort 
$(gb_ComponentTarget__ALLCOMPONENTS)),$(call 
gb_ComponentTarget_get_target,$(comp))$(gb_NEWLINE)))
 
 $(postprocess_WORKDIR)/services_constructors.list: \
     $(SRCDIR)/solenv/bin/constructors.py \
     $(postprocess_WORKDIR)/services_componentfiles.list \
     | $(postprocess_WORKDIR)/.dir
        $(call gb_Output_announce,$(subst $(BUILDDIR)/,,$@),$(true),GEN,2)
-       TEMPFILE=$(shell $(gb_MKTEMP)) && \
-           $(call gb_Helper_abbreviate_dirs,$(call 
gb_ExternalExecutable_get_command,python) $^) > $$TEMPFILE && \
-           $(call gb_Helper_replace_if_different_and_touch,$${TEMPFILE},$@)
+       $(call gb_Helper_abbreviate_dirs,$(call 
gb_ExternalExecutable_get_command,python) $^) > $@.tmp && \
+           $(call gb_Helper_replace_if_different_and_touch,$@.tmp,$@)
 
 .PHONY: $(postprocess_WORKDIR)/services_componentfiles.list
 
diff --git a/postprocess/CustomTarget_registry.mk 
b/postprocess/CustomTarget_registry.mk
index b97a7932b15d..66b205f9771c 100644
--- a/postprocess/CustomTarget_registry.mk
+++ b/postprocess/CustomTarget_registry.mk
@@ -652,10 +652,9 @@ $(call 
gb_CustomTarget_get_workdir,postprocess/registry)/registry_%.list :
 $(call gb_CustomTarget_get_workdir,postprocess/registry)/%.list :
        $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),ECH,2)
        $(call gb_Trace_StartRange,$(subst $(WORKDIR)/,,$@),ECH)
-       mv $(call gb_var2file,$@.tmp,<list> $(foreach i,$(postprocess_DEPS_$*), 
<dependency file='$i'/>) \
+       $(file >$@,<list> $(foreach i,$(postprocess_DEPS_$*), <dependency 
file='$i'/>) \
                   $(foreach i,$(postprocess_OPTDEPS_$*), <dependency file='$i' 
optional='true'/>) \
-                  $(foreach i,$(postprocess_FILES_$*), 
<filename>$(i)</filename>) </list>) \
-          $@
+                  $(foreach i,$(postprocess_FILES_$*), 
<filename>$(i)</filename>) </list>)
        $(call gb_Trace_EndRange,$(subst $(WORKDIR)/,,$@),ECH)
 
 # vim: set noet sw=4 ts=4:
diff --git a/solenv/gbuild/HelpTarget.mk b/solenv/gbuild/HelpTarget.mk
index c4bbfabc7aac..75cb22153d91 100644
--- a/solenv/gbuild/HelpTarget.mk
+++ b/solenv/gbuild/HelpTarget.mk
@@ -567,7 +567,7 @@ $(dir $(call gb_HelpTarget_get_target,%))%/.dir :
 # Translation of the module's .xhp files and all used modules is done.
 # Also creates the list for gb_HelpTarget_get_filelist.
 $(call gb_HelpTarget_get_translation_target,%) :
-       rm -f $@ && mv $(call gb_var2file,$@.tmp,$(strip $(HELP_FILES))) $@
+       $(file >$@,$(strip $(HELP_FILES)))
 
 # Translation of the module's .xhp files and all used and linked modules
 # is done.
diff --git a/solenv/gbuild/LinkTarget.mk b/solenv/gbuild/LinkTarget.mk
index 6634649e5ade..880d13795b87 100644
--- a/solenv/gbuild/LinkTarget.mk
+++ b/solenv/gbuild/LinkTarget.mk
@@ -805,7 +805,7 @@ endef
 
 # call gb_LinkTarget__command_objectlist,linktarget
 define gb_LinkTarget__command_objectlist
-TEMPFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),\
+$(file >$(1),\
        $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \
        $(foreach object,$(CXXOBJECTS),$(call 
gb_CxxObject_get_target,$(object))) \
        $(foreach object,$(OBJCOBJECTS),$(call 
gb_ObjCObject_get_target,$(object))) \
@@ -819,8 +819,7 @@ TEMPFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),\
        $(foreach object,$(GENNASMOBJECTS),$(call 
gb_GenNasmObject_get_target,$(object))) \
        $(foreach object,$(GENCXXCLROBJECTS),$(call 
gb_GenCxxClrObject_get_target,$(object))) \
        $(PCHOBJS) \
-       $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),$(shell cat 
$(extraobjectlist)))) && \
-mv $${TEMPFILE} $(1)
+       $(foreach extraobjectlist,$(EXTRAOBJECTLISTS),$(shell cat 
$(extraobjectlist))))
 
 endef
 
@@ -893,10 +892,9 @@ define gb_LinkTarget__static_dep_x_template
 
 define gb_LinkTarget__command_dep_$(1)
 $$(call gb_Output_announce,LNK:$$(2).d.$(1),$$(true),DEP,1)
-mkdir -p $$(dir $$(1)) && \
-TEMPFILE=$$(call gb_var2file,$$(shell $$(gb_MKTEMP)),\
-       $$(call gb_LinkTarget__get_all_$(1),$$(2))) && \
-       $$(call gb_Helper_replace_if_different_and_touch,$$$${TEMPFILE},$$(1))
+$$(shell mkdir -p $$(dir $$(1)))
+$$(file >$$(1).tmp,$$(call gb_LinkTarget__get_all_$(1),$$(2)))
+$$(call gb_Helper_replace_if_different_and_touch,$$(1).tmp,$$(1))
 
 endef
 
diff --git a/solenv/gbuild/Package.mk b/solenv/gbuild/Package.mk
index 957c0e8c90a9..6f054a549875 100644
--- a/solenv/gbuild/Package.mk
+++ b/solenv/gbuild/Package.mk
@@ -81,8 +81,7 @@ $(call gb_Package_get_target,%) :
        $(call gb_Output_announce,$*,$(true),PKG,2)
        $(call gb_Trace_StartRange,$*,PKG)
        $(if $(PACKAGE_DEFINED),,$(call gb_Output_error,$(RDEPENDS) depend(s) 
on package $* which does not exist.))
-       rm -f $@ && \
-       mv $(call gb_var2file,$@.tmp,$(sort $(FILES))) $@
+       $(file >$@,$(sort $(FILES)))
        $(call gb_Trace_EndRange,$*,PKG)
 
 # for other targets that want to create Packages, does not register at Module
diff --git a/solenv/gbuild/Tempfile.mk b/solenv/gbuild/Tempfile.mk
deleted file mode 100644
index 94dd1e88e19a..000000000000
--- a/solenv/gbuild/Tempfile.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- 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/.
-#
-# This file incorporates work covered by the following license notice:
-#
-#   Licensed to the Apache Software Foundation (ASF) under one or more
-#   contributor license agreements. See the NOTICE file distributed
-#   with this work for additional information regarding copyright
-#   ownership. The ASF licenses this file to you under the Apache
-#   License, Version 2.0 (the "License"); you may not use this file
-#   except in compliance with the License. You may obtain a copy of
-#   the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-define gb_var2file
-$(file >$(1),$(2))$(1)
-endef
-
-# vim: set noet sw=4 ts=4:
diff --git a/solenv/gbuild/gbuild.mk b/solenv/gbuild/gbuild.mk
index 075c029b095d..f14e9f1a1ed4 100644
--- a/solenv/gbuild/gbuild.mk
+++ b/solenv/gbuild/gbuild.mk
@@ -194,7 +194,10 @@ endif
 
 include $(GBUILDDIR)/ExternalExecutable.mk
 include $(GBUILDDIR)/TargetLocations.mk
-include $(GBUILDDIR)/Tempfile.mk
+
+define gb_var2file
+$(file >$(1),$(2))$(1)
+endef
 
 $(eval $(call gb_Helper_init_registries))
 include $(SRCDIR)/Repository.mk
diff --git a/static/CustomTarget_emscripten_fs_image.mk 
b/static/CustomTarget_emscripten_fs_image.mk
index e8810bd2e2f7..f2cf08f65107 100644
--- a/static/CustomTarget_emscripten_fs_image.mk
+++ b/static/CustomTarget_emscripten_fs_image.mk
@@ -1514,10 +1514,9 @@ $(emscripten_fs_image_WORKDIR)/soffice.data.filelist: \
                $(emscripten_fs_image_WORKDIR)/soffice.data.concat_lists \
                $(gb_emscripten_fs_image_files) \
                | $(emscripten_fs_image_WORKDIR)/.dir
-       TEMPFILE=$(call gb_var2file,$(shell $(gb_MKTEMP)),\
+       $(file >$@,\
            $(subst @,@@,$(subst $(BUILDDIR)/,,$(filter 
$(BUILDDIR)%,$(gb_emscripten_fs_image_all_files)))) \
-           $(foreach item,$(filter-out 
$(BUILDDIR)%,$(gb_emscripten_fs_image_all_files)),$(subst @,@@,$(item))@$(subst 
@,@@,$(subst $(SRCDIR)/,,$(item))))) \
-       && mv $$TEMPFILE $@
+           $(foreach item,$(filter-out 
$(BUILDDIR)%,$(gb_emscripten_fs_image_all_files)),$(subst @,@@,$(item))@$(subst 
@,@@,$(subst $(SRCDIR)/,,$(item)))))
 
 # Unfortunately the file packager just allows a cmdline file list, but all 
paths are
 # relative to $(BUILDDIR), so we won't run out of cmdline space that fast...

Reply via email to