xref: /aoo42x/main/solenv/gbuild/Deliver.mk (revision f006f9b4)
17871dc3eSAndrew Rist#**************************************************************
27871dc3eSAndrew Rist#
37871dc3eSAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
47871dc3eSAndrew Rist#  or more contributor license agreements.  See the NOTICE file
57871dc3eSAndrew Rist#  distributed with this work for additional information
67871dc3eSAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
77871dc3eSAndrew Rist#  to you under the Apache License, Version 2.0 (the
87871dc3eSAndrew Rist#  "License"); you may not use this file except in compliance
97871dc3eSAndrew Rist#  with the License.  You may obtain a copy of the License at
107871dc3eSAndrew Rist#
117871dc3eSAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
127871dc3eSAndrew Rist#
137871dc3eSAndrew Rist#  Unless required by applicable law or agreed to in writing,
147871dc3eSAndrew Rist#  software distributed under the License is distributed on an
157871dc3eSAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
167871dc3eSAndrew Rist#  KIND, either express or implied.  See the License for the
177871dc3eSAndrew Rist#  specific language governing permissions and limitations
187871dc3eSAndrew Rist#  under the License.
197871dc3eSAndrew Rist#
207871dc3eSAndrew Rist#**************************************************************
217871dc3eSAndrew Rist
227871dc3eSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweirgb_Deliver_GNUCOPY := $(GNUCOPY)
25cdf0e10cSrcweir
26cdf0e10cSrcweir# if ($true) then old files will get removed from the target location before
27cdf0e10cSrcweir# they are copied there. In multi-user environments, this is needed you need to
28cdf0e10cSrcweir# be the owner of the target file to be able to modify timestamps
29cdf0e10cSrcweirgb_Deliver_CLEARONDELIVER := $(true)
30cdf0e10cSrcweir
31cdf0e10cSrcweirdefine gb_Deliver_init
32cdf0e10cSrcweirgb_Deliver_DELIVERABLES :=
33b63233d8Sdamjangb_Deliver_DELIVERABLES_INDEX :=
34cdf0e10cSrcweir
35cdf0e10cSrcweirendef
36cdf0e10cSrcweir
37b63233d8Sdamjandefine gb_Deliver_do_add
38b63233d8Sdamjan$$(if $(3),,$$(error - missing third parameter for deliverable $(1)))
39b63233d8Sdamjangb_Deliver_DELIVERABLES_$(notdir $(3)) += $$(patsubst $(REPODIR)/%,%,$(2)):$$(patsubst $(REPODIR)/%,%,$(1))
40b63233d8Sdamjangb_Deliver_DELIVERABLES_INDEX := $(sort $(gb_Deliver_DELIVERABLES_INDEX) $(notdir $(3)))
41cdf0e10cSrcweir$(if $(gb_HIRESTIME),,.LOW_RESOLUTION_TIME : $(1))
42cdf0e10cSrcweir
43cdf0e10cSrcweirendef
44cdf0e10cSrcweir
45b63233d8Sdamjandefine gb_Deliver_add_deliverable
46b63233d8Sdamjanifeq ($(MAKECMDGOALS),showdeliverables)
47b63233d8Sdamjan$(call gb_Deliver_do_add,$(OUTDIR)/$(1),$(2),$(3))
48b63233d8Sdamjanelse
49b63233d8Sdamjanifneq ($(CWS_WORK_STAMP),)
50b63233d8Sdamjanelse
51b63233d8Sdamjan$(call gb_Deliver_do_add,$(OUTDIR)/$(1),$(2),$(3))
52b63233d8Sdamjanendif
53b63233d8Sdamjanendif
54b63233d8Sdamjan
55b63233d8Sdamjanendef
56b63233d8Sdamjan
57cdf0e10cSrcweirifeq ($(strip $(gb_Deliver_GNUCOPY)),)
58b63233d8Sdamjandefine gb_Deliver__deliver
59*f006f9b4SDamjan Jovanovicmkdir -p $(dir $(2)) && $(if $(gb_Deliver_CLEARONDELIVER),rm -f $(2) &&) cp -R -P -f $(1) $(2) && touch -r $(1) $(2)
60cdf0e10cSrcweirendef
61cdf0e10cSrcweirelse
62b63233d8Sdamjandefine gb_Deliver__deliver
63*f006f9b4SDamjan Jovanovicmkdir -p $(dir $(2)) && $(gb_Deliver_GNUCOPY) $(if $(gb_Deliver_CLEARONDELIVER),--remove-destination) -R -P --force --preserve=timestamps $(1) $(2)
64cdf0e10cSrcweirendef
65cdf0e10cSrcweirendif
66cdf0e10cSrcweir
67b63233d8Sdamjandefine gb_Deliver_deliver
68b63233d8Sdamjan$(if $(1),$(call gb_Deliver__deliver,$(1),$(2)),\
69b63233d8Sdamjan $(error gb_Deliver_deliver:\
70b63233d8Sdamjan  file does not exist in solver, and cannot be delivered: $(2)))
71b63233d8Sdamjanendef
72b63233d8Sdamjan
73cdf0e10cSrcweir
74cdf0e10cSrcweir# We are currently only creating a deliver.log, if only one module gets build.
75cdf0e10cSrcweir# As it is possible to add gbuild modules into other (which is done for example for
76cdf0e10cSrcweir# the toplevel ooo module already) it does not make sense to create a deliver.log once
77cdf0e10cSrcweir# fully migrated. The whole process should be rethought then.
78cdf0e10cSrcweir# We need the trailing whitespace so that the newline of echo does not become part of the last record.
79cdf0e10cSrcweirdefine gb_Deliver_setdeliverlogcommand
80cdf0e10cSrcweirifeq ($$(words $(gb_Module_ALLMODULES)),1)
81cdf0e10cSrcweir$$(eval $$(call gb_Output_announce,$$(strip $$(gb_Module_ALLMODULES)),$$(true),LOG,1))
82cdf0e10cSrcweirdeliverlog : COMMAND := \
83cdf0e10cSrcweir mkdir -p $$(OUTDIR)/inc/$$(strip $$(gb_Module_ALLMODULES)) \
84b63233d8Sdamjan && RESPONSEFILE=$$(call var2file,$(shell $(gb_MKTEMP)),100,$$(sort $$(foreach list,$$(gb_Deliver_DELIVERABLES_INDEX),$$(gb_Deliver_DELIVERABLES_$$(list))))) \
85cdf0e10cSrcweir && $(gb_AWK) -f $$(GBUILDDIR)/processdelivered.awk < $$$${RESPONSEFILE} \
86cdf0e10cSrcweir        > $$(OUTDIR)/inc/$$(strip $(gb_Module_ALLMODULES))/gb_deliver.log \
87cdf0e10cSrcweir && rm -f $$$${RESPONSEFILE}
88cdf0e10cSrcweirelse
89cdf0e10cSrcweir$$(eval $$(call gb_Output_announce,more than one module - creating no deliver.log,$$(true),LOG,1))
90cdf0e10cSrcweirdeliverlog : COMMAND := true
91cdf0e10cSrcweirendif
92cdf0e10cSrcweirendef
93cdf0e10cSrcweir
94cdf0e10cSrcweir# FIXME: this does not really work for real multi repository builds, but the
95cdf0e10cSrcweir# deliver.log format is broken in that case anyway
96cdf0e10cSrcweir.PHONY : deliverlog showdeliverables
97cdf0e10cSrcweirdeliverlog:
98cdf0e10cSrcweir	$(eval $(call gb_Deliver_setdeliverlogcommand))
99cdf0e10cSrcweir	$(call gb_Helper_abbreviate_dirs, $(COMMAND))
100cdf0e10cSrcweir
101cdf0e10cSrcweir# all : deliverlog
102cdf0e10cSrcweir
103cdf0e10cSrcweirdefine gb_Deliver_print_deliverable
104cdf0e10cSrcweir$(info $(1) $(patsubst $(OUTDIR)/%,%,$(2)))
105cdf0e10cSrcweirendef
106cdf0e10cSrcweir
107cdf0e10cSrcweirshowdeliverables :
108cdf0e10cSrcweir	$(eval MAKEFLAGS := s)
109b63233d8Sdamjan	$(foreach deliverable,$(sort $(foreach list,$(gb_Deliver_DELIVERABLES_INDEX),$(gb_Deliver_DELIVERABLES_$(list)))),\
110cdf0e10cSrcweir			$(call gb_Deliver_print_deliverable,$(REPODIR)/$(firstword $(subst :, ,$(deliverable))),$(REPODIR)/$(lastword $(subst :, ,$(deliverable)))))
111cdf0e10cSrcweir	true
112cdf0e10cSrcweir# vim: set noet sw=4 ts=4:
113