Ansel 0.0
A darktable fork - bloat + design vision
Loading...
Searching...
No Matches
mingw_syntax_check Namespace Reference

Functions

 _drop_unbuildable (flags)
 
 _in_repo (path)
 
 _relevant_flags (argv)
 
 _source_for (entry_file)
 
 build_flag_map (compdb='build/compile_commands.json')
 
 pkg_cflags ()
 
 sources (args)
 
 _missing_unavailable_header (stderr)
 
 _unverifiable_with_full_flags (cmd, own, fmap, path)
 
 check (path, flags, fmap)
 
 main ()
 

Variables

 REPO = os.getcwd()
 
str CC = 'x86_64-w64-mingw32-gcc'
 
str CXX = 'x86_64-w64-mingw32-g++'
 
list PKGS
 
 UNAVAILABLE
 
list WIN_DEFINES
 
 MISSING_HEADER = re.compile(r"fatal error: ([^:]+): No such file or directory")
 
 EXPLICIT_ERROR = re.compile(r'error: #error\s+"?([^"\n]+)')
 
tuple UNBUILDABLE_FEATURES
 

Detailed Description

Syntax-check translation units with the MinGW cross compiler.

Why: a clean Linux build cannot vouch for code inside `#ifdef _WIN32`, and it cannot
see the legacy macros `windows.h` defines (`near`, `grp2`, `interface`, ...). Every
cross-platform breakage in the darktable.h series was of that shape -- green locally,
broken on MinGW, and usually reported in a file that was not at fault. This runs the
real Windows toolchain over the tree so those are caught before CI, or when CI is
unavailable.

This is `-fsyntax-only`: it compiles nothing and links nothing. That is deliberate --
the goal is the preprocessor and the parser, which is where this class of bug lives.

Some libraries have no Fedora mingw64 package (json-glib, lensfun, libcurl, libraw,
osmgpsmap, openjpeg, sentry, OpenCL ...), so files needing them cannot be checked here.
They are reported as SKIPPED and counted separately, never as passing: a check you did
not run is not a check that succeeded. Keep UNAVAILABLE honest -- an entry for a library
that IS installed would downgrade a real failure to "skipped".

Setup (Fedora):
  sudo dnf install mingw64-gcc mingw64-gcc-c++ mingw64-glib2 mingw64-gtk3 \
                   mingw64-lcms2 mingw64-sqlite mingw64-exiv2 mingw64-libpng \
                   mingw64-libtiff mingw64-libjpeg-turbo

Usage:
  python3 tools/mingw_syntax_check.py                    # every .c/.cc under src/
  python3 tools/mingw_syntax_check.py --changed master   # only what a branch touched
  python3 tools/mingw_syntax_check.py src/iop/lens.c    # specific files
  python3 tools/mingw_syntax_check.py --jobs 8

Function Documentation

◆ _drop_unbuildable()

mingw_syntax_check._drop_unbuildable (   flags)
protected

Definition at line 83 of file mingw_syntax_check.py.

Referenced by check().

◆ _in_repo()

mingw_syntax_check._in_repo (   path)
protected
Keep project include paths, drop the host toolchain's own -I/-isystem: those are
Linux headers and must not leak into a MinGW cross check.

Definition at line 92 of file mingw_syntax_check.py.

Referenced by _relevant_flags().

◆ _missing_unavailable_header()

mingw_syntax_check._missing_unavailable_header (   stderr)
protected
The header name if this failure is only 'we do not have it cross-built'.

Definition at line 207 of file mingw_syntax_check.py.

Referenced by _unverifiable_with_full_flags().

◆ _relevant_flags()

mingw_syntax_check._relevant_flags (   argv)
protected
The -D / -include / project -I flags from one compile command.

Definition at line 98 of file mingw_syntax_check.py.

References _in_repo().

Referenced by build_flag_map().

◆ _source_for()

mingw_syntax_check._source_for (   entry_file)
protected
Map a compdb entry back to the source we care about. Generated
introspection_X.c carries the flags for the src/iop/X.c it textually includes.

Definition at line 123 of file mingw_syntax_check.py.

Referenced by build_flag_map().

◆ _unverifiable_with_full_flags()

mingw_syntax_check._unverifiable_with_full_flags (   cmd,
  own,
  fmap,
  path 
)
protected
Dropping a feature define can hide declarations a feature-only file legitimately
uses (src/libs/map_locations.c is entirely map code). Retry with the ORIGINAL flags:
if it then dies on a header we do not have cross-built, the file is unverifiable
here rather than broken.

Definition at line 220 of file mingw_syntax_check.py.

References _missing_unavailable_header().

Referenced by check().

◆ build_flag_map()

mingw_syntax_check.build_flag_map (   compdb = 'build/compile_commands.json')
Per-file -D/-include/project -I flags, taken from the BUILD SYSTEM.

Guessing these is how a cross-check invents failures: the real build force-includes
common/module_api.h and iop/iop_api.h into every module, and gates whole APIs behind
-DHAVE_MAP / -DBUILD_PRINT / -DHAVE_OPENCL. Without them the harness reports missing
declarations that exist perfectly well in the real build.

Generated introspection_X.c entries carry the flags for src/iop/X.c, which is
textually included by them, so they are mapped back onto the original.

Definition at line 136 of file mingw_syntax_check.py.

References _relevant_flags(), and _source_for().

Referenced by main().

◆ check()

mingw_syntax_check.check (   path,
  flags,
  fmap 
)

Definition at line 236 of file mingw_syntax_check.py.

References _drop_unbuildable(), and _unverifiable_with_full_flags().

Referenced by main().

◆ main()

mingw_syntax_check.main ( void  )

Definition at line 268 of file mingw_syntax_check.py.

References build_flag_map(), check(), main(), pkg_cflags(), and sources().

Referenced by main().

◆ pkg_cflags()

mingw_syntax_check.pkg_cflags ( )

Definition at line 173 of file mingw_syntax_check.py.

Referenced by main().

◆ sources()

mingw_syntax_check.sources (   args)

Definition at line 189 of file mingw_syntax_check.py.

Referenced by main().

Variable Documentation

◆ CC

str mingw_syntax_check.CC = 'x86_64-w64-mingw32-gcc'

Definition at line 39 of file mingw_syntax_check.py.

◆ CXX

str mingw_syntax_check.CXX = 'x86_64-w64-mingw32-g++'

Definition at line 40 of file mingw_syntax_check.py.

◆ EXPLICIT_ERROR

mingw_syntax_check.EXPLICIT_ERROR = re.compile(r'error: #error\s+"?([^"\n]+)')

Definition at line 68 of file mingw_syntax_check.py.

◆ MISSING_HEADER

mingw_syntax_check.MISSING_HEADER = re.compile(r"fatal error: ([^:]+): No such file or directory")

Definition at line 62 of file mingw_syntax_check.py.

◆ PKGS

list mingw_syntax_check.PKGS
Initial value:
1= ['gtk+-3.0', 'lcms2', 'sqlite3', 'libpng', 'libtiff-4', 'libjpeg', 'exiv2',
2 'librsvg-2.0', 'libxml-2.0', 'libwebp', 'OpenEXR', 'libsoup-2.4']

Definition at line 41 of file mingw_syntax_check.py.

◆ REPO

mingw_syntax_check.REPO = os.getcwd()

Definition at line 38 of file mingw_syntax_check.py.

◆ UNAVAILABLE

mingw_syntax_check.UNAVAILABLE
Initial value:
1= re.compile(
2 r'(json-glib[/.]|lensfun[/.]|curl/curl\.h|libraw|osmgpsmap|osm-gps-map|openjpeg|'
3 r'cmark|colord|gphoto2|portmidi|pugixml|rawspeed|libdeflate|jasper|portaudio)',
4 re.I)

Definition at line 49 of file mingw_syntax_check.py.

◆ UNBUILDABLE_FEATURES

tuple mingw_syntax_check.UNBUILDABLE_FEATURES
Initial value:
1= ('HAVE_MAP', 'HAVE_LIBAVIF', 'HAVE_LIBHEIF',
2 'HAVE_HTTP_SERVER',
3 'HAVE_SENTRY', 'HAVE_LIBRAW', 'HAVE_OPENJPEG', 'HAVE_WEBP',
4 'HAVE_OPENEXR', 'HAVE_ISO_CODES', 'HAVE_CMARK',
5 'HAVE_OSMGPSMAP_110_OR_NEWER', 'HAVE_OSMGPSMAP_NEWER_THAN_110')

Definition at line 76 of file mingw_syntax_check.py.

◆ WIN_DEFINES

list mingw_syntax_check.WIN_DEFINES
Initial value:
1= ['-DHAVE_CONFIG_H', '-D_POSIX_THREAD_SAFE_FUNCTIONS', '-D_USE_MATH_DEFINES',
2 '-D__USE_MINGW_ANSI_STDIO=1', '-DUNICODE', '-D_UNICODE',
3 '-D__GDK_KEYSYMS_COMPAT_H__']

Definition at line 58 of file mingw_syntax_check.py.