From 35a23442727cdf82558c7e5eab85bc29df86b5d5 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 20 Apr 2022 10:54:29 +0200 Subject: [PATCH 6/6] meson: Add ecpg --- meson.build | 5 ++ src/interfaces/ecpg/compatlib/meson.build | 8 ++++ src/interfaces/ecpg/ecpglib/meson.build | 17 +++++++ src/interfaces/ecpg/include/meson.build | 46 ++++++++++++++++++ src/interfaces/ecpg/meson.build | 5 ++ src/interfaces/ecpg/pgtypeslib/meson.build | 12 +++++ src/interfaces/ecpg/preproc/Makefile | 2 +- src/interfaces/ecpg/preproc/meson.build | 55 ++++++++++++++++++++++ src/interfaces/ecpg/preproc/parse.pl | 6 ++- src/interfaces/meson.build | 1 + src/meson.build | 2 + 11 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 src/interfaces/ecpg/compatlib/meson.build create mode 100644 src/interfaces/ecpg/ecpglib/meson.build create mode 100644 src/interfaces/ecpg/include/meson.build create mode 100644 src/interfaces/ecpg/meson.build create mode 100644 src/interfaces/ecpg/pgtypeslib/meson.build create mode 100644 src/interfaces/ecpg/preproc/meson.build create mode 100644 src/interfaces/meson.build diff --git a/meson.build b/meson.build index e33ed11b08..bd6f1759e8 100644 --- a/meson.build +++ b/meson.build @@ -1637,6 +1637,11 @@ else cdata.set('STRERROR_R_INT', false) endif +# XXX replace with real test +if host_machine.system() == 'darwin' + cdata.set('LOCALE_T_IN_XLOCALE', true) +endif + # MSVC doesn't cope well with defining restrict to __restrict, the # spelling it understands, because it conflicts with # __declspec(restrict). Therefore we define pg_restrict to the diff --git a/src/interfaces/ecpg/compatlib/meson.build b/src/interfaces/ecpg/compatlib/meson.build new file mode 100644 index 0000000000..68ae270038 --- /dev/null +++ b/src/interfaces/ecpg/compatlib/meson.build @@ -0,0 +1,8 @@ +library('ecpg_compat', + 'informix.c', + include_directories : ['.', '../include', postgres_inc, '../../libpq'], + dependencies: [frontend_shlib_code, thread_dep], + link_with: [ecpglib, ecpg_pgtypes], + soversion: 3, + install: true, + ) diff --git a/src/interfaces/ecpg/ecpglib/meson.build b/src/interfaces/ecpg/ecpglib/meson.build new file mode 100644 index 0000000000..c32fc13871 --- /dev/null +++ b/src/interfaces/ecpg/ecpglib/meson.build @@ -0,0 +1,17 @@ +ecpglib = library('ecpg', + 'connect.c', + 'data.c', + 'descriptor.c', + 'error.c', + 'execute.c', + 'memory.c', + 'misc.c', + 'prepare.c', + 'sqlda.c', + 'typename.c', + include_directories : ['.', '../include', postgres_inc], + dependencies: [frontend_shlib_code, libpq, thread_dep], + link_with: [ecpg_pgtypes], + soversion: 6, + install: true, + ) diff --git a/src/interfaces/ecpg/include/meson.build b/src/interfaces/ecpg/include/meson.build new file mode 100644 index 0000000000..840a23998d --- /dev/null +++ b/src/interfaces/ecpg/include/meson.build @@ -0,0 +1,46 @@ +ecpg_conf_keys = [ + 'ENABLE_THREAD_SAFETY', + 'HAVE_INT64', + 'HAVE_LONG_INT_64', + 'HAVE_LONG_LONG_INT_64', + 'PG_USE_STDBOOL', +] + +ecpg_conf_data = configuration_data() + +foreach key : ecpg_conf_keys + if cdata.has(key) + ecpg_conf_data.set(key, cdata.get(key)) + endif +endforeach + +configure_file( + output: 'ecpg_config.h', + configuration: ecpg_conf_data, + install_dir: get_option('includedir'), +) + +install_headers( + 'ecpg_informix.h', + 'ecpgerrno.h', + 'ecpglib.h', + 'ecpgtype.h', + 'pgtypes.h', + 'pgtypes_date.h', + 'pgtypes_error.h', + 'pgtypes_interval.h', + 'pgtypes_numeric.h', + 'pgtypes_timestamp.h', + 'sql3types.h', + 'sqlca.h', + 'sqlda.h', + 'sqlda-compat.h', + 'sqlda-native.h', +) + +install_headers( + 'datetime.h', + 'decimal.h', + 'sqltypes.h', + subdir: 'informix/esql', +) diff --git a/src/interfaces/ecpg/meson.build b/src/interfaces/ecpg/meson.build new file mode 100644 index 0000000000..ffbe84c0e8 --- /dev/null +++ b/src/interfaces/ecpg/meson.build @@ -0,0 +1,5 @@ +subdir('include') +subdir('pgtypeslib') +subdir('ecpglib') +subdir('compatlib') +subdir('preproc') diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build b/src/interfaces/ecpg/pgtypeslib/meson.build new file mode 100644 index 0000000000..9b1d54c019 --- /dev/null +++ b/src/interfaces/ecpg/pgtypeslib/meson.build @@ -0,0 +1,12 @@ +ecpg_pgtypes = library('pgtypes', + 'common.c', + 'datetime.c', + 'dt_common.c', + 'interval.c', + 'numeric.c', + 'timestamp.c', + include_directories : ['.', '../include', postgres_inc], + dependencies: [frontend_shlib_code], + soversion: 3, + install: true, + ) diff --git a/src/interfaces/ecpg/preproc/Makefile b/src/interfaces/ecpg/preproc/Makefile index ef6d645dee..747d824de3 100644 --- a/src/interfaces/ecpg/preproc/Makefile +++ b/src/interfaces/ecpg/preproc/Makefile @@ -65,7 +65,7 @@ preproc.h: preproc.c preproc.c: BISONFLAGS += -d preproc.y: ../../../backend/parser/gram.y parse.pl ecpg.addons ecpg.header ecpg.tokens ecpg.trailer ecpg.type - $(PERL) $(srcdir)/parse.pl $(srcdir) < $< > $@ + $(PERL) $(srcdir)/parse.pl $(srcdir) $< > $@ $(PERL) $(srcdir)/check_rules.pl $(srcdir) $< # generate keyword headers diff --git a/src/interfaces/ecpg/preproc/meson.build b/src/interfaces/ecpg/preproc/meson.build new file mode 100644 index 0000000000..4ae56f21d4 --- /dev/null +++ b/src/interfaces/ecpg/preproc/meson.build @@ -0,0 +1,55 @@ +pgc_c = custom_target('pgc.c', + input: ['pgc.l'], + output: ['pgc.c'], + command: [flex, '-o', '@OUTPUT@', '@INPUT@']) + +preproc_y = custom_target('preproc.y', + input: ['../../../backend/parser/gram.y', + 'parse.pl', + 'ecpg.addons', + 'ecpg.header', + 'ecpg.tokens', + 'ecpg.trailer', + 'ecpg.type'], + output: ['preproc.y'], + command: [perl, '@INPUT1@', '@CURRENT_SOURCE_DIR@', '@INPUT0@'], + capture: true) + +preproc_c = custom_target('preproc.c', + input: [preproc_y], + output: ['preproc.c', 'preproc.h'], + command: [bison, bisonflags, '-d', '-o', '@OUTPUT0@', '@INPUT@']) + +c_kwlist_d_h = custom_target('c_kwlist_d.h', + input: ['c_kwlist.h'], + output: ['c_kwlist_d.h'], + command: [perl, '-I', '@SOURCE_ROOT@/src/tools', '@SOURCE_ROOT@/src/tools/gen_keywordlist.pl', + '--output', '@OUTDIR@', + '--varname', 'ScanCKeywords', '--no-case-fold', '@INPUT0@']) + +ecpg_kwlist_d_h = custom_target('ecpg_kwlist_d.h', + input: ['ecpg_kwlist.h'], + output: ['ecpg_kwlist_d.h'], + command: [perl, '-I', '@SOURCE_ROOT@/src/tools', '@SOURCE_ROOT@/src/tools/gen_keywordlist.pl', + '--output', '@OUTDIR@', + '--varname', 'ScanECPGKeywords', '@INPUT0@']) + +executable('ecpg', + 'c_keywords.c', + 'descriptor.c', + 'ecpg.c', + 'ecpg_keywords.c', + 'keywords.c', + 'output.c', + 'parser.c', + pgc_c, + preproc_c, + 'type.c', + '../ecpglib/typename.c', + 'variable.c', + c_kwlist_d_h, + ecpg_kwlist_d_h, + include_directories : ['.', '../include', postgres_inc], + dependencies: [frontend_shlib_code, libpq], + kwargs: default_bin_args, + ) diff --git a/src/interfaces/ecpg/preproc/parse.pl b/src/interfaces/ecpg/preproc/parse.pl index dee6b8200d..0dd9f30b41 100644 --- a/src/interfaces/ecpg/preproc/parse.pl +++ b/src/interfaces/ecpg/preproc/parse.pl @@ -19,6 +19,8 @@ my $path = shift @ARGV; $path = "." unless $path; +open(our $infile, '<', $ARGV[0]) or die; + my $copymode = 0; my $brace_indent = 0; my $yaccmode = 0; @@ -132,9 +134,11 @@ include_file('trailer', 'ecpg.trailer'); dump_buffer('trailer'); +close($infile); + sub main { - line: while (<>) + line: while (<$infile>) { if (/ERRCODE_FEATURE_NOT_SUPPORTED/) { diff --git a/src/interfaces/meson.build b/src/interfaces/meson.build new file mode 100644 index 0000000000..fb85e3fd20 --- /dev/null +++ b/src/interfaces/meson.build @@ -0,0 +1 @@ +subdir('ecpg') diff --git a/src/meson.build b/src/meson.build index 414be1db41..a7fdd5a13e 100644 --- a/src/meson.build +++ b/src/meson.build @@ -8,3 +8,5 @@ subdir('backend') subdir('bin') subdir('pl') + +subdir('interfaces') -- 2.35.1