]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
meson: Do less when not building from git
authorAndrea Bolognani <abologna@redhat.com>
Tue, 3 Oct 2023 12:57:05 +0000 (14:57 +0200)
committerAndrea Bolognani <abologna@redhat.com>
Thu, 26 Oct 2023 09:31:16 +0000 (11:31 +0200)
As explained in the comment, the syntax-check machinery uses git
to figure out the list of files it should operate on, so we can
only enable it when building from git.

Despite only registering the various tests with meson in that
case, however, we unconditionally perform a bunch of preparation
that is only useful for the purpose of registering and running
the tests. If we're not going to do that, we can skip a few steps
and save a bit of time.

Best viewed with 'git show -w'.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
build-aux/meson.build

index 16d085505d7708dc4d7245d21f13803a9f93ca38..b5d88a4c44354a613e80a68d06b10bc8bfccb89a 100644 (file)
@@ -1,63 +1,62 @@
-flake8_path = ''
-if flake8_prog.found()
-  flake8_path = flake8_prog.full_path()
-endif
+# Skip syntax-check if not building from git because we get the list of files
+# to check using git commands and it fails if we are not in git repository.
+if git
+  flake8_path = ''
+  if flake8_prog.found()
+    flake8_path = flake8_prog.full_path()
+  endif
 
-if host_machine.system() == 'freebsd' or host_machine.system() == 'darwin'
-  make_prog = find_program('gmake')
-  sed_prog = find_program('gsed')
-else
-  make_prog = find_program('make')
-  sed_prog = find_program('sed')
-endif
+  if host_machine.system() == 'freebsd' or host_machine.system() == 'darwin'
+    make_prog = find_program('gmake')
+    sed_prog = find_program('gsed')
+  else
+    make_prog = find_program('make')
+    sed_prog = find_program('sed')
+  endif
 
-if host_machine.system() == 'freebsd'
-  grep_prog = find_program('grep')
-  grep_cmd = run_command(grep_prog, '--version', check: true)
-  if grep_cmd.stdout().startswith('grep (BSD grep')
-    grep_prog = find_program('/usr/local/bin/grep', required: false)
-    if not grep_prog.found()
-      error('GNU grep not found')
+  if host_machine.system() == 'freebsd'
+    grep_prog = find_program('grep')
+    grep_cmd = run_command(grep_prog, '--version', check: true)
+    if grep_cmd.stdout().startswith('grep (BSD grep')
+      grep_prog = find_program('/usr/local/bin/grep', required: false)
+      if not grep_prog.found()
+        error('GNU grep not found')
+      endif
     endif
+  elif host_machine.system() == 'darwin'
+    grep_prog = find_program('ggrep')
+  else
+    grep_prog = find_program('grep')
   endif
-elif host_machine.system() == 'darwin'
-  grep_prog = find_program('ggrep')
-else
-  grep_prog = find_program('grep')
-endif
-
-awk_prog = find_program('awk')
 
-syntax_check_conf = configuration_data({
-  'top_srcdir': meson.project_source_root(),
-  'top_builddir': meson.project_build_root(),
-  'flake8_path': flake8_path,
-  'runutf8': ' '.join(runutf8),
-  'PYTHON3': python3_prog.full_path(),
-  'GREP': grep_prog.full_path(),
-  'SED': sed_prog.full_path(),
-  'AWK': awk_prog.full_path(),
-})
+  awk_prog = find_program('awk')
 
-configure_file(
-  input: 'Makefile.in',
-  output: '@BASENAME@',
-  configuration: syntax_check_conf,
-)
+  syntax_check_conf = configuration_data({
+    'top_srcdir': meson.project_source_root(),
+    'top_builddir': meson.project_build_root(),
+    'flake8_path': flake8_path,
+    'runutf8': ' '.join(runutf8),
+    'PYTHON3': python3_prog.full_path(),
+    'GREP': grep_prog.full_path(),
+    'SED': sed_prog.full_path(),
+    'AWK': awk_prog.full_path(),
+  })
 
-rc = run_command(
-  'sed', '-n',
-  's/^sc_\\([a-zA-Z0-9_-]*\\):.*/\\1/p',
-  meson.current_source_dir() / 'syntax-check.mk',
-  check: true,
-)
+  configure_file(
+    input: 'Makefile.in',
+    output: '@BASENAME@',
+    configuration: syntax_check_conf,
+  )
 
-sc_tests = rc.stdout().strip().split()
+  rc = run_command(
+    'sed', '-n',
+    's/^sc_\\([a-zA-Z0-9_-]*\\):.*/\\1/p',
+    meson.current_source_dir() / 'syntax-check.mk',
+    check: true,
+  )
 
+  sc_tests = rc.stdout().strip().split()
 
-# Skip syntax-check if not building from git because we get the list of files
-# to check using git commands and it fails if we are not in git repository.
-if git
   foreach target : sc_tests
     test(
       target,