meson: Basic cygwin support
authorAndres Freund <[email protected]>
Tue, 6 Dec 2022 19:25:54 +0000 (11:25 -0800)
committerAndres Freund <[email protected]>
Tue, 6 Dec 2022 19:25:54 +0000 (11:25 -0800)
There likely are further issues, but as evidenced by the CI task proposed by
Justin in the referenced thread, this suffices to build and run basic tests in
cygwin (some fixes for the test infrastructure are needed, but that's
independent of the meson aspect).

Author: Justin Pryzby <[email protected]>
Reviewed-by: Andres Freund <[email protected]>
Discussion: https://postgr.es/m/20221021034040[email protected]

meson.build
src/port/meson.build
src/test/regress/meson.build

index 725e10d815ca6dc72bd4d5ba166bb10799744d06..172c144135225db8c188d754be16a8f0f620db32 100644 (file)
@@ -211,6 +211,10 @@ if host_system == 'aix'
 
 elif host_system == 'cygwin'
   cppflags += '-D_GNU_SOURCE'
+  dlsuffix = '.dll'
+  mod_link_args_fmt = ['@0@']
+  mod_link_with_name = 'lib@[email protected]'
+  mod_link_with_dir = 'libdir'
 
 elif host_system == 'darwin'
   dlsuffix = '.dylib'
@@ -2310,8 +2314,8 @@ gnugetopt_dep = cc.find_library('gnugetopt', required: false)
 #   (i.e., allow '-' as a flag character), so use our version on those platforms
 # - We want to use system's getopt_long() only if the system provides struct
 #   option
-always_replace_getopt = host_system in ['windows', 'openbsd', 'solaris']
-always_replace_getopt_long = host_system == 'windows' or not cdata.has('HAVE_STRUCT_OPTION')
+always_replace_getopt = host_system in ['windows', 'cygwin', 'openbsd', 'solaris']
+always_replace_getopt_long = host_system in ['windows', 'cygwin'] or not cdata.has('HAVE_STRUCT_OPTION')
 
 # Required on BSDs
 execinfo_dep = cc.find_library('execinfo', required: false)
index c2222696f1b1b59646d38b325efb78377e1daa97..0ba83cc79303827c27c805fe6d51f1ecdc3ebfd2 100644 (file)
@@ -40,6 +40,10 @@ if host_system == 'windows'
     'win32setlocale.c',
     'win32stat.c',
   )
+elif host_system == 'cygwin'
+  pgport_sources += files(
+    'dirmod.c',
+  )
 endif
 
 if cc.get_id() == 'msvc'
index f1adcd9198cf801e5ea8dd0de798ac64db6bd677..72a23737fa708bbfa95375157d79b5ba0e56f9f7 100644 (file)
@@ -12,6 +12,8 @@ regress_sources = pg_regress_c + files(
 host_tuple_cc = cc.get_id()
 if host_system == 'windows' and host_tuple_cc == 'gcc'
   host_tuple_cc = 'mingw'
+elif host_system == 'cygwin' and host_tuple_cc == 'gcc'
+  host_tuple_cc = 'cygwin'
 endif
 host_tuple = '@0@-@1@-@2@'.format(host_cpu, host_system, host_tuple_cc)