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