Subject: |
Re: Dependency issue with shared database templates unless using "make clean" |
From: |
Benjamin Franksen <[email protected]> |
To: |
<[email protected]> |
Date: |
Wed, 11 Jun 2014 17:44:06 +0200 |
On Wednesday, June 11, 2014 14:53:31 Kasemir, Kay wrote:
> We have certain database templates that are shared, and run into a
> problem with the make system when trying to re-build them without a
> prior "make clean". As the project grows, it's very inconvenient that
> every change requires a full rebuild.
>
> Assume we have some example.template in a shared location:
>
> /path/to/my/support/example/db/example.template
>
> In the configure/RELEASE file of a new application, we define its
> path:
>
> # Where the shared templates are
> SUPPORT_EXAMPLE=/path/to/my/support/example
>
> In the application's Db directory, we have my_database.substitutions:
>
> file example.template
> { ..
>
> .. and in the Makefile there's
>
> TOP=../..
> include $(TOP)/configure/CONFIG
> DB += my_database.db
> include $(TOP)/configure/RULES
>
> A fresh build works OK:
>
> $ make
> perl ......R3.14.12.2/base/bin/linux-x86_64/makeMakefile.pl
> O.linux-x86_64 ../../.. mkdir O.Common
> make -C O.linux-x86_64 -f ../Makefile TOP=../../.. T_A=linux-x86_64
> install make[1]: Entering directory `....xxxxApp/Db/O.linux-x86_64'
> echo "../O.Common/my_database.db : " >> my_database.db.d
> Inflating database from ../my_database.substitutions
> msi -I. -I.. -I ../../../db
> -I/home/controls/epics/R3.14.12.2/base/db
> -I/path/to/my/support/example/db -S../my_database.substitutions >
> my_database.tmp mv my_database.tmp ../O.Common/my_database.db
> Installing created db file ../../../db/my_database.db
>
> But when trying to run 'make' again, this fails:
> $ make
> make -C O.linux-x86_64 -f ../Makefile TOP=../../.. T_A=linux-x86_64
> install make[1]: Entering directory `....xxxxApp/Db/O.linux-x86_64'
> make[1]: *** No rule to make target `example.template', needed by
> `../O.Common/my_database.db'. Stop.
>
> The problem seems to be that makeDbDepends.pl, called from RULES.Db,
> creates a dependency file like this:
>
> $ cat O.linux-x86_64/my_database.db.d
> ../O.Common/my_database.db: example.template
> ../O.Common/my_database.db :
>
> When msi is called, it received command line options like
> "-I/path/to/my/support/example/db" that allow it to find all
> dependencies, but when 'make' is looking at the my_database.db.d
> dependency file, it only has "example.template" without any idea
> where to find it, so it rightly complains "No rule to make..".
>
> Would it make sense to invoke makeDbDepends.pl with options similar to
> the msi invocation, and update it to write the full path to all
> dependencies into the dependency file? That way, makeDbDepends.pl
> could create a dependency file that lists the complete path names,
> i.e.
>
> ../O.Common/my_database.db:
> /path/to/my/support/example/db/example.template
>
> and then make would be happy.
We are using our own rules to correctly create dependencies for
substitution files. I never need to make clean when changing template
files since I use them. In these rules, I replaced makeDbDepends.pl with
a perl one-liner that correctly parses substitution files. This is a
copy from our own set of build rules:
DEPENDS+=$(patsubst %,%$(RAW)$(DEP),$(COMMON_DBS))
$(COMMON_DIR)/%.template$(DEP): %.substitutions
$(ECHO) "Inflating template from $(<F)"
$(PERL) -e 'undef $$/; $$_=<>;
@d=m/(?:^|})\s*file\s+([^{\s]*)\s*\{/mg; print
"$(COMMON_DIR)/$*.template: @d\n";' $< > $(@F).tmp
$(MV) $(@F).tmp $@
$(COMMON_DIR)/%.db$(RAW)$(DEP): %.substitutions
$(ECHO) "Inflating database (raw) from $(<F)"
$(PERL) -e 'undef $$/; $$_=<>;
@d=m/(?:^|})\s*file\s+([^{\s]*)\s*\{/mg; print
"$(COMMON_DIR)/$*.db$(RAW): @d\n";' $< > $(@F).tmp
$(MV) $(@F).tmp $@
$(COMMON_DIR)/%.db$(RAW): %.substitutions
$(ECHO) "Inflating database from $(<F)"
$(MSI) $(DBFLAGS) -S$< $(TEMPLATE_FILENAME) > $(@F).tmp
$(MV) $(@F).tmp $@
Now, this works for template files found in support modules only if
make's vpath for template files is the same path that msi gets. So, in
addition to these rules, you need to tell make
RELEASE_DBSEARCHDIRS = $(RELEASE_DBFLAGS:-I%=%)
vpath %.db $(RELEASE_DBSEARCHDIRS) $(COMMON_DIR)
vpath %.template $(RELEASE_DBSEARCHDIRS)
DBFLAGS = $($*_DBFLAGS) $(USR_DBFLAGS) -I. -I.. -I$(COMMON_DIR)
$(INSTALL_DBFLAGS) $(RELEASE_DBFLAGS)
These rules and definitions are taken from a site specific RULES_BUILD
file that gets loaded in addition to the one in base via the
CFG += RULES_BUILD
mechanism. (We have many more rules files for other file types, like
RULES_DL, RULES_DOC, and also several CONFIG_xyz files, all of them in
the same support module that gets shared between our projects).
Cheers
Ben
--
"Make it so they have to reboot after every typo." ― Scott Adams
Attachment:
signature.asc
Description: This is a digitally signed message part.
- References:
- Dependency issue with shared database templates unless using "make clean" Kasemir, Kay
- Navigate by Date:
- Prev:
Re: Dependency issue with shared database templates unless using "make clean" Andrew Johnson
- Next:
Re: Dependency issue with shared database templates unless using "make clean" Kasemir, Kay
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
<2014>
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: Dependency issue with shared database templates unless using "make clean" Kasemir, Kay
- Next:
lakeshore 336/350 support Pearson, Matthew R.
- Index:
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
<2014>
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|