Message ID | 20210701141011.785641-8-anthony.perard@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xen: Build system improvements | expand |
On 01.07.2021 16:09, Anthony PERARD wrote: > Improvement are: > - give the path to xlat.lst as argument > - include `grep -v` in compat-build-source.py script, we don't need to > write this in several scripted language. > > Also remove dependency on Makefile as the file generation doesn't > depend on it anymore. Did it before any more? In the subsequent patch I can see more of a reason to drop the dependency, but neither there nor here I'm really convinced: In general I think every generate file would better depend on the makefile containing the rule used for its building, as a change to that rule means the target wants rebuilding. Therefore for the moment ... > No changes in final compat/%.h headers. > > Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> > Acked-by: Jan Beulich <jbeulich@suse.com> ... this holds only with the dependency kept in place. But I'll be happy to get convinced otherwise. Jan
On Wed, Jul 07, 2021 at 04:58:29PM +0200, Jan Beulich wrote: > On 01.07.2021 16:09, Anthony PERARD wrote: > > Improvement are: > > - give the path to xlat.lst as argument > > - include `grep -v` in compat-build-source.py script, we don't need to > > write this in several scripted language. > > > > Also remove dependency on Makefile as the file generation doesn't > > depend on it anymore. > > Did it before any more? Kind of, yes, there is "grep -v" that makes the Makefile part of the script that generates the target. > In the subsequent patch I can see more of > a reason to drop the dependency, but neither there nor here I'm > really convinced: In general I think every generate file would > better depend on the makefile containing the rule used for its > building, as a change to that rule means the target wants > rebuilding. Does that mean that nearly every single targets should depends on a "Makefile" or on "Rules.mk" ? :-) As for the current target "compat/%.c", with this patch applied, the only few things that the content of the file depends on is the script, the first dependency, and "xlat.lst" (also a dependency). So the Makefile doesn't play a role into what get's into the target, the "mkdir" and the "mv" don't really matter. If the rule where to be changed in a way that changed the content of the target, that would be wrong in my opinion, the change should be done in the script. If someone wanted to rewrite the script in a different language and thus renaming the script, that would be fine too as make would notice that the new script is newer that the target (as the file for the script as just been created). But, I guess we could start to use the "if_changed" macro here to detected rule changes. I really don't like when a target depends on a "Makefile" because that means the target gets rebuilt for unrelated reason so I'd like to avoid dependency on it when possible. > Therefore for the moment ... > > > Acked-by: Jan Beulich <jbeulich@suse.com> > > ... this holds only with the dependency kept in place. But I'll > be happy to get convinced otherwise. Thanks,
On 12.07.2021 16:35, Anthony PERARD wrote: > On Wed, Jul 07, 2021 at 04:58:29PM +0200, Jan Beulich wrote: >> On 01.07.2021 16:09, Anthony PERARD wrote: >>> Improvement are: >>> - give the path to xlat.lst as argument >>> - include `grep -v` in compat-build-source.py script, we don't need to >>> write this in several scripted language. >>> >>> Also remove dependency on Makefile as the file generation doesn't >>> depend on it anymore. >> >> Did it before any more? > > Kind of, yes, there is "grep -v" that makes the Makefile part of the > script that generates the target. > >> In the subsequent patch I can see more of >> a reason to drop the dependency, but neither there nor here I'm >> really convinced: In general I think every generate file would >> better depend on the makefile containing the rule used for its >> building, as a change to that rule means the target wants >> rebuilding. > > Does that mean that nearly every single targets should depends on a > "Makefile" or on "Rules.mk" ? :-) Well, yes, I indeed think so. > As for the current target "compat/%.c", with this patch applied, the > only few things that the content of the file depends on is the script, > the first dependency, and "xlat.lst" (also a dependency). So the > Makefile doesn't play a role into what get's into the target, the > "mkdir" and the "mv" don't really matter. If the rule where to be > changed in a way that changed the content of the target, that would be > wrong in my opinion, the change should be done in the script. > If someone wanted to rewrite the script in a different language and thus > renaming the script, that would be fine too as make would notice that > the new script is newer that the target (as the file for the script as > just been created). Right, but e.g. adding an option to the scrip invocation would then not trigger a rebuild. > But, I guess we could start to use the "if_changed" macro here to > detected rule changes. > > I really don't like when a target depends on a "Makefile" because that > means the target gets rebuilt for unrelated reason so I'd like to avoid > dependency on it when possible. I can see the background of this viewpoint, but personally I think the extra rebuilds are the price to pay to not have any rebuilds skipped when they would be needed. Overall it is my understanding that to get this more fine grained is what if_changed is for. Jan
diff --git a/xen/include/Makefile b/xen/include/Makefile index c8ca97eed0fc..be3b81485bdc 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -59,10 +59,9 @@ compat/%.h: compat/%.i Makefile $(BASEDIR)/tools/compat-build-header.py compat/%.i: compat/%.c Makefile $(CPP) $(filter-out -Wa$(comma)% -include %/include/xen/config.h,$(XEN_CFLAGS)) $(cppflags-y) -o $@ $< -compat/%.c: public/%.h xlat.lst Makefile $(BASEDIR)/tools/compat-build-source.py +compat/%.c: public/%.h xlat.lst $(BASEDIR)/tools/compat-build-source.py mkdir -p $(@D) - grep -v 'DEFINE_XEN_GUEST_HANDLE(long)' $< | \ - $(PYTHON) $(BASEDIR)/tools/compat-build-source.py >$@.new + $(PYTHON) $(BASEDIR)/tools/compat-build-source.py xlat.lst <$< >$@.new mv -f $@.new $@ compat/.xlat/%.h: compat/%.h compat/.xlat/%.lst $(BASEDIR)/tools/get-fields.sh Makefile diff --git a/xen/tools/compat-build-source.py b/xen/tools/compat-build-source.py index 2bcaf27d05a3..274d6917ab7f 100755 --- a/xen/tools/compat-build-source.py +++ b/xen/tools/compat-build-source.py @@ -13,7 +13,11 @@ pats = [ [ r"XEN_GUEST_HANDLE", r"COMPAT_HANDLE" ], ]; -xlatf = open('xlat.lst', 'r') +try: + xlatf = open(sys.argv[1], 'r') +except IndexError: + print('missing path to xlat.lst argument') + sys.exit(1) for line in xlatf.readlines(): match = re.subn(r"^\s*\?\s+(\w*)\s.*", r"\1", line.rstrip()) if match[1]: @@ -25,6 +29,8 @@ for pat in pats: pat[0] = re.compile(pat[0]) for line in sys.stdin.readlines(): + if 'DEFINE_XEN_GUEST_HANDLE(long)' in line: + continue for pat in pats: line = re.sub(pat[0], pat[1], line) print(line.rstrip())