From 4266f4e29ada827cec1f38ab88ff2c071f6deb2f Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Fri, 3 Jun 2022 12:06:56 -0400 Subject: [PATCH] Fix check-* scripts when harfbuzz is a subproject When harfbuzz is a subproject paths are in the form "subprojects/harfbuzz/src/...". Instead of removing "src/" prefix, take the absolute path and make it relative to current source dir. This fix regression introduced in https://github.com/harfbuzz/harfbuzz/pull/3394. --- src/Makefile.am | 1 + src/check-c-linkage-decls.py | 16 +++++++++------- src/check-header-guards.py | 15 ++++++++------- src/check-includes.py | 15 ++++++++------- src/meson.build | 1 + 5 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index 81eb4c92e..e1b56a5e9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -437,6 +437,7 @@ endif TESTS_ENVIRONMENT = \ srcdir="$(srcdir)" \ + base_srcdir="$(srcdir)" \ builddir="$(builddir)" \ MAKE="$(MAKE) $(AM_MAKEFLAGS)" \ HBSOURCES="$(HBSOURCES)" \ diff --git a/src/check-c-linkage-decls.py b/src/check-c-linkage-decls.py index 49cd29628..fe18eda89 100755 --- a/src/check-c-linkage-decls.py +++ b/src/check-c-linkage-decls.py @@ -2,18 +2,20 @@ import sys, os -os.chdir (os.getenv ('srcdir', os.path.dirname (__file__))) +srcdir = os.getenv ('srcdir', os.path.dirname (__file__)) +base_srcdir = os.getenv ('base_srcdir', srcdir) + +os.chdir (srcdir) + +def removeprefix(s): + abs_path = os.path.join(base_srcdir, s) + return os.path.relpath(abs_path, srcdir) -def removeprefix(s, prefix): - if s.startswith(prefix): - return s[len(prefix):] - else: - return s[:] HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \ [x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')] HBSOURCES = [ - removeprefix(x, 'src%s' % os.path.sep) for x in os.getenv ('HBSOURCES', '').split () + removeprefix(x) for x in os.getenv ('HBSOURCES', '').split () ] or [ x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh')) ] diff --git a/src/check-header-guards.py b/src/check-header-guards.py index b45ffe1ad..35ae6bef6 100755 --- a/src/check-header-guards.py +++ b/src/check-header-guards.py @@ -2,19 +2,20 @@ import sys, os, re -os.chdir (os.getenv ('srcdir', os.path.dirname (__file__))) +srcdir = os.getenv ('srcdir', os.path.dirname (__file__)) +base_srcdir = os.getenv ('base_srcdir', srcdir) -def removeprefix(s, prefix): - if s.startswith(prefix): - return s[len(prefix):] - else: - return s[:] +os.chdir (srcdir) + +def removeprefix(s): + abs_path = os.path.join(base_srcdir, s) + return os.path.relpath(abs_path, srcdir) HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \ [x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')] HBSOURCES = [ - removeprefix(x, 'src%s' % os.path.sep) for x in os.getenv ('HBSOURCES', '').split () + removeprefix(x) for x in os.getenv ('HBSOURCES', '').split () ] or [ x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh')) ] diff --git a/src/check-includes.py b/src/check-includes.py index ed201aa3e..fc95874b1 100755 --- a/src/check-includes.py +++ b/src/check-includes.py @@ -2,19 +2,20 @@ import sys, os, re -os.chdir (os.getenv ('srcdir', os.path.dirname (__file__))) +srcdir = os.getenv ('srcdir', os.path.dirname (__file__)) +base_srcdir = os.getenv ('base_srcdir', srcdir) -def removeprefix(s, prefix): - if s.startswith(prefix): - return s[len(prefix):] - else: - return s[:] +os.chdir (srcdir) + +def removeprefix(s): + abs_path = os.path.join(base_srcdir, s) + return os.path.relpath(abs_path, srcdir) HBHEADERS = [os.path.basename (x) for x in os.getenv ('HBHEADERS', '').split ()] or \ [x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith ('.h')] HBSOURCES = [ - removeprefix(x, 'src%s' % os.path.sep) for x in os.getenv ('HBSOURCES', '').split () + removeprefix(x) for x in os.getenv ('HBSOURCES', '').split () ] or [ x for x in os.listdir ('.') if x.startswith ('hb') and x.endswith (('.cc', '.hh')) ] diff --git a/src/meson.build b/src/meson.build index 41102bcaa..e81496567 100644 --- a/src/meson.build +++ b/src/meson.build @@ -718,6 +718,7 @@ if get_option('tests').enabled() env = environment() env.set('srcdir', meson.current_source_dir()) + env.set('base_srcdir', meson.source_root()) env.set('builddir', meson.current_build_dir()) env.set('libs', meson.current_build_dir()) # TODO: Merge this with builddir after autotools removal HBSOURCES = []