2023-10-03 14:57:05 +02:00
# 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.
2023-10-03 15:39:02 +02:00
if git and tests_enabled [ 0 ]
2023-10-03 14:57:05 +02:00
flake8_path = ''
if flake8_prog . found ( )
flake8_path = flake8_prog . full_path ( )
endif
2023-02-01 11:19:16 -05:00
black_path = ''
if black_prog . found ( )
black_path = black_prog . full_path ( )
endif
2020-06-25 23:29:43 +02:00
2023-10-03 14:57:05 +02:00
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
2021-03-02 18:31:36 +04:00
2023-10-03 14:57:05 +02:00
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
2021-03-24 09:45:29 +01:00
endif
2023-10-03 14:57:05 +02:00
elif host_machine . system ( ) == 'darwin'
grep_prog = find_program ( 'ggrep' )
else
grep_prog = find_program ( 'grep' )
2021-03-02 18:31:36 +04:00
endif
2022-05-23 15:20:48 +02:00
2023-10-03 14:57:05 +02:00
awk_prog = find_program ( 'awk' )
2021-03-02 18:31:36 +04:00
2023-10-03 14:57:05 +02:00
syntax_check_conf = configuration_data ( {
'top_srcdir' : meson . project_source_root ( ) ,
'top_builddir' : meson . project_build_root ( ) ,
'flake8_path' : flake8_path ,
2023-02-01 11:19:16 -05:00
'black_path' : black_path ,
2023-10-03 14:57:05 +02:00
'runutf8' : ' ' . join ( runutf8 ) ,
'PYTHON3' : python3_prog . full_path ( ) ,
'GREP' : grep_prog . full_path ( ) ,
'SED' : sed_prog . full_path ( ) ,
'AWK' : awk_prog . full_path ( ) ,
} )
2021-03-02 18:31:36 +04:00
2023-10-03 14:57:05 +02:00
configure_file (
input : 'Makefile.in' ,
output : '@BASENAME@' ,
configuration : syntax_check_conf ,
)
2020-06-25 23:29:43 +02:00
2023-10-03 14:57:05 +02:00
rc = run_command (
'sed' , '-n' ,
's/^sc_\\([a-zA-Z0-9_-]*\\):.*/\\1/p' ,
meson . current_source_dir ( ) / 'syntax-check.mk' ,
check : true ,
)
2020-06-25 23:29:43 +02:00
2023-10-03 14:57:05 +02:00
sc_tests = rc . stdout ( ) . strip ( ) . split ( )
2020-06-25 23:29:43 +02:00
foreach target : sc_tests
test (
target ,
make_prog ,
2022-05-23 15:47:43 +02:00
args : [ '-C' , meson . current_build_dir ( ) , 'sc_@0@' . format ( target ) ] ,
2020-06-25 23:29:43 +02:00
depends : [
potfiles_dep ,
] ,
suite : 'syntax-check' ,
)
endforeach
endif