diff options
Diffstat (limited to 'src')
199 files changed, 5482 insertions, 0 deletions
diff --git a/src/backend/access/brin/meson.build b/src/backend/access/brin/meson.build new file mode 100644 index 00000000000..a54c7532927 --- /dev/null +++ b/src/backend/access/brin/meson.build @@ -0,0 +1,12 @@ +backend_sources += files( + 'brin.c', + 'brin_bloom.c', + 'brin_inclusion.c', + 'brin_minmax.c', + 'brin_minmax_multi.c', + 'brin_pageops.c', + 'brin_revmap.c', + 'brin_tuple.c', + 'brin_validate.c', + 'brin_xlog.c', +) diff --git a/src/backend/access/common/meson.build b/src/backend/access/common/meson.build new file mode 100644 index 00000000000..857beaa32d3 --- /dev/null +++ b/src/backend/access/common/meson.build @@ -0,0 +1,18 @@ +backend_sources += files( + 'attmap.c', + 'bufmask.c', + 'detoast.c', + 'heaptuple.c', + 'indextuple.c', + 'printsimple.c', + 'printtup.c', + 'relation.c', + 'reloptions.c', + 'scankey.c', + 'session.c', + 'syncscan.c', + 'toast_compression.c', + 'toast_internals.c', + 'tupconvert.c', + 'tupdesc.c', +) diff --git a/src/backend/access/gin/meson.build b/src/backend/access/gin/meson.build new file mode 100644 index 00000000000..56d6f343d54 --- /dev/null +++ b/src/backend/access/gin/meson.build @@ -0,0 +1,17 @@ +backend_sources += files( + 'ginarrayproc.c', + 'ginbtree.c', + 'ginbulk.c', + 'gindatapage.c', + 'ginentrypage.c', + 'ginfast.c', + 'ginget.c', + 'gininsert.c', + 'ginlogic.c', + 'ginpostinglist.c', + 'ginscan.c', + 'ginutil.c', + 'ginvacuum.c', + 'ginvalidate.c', + 'ginxlog.c', +) diff --git a/src/backend/access/gist/meson.build b/src/backend/access/gist/meson.build new file mode 100644 index 00000000000..1a996b5e25d --- /dev/null +++ b/src/backend/access/gist/meson.build @@ -0,0 +1,13 @@ +backend_sources += files( + 'gist.c', + 'gistbuild.c', + 'gistbuildbuffers.c', + 'gistget.c', + 'gistproc.c', + 'gistscan.c', + 'gistsplit.c', + 'gistutil.c', + 'gistvacuum.c', + 'gistvalidate.c', + 'gistxlog.c', +) diff --git a/src/backend/access/hash/meson.build b/src/backend/access/hash/meson.build new file mode 100644 index 00000000000..22f2c691c34 --- /dev/null +++ b/src/backend/access/hash/meson.build @@ -0,0 +1,12 @@ +backend_sources += files( + 'hash.c', + 'hash_xlog.c', + 'hashfunc.c', + 'hashinsert.c', + 'hashovfl.c', + 'hashpage.c', + 'hashsearch.c', + 'hashsort.c', + 'hashutil.c', + 'hashvalidate.c', +) diff --git a/src/backend/access/heap/meson.build b/src/backend/access/heap/meson.build new file mode 100644 index 00000000000..f1dca73743c --- /dev/null +++ b/src/backend/access/heap/meson.build @@ -0,0 +1,11 @@ +backend_sources += files( + 'heapam.c', + 'heapam_handler.c', + 'heapam_visibility.c', + 'heaptoast.c', + 'hio.c', + 'pruneheap.c', + 'rewriteheap.c', + 'vacuumlazy.c', + 'visibilitymap.c', +) diff --git a/src/backend/access/index/meson.build b/src/backend/access/index/meson.build new file mode 100644 index 00000000000..18af5533e65 --- /dev/null +++ b/src/backend/access/index/meson.build @@ -0,0 +1,6 @@ +backend_sources += files( + 'amapi.c', + 'amvalidate.c', + 'genam.c', + 'indexam.c', +) diff --git a/src/backend/access/meson.build b/src/backend/access/meson.build new file mode 100644 index 00000000000..9874291fc0a --- /dev/null +++ b/src/backend/access/meson.build @@ -0,0 +1,13 @@ +subdir('brin') +subdir('common') +subdir('gin') +subdir('gist') +subdir('hash') +subdir('heap') +subdir('index') +subdir('nbtree') +subdir('rmgrdesc') +subdir('spgist') +subdir('table') +subdir('tablesample') +subdir('transam') diff --git a/src/backend/access/nbtree/meson.build b/src/backend/access/nbtree/meson.build new file mode 100644 index 00000000000..07dc29e8190 --- /dev/null +++ b/src/backend/access/nbtree/meson.build @@ -0,0 +1,13 @@ +backend_sources += files( + 'nbtcompare.c', + 'nbtdedup.c', + 'nbtinsert.c', + 'nbtpage.c', + 'nbtree.c', + 'nbtsearch.c', + 'nbtsort.c', + 'nbtsplitloc.c', + 'nbtutils.c', + 'nbtvalidate.c', + 'nbtxlog.c', +) diff --git a/src/backend/access/rmgrdesc/meson.build b/src/backend/access/rmgrdesc/meson.build new file mode 100644 index 00000000000..f3a6e0a571b --- /dev/null +++ b/src/backend/access/rmgrdesc/meson.build @@ -0,0 +1,26 @@ +# used by frontend programs like pg_waldump +rmgr_desc_sources = files( + 'brindesc.c', + 'clogdesc.c', + 'committsdesc.c', + 'dbasedesc.c', + 'genericdesc.c', + 'gindesc.c', + 'gistdesc.c', + 'hashdesc.c', + 'heapdesc.c', + 'logicalmsgdesc.c', + 'mxactdesc.c', + 'nbtdesc.c', + 'relmapdesc.c', + 'replorigindesc.c', + 'seqdesc.c', + 'smgrdesc.c', + 'spgdesc.c', + 'standbydesc.c', + 'tblspcdesc.c', + 'xactdesc.c', + 'xlogdesc.c', +) + +backend_sources += rmgr_desc_sources diff --git a/src/backend/access/spgist/meson.build b/src/backend/access/spgist/meson.build new file mode 100644 index 00000000000..f18d0d2e53f --- /dev/null +++ b/src/backend/access/spgist/meson.build @@ -0,0 +1,13 @@ +backend_sources += files( + 'spgdoinsert.c', + 'spginsert.c', + 'spgkdtreeproc.c', + 'spgproc.c', + 'spgquadtreeproc.c', + 'spgscan.c', + 'spgtextproc.c', + 'spgutils.c', + 'spgvacuum.c', + 'spgvalidate.c', + 'spgxlog.c', +) diff --git a/src/backend/access/table/meson.build b/src/backend/access/table/meson.build new file mode 100644 index 00000000000..66c706d640e --- /dev/null +++ b/src/backend/access/table/meson.build @@ -0,0 +1,6 @@ +backend_sources += files( + 'table.c', + 'tableam.c', + 'tableamapi.c', + 'toast_helper.c', +) diff --git a/src/backend/access/tablesample/meson.build b/src/backend/access/tablesample/meson.build new file mode 100644 index 00000000000..63ee8203226 --- /dev/null +++ b/src/backend/access/tablesample/meson.build @@ -0,0 +1,5 @@ +backend_sources += files( + 'bernoulli.c', + 'system.c', + 'tablesample.c', +) diff --git a/src/backend/access/transam/meson.build b/src/backend/access/transam/meson.build new file mode 100644 index 00000000000..c32169bd2c6 --- /dev/null +++ b/src/backend/access/transam/meson.build @@ -0,0 +1,31 @@ +backend_sources += files( + 'clog.c', + 'commit_ts.c', + 'generic_xlog.c', + 'multixact.c', + 'parallel.c', + 'rmgr.c', + 'slru.c', + 'subtrans.c', + 'timeline.c', + 'transam.c', + 'twophase.c', + 'twophase_rmgr.c', + 'varsup.c', + 'xact.c', + 'xlog.c', + 'xlogarchive.c', + 'xlogfuncs.c', + 'xloginsert.c', + 'xlogprefetcher.c', + 'xlogrecovery.c', + 'xlogstats.c', + 'xlogutils.c', +) + +# used by frontend programs to build a frontend xlogreader +xlogreader_sources = files( + 'xlogreader.c', +) + +backend_sources += xlogreader_sources diff --git a/src/backend/backup/meson.build b/src/backend/backup/meson.build new file mode 100644 index 00000000000..a09305cadfa --- /dev/null +++ b/src/backend/backup/meson.build @@ -0,0 +1,13 @@ +backend_sources += files( + 'backup_manifest.c', + 'basebackup.c', + 'basebackup_copy.c', + 'basebackup_gzip.c', + 'basebackup_lz4.c', + 'basebackup_progress.c', + 'basebackup_server.c', + 'basebackup_sink.c', + 'basebackup_target.c', + 'basebackup_throttle.c', + 'basebackup_zstd.c', +) diff --git a/src/backend/bootstrap/meson.build b/src/backend/bootstrap/meson.build new file mode 100644 index 00000000000..55c33dd21c3 --- /dev/null +++ b/src/backend/bootstrap/meson.build @@ -0,0 +1,28 @@ +backend_sources += files( + 'bootstrap.c') + +# see ../parser/meson.build +boot_parser_sources = [] + +bootscanner = custom_target('bootscanner', + input: 'bootscanner.l', + output: 'bootscanner.c', + command: flex_cmd, +) +generated_sources += bootscanner +boot_parser_sources += bootscanner + +bootparse = custom_target('bootparse', + input: 'bootparse.y', + kwargs: bison_kw, +) +generated_sources += bootparse.to_list() +boot_parser_sources += bootparse + +boot_parser = static_library('boot_parser', + boot_parser_sources, + dependencies: [backend_code], + include_directories: include_directories('.'), + kwargs: internal_lib_args, +) +backend_link_with += boot_parser diff --git a/src/backend/catalog/meson.build b/src/backend/catalog/meson.build new file mode 100644 index 00000000000..08747914516 --- /dev/null +++ b/src/backend/catalog/meson.build @@ -0,0 +1,44 @@ +backend_sources += files( + 'aclchk.c', + 'catalog.c', + 'dependency.c', + 'heap.c', + 'index.c', + 'indexing.c', + 'namespace.c', + 'objectaccess.c', + 'objectaddress.c', + 'partition.c', + 'pg_aggregate.c', + 'pg_attrdef.c', + 'pg_cast.c', + 'pg_class.c', + 'pg_collation.c', + 'pg_constraint.c', + 'pg_conversion.c', + 'pg_db_role_setting.c', + 'pg_depend.c', + 'pg_enum.c', + 'pg_inherits.c', + 'pg_largeobject.c', + 'pg_namespace.c', + 'pg_operator.c', + 'pg_parameter_acl.c', + 'pg_proc.c', + 'pg_publication.c', + 'pg_range.c', + 'pg_shdepend.c', + 'pg_subscription.c', + 'pg_type.c', + 'storage.c', + 'toasting.c', +) + + +install_data( + 'information_schema.sql', + 'sql_features.txt', + 'system_functions.sql', + 'system_views.sql', + install_dir: dir_data, +) diff --git a/src/backend/commands/meson.build b/src/backend/commands/meson.build new file mode 100644 index 00000000000..9b350d025ff --- /dev/null +++ b/src/backend/commands/meson.build @@ -0,0 +1,51 @@ +backend_sources += files( + 'aggregatecmds.c', + 'alter.c', + 'amcmds.c', + 'analyze.c', + 'async.c', + 'cluster.c', + 'collationcmds.c', + 'comment.c', + 'constraint.c', + 'conversioncmds.c', + 'copy.c', + 'copyfrom.c', + 'copyfromparse.c', + 'copyto.c', + 'createas.c', + 'dbcommands.c', + 'define.c', + 'discard.c', + 'dropcmds.c', + 'event_trigger.c', + 'explain.c', + 'extension.c', + 'foreigncmds.c', + 'functioncmds.c', + 'indexcmds.c', + 'lockcmds.c', + 'matview.c', + 'opclasscmds.c', + 'operatorcmds.c', + 'policy.c', + 'portalcmds.c', + 'prepare.c', + 'proclang.c', + 'publicationcmds.c', + 'schemacmds.c', + 'seclabel.c', + 'sequence.c', + 'statscmds.c', + 'subscriptioncmds.c', + 'tablecmds.c', + 'tablespace.c', + 'trigger.c', + 'tsearchcmds.c', + 'typecmds.c', + 'user.c', + 'vacuum.c', + 'vacuumparallel.c', + 'variable.c', + 'view.c', +) diff --git a/src/backend/executor/meson.build b/src/backend/executor/meson.build new file mode 100644 index 00000000000..518674cfa28 --- /dev/null +++ b/src/backend/executor/meson.build @@ -0,0 +1,67 @@ +backend_sources += files( + 'execAmi.c', + 'execAsync.c', + 'execCurrent.c', + 'execExpr.c', + 'execExprInterp.c', + 'execGrouping.c', + 'execIndexing.c', + 'execJunk.c', + 'execMain.c', + 'execParallel.c', + 'execPartition.c', + 'execProcnode.c', + 'execReplication.c', + 'execSRF.c', + 'execScan.c', + 'execTuples.c', + 'execUtils.c', + 'functions.c', + 'instrument.c', + 'nodeAgg.c', + 'nodeAppend.c', + 'nodeBitmapAnd.c', + 'nodeBitmapHeapscan.c', + 'nodeBitmapIndexscan.c', + 'nodeBitmapOr.c', + 'nodeCtescan.c', + 'nodeCustom.c', + 'nodeForeignscan.c', + 'nodeFunctionscan.c', + 'nodeGather.c', + 'nodeGatherMerge.c', + 'nodeGroup.c', + 'nodeHash.c', + 'nodeHashjoin.c', + 'nodeIncrementalSort.c', + 'nodeIndexonlyscan.c', + 'nodeIndexscan.c', + 'nodeLimit.c', + 'nodeLockRows.c', + 'nodeMaterial.c', + 'nodeMemoize.c', + 'nodeMergeAppend.c', + 'nodeMergejoin.c', + 'nodeModifyTable.c', + 'nodeNamedtuplestorescan.c', + 'nodeNestloop.c', + 'nodeProjectSet.c', + 'nodeRecursiveunion.c', + 'nodeResult.c', + 'nodeSamplescan.c', + 'nodeSeqscan.c', + 'nodeSetOp.c', + 'nodeSort.c', + 'nodeSubplan.c', + 'nodeSubqueryscan.c', + 'nodeTableFuncscan.c', + 'nodeTidrangescan.c', + 'nodeTidscan.c', + 'nodeUnique.c', + 'nodeValuesscan.c', + 'nodeWindowAgg.c', + 'nodeWorktablescan.c', + 'spi.c', + 'tqueue.c', + 'tstoreReceiver.c', +) diff --git a/src/backend/foreign/meson.build b/src/backend/foreign/meson.build new file mode 100644 index 00000000000..57463db92c1 --- /dev/null +++ b/src/backend/foreign/meson.build @@ -0,0 +1,3 @@ +backend_sources += files( + 'foreign.c' +) diff --git a/src/backend/jit/llvm/meson.build b/src/backend/jit/llvm/meson.build new file mode 100644 index 00000000000..de2e624ab58 --- /dev/null +++ b/src/backend/jit/llvm/meson.build @@ -0,0 +1,73 @@ +if not llvm.found() + subdir_done() +endif + +# Build LLVM JIT backend module + +llvmjit_sources = [] + +# Infrastructure +llvmjit_sources += files( + 'llvmjit.c', + 'llvmjit_error.cpp', + 'llvmjit_inline.cpp', + 'llvmjit_wrap.cpp', +) + +# Code generation +llvmjit_sources += files( + 'llvmjit_deform.c', + 'llvmjit_expr.c', +) + +llvmjit = shared_module('llvmjit', + llvmjit_sources, + kwargs: pg_mod_args + { + 'dependencies': pg_mod_args['dependencies'] + [llvm], + } +) + +backend_targets += llvmjit + + +# Define a few bits and pieces used here and elsewhere to generate bitcode + +llvm_irgen_args = [ + '-c', '-o', '@OUTPUT@', '@INPUT@', + '-flto=thin', '-emit-llvm', + '-MD', '-MQ', '@OUTPUT@', '-MF', '@DEPFILE@', + '-O2', + '-Wno-ignored-attributes', + '-Wno-empty-body', +] + +if ccache.found() + llvm_irgen_command = ccache + llvm_irgen_args = [clang.path()] + llvm_irgen_args +else + llvm_irgen_command = clang +endif + + +# XXX: Need to determine proper version of the function cflags for clang +bitcode_cflags = ['-fno-strict-aliasing', '-fwrapv'] +bitcode_cflags += cppflags + +# XXX: Worth improving on the logic to find directories here +bitcode_cflags += '-I@BUILD_ROOT@/src/include' +bitcode_cflags += '-I@BUILD_ROOT@/src/backend/utils/misc' +bitcode_cflags += '-I@SOURCE_ROOT@/src/include' + + +# Note this is intentionally not installed to bitcodedir, as it's not for +# inlining +llvmjit_types = custom_target('llvmjit_types.bc', + command: [llvm_irgen_command] + llvm_irgen_args + bitcode_cflags, + input: 'llvmjit_types.c', + output: 'llvmjit_types.bc', + depends: [postgres], + install: true, + install_dir: dir_lib_pkg, + depfile: '@BASENAME@.c.bc.d', +) +backend_targets += llvmjit_types diff --git a/src/backend/jit/meson.build b/src/backend/jit/meson.build new file mode 100644 index 00000000000..63cd33a4bed --- /dev/null +++ b/src/backend/jit/meson.build @@ -0,0 +1,3 @@ +backend_sources += files( + 'jit.c' +) diff --git a/src/backend/lib/meson.build b/src/backend/lib/meson.build new file mode 100644 index 00000000000..48da1bddce7 --- /dev/null +++ b/src/backend/lib/meson.build @@ -0,0 +1,12 @@ +backend_sources += files( + 'binaryheap.c', + 'bipartite_match.c', + 'bloomfilter.c', + 'dshash.c', + 'hyperloglog.c', + 'ilist.c', + 'integerset.c', + 'knapsack.c', + 'pairingheap.c', + 'rbtree.c', +) diff --git a/src/backend/libpq/meson.build b/src/backend/libpq/meson.build new file mode 100644 index 00000000000..6061269ef13 --- /dev/null +++ b/src/backend/libpq/meson.build @@ -0,0 +1,32 @@ +backend_sources += files( + 'auth-sasl.c', + 'auth-scram.c', + 'auth.c', + 'be-fsstubs.c', + 'be-secure-common.c', + 'be-secure.c', + 'crypt.c', + 'hba.c', + 'ifaddr.c', + 'pqcomm.c', + 'pqformat.c', + 'pqmq.c', + 'pqsignal.c', +) + +if ssl.found() + backend_sources += files('be-secure-openssl.c') +endif + +if gssapi.found() + backend_sources += files( + 'be-secure-gssapi.c', + 'be-gssapi-common.c' + ) +endif + +install_data( + 'pg_hba.conf.sample', + 'pg_ident.conf.sample', + install_dir: dir_data, +) diff --git a/src/backend/main/meson.build b/src/backend/main/meson.build new file mode 100644 index 00000000000..241e125f089 --- /dev/null +++ b/src/backend/main/meson.build @@ -0,0 +1,2 @@ +main_file = files('main.c') +backend_sources += main_file diff --git a/src/backend/meson.build b/src/backend/meson.build new file mode 100644 index 00000000000..fefa40ddb64 --- /dev/null +++ b/src/backend/meson.build @@ -0,0 +1,190 @@ +backend_build_deps = [backend_code] +backend_sources = [] +backend_link_with = [pgport_srv, common_srv] + +generated_backend_sources = [] + +subdir('access') +subdir('backup') +subdir('bootstrap') +subdir('catalog') +subdir('commands') +subdir('executor') +subdir('foreign') +subdir('jit') +subdir('lib') +subdir('libpq') +subdir('main') +subdir('nodes') +subdir('optimizer') +subdir('parser') +subdir('partitioning') +subdir('port') +subdir('postmaster') +subdir('regex') +subdir('replication') +subdir('rewrite') +subdir('statistics') +subdir('storage') +subdir('tcop') +subdir('tsearch') +subdir('utils') + +subdir('po', if_found: libintl) + + +backend_link_args = [] +backend_link_depends = [] + + +# On windows when compiling with msvc we need to make postgres export all its +# symbols so that extension libraries can use them. For that we need to scan +# the constituting objects and generate a file specifying all the functions as +# exported (variables need an "import" declaration in the header, hence +# PGDLLEXPORT, but functions work without that, due to import libraries +# basically being trampolines). +# +# For dtrace probes we need to invoke dtrace on all input files, before +# linking the final executable (see more below). +# +# +# On meson there's currently no easy way to do this that I found. So we build +# a static library with all the input objects, run our script to generate +# exports, and build the final executable using that static library +# +# We could do that only if either dtrace or msvc is in use, but it seems +# easier to just always do so. +# +# Can't name the static library 'postgres', because msbuild ends up with a +# conflict for the .pdb file otherwise. + +postgres_lib = static_library('postgres_lib', + backend_sources + timezone_sources + generated_backend_sources, + link_whole: backend_link_with, + dependencies: backend_build_deps, + kwargs: internal_lib_args, +) + +if cc.get_id() == 'msvc' + postgres_def = custom_target('postgres.def', + command: [perl, files('../tools/msvc/gendef.pl'), + '--arch', host_cpu, + '--tempdir', '@PRIVATE_DIR@', + '--deffile', '@OUTPUT@', + '@INPUT@'], + input: [postgres_lib, common_srv, pgport_srv], + output: 'postgres.def', + depends: [postgres_lib, common_srv, pgport_srv], + install: false, + build_by_default: false, + ) + + backend_link_args += '/DEF:@0@'.format(postgres_def.full_path()) + backend_link_depends += postgres_def + +elif host_system == 'aix' + # The '.' argument leads mkldexport.sh to emit "#! .", which refers to the + # main executable, allowing extension libraries to resolve their undefined + # symbols to symbols in the postgres binary. + postgres_imp = custom_target('postgres.imp', + command: [files('port/aix/mkldexport.sh'), '@INPUT@', '.'], + input: postgres_lib, + output: 'postgres.imp', + capture: true, + install: true, + install_dir: dir_lib, + build_by_default: false, + ) + backend_link_args += '-Wl,-bE:@0@'.format(postgres_imp.full_path()) + backend_link_depends += postgres_imp +endif + +backend_input = [] +backend_objs = [postgres_lib.extract_all_objects(recursive: false)] + +# As of 1/2010: +# The probes.o file is necessary for dtrace support on Solaris, and on recent +# versions of systemtap. (Older systemtap releases just produce an empty +# file, but that's okay.) However, macOS's dtrace doesn't use it and doesn't +# even recognize the -G option. So, build probes.o except on macOS. +# This might need adjustment as other platforms add dtrace support. +# +# On at least linux we don't actually need to pass in all the objects, but +# at least on FreeBSD and Solaris we have to. +# +# XXX: The reason we don't use the objects for generated sources is that +# hits a meson bug. Luckily we don't don't have probes in generated +# sources... +if dtrace.found() and host_system != 'darwin' + backend_input += custom_target( + 'probes.o', + input: ['utils/probes.d', postgres_lib.extract_objects(backend_sources, timezone_sources)], + output: 'probes.o', + command: [dtrace, '-C', '-G', '-o', '@OUTPUT@', '-s', '@INPUT@'], + install: false, + ) +endif + +postgres = executable('postgres', + backend_input, + objects: backend_objs, + link_args: backend_link_args, + link_with: backend_link_with, + link_depends: backend_link_depends, + export_dynamic: true, + implib: true, + dependencies: backend_build_deps, + kwargs: default_bin_args, +) + +backend_targets += postgres + +pg_mod_c_args = cflags_mod +pg_mod_cpp_args = cxxflags_mod +pg_mod_link_args = ldflags_sl + ldflags_mod +pg_mod_link_depend = [] + +# A few platforms like MacOS and Windows link shared modules against postgres, +# or a [import] library derived from it. Set up the link flags for that. +if mod_link_args_fmt.length() > 0 + # To avoid unnecessary build-time dependencies on other operating systems, + # only the dependency when it when necessary. + pg_mod_link_depend += postgres + + name = mod_link_with_name.format('postgres') + link_with_uninst = meson.current_build_dir() / name + link_with_inst = '${@0@}/@1@'.format(mod_link_with_dir, name) + + foreach el : mod_link_args_fmt + pg_mod_link_args += el.format(link_with_uninst) + endforeach +endif + + +# Note there's intentionally no dependency on pgport/common here - we want the +# symbols from the main binary for extension modules, rather than the +# extension linking separately to pgport/common. +backend_mod_code = declare_dependency( + compile_args: pg_mod_c_args, + include_directories: postgres_inc, + link_args: pg_mod_link_args, + sources: generated_headers + generated_backend_headers, + dependencies: backend_mod_deps, +) + +pg_mod_args = default_mod_args + { + 'dependencies': [backend_mod_code], + 'cpp_args': pg_mod_cpp_args, + 'link_depends': pg_mod_link_depend, +} + + + +# Shared modules that, on some system, link against the server binary. Only +# enter these after we defined the server build. + +subdir('jit/llvm') +subdir('replication/libpqwalreceiver') +subdir('replication/pgoutput') +subdir('snowball') +subdir('utils/mb/conversion_procs') diff --git a/src/backend/nodes/meson.build b/src/backend/nodes/meson.build new file mode 100644 index 00000000000..8e0d4039f24 --- /dev/null +++ b/src/backend/nodes/meson.build @@ -0,0 +1,29 @@ +backend_sources += files( + 'bitmapset.c', + 'extensible.c', + 'list.c', + 'makefuncs.c', + 'nodeFuncs.c', + 'nodes.c', + 'params.c', + 'print.c', + 'read.c', + 'tidbitmap.c', + 'value.c', +) + +# these include .c files generated in ../../include/nodes, seems nicer to not +# add that as an include path for the whole backend +nodefunc_sources = files( + 'copyfuncs.c', + 'equalfuncs.c', + 'outfuncs.c', + 'readfuncs.c', +) +nodefuncs = static_library('nodefuncs', + nodefunc_sources, + dependencies: [backend_code], + include_directories: include_directories('../../include/nodes'), + kwargs: internal_lib_args, +) +backend_link_with += nodefuncs diff --git a/src/backend/optimizer/geqo/meson.build b/src/backend/optimizer/geqo/meson.build new file mode 100644 index 00000000000..c04f1dc2dfd --- /dev/null +++ b/src/backend/optimizer/geqo/meson.build @@ -0,0 +1,17 @@ +backend_sources += files( + 'geqo_copy.c', + 'geqo_cx.c', + 'geqo_erx.c', + 'geqo_eval.c', + 'geqo_main.c', + 'geqo_misc.c', + 'geqo_mutation.c', + 'geqo_ox1.c', + 'geqo_ox2.c', + 'geqo_pmx.c', + 'geqo_pool.c', + 'geqo_px.c', + 'geqo_random.c', + 'geqo_recombination.c', + 'geqo_selection.c', +) diff --git a/src/backend/optimizer/meson.build b/src/backend/optimizer/meson.build new file mode 100644 index 00000000000..1ab1d9934ae --- /dev/null +++ b/src/backend/optimizer/meson.build @@ -0,0 +1,5 @@ +subdir('geqo') +subdir('path') +subdir('plan') +subdir('prep') +subdir('util') diff --git a/src/backend/optimizer/path/meson.build b/src/backend/optimizer/path/meson.build new file mode 100644 index 00000000000..310042e7aee --- /dev/null +++ b/src/backend/optimizer/path/meson.build @@ -0,0 +1,11 @@ +backend_sources += files( + 'allpaths.c', + 'clausesel.c', + 'costsize.c', + 'equivclass.c', + 'indxpath.c', + 'joinpath.c', + 'joinrels.c', + 'pathkeys.c', + 'tidpath.c', +) diff --git a/src/backend/optimizer/plan/meson.build b/src/backend/optimizer/plan/meson.build new file mode 100644 index 00000000000..22ec65a3845 --- /dev/null +++ b/src/backend/optimizer/plan/meson.build @@ -0,0 +1,10 @@ +backend_sources += files( + 'analyzejoins.c', + 'createplan.c', + 'initsplan.c', + 'planagg.c', + 'planmain.c', + 'planner.c', + 'setrefs.c', + 'subselect.c', +) diff --git a/src/backend/optimizer/prep/meson.build b/src/backend/optimizer/prep/meson.build new file mode 100644 index 00000000000..4549a5b0e79 --- /dev/null +++ b/src/backend/optimizer/prep/meson.build @@ -0,0 +1,7 @@ +backend_sources += files( + 'prepagg.c', + 'prepjointree.c', + 'prepqual.c', + 'preptlist.c', + 'prepunion.c', +) diff --git a/src/backend/optimizer/util/meson.build b/src/backend/optimizer/util/meson.build new file mode 100644 index 00000000000..e7ceaf566b5 --- /dev/null +++ b/src/backend/optimizer/util/meson.build @@ -0,0 +1,16 @@ +backend_sources += files( + 'appendinfo.c', + 'clauses.c', + 'inherit.c', + 'joininfo.c', + 'orclauses.c', + 'paramassign.c', + 'pathnode.c', + 'placeholder.c', + 'plancat.c', + 'predtest.c', + 'relnode.c', + 'restrictinfo.c', + 'tlist.c', + 'var.c', +) diff --git a/src/backend/parser/meson.build b/src/backend/parser/meson.build new file mode 100644 index 00000000000..15d5a349eeb --- /dev/null +++ b/src/backend/parser/meson.build @@ -0,0 +1,48 @@ +backend_sources += files( + 'analyze.c', + 'parse_agg.c', + 'parse_clause.c', + 'parse_coerce.c', + 'parse_collate.c', + 'parse_cte.c', + 'parse_enr.c', + 'parse_expr.c', + 'parse_func.c', + 'parse_merge.c', + 'parse_node.c', + 'parse_oper.c', + 'parse_param.c', + 'parse_relation.c', + 'parse_target.c', + 'parse_type.c', + 'parse_utilcmd.c', + 'scansup.c', +) + +# Build a small utility static lib for the parser. The generation of the +# parser is slow, and building this separately avoids other parts of the +# backend having to wait till gram.h is generated. +parser_sources = files('parser.c') + +backend_scanner = custom_target('scan', + input: 'scan.l', + output: 'scan.c', + command: [flex_cmd, '--no-backup', '--fix-warnings', '--', '-CF', '-p', '-p'], +) +generated_sources += backend_scanner +parser_sources += backend_scanner + +backend_parser = custom_target('gram', + input: 'gram.y', + kwargs: bison_kw, +) +generated_sources += backend_parser.to_list() +parser_sources += backend_parser + +parser = static_library('parser', + parser_sources, + dependencies: [backend_code], + include_directories: include_directories('.'), + kwargs: internal_lib_args, +) +backend_link_with += parser diff --git a/src/backend/partitioning/meson.build b/src/backend/partitioning/meson.build new file mode 100644 index 00000000000..e5e3806a0cc --- /dev/null +++ b/src/backend/partitioning/meson.build @@ -0,0 +1,5 @@ +backend_sources += files( + 'partbounds.c', + 'partdesc.c', + 'partprune.c', +) diff --git a/src/backend/po/meson.build b/src/backend/po/meson.build new file mode 100644 index 00000000000..4ace0554680 --- /dev/null +++ b/src/backend/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('postgres-' + pg_version_major.to_string()) diff --git a/src/backend/port/meson.build b/src/backend/port/meson.build new file mode 100644 index 00000000000..a22c25dd952 --- /dev/null +++ b/src/backend/port/meson.build @@ -0,0 +1,31 @@ +backend_sources += files( + 'atomics.c', +) + + +if cdata.has('USE_UNNAMED_POSIX_SEMAPHORES') or cdata.has('USE_NAMED_POSIX_SEMAPHORES') + backend_sources += files('posix_sema.c') +endif + +if cdata.has('USE_SYSV_SEMAPHORES') + backend_sources += files('sysv_sema.c') +endif + +if cdata.has('USE_WIN32_SEMAPHORES') + backend_sources += files('win32_sema.c') +endif + +if cdata.has('USE_SYSV_SHARED_MEMORY') + backend_sources += files('sysv_shmem.c') +endif + +if cdata.has('USE_WIN32_SHARED_MEMORY') + backend_sources += files('win32_shmem.c') +endif + +if host_system == 'windows' + subdir('win32') +endif + +# autoconf generates the file there, ensure we get a conflict +generated_sources_ac += {'src/backend/port': ['pg_sema.c', 'pg_shmem.c', 'tas.s']} diff --git a/src/backend/port/win32/meson.build b/src/backend/port/win32/meson.build new file mode 100644 index 00000000000..68fe4cc3cd0 --- /dev/null +++ b/src/backend/port/win32/meson.build @@ -0,0 +1,6 @@ +backend_sources += files( + 'crashdump.c', + 'signal.c', + 'socket.c', + 'timer.c', +) diff --git a/src/backend/postmaster/meson.build b/src/backend/postmaster/meson.build new file mode 100644 index 00000000000..293a44ca295 --- /dev/null +++ b/src/backend/postmaster/meson.build @@ -0,0 +1,15 @@ +backend_sources += files( + 'autovacuum.c', + 'auxprocess.c', + 'bgworker.c', + 'bgwriter.c', + 'checkpointer.c', + 'fork_process.c', + 'interrupt.c', + 'pgarch.c', + 'postmaster.c', + 'shell_archive.c', + 'startup.c', + 'syslogger.c', + 'walwriter.c', +) diff --git a/src/backend/regex/meson.build b/src/backend/regex/meson.build new file mode 100644 index 00000000000..c84e57fdba5 --- /dev/null +++ b/src/backend/regex/meson.build @@ -0,0 +1,8 @@ +backend_sources += files( + 'regcomp.c', + 'regerror.c', + 'regexec.c', + 'regexport.c', + 'regfree.c', + 'regprefix.c', +) diff --git a/src/backend/replication/libpqwalreceiver/meson.build b/src/backend/replication/libpqwalreceiver/meson.build new file mode 100644 index 00000000000..3fc786c80a0 --- /dev/null +++ b/src/backend/replication/libpqwalreceiver/meson.build @@ -0,0 +1,13 @@ +libpqwalreceiver_sources = files( + 'libpqwalreceiver.c', +) + +libpqwalreceiver = shared_module('pqwalreceiver', + libpqwalreceiver_sources, + kwargs: pg_mod_args + { + 'name_prefix': 'lib', + 'dependencies': pg_mod_args['dependencies'] + [libpq], + } +) + +backend_targets += libpqwalreceiver diff --git a/src/backend/replication/logical/meson.build b/src/backend/replication/logical/meson.build new file mode 100644 index 00000000000..773583a12ba --- /dev/null +++ b/src/backend/replication/logical/meson.build @@ -0,0 +1,14 @@ +backend_sources += files( + 'decode.c', + 'launcher.c', + 'logical.c', + 'logicalfuncs.c', + 'message.c', + 'origin.c', + 'proto.c', + 'relation.c', + 'reorderbuffer.c', + 'snapbuild.c', + 'tablesync.c', + 'worker.c', +) diff --git a/src/backend/replication/meson.build b/src/backend/replication/meson.build new file mode 100644 index 00000000000..27b9bf13182 --- /dev/null +++ b/src/backend/replication/meson.build @@ -0,0 +1,51 @@ +backend_sources += files( + 'slot.c', + 'slotfuncs.c', + 'syncrep.c', + 'walreceiver.c', + 'walreceiverfuncs.c', + 'walsender.c', +) + +# see ../parser/meson.build +repl_parser_sources = [] + +repl_scanner = custom_target('repl_scanner', + input: 'repl_scanner.l', + output: 'repl_scanner.c', + command: flex_cmd, +) +generated_sources += repl_scanner +repl_parser_sources += repl_scanner + +repl_gram = custom_target('repl_gram', + input: 'repl_gram.y', + kwargs: bison_kw, +) +generated_sources += repl_gram.to_list() +repl_parser_sources += repl_gram + +syncrep_scanner = custom_target('syncrep_scanner', + input: 'syncrep_scanner.l', + output: 'syncrep_scanner.c', + command: flex_cmd, +) +generated_sources += syncrep_scanner +repl_parser_sources += syncrep_scanner + +syncrep_gram = custom_target('syncrep_gram', + input: 'syncrep_gram.y', + kwargs: bison_kw, +) +generated_sources += syncrep_gram.to_list() +repl_parser_sources += syncrep_gram + +repl_parser = static_library('repl_parser', + repl_parser_sources, + dependencies: [backend_code], + include_directories: include_directories('.'), + kwargs: internal_lib_args, +) +backend_link_with += repl_parser + +subdir('logical') diff --git a/src/backend/replication/pgoutput/meson.build b/src/backend/replication/pgoutput/meson.build new file mode 100644 index 00000000000..ab956361a62 --- /dev/null +++ b/src/backend/replication/pgoutput/meson.build @@ -0,0 +1,10 @@ +pgoutput_sources = files( + 'pgoutput.c', +) + +pgoutput = shared_module('pgoutput', + pgoutput_sources, + kwargs: pg_mod_args, +) + +backend_targets += pgoutput diff --git a/src/backend/rewrite/meson.build b/src/backend/rewrite/meson.build new file mode 100644 index 00000000000..21fa0e230b0 --- /dev/null +++ b/src/backend/rewrite/meson.build @@ -0,0 +1,9 @@ +backend_sources += files( + 'rewriteDefine.c', + 'rewriteHandler.c', + 'rewriteManip.c', + 'rewriteRemove.c', + 'rewriteSearchCycle.c', + 'rewriteSupport.c', + 'rowsecurity.c', +) diff --git a/src/backend/snowball/meson.build b/src/backend/snowball/meson.build new file mode 100644 index 00000000000..8c6f685cb32 --- /dev/null +++ b/src/backend/snowball/meson.build @@ -0,0 +1,88 @@ +dict_snowball_sources = files( + 'libstemmer/api.c', + 'libstemmer/utilities.c', + 'dict_snowball.c', +) + +dict_snowball_sources += files( + 'libstemmer/stem_ISO_8859_1_basque.c', + 'libstemmer/stem_ISO_8859_1_catalan.c', + 'libstemmer/stem_ISO_8859_1_danish.c', + 'libstemmer/stem_ISO_8859_1_dutch.c', + 'libstemmer/stem_ISO_8859_1_english.c', + 'libstemmer/stem_ISO_8859_1_finnish.c', + 'libstemmer/stem_ISO_8859_1_french.c', + 'libstemmer/stem_ISO_8859_1_german.c', + 'libstemmer/stem_ISO_8859_1_indonesian.c', + 'libstemmer/stem_ISO_8859_1_irish.c', + 'libstemmer/stem_ISO_8859_1_italian.c', + 'libstemmer/stem_ISO_8859_1_norwegian.c', + 'libstemmer/stem_ISO_8859_1_porter.c', + 'libstemmer/stem_ISO_8859_1_portuguese.c', + 'libstemmer/stem_ISO_8859_1_spanish.c', + 'libstemmer/stem_ISO_8859_1_swedish.c', + 'libstemmer/stem_ISO_8859_2_hungarian.c', + 'libstemmer/stem_ISO_8859_2_romanian.c', + 'libstemmer/stem_KOI8_R_russian.c', + 'libstemmer/stem_UTF_8_arabic.c', + 'libstemmer/stem_UTF_8_armenian.c', + 'libstemmer/stem_UTF_8_basque.c', + 'libstemmer/stem_UTF_8_catalan.c', + 'libstemmer/stem_UTF_8_danish.c', + 'libstemmer/stem_UTF_8_dutch.c', + 'libstemmer/stem_UTF_8_english.c', + 'libstemmer/stem_UTF_8_finnish.c', + 'libstemmer/stem_UTF_8_french.c', + 'libstemmer/stem_UTF_8_german.c', + 'libstemmer/stem_UTF_8_greek.c', + 'libstemmer/stem_UTF_8_hindi.c', + 'libstemmer/stem_UTF_8_hungarian.c', + 'libstemmer/stem_UTF_8_indonesian.c', + 'libstemmer/stem_UTF_8_irish.c', + 'libstemmer/stem_UTF_8_italian.c', + 'libstemmer/stem_UTF_8_lithuanian.c', + 'libstemmer/stem_UTF_8_nepali.c', + 'libstemmer/stem_UTF_8_norwegian.c', + 'libstemmer/stem_UTF_8_porter.c', + 'libstemmer/stem_UTF_8_portuguese.c', + 'libstemmer/stem_UTF_8_romanian.c', + 'libstemmer/stem_UTF_8_russian.c', + 'libstemmer/stem_UTF_8_serbian.c', + 'libstemmer/stem_UTF_8_spanish.c', + 'libstemmer/stem_UTF_8_swedish.c', + 'libstemmer/stem_UTF_8_tamil.c', + 'libstemmer/stem_UTF_8_turkish.c', + 'libstemmer/stem_UTF_8_yiddish.c', +) + +# see comment in src/include/snowball/header.h +stemmer_inc = include_directories('../../include/snowball') + +dict_snowball = shared_module('dict_snowball', + dict_snowball_sources, + kwargs: pg_mod_args + { + 'include_directories': [stemmer_inc], + } +) + +snowball_create = custom_target('snowball_create', + output: ['snowball_create.sql'], + depfile: 'snowball_create.dep', + command: [ + perl, files('snowball_create.pl'), + '--depfile', + '--input', '@CURRENT_SOURCE_DIR@', + '--outdir', '@OUTDIR@', + ], + install: true, + install_dir: dir_data, +) +generated_sources += snowball_create + +install_subdir('stopwords', + install_dir: dir_data / 'tsearch_data', + strip_directory: true, +) + +backend_targets += dict_snowball +backend_targets += snowball_create diff --git a/src/backend/statistics/meson.build b/src/backend/statistics/meson.build new file mode 100644 index 00000000000..8530c55f73c --- /dev/null +++ b/src/backend/statistics/meson.build @@ -0,0 +1,6 @@ +backend_sources += files( + 'dependencies.c', + 'extended_stats.c', + 'mcv.c', + 'mvdistinct.c', +) diff --git a/src/backend/storage/buffer/meson.build b/src/backend/storage/buffer/meson.build new file mode 100644 index 00000000000..56a59b52484 --- /dev/null +++ b/src/backend/storage/buffer/meson.build @@ -0,0 +1,7 @@ +backend_sources += files( + 'buf_init.c', + 'buf_table.c', + 'bufmgr.c', + 'freelist.c', + 'localbuf.c', +) diff --git a/src/backend/storage/file/meson.build b/src/backend/storage/file/meson.build new file mode 100644 index 00000000000..e1d5047d4aa --- /dev/null +++ b/src/backend/storage/file/meson.build @@ -0,0 +1,8 @@ +backend_sources += files( + 'buffile.c', + 'copydir.c', + 'fd.c', + 'fileset.c', + 'reinit.c', + 'sharedfileset.c', +) diff --git a/src/backend/storage/freespace/meson.build b/src/backend/storage/freespace/meson.build new file mode 100644 index 00000000000..e4200ea6527 --- /dev/null +++ b/src/backend/storage/freespace/meson.build @@ -0,0 +1,5 @@ +backend_sources += files( + 'freespace.c', + 'fsmpage.c', + 'indexfsm.c', +) diff --git a/src/backend/storage/ipc/meson.build b/src/backend/storage/ipc/meson.build new file mode 100644 index 00000000000..516bc1d0193 --- /dev/null +++ b/src/backend/storage/ipc/meson.build @@ -0,0 +1,20 @@ +backend_sources += files( + 'barrier.c', + 'dsm.c', + 'dsm_impl.c', + 'ipc.c', + 'ipci.c', + 'latch.c', + 'pmsignal.c', + 'procarray.c', + 'procsignal.c', + 'shm_mq.c', + 'shm_toc.c', + 'shmem.c', + 'shmqueue.c', + 'signalfuncs.c', + 'sinval.c', + 'sinvaladt.c', + 'standby.c', + +) diff --git a/src/backend/storage/large_object/meson.build b/src/backend/storage/large_object/meson.build new file mode 100644 index 00000000000..8a181ab9b34 --- /dev/null +++ b/src/backend/storage/large_object/meson.build @@ -0,0 +1,3 @@ +backend_sources += files( + 'inv_api.c', +) diff --git a/src/backend/storage/lmgr/meson.build b/src/backend/storage/lmgr/meson.build new file mode 100644 index 00000000000..68237c8a2e8 --- /dev/null +++ b/src/backend/storage/lmgr/meson.build @@ -0,0 +1,13 @@ +backend_sources += files( + 'condition_variable.c', + 'deadlock.c', + 'lmgr.c', + 'lock.c', + 'lwlock.c', + 'predicate.c', + 'proc.c', + 's_lock.c', + 'spin.c', +) + +generated_backend_sources += lwlocknames[1] diff --git a/src/backend/storage/meson.build b/src/backend/storage/meson.build new file mode 100644 index 00000000000..daad628d74c --- /dev/null +++ b/src/backend/storage/meson.build @@ -0,0 +1,9 @@ +subdir('buffer') +subdir('file') +subdir('freespace') +subdir('ipc') +subdir('large_object') +subdir('lmgr') +subdir('page') +subdir('smgr') +subdir('sync') diff --git a/src/backend/storage/page/meson.build b/src/backend/storage/page/meson.build new file mode 100644 index 00000000000..2ecd16c952c --- /dev/null +++ b/src/backend/storage/page/meson.build @@ -0,0 +1,5 @@ +backend_sources += files( + 'bufpage.c', + 'checksum.c', + 'itemptr.c', +) diff --git a/src/backend/storage/smgr/meson.build b/src/backend/storage/smgr/meson.build new file mode 100644 index 00000000000..fdeb1223b32 --- /dev/null +++ b/src/backend/storage/smgr/meson.build @@ -0,0 +1,4 @@ +backend_sources += files( + 'md.c', + 'smgr.c', +) diff --git a/src/backend/storage/sync/meson.build b/src/backend/storage/sync/meson.build new file mode 100644 index 00000000000..05148b91a8e --- /dev/null +++ b/src/backend/storage/sync/meson.build @@ -0,0 +1,4 @@ +backend_sources += files( + 'sync.c', + +) diff --git a/src/backend/tcop/meson.build b/src/backend/tcop/meson.build new file mode 100644 index 00000000000..fb54aae8122 --- /dev/null +++ b/src/backend/tcop/meson.build @@ -0,0 +1,8 @@ +backend_sources += files( + 'cmdtag.c', + 'dest.c', + 'fastpath.c', + 'postgres.c', + 'pquery.c', + 'utility.c', +) diff --git a/src/backend/tsearch/meson.build b/src/backend/tsearch/meson.build new file mode 100644 index 00000000000..4144e9befc5 --- /dev/null +++ b/src/backend/tsearch/meson.build @@ -0,0 +1,21 @@ +backend_sources += files( + 'dict.c', + 'dict_ispell.c', + 'dict_simple.c', + 'dict_synonym.c', + 'dict_thesaurus.c', + 'regis.c', + 'spell.c', + 'to_tsany.c', + 'ts_locale.c', + 'ts_parse.c', + 'ts_selfuncs.c', + 'ts_typanalyze.c', + 'ts_utils.c', + 'wparser.c', + 'wparser_def.c', +) + +install_subdir('dicts', + install_dir: dir_data / 'tsearch_data', + strip_directory: true) diff --git a/src/backend/utils/activity/meson.build b/src/backend/utils/activity/meson.build new file mode 100644 index 00000000000..5b3b558a67d --- /dev/null +++ b/src/backend/utils/activity/meson.build @@ -0,0 +1,18 @@ +backend_sources += files( + 'backend_progress.c', + 'backend_status.c', + 'pgstat.c', + 'pgstat_archiver.c', + 'pgstat_bgwriter.c', + 'pgstat_checkpointer.c', + 'pgstat_database.c', + 'pgstat_function.c', + 'pgstat_relation.c', + 'pgstat_replslot.c', + 'pgstat_shmem.c', + 'pgstat_slru.c', + 'pgstat_subscription.c', + 'pgstat_wal.c', + 'pgstat_xact.c', + 'wait_event.c', +) diff --git a/src/backend/utils/adt/meson.build b/src/backend/utils/adt/meson.build new file mode 100644 index 00000000000..ed9ceadfef0 --- /dev/null +++ b/src/backend/utils/adt/meson.build @@ -0,0 +1,131 @@ +backend_sources += files( + 'acl.c', + 'amutils.c', + 'array_expanded.c', + 'array_selfuncs.c', + 'array_typanalyze.c', + 'array_userfuncs.c', + 'arrayfuncs.c', + 'arraysubs.c', + 'arrayutils.c', + 'ascii.c', + 'bool.c', + 'cash.c', + 'char.c', + 'cryptohashfuncs.c', + 'date.c', + 'datetime.c', + 'datum.c', + 'dbsize.c', + 'domains.c', + 'encode.c', + 'enum.c', + 'expandeddatum.c', + 'expandedrecord.c', + 'float.c', + 'format_type.c', + 'formatting.c', + 'genfile.c', + 'geo_ops.c', + 'geo_selfuncs.c', + 'geo_spgist.c', + 'hbafuncs.c', + 'inet_cidr_ntop.c', + 'inet_net_pton.c', + 'int.c', + 'int8.c', + 'json.c', + 'jsonb.c', + 'jsonb_gin.c', + 'jsonb_op.c', + 'jsonb_util.c', + 'jsonbsubs.c', + 'jsonfuncs.c', + 'jsonpath.c', + 'jsonpath_exec.c', + 'like.c', + 'like_support.c', + 'lockfuncs.c', + 'mac.c', + 'mac8.c', + 'mcxtfuncs.c', + 'misc.c', + 'multirangetypes.c', + 'multirangetypes_selfuncs.c', + 'name.c', + 'network.c', + 'network_gist.c', + 'network_selfuncs.c', + 'network_spgist.c', + 'numeric.c', + 'numutils.c', + 'oid.c', + 'oracle_compat.c', + 'orderedsetaggs.c', + 'partitionfuncs.c', + 'pg_locale.c', + 'pg_lsn.c', + 'pg_upgrade_support.c', + 'pgstatfuncs.c', + 'pseudotypes.c', + 'quote.c', + 'rangetypes.c', + 'rangetypes_gist.c', + 'rangetypes_selfuncs.c', + 'rangetypes_spgist.c', + 'rangetypes_typanalyze.c', + 'regexp.c', + 'regproc.c', + 'ri_triggers.c', + 'rowtypes.c', + 'ruleutils.c', + 'selfuncs.c', + 'tid.c', + 'timestamp.c', + 'trigfuncs.c', + 'tsginidx.c', + 'tsgistidx.c', + 'tsquery.c', + 'tsquery_cleanup.c', + 'tsquery_gist.c', + 'tsquery_op.c', + 'tsquery_rewrite.c', + 'tsquery_util.c', + 'tsrank.c', + 'tsvector.c', + 'tsvector_op.c', + 'tsvector_parser.c', + 'uuid.c', + 'varbit.c', + 'varchar.c', + 'varlena.c', + 'version.c', + 'windowfuncs.c', + 'xid.c', + 'xid8funcs.c', + 'xml.c', +) + + +jsonpath_scan = custom_target('jsonpath_scan', + input: 'jsonpath_scan.l', + output: 'jsonpath_scan.c', + command: [flex_cmd, '--no-backup', '--', '-CF', '-p', '-p'], +) +generated_sources += jsonpath_scan + +jsonpath_gram = custom_target('jsonpath_parse', + input: 'jsonpath_gram.y', + kwargs: bison_kw, +) +generated_sources += jsonpath_gram.to_list() + +# so we don't need to add . as an include dir for the whole backend +backend_link_with += static_library('jsonpath', + jsonpath_scan, jsonpath_gram, + dependencies: [backend_code], + include_directories: include_directories('.'), + kwargs: internal_lib_args, +) + +#generated_backend_sources += jsonpath_gram.to_list() diff --git a/src/backend/utils/cache/meson.build b/src/backend/utils/cache/meson.build new file mode 100644 index 00000000000..4fe6db6bda6 --- /dev/null +++ b/src/backend/utils/cache/meson.build @@ -0,0 +1,16 @@ +backend_sources += files( + 'attoptcache.c', + 'catcache.c', + 'evtcache.c', + 'inval.c', + 'lsyscache.c', + 'partcache.c', + 'plancache.c', + 'relcache.c', + 'relfilenumbermap.c', + 'relmapper.c', + 'spccache.c', + 'syscache.c', + 'ts_cache.c', + 'typcache.c', +) diff --git a/src/backend/utils/error/meson.build b/src/backend/utils/error/meson.build new file mode 100644 index 00000000000..325446c8f93 --- /dev/null +++ b/src/backend/utils/error/meson.build @@ -0,0 +1,6 @@ +backend_sources += files( + 'assert.c', + 'csvlog.c', + 'elog.c', + 'jsonlog.c', +) diff --git a/src/backend/utils/fmgr/meson.build b/src/backend/utils/fmgr/meson.build new file mode 100644 index 00000000000..e545b424fd2 --- /dev/null +++ b/src/backend/utils/fmgr/meson.build @@ -0,0 +1,8 @@ +backend_sources += files( + 'dfmgr.c', + 'fmgr.c', + 'funcapi.c', +) + +# fmgrtab.c +generated_backend_sources += fmgrtab_target[2] diff --git a/src/backend/utils/hash/meson.build b/src/backend/utils/hash/meson.build new file mode 100644 index 00000000000..242e2f0ecdf --- /dev/null +++ b/src/backend/utils/hash/meson.build @@ -0,0 +1,4 @@ +backend_sources += files( + 'dynahash.c', + 'pg_crc.c' +) diff --git a/src/backend/utils/init/meson.build b/src/backend/utils/init/meson.build new file mode 100644 index 00000000000..ec9d72c3df1 --- /dev/null +++ b/src/backend/utils/init/meson.build @@ -0,0 +1,4 @@ +backend_sources += files( + 'globals.c', + 'miscinit.c', + 'postinit.c') diff --git a/src/backend/utils/mb/conversion_procs/meson.build b/src/backend/utils/mb/conversion_procs/meson.build new file mode 100644 index 00000000000..1bc971d1945 --- /dev/null +++ b/src/backend/utils/mb/conversion_procs/meson.build @@ -0,0 +1,36 @@ +encodings = { + 'cyrillic_and_mic': ['cyrillic_and_mic/cyrillic_and_mic.c'], + 'euc2004_sjis2004': ['euc2004_sjis2004/euc2004_sjis2004.c'], + 'euc_cn_and_mic': ['euc_cn_and_mic/euc_cn_and_mic.c'], + 'euc_jp_and_sjis': ['euc_jp_and_sjis/euc_jp_and_sjis.c'], + 'euc_kr_and_mic': ['euc_kr_and_mic/euc_kr_and_mic.c'], + 'euc_tw_and_big5': [ + 'euc_tw_and_big5/euc_tw_and_big5.c', + 'euc_tw_and_big5/big5.c', + ], + 'latin2_and_win1250': ['latin2_and_win1250/latin2_and_win1250.c'], + 'latin_and_mic': ['latin_and_mic/latin_and_mic.c'], + 'utf8_and_big5': ['utf8_and_big5/utf8_and_big5.c'], + 'utf8_and_cyrillic': ['utf8_and_cyrillic/utf8_and_cyrillic.c'], + 'utf8_and_euc2004': ['utf8_and_euc2004/utf8_and_euc2004.c'], + 'utf8_and_euc_cn': ['utf8_and_euc_cn/utf8_and_euc_cn.c'], + 'utf8_and_euc_jp': ['utf8_and_euc_jp/utf8_and_euc_jp.c'], + 'utf8_and_euc_kr': ['utf8_and_euc_kr/utf8_and_euc_kr.c'], + 'utf8_and_euc_tw': ['utf8_and_euc_tw/utf8_and_euc_tw.c'], + 'utf8_and_gb18030': ['utf8_and_gb18030/utf8_and_gb18030.c'], + 'utf8_and_gbk': ['utf8_and_gbk/utf8_and_gbk.c'], + 'utf8_and_iso8859': ['utf8_and_iso8859/utf8_and_iso8859.c'], + 'utf8_and_iso8859_1': ['utf8_and_iso8859_1/utf8_and_iso8859_1.c'], + 'utf8_and_johab': ['utf8_and_johab/utf8_and_johab.c'], + 'utf8_and_sjis': ['utf8_and_sjis/utf8_and_sjis.c'], + 'utf8_and_sjis2004': ['utf8_and_sjis2004/utf8_and_sjis2004.c'], + 'utf8_and_uhc': ['utf8_and_uhc/utf8_and_uhc.c'], + 'utf8_and_win': ['utf8_and_win/utf8_and_win.c'], +} + +foreach encoding, sources : encodings + backend_targets += shared_module(encoding, + sources, + kwargs: pg_mod_args, + ) +endforeach diff --git a/src/backend/utils/mb/meson.build b/src/backend/utils/mb/meson.build new file mode 100644 index 00000000000..39e45638db0 --- /dev/null +++ b/src/backend/utils/mb/meson.build @@ -0,0 +1,9 @@ +backend_sources += files( + 'conv.c', + 'mbutils.c', + 'stringinfo_mb.c', + 'wstrcmp.c', + 'wstrncmp.c', +) + +# Note we only enter conversion_procs once the backend build is defined diff --git a/src/backend/utils/meson.build b/src/backend/utils/meson.build new file mode 100644 index 00000000000..3a916320bb3 --- /dev/null +++ b/src/backend/utils/meson.build @@ -0,0 +1,17 @@ +install_data('errcodes.txt', + install_dir: dir_data, +) + +subdir('activity') +subdir('adt') +subdir('cache') +subdir('error') +subdir('fmgr') +subdir('hash') +subdir('init') +subdir('mb') +subdir('misc') +subdir('mmgr') +subdir('resowner') +subdir('sort') +subdir('time') diff --git a/src/backend/utils/misc/meson.build b/src/backend/utils/misc/meson.build new file mode 100644 index 00000000000..db4de225e18 --- /dev/null +++ b/src/backend/utils/misc/meson.build @@ -0,0 +1,35 @@ +backend_sources += files( + 'guc.c', + 'guc_funcs.c', + 'guc_tables.c', + 'help_config.c', + 'pg_config.c', + 'pg_controldata.c', + 'pg_rusage.c', + 'ps_status.c', + 'queryenvironment.c', + 'queryjumble.c', + 'rls.c', + 'sampling.c', + 'superuser.c', + 'timeout.c', + 'tzparser.c', +) + +guc_scan = custom_target('guc_scan', + input: 'guc-file.l', + output: 'guc-file.c', + command: flex_cmd) +generated_sources += guc_scan + +# so we don't need to add . as an include dir for the whole backend +backend_link_with += static_library('guc-file', + guc_scan, + dependencies: [backend_code], + include_directories: include_directories('.'), + kwargs: internal_lib_args, +) + +install_data('postgresql.conf.sample', + install_dir: dir_data, +) diff --git a/src/backend/utils/mmgr/meson.build b/src/backend/utils/mmgr/meson.build new file mode 100644 index 00000000000..641bb181ba1 --- /dev/null +++ b/src/backend/utils/mmgr/meson.build @@ -0,0 +1,10 @@ +backend_sources += files( + 'aset.c', + 'dsa.c', + 'freepage.c', + 'generation.c', + 'mcxt.c', + 'memdebug.c', + 'portalmem.c', + 'slab.c', +) diff --git a/src/backend/utils/resowner/meson.build b/src/backend/utils/resowner/meson.build new file mode 100644 index 00000000000..d30891ca027 --- /dev/null +++ b/src/backend/utils/resowner/meson.build @@ -0,0 +1,3 @@ +backend_sources += files( + 'resowner.c' +) diff --git a/src/backend/utils/sort/meson.build b/src/backend/utils/sort/meson.build new file mode 100644 index 00000000000..1862ceae8c1 --- /dev/null +++ b/src/backend/utils/sort/meson.build @@ -0,0 +1,9 @@ +backend_sources += files( + 'logtape.c', + 'qsort_interruptible.c', + 'sharedtuplestore.c', + 'sortsupport.c', + 'tuplesort.c', + 'tuplesortvariants.c', + 'tuplestore.c', +) diff --git a/src/backend/utils/time/meson.build b/src/backend/utils/time/meson.build new file mode 100644 index 00000000000..6fff8792bb0 --- /dev/null +++ b/src/backend/utils/time/meson.build @@ -0,0 +1,4 @@ +backend_sources += files( + 'combocid.c', + 'snapmgr.c', +) diff --git a/src/bin/initdb/meson.build b/src/bin/initdb/meson.build new file mode 100644 index 00000000000..9f213274d2f --- /dev/null +++ b/src/bin/initdb/meson.build @@ -0,0 +1,30 @@ +initdb_sources = files( + 'findtimezone.c', + 'initdb.c' +) + +initdb_sources += timezone_localtime_source + +#fixme: reimplement libpq_pgport logic + +initdb = executable('initdb', + initdb_sources, + include_directories: [timezone_inc], + dependencies: [frontend_code, libpq, icu, icu_i18n], + kwargs: default_bin_args, +) +bin_targets += initdb + +tests += { + 'name': 'initdb', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'env': {'with_icu': icu.found() ? 'yes' : 'no'}, + 'tests': [ + 't/001_initdb.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/initdb/po/meson.build b/src/bin/initdb/po/meson.build new file mode 100644 index 00000000000..8b8a9fd2ce1 --- /dev/null +++ b/src/bin/initdb/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('initdb-' + pg_version_major.to_string()) diff --git a/src/bin/meson.build b/src/bin/meson.build new file mode 100644 index 00000000000..5fd5a9d2f98 --- /dev/null +++ b/src/bin/meson.build @@ -0,0 +1,20 @@ +subdir('initdb') +subdir('pg_amcheck') +subdir('pg_archivecleanup') +subdir('pg_basebackup') +subdir('pg_checksums') +subdir('pg_config') +subdir('pg_controldata') +subdir('pg_ctl') +subdir('pg_dump') +subdir('pg_resetwal') +subdir('pg_rewind') +subdir('pg_test_fsync') +subdir('pg_test_timing') +subdir('pg_upgrade') +subdir('pg_verifybackup') +subdir('pg_waldump') +subdir('pgbench') +subdir('pgevent') +subdir('psql') +subdir('scripts') diff --git a/src/bin/pg_amcheck/meson.build b/src/bin/pg_amcheck/meson.build new file mode 100644 index 00000000000..8e197eba5f3 --- /dev/null +++ b/src/bin/pg_amcheck/meson.build @@ -0,0 +1,27 @@ +pg_amcheck_sources = files( + 'pg_amcheck.c' +) + +pg_amcheck = executable('pg_amcheck', + pg_amcheck_sources, + dependencies: [frontend_code, libpq], + kwargs: default_bin_args, +) +bin_targets += pg_amcheck + +tests += { + 'name': 'pg_amcheck', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + 't/002_nonesuch.pl', + 't/003_check.pl', + 't/004_verify_heapam.pl', + 't/005_opclass_damage.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_amcheck/po/meson.build b/src/bin/pg_amcheck/po/meson.build new file mode 100644 index 00000000000..b255f552c94 --- /dev/null +++ b/src/bin/pg_amcheck/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_amcheck-' + pg_version_major.to_string()) diff --git a/src/bin/pg_archivecleanup/meson.build b/src/bin/pg_archivecleanup/meson.build new file mode 100644 index 00000000000..87a0d980c4f --- /dev/null +++ b/src/bin/pg_archivecleanup/meson.build @@ -0,0 +1,19 @@ +pg_archivecleanup = executable('pg_archivecleanup', + ['pg_archivecleanup.c'], + dependencies: [frontend_code], + kwargs: default_bin_args, +) +bin_targets += pg_archivecleanup + +tests += { + 'name': 'pg_archivecleanup', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/010_pg_archivecleanup.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_archivecleanup/po/meson.build b/src/bin/pg_archivecleanup/po/meson.build new file mode 100644 index 00000000000..37935fcabc4 --- /dev/null +++ b/src/bin/pg_archivecleanup/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_archivecleanup-' + pg_version_major.to_string()) diff --git a/src/bin/pg_basebackup/meson.build b/src/bin/pg_basebackup/meson.build new file mode 100644 index 00000000000..d26fed9cd8a --- /dev/null +++ b/src/bin/pg_basebackup/meson.build @@ -0,0 +1,61 @@ +common_sources = files( + 'bbstreamer_file.c', + 'bbstreamer_gzip.c', + 'bbstreamer_inject.c', + 'bbstreamer_lz4.c', + 'bbstreamer_tar.c', + 'bbstreamer_zstd.c', + 'receivelog.c', + 'streamutil.c', + 'walmethods.c', +) + +pg_basebackup_deps = [frontend_code, libpq, lz4, zlib, zstd] +pg_basebackup_common = static_library('libpg_basebackup_common', + common_sources, + dependencies: pg_basebackup_deps, + kwargs: internal_lib_args, +) + +pg_basebackup = executable('pg_basebackup', + 'pg_basebackup.c', + link_with: [pg_basebackup_common], + dependencies: pg_basebackup_deps, + kwargs: default_bin_args, +) +bin_targets += pg_basebackup + +pg_receivewal = executable('pg_receivewal', + 'pg_receivewal.c', + link_with: [pg_basebackup_common], + dependencies: pg_basebackup_deps, + kwargs: default_bin_args, +) +bin_targets += pg_receivewal + +pg_recvlogical = executable('pg_recvlogical', + 'pg_recvlogical.c', + link_with: [pg_basebackup_common], + dependencies: pg_basebackup_deps, + kwargs: default_bin_args, +) +bin_targets += pg_recvlogical + +tests += { + 'name': 'pg_basebackup', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'env': {'GZIP_PROGRAM': gzip.path(), + 'TAR': tar.path(), + 'LZ4': program_lz4.found() ? program_lz4.path() : '', + 'ZSTD': program_zstd.found() ? program_zstd.path() : ''}, + 'tests': [ + 't/010_pg_basebackup.pl', + 't/020_pg_receivewal.pl', + 't/030_pg_recvlogical.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_basebackup/po/meson.build b/src/bin/pg_basebackup/po/meson.build new file mode 100644 index 00000000000..cab021153fe --- /dev/null +++ b/src/bin/pg_basebackup/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_basebackup-' + pg_version_major.to_string()) diff --git a/src/bin/pg_checksums/meson.build b/src/bin/pg_checksums/meson.build new file mode 100644 index 00000000000..ee1f367bac3 --- /dev/null +++ b/src/bin/pg_checksums/meson.build @@ -0,0 +1,21 @@ +pg_checksums = executable('pg_checksums', + ['pg_checksums.c'], + include_directories: [timezone_inc], + dependencies: [frontend_code], + kwargs: default_bin_args, +) +bin_targets += pg_checksums + +tests += { + 'name': 'pg_checksums', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + 't/002_actions.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_checksums/po/meson.build b/src/bin/pg_checksums/po/meson.build new file mode 100644 index 00000000000..2c47c2338f6 --- /dev/null +++ b/src/bin/pg_checksums/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_checksums-' + pg_version_major.to_string()) diff --git a/src/bin/pg_config/meson.build b/src/bin/pg_config/meson.build new file mode 100644 index 00000000000..0ecbf2f9d28 --- /dev/null +++ b/src/bin/pg_config/meson.build @@ -0,0 +1,19 @@ +pg_config = executable('pg_config', + ['pg_config.c'], + dependencies: [frontend_code], + kwargs: default_bin_args, +) +bin_targets += pg_config + +tests += { + 'name': 'pg_config', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_pg_config.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_config/po/meson.build b/src/bin/pg_config/po/meson.build new file mode 100644 index 00000000000..b6fb6db9213 --- /dev/null +++ b/src/bin/pg_config/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_config-' + pg_version_major.to_string()) diff --git a/src/bin/pg_controldata/meson.build b/src/bin/pg_controldata/meson.build new file mode 100644 index 00000000000..557e672beb7 --- /dev/null +++ b/src/bin/pg_controldata/meson.build @@ -0,0 +1,19 @@ +pg_controldata = executable('pg_controldata', + ['pg_controldata.c'], + dependencies: [frontend_code], + kwargs: default_bin_args, +) +bin_targets += pg_controldata + +tests += { + 'name': 'pg_controldata', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_pg_controldata.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_controldata/po/meson.build b/src/bin/pg_controldata/po/meson.build new file mode 100644 index 00000000000..31b486d002c --- /dev/null +++ b/src/bin/pg_controldata/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_controldata-' + pg_version_major.to_string()) diff --git a/src/bin/pg_ctl/meson.build b/src/bin/pg_ctl/meson.build new file mode 100644 index 00000000000..6812e73e329 --- /dev/null +++ b/src/bin/pg_ctl/meson.build @@ -0,0 +1,22 @@ +pg_ctl = executable('pg_ctl', + ['pg_ctl.c'], + dependencies: [frontend_code, libpq], + kwargs: default_bin_args, +) +bin_targets += pg_ctl + +tests += { + 'name': 'pg_ctl', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_start_stop.pl', + 't/002_status.pl', + 't/003_promote.pl', + 't/004_logrotate.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_ctl/po/meson.build b/src/bin/pg_ctl/po/meson.build new file mode 100644 index 00000000000..947b5108423 --- /dev/null +++ b/src/bin/pg_ctl/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_ctl-' + pg_version_major.to_string()) diff --git a/src/bin/pg_dump/meson.build b/src/bin/pg_dump/meson.build new file mode 100644 index 00000000000..785ec094dbd --- /dev/null +++ b/src/bin/pg_dump/meson.build @@ -0,0 +1,75 @@ +pg_dump_common_sources = files( + 'compress_io.c', + 'dumputils.c', + 'parallel.c', + 'pg_backup_archiver.c', + 'pg_backup_custom.c', + 'pg_backup_db.c', + 'pg_backup_directory.c', + 'pg_backup_null.c', + 'pg_backup_tar.c', + 'pg_backup_utils.c', +) + +pg_dump_common = static_library('libpgdump_common', + pg_dump_common_sources, + dependencies: [frontend_code, libpq, zlib], + kwargs: internal_lib_args, +) + + +pg_dump_sources = files( + 'common.c', + 'pg_dump.c', + 'pg_dump_sort.c', +) + +pg_dump = executable('pg_dump', + pg_dump_sources, + link_with: [pg_dump_common], + dependencies: [frontend_code, libpq, zlib], + kwargs: default_bin_args, +) +bin_targets += pg_dump + + +pg_dumpall_sources = files( + 'pg_dumpall.c', +) + +pg_dumpall = executable('pg_dumpall', + pg_dumpall_sources, + link_with: [pg_dump_common], + dependencies: [frontend_code, libpq, zlib], + kwargs: default_bin_args, +) +bin_targets += pg_dumpall + + +pg_restore_sources = files( + 'pg_restore.c', +) + +pg_restore = executable('pg_restore', + pg_restore_sources, + link_with: [pg_dump_common], + dependencies: [frontend_code, libpq, zlib], + kwargs: default_bin_args, +) +bin_targets += pg_restore + +tests += { + 'name': 'pg_dump', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + 't/002_pg_dump.pl', + 't/003_pg_dump_with_server.pl', + 't/010_dump_connstr.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_dump/po/meson.build b/src/bin/pg_dump/po/meson.build new file mode 100644 index 00000000000..82e5e537ff4 --- /dev/null +++ b/src/bin/pg_dump/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_dump-' + pg_version_major.to_string()) diff --git a/src/bin/pg_resetwal/meson.build b/src/bin/pg_resetwal/meson.build new file mode 100644 index 00000000000..7c5de134ac0 --- /dev/null +++ b/src/bin/pg_resetwal/meson.build @@ -0,0 +1,20 @@ +pg_resetwal = executable('pg_resetwal', + files('pg_resetwal.c'), + dependencies: [frontend_code], + kwargs: default_bin_args, +) +bin_targets += pg_resetwal + +tests += { + 'name': 'pg_resetwal', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + 't/002_corrupted.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_resetwal/po/meson.build b/src/bin/pg_resetwal/po/meson.build new file mode 100644 index 00000000000..d130d3b775f --- /dev/null +++ b/src/bin/pg_resetwal/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_resetwal-' + pg_version_major.to_string()) diff --git a/src/bin/pg_rewind/meson.build b/src/bin/pg_rewind/meson.build new file mode 100644 index 00000000000..d8ec9e482d5 --- /dev/null +++ b/src/bin/pg_rewind/meson.build @@ -0,0 +1,42 @@ +pg_rewind_sources = files( + 'datapagemap.c', + 'file_ops.c', + 'filemap.c', + 'libpq_source.c', + 'local_source.c', + 'parsexlog.c', + 'pg_rewind.c', + 'timeline.c', +) + +pg_rewind_sources += xlogreader_sources + +pg_rewind = executable('pg_rewind', + pg_rewind_sources, + dependencies: [frontend_code, libpq, lz4, zstd], + c_args: ['-DFRONTEND'], # needed for xlogreader et al + kwargs: default_bin_args, +) +bin_targets += pg_rewind + + +tests += { + 'name': 'pg_rewind', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + 't/002_databases.pl', + 't/003_extrafiles.pl', + 't/004_pg_xlog_symlink.pl', + 't/005_same_timeline.pl', + 't/006_options.pl', + 't/007_standby_source.pl', + 't/008_min_recovery_point.pl', + 't/009_growing_files.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_rewind/po/meson.build b/src/bin/pg_rewind/po/meson.build new file mode 100644 index 00000000000..a105600b348 --- /dev/null +++ b/src/bin/pg_rewind/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_rewind-' + pg_version_major.to_string()) diff --git a/src/bin/pg_test_fsync/meson.build b/src/bin/pg_test_fsync/meson.build new file mode 100644 index 00000000000..2c01831e11f --- /dev/null +++ b/src/bin/pg_test_fsync/meson.build @@ -0,0 +1,21 @@ +test_fsync_sources = files('pg_test_fsync.c') + +pg_test_fsync = executable('pg_test_fsync', + test_fsync_sources, + dependencies: [frontend_code], + kwargs: default_bin_args, +) +bin_targets += pg_test_fsync + +tests += { + 'name': 'pg_test_fsync', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_test_fsync/po/meson.build b/src/bin/pg_test_fsync/po/meson.build new file mode 100644 index 00000000000..2ee1125282d --- /dev/null +++ b/src/bin/pg_test_fsync/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_test_fsync-' + pg_version_major.to_string()) diff --git a/src/bin/pg_test_timing/meson.build b/src/bin/pg_test_timing/meson.build new file mode 100644 index 00000000000..0a3068f1657 --- /dev/null +++ b/src/bin/pg_test_timing/meson.build @@ -0,0 +1,19 @@ +pg_test_timing = executable('pg_test_timing', + ['pg_test_timing.c'], + dependencies: [frontend_code], + kwargs: default_bin_args, +) +bin_targets += pg_test_timing + +tests += { + 'name': 'pg_test_timing', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_test_timing/po/meson.build b/src/bin/pg_test_timing/po/meson.build new file mode 100644 index 00000000000..cda8615165b --- /dev/null +++ b/src/bin/pg_test_timing/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_test_timing-' + pg_version_major.to_string()) diff --git a/src/bin/pg_upgrade/meson.build b/src/bin/pg_upgrade/meson.build new file mode 100644 index 00000000000..02f030e0ccf --- /dev/null +++ b/src/bin/pg_upgrade/meson.build @@ -0,0 +1,40 @@ +pg_upgrade_sources = files( + 'check.c', + 'controldata.c', + 'dump.c', + 'exec.c', + 'file.c', + 'function.c', + 'info.c', + 'option.c', + 'parallel.c', + 'pg_upgrade.c', + 'relfilenumber.c', + 'server.c', + 'tablespace.c', + 'util.c', + 'version.c', +) + +pg_upgrade = executable('pg_upgrade', + pg_upgrade_sources, + dependencies: [frontend_code, libpq], + kwargs: default_bin_args, +) +bin_targets += pg_upgrade + + +tests += { + 'name': 'pg_upgrade', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + 't/002_pg_upgrade.pl', + ], + 'test_kwargs': {'priority': 40}, # pg_upgrade tests are slow + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_upgrade/po/meson.build b/src/bin/pg_upgrade/po/meson.build new file mode 100644 index 00000000000..39301cbede8 --- /dev/null +++ b/src/bin/pg_upgrade/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_upgrade-' + pg_version_major.to_string()) diff --git a/src/bin/pg_verifybackup/meson.build b/src/bin/pg_verifybackup/meson.build new file mode 100644 index 00000000000..4c3b2bb5f97 --- /dev/null +++ b/src/bin/pg_verifybackup/meson.build @@ -0,0 +1,33 @@ +pg_verifybackup_sources = files( + 'parse_manifest.c', + 'pg_verifybackup.c' +) + +pg_verifybackup = executable('pg_verifybackup', + pg_verifybackup_sources, + dependencies: [frontend_code, libpq], + kwargs: default_bin_args, +) +bin_targets += pg_verifybackup + +tests += { + 'name': 'pg_verifybackup', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + 't/002_algorithm.pl', + 't/003_corruption.pl', + 't/004_options.pl', + 't/005_bad_manifest.pl', + 't/006_encoding.pl', + 't/007_wal.pl', + 't/008_untar.pl', + 't/009_extract.pl', + 't/010_client_untar.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_verifybackup/po/meson.build b/src/bin/pg_verifybackup/po/meson.build new file mode 100644 index 00000000000..b583f1958ba --- /dev/null +++ b/src/bin/pg_verifybackup/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_verifybackup-' + pg_version_major.to_string()) diff --git a/src/bin/pg_waldump/meson.build b/src/bin/pg_waldump/meson.build new file mode 100644 index 00000000000..95872652ffd --- /dev/null +++ b/src/bin/pg_waldump/meson.build @@ -0,0 +1,30 @@ +pg_waldump_sources = files( + 'compat.c', + 'pg_waldump.c', + 'rmgrdesc.c', +) + +pg_waldump_sources += rmgr_desc_sources +pg_waldump_sources += xlogreader_sources +pg_waldump_sources += files('../../backend/access/transam/xlogstats.c') + +pg_waldump = executable('pg_waldump', + pg_waldump_sources, + dependencies: [frontend_code, lz4, zstd], + c_args: ['-DFRONTEND'], # needed for xlogreader et al + kwargs: default_bin_args, +) +bin_targets += pg_waldump + +tests += { + 'name': 'pg_waldump', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_basic.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/pg_waldump/po/meson.build b/src/bin/pg_waldump/po/meson.build new file mode 100644 index 00000000000..f335aa4b360 --- /dev/null +++ b/src/bin/pg_waldump/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pg_waldump-' + pg_version_major.to_string()) diff --git a/src/bin/pgbench/meson.build b/src/bin/pgbench/meson.build new file mode 100644 index 00000000000..6564e54029c --- /dev/null +++ b/src/bin/pgbench/meson.build @@ -0,0 +1,38 @@ +pgbench_sources = files( + 'pgbench.c', +) + +exprscan = custom_target('exprscan', + input: 'exprscan.l', + output: 'exprscan.c', + command: flex_cmd, +) +generated_sources += exprscan +pgbench_sources += exprscan + +exprparse = custom_target('exprparse', + input: 'exprparse.y', + kwargs: bison_kw, +) +generated_sources += exprparse.to_list() +pgbench_sources += exprparse + +pgbench = executable('pgbench', + pgbench_sources, + dependencies: [frontend_code, libpq, thread_dep], + include_directories: include_directories('.'), + kwargs: default_bin_args, +) +bin_targets += pgbench + +tests += { + 'name': 'pgbench', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_pgbench_with_server.pl', + 't/002_pgbench_no_server.pl', + ], + }, +} diff --git a/src/bin/pgevent/meson.build b/src/bin/pgevent/meson.build new file mode 100644 index 00000000000..7a468879fd2 --- /dev/null +++ b/src/bin/pgevent/meson.build @@ -0,0 +1,24 @@ +if host_system != 'windows' + subdir_done() +endif + +pgevent_sources = files( + 'pgevent.c', +) + +# FIXME: copied from Mkvcbuild.pm, but I don't think that's the right approach +pgevent_link_args = [] +if cc.get_id() == 'msvc' + pgevent_link_args += '/ignore:4104' +endif + +pgevent = shared_library('pgevent', + pgevent_sources, + dependencies: [frontend_code], + link_args: pgevent_link_args, + vs_module_defs: 'pgevent.def', + kwargs: default_lib_args + { + 'name_prefix': '', + }, +) +bin_targets += pgevent diff --git a/src/bin/psql/meson.build b/src/bin/psql/meson.build new file mode 100644 index 00000000000..ea850c8fdf5 --- /dev/null +++ b/src/bin/psql/meson.build @@ -0,0 +1,67 @@ +psql_sources = files( + 'command.c', + 'common.c', + 'copy.c', + 'crosstabview.c', + 'describe.c', + 'help.c', + 'input.c', + 'large_obj.c', + 'mainloop.c', + 'prompt.c', + 'startup.c', + 'stringutils.c', + 'tab-complete.c', + 'variables.c', +) + +psqlscanslash = custom_target('psqlscanslash', + input: 'psqlscanslash.l', + output: 'psqlscanslash.c', + command: [flex_cmd, '--no-backup', '--fix-warnings', '--', '-Cfe', '-p', '-p']) +generated_sources += psqlscanslash +psql_sources += psqlscanslash +bin_targets += psqlscanslash + +sql_help = custom_target('psql_help', + output: ['sql_help.c', 'sql_help.h'], + depfile: 'sql_help.dep', + command: [ + perl, files('create_help.pl'), + '--docdir', '@SOURCE_ROOT@/doc/src/sgml/ref', + '--depfile', '@DEPFILE@', + '--outdir', '@OUTDIR@', + '--basename', 'sql_help', + ], +) +generated_sources += sql_help.to_list() +psql_sources += sql_help +bin_targets += sql_help + +psql = executable('psql', + psql_sources, + include_directories: include_directories('.'), + dependencies: [frontend_code, libpq, readline], + kwargs: default_bin_args, +) +bin_targets += psql + +install_data('psqlrc.sample', + install_dir: dir_data, +) + +tests += { + 'name': 'psql', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'env': {'with_readline': readline.found() ? 'yes' : 'no'}, + 'tests': [ + 't/001_basic.pl', + 't/010_tab_completion.pl', + 't/020_cancel.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/psql/po/meson.build b/src/bin/psql/po/meson.build new file mode 100644 index 00000000000..45fe425298d --- /dev/null +++ b/src/bin/psql/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('psql-' + pg_version_major.to_string()) diff --git a/src/bin/scripts/meson.build b/src/bin/scripts/meson.build new file mode 100644 index 00000000000..eaf250c7f73 --- /dev/null +++ b/src/bin/scripts/meson.build @@ -0,0 +1,51 @@ +scripts_common = static_library('libscripts_common', + files('common.c'), + dependencies: [frontend_code, libpq], + kwargs: internal_lib_args, +) + +binaries = [ + 'createdb', + 'dropdb', + 'createuser', + 'dropuser', + 'clusterdb', + 'vacuumdb', + 'reindexdb', + 'pg_isready', +] + +foreach binary : binaries + binary = executable(binary, + files(binary + '.c'), + link_with: [scripts_common], + dependencies: [frontend_code, libpq], + kwargs: default_bin_args, + ) + bin_targets += binary +endforeach + +tests += { + 'name': 'scripts', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/010_clusterdb.pl', + 't/011_clusterdb_all.pl', + 't/020_createdb.pl', + 't/040_createuser.pl', + 't/050_dropdb.pl', + 't/070_dropuser.pl', + 't/080_pg_isready.pl', + 't/090_reindexdb.pl', + 't/091_reindexdb_all.pl', + 't/100_vacuumdb.pl', + 't/101_vacuumdb_all.pl', + 't/102_vacuumdb_stages.pl', + 't/200_connstr.pl', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/bin/scripts/po/meson.build b/src/bin/scripts/po/meson.build new file mode 100644 index 00000000000..3c531459c2d --- /dev/null +++ b/src/bin/scripts/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pgscripts-' + pg_version_major.to_string()) diff --git a/src/common/meson.build b/src/common/meson.build new file mode 100644 index 00000000000..23842e1ffef --- /dev/null +++ b/src/common/meson.build @@ -0,0 +1,174 @@ +common_sources = files( + 'archive.c', + 'base64.c', + 'checksum_helper.c', + 'compression.c', + 'controldata_utils.c', + 'encnames.c', + 'exec.c', + 'file_perm.c', + 'file_utils.c', + 'hashfn.c', + 'ip.c', + 'jsonapi.c', + 'keywords.c', + 'kwlookup.c', + 'link-canary.c', + 'md5_common.c', + 'pg_get_line.c', + 'pg_lzcompress.c', + 'pg_prng.c', + 'pgfnames.c', + 'psprintf.c', + 'relpath.c', + 'rmtree.c', + 'saslprep.c', + 'scram-common.c', + 'string.c', + 'stringinfo.c', + 'unicode_norm.c', + 'username.c', + 'wait_error.c', + 'wchar.c', +) + +if ssl.found() + common_sources += files( + 'cryptohash_openssl.c', + 'hmac_openssl.c', + 'protocol_openssl.c', + ) +else + common_sources += files( + 'cryptohash.c', + 'hmac.c', + 'md5.c', + 'sha1.c', + 'sha2.c', + ) +endif + +common_kwlist = custom_target('kwlist', + input: files('../include/parser/kwlist.h'), + output: 'kwlist_d.h', + command: [perl, '-I', '@SOURCE_ROOT@/src/tools', files('../tools/gen_keywordlist.pl'), + '--extern', '--output', '@OUTDIR@', '@INPUT@']) +generated_sources += common_kwlist +common_sources += common_kwlist + +# The code imported from Ryu gets a pass on declaration-after-statement, +# in order to keep it more closely aligned with its upstream. +ryu_sources = files( + 'd2s.c', + 'f2s.c', +) +ryu_cflags = [] + +if using_declaration_after_statement_warning + ryu_cflags += ['-Wno-declaration-after-statement'] +endif + +config_info_sources = files('config_info.c',) +config_info_cflags = [ + '-DVAL_CC="@0@"'.format(var_cc), + '-DVAL_CPPFLAGS="@0@"'.format(var_cppflags), + '-DVAL_CFLAGS="@0@"'.format(var_cflags), + '-DVAL_CFLAGS_SL="@0@"'.format(var_cflags_sl), + '-DVAL_LDFLAGS="@0@"'.format(var_ldflags), + '-DVAL_LDFLAGS_EX="@0@"'.format(var_ldflags_ex), + '-DVAL_LDFLAGS_SL="@0@"'.format(var_ldflags_sl), + '-DVAL_LIBS="@0@"'.format(var_libs), +] + +# Some files need to be built with different cflags. The different sets are +# defined here. +common_cflags = { + 'ryu': ryu_cflags, + 'config_info': config_info_cflags, +} +common_sources_cflags = { + 'ryu': ryu_sources, + 'config_info': config_info_sources +} + + +# A few files are currently only built for frontend, not server +# (Mkvcbuild.pm has a copy of this list, too). logging.c is excluded +# from OBJS_FRONTEND_SHLIB (shared library) as a matter of policy, +# because it is not appropriate for general purpose libraries such +# as libpq to report errors directly. + +common_sources_frontend_shlib = common_sources +common_sources_frontend_shlib += files( + 'fe_memutils.c', + 'restricted_token.c', + 'sprompt.c', +) + +common_sources_frontend_static = common_sources_frontend_shlib +common_sources_frontend_static += files( + 'logging.c', +) + +# Build pgport once for backend, once for use in frontend binaries, and once +# for use in shared libraries +# +# XXX: in most environments we could probably link_whole pgcommon_shlib +# against pgcommon_static, instead of compiling twice. +# +# For the server build of pgcommon, depend on lwlocknames_h, because at least +# cryptohash_openssl.c, hmac_openssl.c depend on it. That's arguably a +# layering violation, but ... +pgcommon = {} +pgcommon_variants = { + '_srv': internal_lib_args + { + 'sources': common_sources + [lwlocknames_h], + 'dependencies': [backend_common_code], + }, + '': default_lib_args + { + 'sources': common_sources_frontend_static, + 'dependencies': [frontend_common_code], + }, + '_shlib': default_lib_args + { + 'pic': true, + 'sources': common_sources_frontend_shlib, + 'dependencies': [frontend_common_code], + }, +} + +foreach name, opts : pgcommon_variants + + # Build internal static libraries for sets of files that need to be built + # with different cflags + cflag_libs = [] + foreach cflagname, sources : common_sources_cflags + if sources.length() == 0 + continue + endif + c_args = opts.get('c_args', []) + common_cflags[cflagname] + cflag_libs += static_library('libpgcommon@0@_@1@'.format(name, cflagname), + include_directories: include_directories('.'), + kwargs: opts + { + 'sources': sources, + 'c_args': c_args, + 'build_by_default': false, + 'install': false, + }, + ) + endforeach + + lib = static_library('libpgcommon@0@'.format(name), + link_with: cflag_libs, + include_directories: include_directories('.'), + kwargs: opts + { + 'dependencies': opts['dependencies'] + [ssl], + } + ) + pgcommon += {name: lib} +endforeach + +common_srv = pgcommon['_srv'] +common_shlib = pgcommon['_shlib'] +common_static = pgcommon[''] + +subdir('unicode') diff --git a/src/common/unicode/meson.build b/src/common/unicode/meson.build new file mode 100644 index 00000000000..13965d59f49 --- /dev/null +++ b/src/common/unicode/meson.build @@ -0,0 +1,106 @@ +UNICODE_VERSION = '15.0.0' + +unicode_data = {} +unicode_baseurl = 'https://www.unicode.org/Public/@0@/ucd/@1@' + +if not wget.found() + subdir_done() +endif + +# These files are part of the Unicode Character Database. Download them on +# demand. +foreach f : ['UnicodeData.txt', 'EastAsianWidth.txt', 'DerivedNormalizationProps.txt', 'CompositionExclusions.txt', 'NormalizationTest.txt'] + url = unicode_baseurl.format(UNICODE_VERSION, f) + target = custom_target(f, + output: f, + command: [wget, wget_flags, url], + build_by_default: false, + ) + unicode_data += {f: target} +endforeach + + +update_unicode_targets = [] + +update_unicode_targets += \ + custom_target('unicode_norm_table.h', + input: [unicode_data['UnicodeData.txt'], unicode_data['CompositionExclusions.txt']], + output: ['unicode_norm_table.h', 'unicode_norm_hashfunc.h'], + command: [ + perl, files('generate-unicode_norm_table.pl'), + '--outdir', '@OUTDIR@', '@INPUT@'], + build_by_default: false, + ) + +update_unicode_targets += \ + custom_target('unicode_nonspacing_table.h', + input: [unicode_data['UnicodeData.txt']], + output: ['unicode_nonspacing_table.h'], + command: [perl, files('generate-unicode_nonspacing_table.pl'), '@INPUT@'], + build_by_default: false, + capture: true, + ) + +update_unicode_targets += \ + custom_target('unicode_east_asian_fw_table.h', + input: [unicode_data['EastAsianWidth.txt']], + output: ['unicode_east_asian_fw_table.h'], + command: [perl, files('generate-unicode_east_asian_fw_table.pl'), '@INPUT@'], + build_by_default: false, + capture: true, + ) + +update_unicode_targets += \ + custom_target('unicode_normprops_table.h', + input: [unicode_data['DerivedNormalizationProps.txt']], + output: ['unicode_normprops_table.h'], + command: [perl, files('generate-unicode_normprops_table.pl'), '@INPUT@'], + build_by_default: false, + capture: true, + ) + +norm_test_table = custom_target('norm_test_table.h', + input: [unicode_data['NormalizationTest.txt']], + output: ['norm_test_table.h'], + command: [perl, files('generate-norm_test_table.pl'), '@INPUT@', '@OUTPUT@'], + build_by_default: false, + ) + +inc = include_directories('.') + +norm_test = executable('norm_test', + ['norm_test.c', norm_test_table], + dependencies: [frontend_port_code], + include_directories: inc, + link_with: [common_static, pgport_static], + build_by_default: false, + kwargs: default_bin_args + { + 'install': false, + } +) + +update_unicode_dep = [] + +if not meson.is_cross_build() + update_unicode_dep += custom_target('norm_test.run', + output: 'norm_test.run', + input: update_unicode_targets, + command: [norm_test], + build_by_default: false, + build_always_stale: true, + ) +endif + + +# Use a custom target, as run targets serialize the output, making this harder +# to debug, and don't deal well with targets with multiple outputs. +update_unicode = custom_target('update-unicode', + depends: update_unicode_dep, + output: ['dont-exist'], + input: update_unicode_targets, + command: ['cp', '@INPUT@', '@SOURCE_ROOT@/src/include/common/'], + build_by_default: false, + build_always_stale: true, +) + +alias_target('update-unicode', update_unicode) diff --git a/src/fe_utils/meson.build b/src/fe_utils/meson.build new file mode 100644 index 00000000000..b6bf8e1ca21 --- /dev/null +++ b/src/fe_utils/meson.build @@ -0,0 +1,29 @@ +fe_utils_sources = files( + 'archive.c', + 'cancel.c', + 'conditional.c', + 'connect_utils.c', + 'mbprint.c', + 'option_utils.c', + 'parallel_slot.c', + 'print.c', + 'query_utils.c', + 'recovery_gen.c', + 'simple_list.c', + 'string_utils.c', +) + +psqlscan = custom_target('psqlscan', + input: 'psqlscan.l', + output: 'psqlscan.c', + command: [flex_cmd, '--no-backup', '--fix-warnings', '--', '-Cfe', '-p', '-p'], +) +generated_sources += psqlscan +fe_utils_sources += psqlscan + +fe_utils = static_library('libpgfeutils', + fe_utils_sources + generated_headers, + include_directories: [postgres_inc, libpq_inc], + dependencies: frontend_common_code, + kwargs: default_lib_args, +) diff --git a/src/include/catalog/meson.build b/src/include/catalog/meson.build new file mode 100644 index 00000000000..45ffa99692e --- /dev/null +++ b/src/include/catalog/meson.build @@ -0,0 +1,142 @@ +catalog_headers = [ + 'pg_proc.h', + 'pg_type.h', + 'pg_attribute.h', + 'pg_class.h', + 'pg_attrdef.h', + 'pg_constraint.h', + 'pg_inherits.h', + 'pg_index.h', + 'pg_operator.h', + 'pg_opfamily.h', + 'pg_opclass.h', + 'pg_am.h', + 'pg_amop.h', + 'pg_amproc.h', + 'pg_language.h', + 'pg_largeobject_metadata.h', + 'pg_largeobject.h', + 'pg_aggregate.h', + 'pg_statistic.h', + 'pg_statistic_ext.h', + 'pg_statistic_ext_data.h', + 'pg_rewrite.h', + 'pg_trigger.h', + 'pg_event_trigger.h', + 'pg_description.h', + 'pg_cast.h', + 'pg_enum.h', + 'pg_namespace.h', + 'pg_conversion.h', + 'pg_depend.h', + 'pg_database.h', + 'pg_db_role_setting.h', + 'pg_tablespace.h', + 'pg_authid.h', + 'pg_auth_members.h', + 'pg_shdepend.h', + 'pg_shdescription.h', + 'pg_ts_config.h', + 'pg_ts_config_map.h', + 'pg_ts_dict.h', + 'pg_ts_parser.h', + 'pg_ts_template.h', + 'pg_extension.h', + 'pg_foreign_data_wrapper.h', + 'pg_foreign_server.h', + 'pg_user_mapping.h', + 'pg_foreign_table.h', + 'pg_policy.h', + 'pg_replication_origin.h', + 'pg_default_acl.h', + 'pg_init_privs.h', + 'pg_seclabel.h', + 'pg_shseclabel.h', + 'pg_collation.h', + 'pg_parameter_acl.h', + 'pg_partitioned_table.h', + 'pg_range.h', + 'pg_transform.h', + 'pg_sequence.h', + 'pg_publication.h', + 'pg_publication_namespace.h', + 'pg_publication_rel.h', + 'pg_subscription.h', + 'pg_subscription_rel.h', +] + +bki_data = [ + 'pg_aggregate.dat', + 'pg_am.dat', + 'pg_amop.dat', + 'pg_amproc.dat', + 'pg_authid.dat', + 'pg_cast.dat', + 'pg_class.dat', + 'pg_collation.dat', + 'pg_conversion.dat', + 'pg_database.dat', + 'pg_language.dat', + 'pg_namespace.dat', + 'pg_opclass.dat', + 'pg_operator.dat', + 'pg_opfamily.dat', + 'pg_proc.dat', + 'pg_range.dat', + 'pg_tablespace.dat', + 'pg_ts_config.dat', + 'pg_ts_config_map.dat', + 'pg_ts_dict.dat', + 'pg_ts_parser.dat', + 'pg_ts_template.dat', + 'pg_type.dat', +] +bki_data_f = files(bki_data) + + +input = [] +output_files = ['postgres.bki', 'system_constraints.sql', 'schemapg.h', 'system_fk_info.h'] +output_install = [dir_data, dir_data, dir_include_server / 'catalog', dir_include_server / 'catalog'] + +foreach h : catalog_headers + fname = h.split('.h')[0] + '_d.h' + input += files(h) + output_files += fname + output_install += dir_include_server / 'catalog' +endforeach + +generated_catalog_headers = custom_target('generated_catalog_headers', + output: output_files, + install_dir: output_install, + input: input, + depend_files: bki_data_f, + build_by_default: true, + install: true, + command: [ + perl, + files('../../backend/catalog/genbki.pl'), + '--include-path=@SOURCE_ROOT@/src/include', + '--set-version=' + pg_version_major.to_string(), + '--output=@OUTDIR@', '@INPUT@' + ], +) + +generated_headers += generated_catalog_headers.to_list() + +# autoconf generates the file there, ensure we get a conflict +generated_sources_ac += {'src/backend/catalog': output_files + ['bki-stamp']} +generated_sources_ac += {'src/include/catalog': ['header-stamp']} + +# 'reformat-dat-files' is a convenience target for rewriting the +# catalog data files in our standard format. This includes collapsing +# out any entries that are redundant with a BKI_DEFAULT annotation. +run_target('reformat-dat-files', + command: [perl, files('reformat_dat_file.pl'), '--output', '@CURRENT_SOURCE_DIR@', bki_data_f], +) + +# 'expand-dat-files' is a convenience target for expanding out all +# default values in the catalog data files. This should be run before +# altering or removing any BKI_DEFAULT annotation. +run_target('expand-dat-files', + command: [perl, files('reformat_dat_file.pl'), '--output', '@CURRENT_SOURCE_DIR@', bki_data_f, '--full-tuples'], +) diff --git a/src/include/meson.build b/src/include/meson.build new file mode 100644 index 00000000000..e5390df0584 --- /dev/null +++ b/src/include/meson.build @@ -0,0 +1,173 @@ +pg_config_ext = configure_file( + input: 'pg_config_ext.h.meson', + output: 'pg_config_ext.h', + configuration: cdata, + install: true, + install_dir: dir_include, +) +configure_files += pg_config_ext + +pg_config_os = configure_file( + output: 'pg_config_os.h', + input: files('port/@0@.h'.format(portname)), + install: true, + install_dir: dir_include, + copy: true, +) +configure_files += pg_config_os + +pg_config = configure_file( + output: 'pg_config.h', + install: true, + install_dir: dir_include, + configuration: cdata, +) +configure_files += pg_config + + +config_paths_data = configuration_data() +config_paths_data.set_quoted('PGBINDIR', dir_prefix / dir_bin) +config_paths_data.set_quoted('PGSHAREDIR', dir_prefix / dir_data) +config_paths_data.set_quoted('SYSCONFDIR', dir_prefix / dir_sysconf) +config_paths_data.set_quoted('INCLUDEDIR', dir_prefix / dir_include) +config_paths_data.set_quoted('PKGINCLUDEDIR', dir_prefix / dir_include_pkg) +config_paths_data.set_quoted('INCLUDEDIRSERVER', dir_prefix / dir_include_server) +config_paths_data.set_quoted('LIBDIR', dir_prefix / dir_lib) +config_paths_data.set_quoted('PKGLIBDIR', dir_prefix / dir_lib_pkg) +config_paths_data.set_quoted('LOCALEDIR', dir_prefix / dir_locale) +config_paths_data.set_quoted('DOCDIR', dir_prefix / dir_doc) +config_paths_data.set_quoted('HTMLDIR', dir_prefix / dir_doc_html) +config_paths_data.set_quoted('MANDIR', dir_prefix / dir_man) + + +var_cc = ' '.join(cc.cmd_array()) +var_cpp = ' '.join(cc.cmd_array() + ['-E']) +var_cflags = ' '.join(cflags + cflags_warn) +var_cxxflags = ' '.join(cxxflags + cxxflags_warn) +var_cppflags = ' '.join(cppflags) +var_cflags_sl = '-fPIC' #FIXME +var_ldflags = ' '.join(ldflags) +var_ldflags_sl = ''.join(ldflags_sl) +var_ldflags_ex = '' # FIXME +# FIXME - some extensions might directly use symbols from one of libs. If +# that symbol isn't used by postgres, and statically linked, it'll cause an +# undefined symbol at runtime. And obviously it'll cause problems for +# executables, although those are probably less common. +var_libs = '' + + +pg_config_paths = configure_file( + output: 'pg_config_paths.h', + configuration: config_paths_data, + install: false, +) +configure_files += pg_config_paths + +install_headers( + 'pg_config_manual.h', + 'postgres_ext.h', +) + +install_headers( + 'libpq/libpq-fs.h', + install_dir: dir_include / 'libpq', +) + +install_headers( + 'c.h', + 'port.h', + 'postgres_fe.h', + install_dir: dir_include_internal +) + +install_headers( + 'libpq/pqcomm.h', + install_dir: dir_include_internal / 'libpq', +) + +install_headers( + 'c.h', + 'fmgr.h', + 'funcapi.h', + 'getopt_long.h', + 'miscadmin.h', + 'pg_config_manual.h', + 'pg_getopt.h', + 'pg_trace.h', + 'pgstat.h', + 'pgtar.h', + 'pgtime.h', + 'port.h', + 'postgres.h', + 'postgres_ext.h', + 'postgres_fe.h', + 'windowapi.h', + pg_config_ext, + pg_config_os, + pg_config, + install_dir: dir_include_server, +) + +subdir('catalog') +subdir('nodes') +subdir('storage') +subdir('utils') + +header_subdirs = [ + 'access', + 'catalog', + 'bootstrap', + 'commands', + 'common', + 'datatype', + 'executor', + 'fe_utils', + 'foreign', + 'jit', + 'lib', + 'libpq', + 'mb', + 'nodes', + 'optimizer', + 'parser', + 'partitioning', + 'postmaster', + 'regex', + 'replication', + 'rewrite', + 'statistics', + 'storage', + 'tcop', + 'snowball', + 'tsearch', + 'utils', + 'port', + 'portability', +] + +# XXX: installing headers this way has the danger of installing editor files +# etc, unfortunately install_subdir() doesn't allow including / excluding by +# pattern currently. +foreach d : header_subdirs + if d == 'catalog' + continue + endif + install_subdir(d, install_dir: dir_include_server, + exclude_files: ['.gitignore', 'meson.build']) +endforeach + +install_subdir('catalog', + install_dir: dir_include_server, + exclude_files: [ + '.gitignore', + 'Makefile', + 'duplicate_oids', + 'meson.build', + 'reformat_dat_file.pl', + 'renumber_oids.pl', + 'unused_oids', + ] + bki_data, +) + +# autoconf generates the file there, ensure we get a conflict +generated_sources_ac += {'src/include': ['stamp-h', 'stamp-ext-h']} diff --git a/src/include/nodes/meson.build b/src/include/nodes/meson.build new file mode 100644 index 00000000000..b7df232081f --- /dev/null +++ b/src/include/nodes/meson.build @@ -0,0 +1,58 @@ +node_support_input_i = [ + 'nodes/nodes.h', + 'nodes/primnodes.h', + 'nodes/parsenodes.h', + 'nodes/pathnodes.h', + 'nodes/plannodes.h', + 'nodes/execnodes.h', + 'access/amapi.h', + 'access/sdir.h', + 'access/tableam.h', + 'access/tsmapi.h', + 'commands/event_trigger.h', + 'commands/trigger.h', + 'executor/tuptable.h', + 'foreign/fdwapi.h', + 'nodes/extensible.h', + 'nodes/lockoptions.h', + 'nodes/replnodes.h', + 'nodes/supportnodes.h', + 'nodes/value.h', + 'utils/rel.h', +] + +node_support_input = [] +foreach i : node_support_input_i + node_support_input += meson.source_root() / 'src' / 'include' / i +endforeach + +node_support_output = [ + 'nodetags.h', + 'outfuncs.funcs.c', 'outfuncs.switch.c', + 'readfuncs.funcs.c', 'readfuncs.switch.c', + 'copyfuncs.funcs.c', 'copyfuncs.switch.c', + 'equalfuncs.funcs.c', 'equalfuncs.switch.c', +] +node_support_install = [ + dir_include_server / 'nodes', + false, false, + false, false, + false, false, + false, false, +] + +generated_nodes = custom_target('nodetags.h', + input: node_support_input, + output: node_support_output, + command: [ + perl, files('../../backend/nodes/gen_node_support.pl'), + '-o', '@OUTDIR@', + '@INPUT@'], + install: true, + install_dir: node_support_install, +) +generated_headers += generated_nodes[0] + +# autoconf generates the file there, ensure we get a conflict +generated_sources_ac += {'src/backend/nodes': node_support_output + ['node-support-stamp']} +generated_sources_ac += {'src/include/nodes': ['header-stamp']} diff --git a/src/include/pg_config_ext.h.meson b/src/include/pg_config_ext.h.meson new file mode 100644 index 00000000000..57cdfca0cfd --- /dev/null +++ b/src/include/pg_config_ext.h.meson @@ -0,0 +1,7 @@ +/* + * src/include/pg_config_ext.h.in. This is generated manually, not by + * autoheader, since we want to limit which symbols get defined here. + */ + +/* Define to the name of a signed 64-bit integer type. */ +#mesondefine PG_INT64_TYPE diff --git a/src/include/storage/meson.build b/src/include/storage/meson.build new file mode 100644 index 00000000000..eae9f98920e --- /dev/null +++ b/src/include/storage/meson.build @@ -0,0 +1,19 @@ +lwlocknames = custom_target('lwlocknames', + input: files('../../backend/storage/lmgr/lwlocknames.txt'), + output: ['lwlocknames.h', 'lwlocknames.c'], + command: [ + perl, files('../../backend/storage/lmgr/generate-lwlocknames.pl'), + '-o', '@OUTDIR@', + '@INPUT@' + ], + build_by_default: true, + install: true, + install_dir: [dir_include_server / 'storage', false], +) + +lwlocknames_h = lwlocknames[0] + +generated_backend_headers += lwlocknames_h + +# autoconf generates the file there, ensure we get a conflict +generated_sources_ac += {'src/backend/storage/lmgr': ['lwlocknames.c', 'lwlocknames.h']} diff --git a/src/include/utils/meson.build b/src/include/utils/meson.build new file mode 100644 index 00000000000..bded105f7ea --- /dev/null +++ b/src/include/utils/meson.build @@ -0,0 +1,57 @@ +errcodes = custom_target('errcodes', + input: files('../../backend/utils/errcodes.txt'), + output: ['errcodes.h'], + command: [ + perl, files('../../backend/utils/generate-errcodes.pl'), + '--outfile', '@OUTPUT@', + '@INPUT@', + ], + install: true, + install_dir: dir_include_server / 'utils', +) +generated_headers += errcodes + +if dtrace.found() + probes_tmp = custom_target('probes.h.tmp', + input: files('../../backend/utils/probes.d'), + output: 'probes.h.tmp', + command: [dtrace, '-C', '-h', '-s', '@INPUT@', '-o', '@OUTPUT@'], + ) + probes = custom_target('probes.h', + input: probes_tmp, + output: 'probes.h', + capture: true, + command: [sed, '-f', files('../../backend/utils/postprocess_dtrace.sed'), '@INPUT@'], + install: true, + install_dir: dir_include_server / 'utils', + ) +else + probes = custom_target('probes.h', + input: files('../../backend/utils/probes.d'), + output: 'probes.h', + capture: true, + command: [sed, '-f', files('../../backend/utils/Gen_dummy_probes.sed'), '@INPUT@'], + install: true, + install_dir: dir_include_server / 'utils', + ) +endif + +generated_backend_headers += probes + +fmgrtab_output = ['fmgroids.h', 'fmgrprotos.h', 'fmgrtab.c'] +fmgrtab_target = custom_target('fmgrtab', + input: '../catalog/pg_proc.dat', + output : fmgrtab_output, + command: [perl, '-I', '@SOURCE_ROOT@/src/backend/catalog/', files('../../backend/utils/Gen_fmgrtab.pl'), '--include-path=@SOURCE_ROOT@/src/include', '--output=@OUTDIR@', '@INPUT@'], + install: true, + install_dir: [dir_include_server / 'utils', dir_include_server / 'utils', false], +) + +generated_backend_headers += fmgrtab_target[0] +generated_backend_headers += fmgrtab_target[1] + +# autoconf generates the file there, ensure we get a conflict +generated_sources_ac += { + 'src/backend/utils': fmgrtab_output + ['errcodes.h', 'probes.h', 'fmgr-stamp'], + 'src/include/utils': ['header-stamp'], +} diff --git a/src/interfaces/ecpg/compatlib/meson.build b/src/interfaces/ecpg/compatlib/meson.build new file mode 100644 index 00000000000..5887cb92b52 --- /dev/null +++ b/src/interfaces/ecpg/compatlib/meson.build @@ -0,0 +1,22 @@ +export_file = custom_target('libpq.exports', kwargs: gen_export_kwargs) + +ecpg_compat = both_libraries('libecpg_compat', + 'informix.c', + include_directories: ['.', ecpg_inc, postgres_inc, libpq_inc], + c_args: ['-DSO_MAJOR_VERSION=3'], + dependencies: [frontend_code, thread_dep], + link_with: [ecpglib, ecpg_pgtypes], + soversion: host_system != 'windows' ? '3' : '', + darwin_versions: ['3', '3.' + pg_version_major.to_string()], + version: '3.' + pg_version_major.to_string(), + link_args: export_fmt.format(export_file.full_path()), + link_depends: export_file, + kwargs: default_lib_args, +) +ecpg_targets += [ecpg_compat.get_shared_lib(), ecpg_compat.get_static_lib()] + +pkgconfig.generate( + ecpg_compat.get_shared_lib(), + description: 'PostgreSQL libecpg_compat library', + url: pg_url, +) diff --git a/src/interfaces/ecpg/ecpglib/meson.build b/src/interfaces/ecpg/ecpglib/meson.build new file mode 100644 index 00000000000..2da029ec8ea --- /dev/null +++ b/src/interfaces/ecpg/ecpglib/meson.build @@ -0,0 +1,37 @@ +ecpglib_sources = files( + 'connect.c', + 'data.c', + 'descriptor.c', + 'error.c', + 'execute.c', + 'memory.c', + 'misc.c', + 'prepare.c', + 'sqlda.c', + 'typename.c', +) + +export_file = custom_target('libpq.exports', kwargs: gen_export_kwargs) + +ecpglib = both_libraries('libecpg', + ecpglib_sources, + include_directories: ['.', ecpg_inc, postgres_inc], + c_args: ['-DSO_MAJOR_VERSION=6'], + dependencies: [frontend_code, libpq, thread_dep], + link_with: [ecpg_pgtypes], + soversion: host_system != 'windows' ? '6' : '', + darwin_versions: ['6', '6.' + pg_version_major.to_string()], + version: '6.' + pg_version_major.to_string(), + link_args: export_fmt.format(export_file.full_path()), + link_depends: export_file, + kwargs: default_lib_args, +) +ecpg_targets += [ecpglib.get_shared_lib(), ecpglib.get_static_lib()] + +pkgconfig.generate( + ecpglib.get_shared_lib(), + description: 'PostgreSQL libecpg library', + url: pg_url, +) + +subdir('po', if_found: libintl) diff --git a/src/interfaces/ecpg/ecpglib/po/meson.build b/src/interfaces/ecpg/ecpglib/po/meson.build new file mode 100644 index 00000000000..246e399ebd3 --- /dev/null +++ b/src/interfaces/ecpg/ecpglib/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('ecpglib' + '6' + '-' + pg_version_major.to_string()) diff --git a/src/interfaces/ecpg/include/meson.build b/src/interfaces/ecpg/include/meson.build new file mode 100644 index 00000000000..c95d0455b9a --- /dev/null +++ b/src/interfaces/ecpg/include/meson.build @@ -0,0 +1,51 @@ +ecpg_inc = include_directories('.') + +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 + +ecpg_config_h = configure_file( + output: 'ecpg_config.h', + configuration: ecpg_conf_data, + install_dir: dir_include, +) +configure_files += ecpg_config_h + +generated_sources_ac += {'src/interfaces/ecpg/include': ['stamp-h']} + +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', + install_dir: dir_include_pkg / 'informix' / 'esql', +) diff --git a/src/interfaces/ecpg/meson.build b/src/interfaces/ecpg/meson.build new file mode 100644 index 00000000000..f079b42269f --- /dev/null +++ b/src/interfaces/ecpg/meson.build @@ -0,0 +1,9 @@ +ecpg_targets = [] + +subdir('include') +subdir('pgtypeslib') +subdir('ecpglib') +subdir('compatlib') +subdir('preproc') + +alias_target('ecpg', ecpg_targets) diff --git a/src/interfaces/ecpg/pgtypeslib/meson.build b/src/interfaces/ecpg/pgtypeslib/meson.build new file mode 100644 index 00000000000..96489d9f1d7 --- /dev/null +++ b/src/interfaces/ecpg/pgtypeslib/meson.build @@ -0,0 +1,30 @@ +ecpg_pgtypes_sources = files( + 'common.c', + 'datetime.c', + 'dt_common.c', + 'interval.c', + 'numeric.c', + 'timestamp.c', +) + +export_file = custom_target('libpq.exports', kwargs: gen_export_kwargs) + +ecpg_pgtypes = both_libraries('libpgtypes', + ecpg_pgtypes_sources, + include_directories: ['.', ecpg_inc, postgres_inc], + c_args: ['-DSO_MAJOR_VERSION=3'], + dependencies: [frontend_code], + version: '3.' + pg_version_major.to_string(), + soversion: host_system != 'windows' ? '3' : '', + darwin_versions: ['3', '3.' + pg_version_major.to_string()], + link_args: export_fmt.format(export_file.full_path()), + link_depends: export_file, + kwargs: default_lib_args, +) +ecpg_targets += [ecpg_pgtypes.get_shared_lib(), ecpg_pgtypes.get_static_lib()] + +pkgconfig.generate( + ecpg_pgtypes.get_shared_lib(), + description: 'PostgreSQL libpgtypes library', + url: pg_url, +) diff --git a/src/interfaces/ecpg/preproc/meson.build b/src/interfaces/ecpg/preproc/meson.build new file mode 100644 index 00000000000..1be49c8c27f --- /dev/null +++ b/src/interfaces/ecpg/preproc/meson.build @@ -0,0 +1,104 @@ +ecpg_sources = files( + '../ecpglib/typename.c', + 'c_keywords.c', + 'descriptor.c', + 'ecpg.c', + 'ecpg_keywords.c', + 'keywords.c', + 'output.c', + 'parser.c', + 'type.c', + 'variable.c', +) + +pgc = custom_target('pgc.c', + input: 'pgc.l', + output: 'pgc.c', + command: flex_cmd, +) +generated_sources += pgc +ecpg_sources += pgc + +ecpg_files = [ + 'ecpg.addons', + 'ecpg.header', + 'ecpg.tokens', + 'ecpg.trailer', + 'ecpg.type', +] + +preproc_y = custom_target('preproc.y', + input: [ + '../../../backend/parser/gram.y', + ecpg_files, + ], + output: ['preproc.y'], + command: [ + perl, files('parse.pl'), + '--srcdir', '@CURRENT_SOURCE_DIR@', + '--parser', '@INPUT0@', + '--output', '@OUTPUT0@', + ], +) +generated_sources += preproc_y + +check_rules = custom_target('preproc.y.check_rules', + input: [ + '../../../backend/parser/gram.y', + ecpg_files, + ], + output: 'preproc.y.check_rules', + command: [ + perl, files('check_rules.pl'), + '--srcdir', '@CURRENT_SOURCE_DIR@', + '--parser', '@INPUT0@', + '--stamp', '@OUTPUT0@', + ], +) + +preproc = custom_target('preproc.c', + input: preproc_y, + kwargs: bison_kw, +) +generated_sources += preproc.to_list() +ecpg_sources += preproc + +c_kwlist = custom_target('c_kwlist_d.h', + input: ['c_kwlist.h'], + output: ['c_kwlist_d.h'], + depends: check_rules, + command: [ + perl, + '-I', '@SOURCE_ROOT@/src/tools', + '@SOURCE_ROOT@/src/tools/gen_keywordlist.pl', + '--output', '@OUTDIR@', + '--varname', 'ScanCKeywords', + '--no-case-fold', '@INPUT0@', + ], +) +generated_sources += c_kwlist +ecpg_sources += c_kwlist + +ecpg_kwlist = 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@', + ] +) +generated_sources += ecpg_kwlist +ecpg_sources += ecpg_kwlist + +ecpg_exe = executable('ecpg', + ecpg_sources, + include_directories: ['.', ecpg_inc, postgres_inc, libpq_inc], + dependencies: [frontend_code], + kwargs: default_bin_args, +) +ecpg_targets += ecpg_exe + +subdir('po', if_found: libintl) diff --git a/src/interfaces/ecpg/preproc/po/meson.build b/src/interfaces/ecpg/preproc/po/meson.build new file mode 100644 index 00000000000..d73b05afd5e --- /dev/null +++ b/src/interfaces/ecpg/preproc/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('ecpg-' + pg_version_major.to_string()) diff --git a/src/interfaces/ecpg/test/compat_informix/meson.build b/src/interfaces/ecpg/test/compat_informix/meson.build new file mode 100644 index 00000000000..6bb0d980761 --- /dev/null +++ b/src/interfaces/ecpg/test/compat_informix/meson.build @@ -0,0 +1,31 @@ +pgc_files = [ + 'charfuncs', + 'dec_test', + 'describe', + 'rfmtdate', + 'rfmtlong', + 'rnull', + 'sqlda', + 'test_informix', + 'test_informix2', +] + +pgc_extra_flags = { + 'rnull': ['-r', 'no_indicator',], +} + +foreach pgc_file : pgc_files + exe_input = custom_target('@0@.c'.format(pgc_file), + input: '@0@.pgc'.format(pgc_file), + command: ecpg_preproc_test_command_start + + ['-C', 'INFORMIX',] + + pgc_extra_flags.get(pgc_file, []) + + ecpg_preproc_test_command_end, + kwargs: ecpg_preproc_kw, + ) + + ecpg_test_dependencies += executable(pgc_file, + exe_input, + kwargs: ecpg_test_exec_kw, + ) +endforeach diff --git a/src/interfaces/ecpg/test/compat_oracle/meson.build b/src/interfaces/ecpg/test/compat_oracle/meson.build new file mode 100644 index 00000000000..2e8794ba386 --- /dev/null +++ b/src/interfaces/ecpg/test/compat_oracle/meson.build @@ -0,0 +1,20 @@ +pgc_files = [ + 'char_array', +] + +foreach pgc_file : pgc_files + exe_input = custom_target('@0@.c'.format(pgc_file), + input: '@0@.pgc'.format(pgc_file), + output: '@BASENAME@.c', + command: ecpg_preproc_test_command_start + + ['-C', 'ORACLE',] + + ecpg_preproc_test_command_end, + install: false, + build_by_default: false, + ) + + ecpg_test_dependencies += executable(pgc_file, + exe_input, + kwargs: ecpg_test_exec_kw, + ) +endforeach diff --git a/src/interfaces/ecpg/test/connect/meson.build b/src/interfaces/ecpg/test/connect/meson.build new file mode 100644 index 00000000000..0b1c3593146 --- /dev/null +++ b/src/interfaces/ecpg/test/connect/meson.build @@ -0,0 +1,20 @@ +pgc_files = [ + 'test1', + 'test2', + 'test3', + 'test4', + 'test5', +] + +foreach pgc_file : pgc_files + exe_input = custom_target('@0@.c'.format(pgc_file), + input: '@0@.pgc'.format(pgc_file), + command: ecpg_preproc_test_command_start + ecpg_preproc_test_command_end, + kwargs: ecpg_preproc_kw, + ) + + ecpg_test_dependencies += executable(pgc_file, + exe_input, + kwargs: ecpg_test_exec_kw, + ) +endforeach diff --git a/src/interfaces/ecpg/test/meson.build b/src/interfaces/ecpg/test/meson.build new file mode 100644 index 00000000000..f0ace641f0c --- /dev/null +++ b/src/interfaces/ecpg/test/meson.build @@ -0,0 +1,84 @@ +# can't run ecpg to build test dependencies, at least not without an emulator +if meson.is_cross_build() + subdir_done() +endif + +pg_regress_ecpg_sources = pg_regress_c + files( + 'pg_regress_ecpg.c', +) + +pg_regress_ecpg = executable('pg_regress_ecpg', + pg_regress_ecpg_sources, + c_args: pg_regress_cflags, + include_directories: [pg_regress_inc, include_directories('.')], + dependencies: [frontend_code], + kwargs: default_bin_args + { + 'install': false + }, +) +testprep_targets += pg_regress_ecpg + +# create .c files and executables from .pgc files +ecpg_test_exec_kw = { + 'dependencies': [frontend_code, libpq], + 'include_directories': [ecpg_inc], + 'link_with': [ecpglib, ecpg_compat, ecpg_pgtypes], + 'build_by_default': false, + 'install': false, +} + +ecpg_preproc_kw = { + 'output': '@BASENAME@.c', + 'install': false, + 'build_by_default': false, +} + +ecpg_preproc_test_command_start = [ + ecpg_exe, + '--regression', + '-I@CURRENT_SOURCE_DIR@', + '-I@SOURCE_ROOT@' + '/src/interfaces/ecpg/include/', +] +ecpg_preproc_test_command_end = [ + '-o', '@OUTPUT@', '@INPUT@' +] + +ecpg_test_dependencies = [] + +subdir('compat_informix') +subdir('compat_oracle') +subdir('connect') +subdir('pgtypeslib') +subdir('preproc') +subdir('sql') +subdir('thread') + +testprep_targets += ecpg_test_dependencies + +ecpg_test_files = files( + 'ecpg_schedule', +) + +ecpg_regress_args = [ + '--dbname=ecpg1_regression,ecpg2_regression', + '--create-role=regress_ecpg_user1,regress_ecpg_user2', + '--encoding=SQL_ASCII', +] + +tests += { + 'name': 'ecpg', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'ecpg': { + 'expecteddir': meson.current_source_dir(), + 'inputdir': meson.current_build_dir(), + 'schedule': ecpg_test_files, + 'sql': [ + 'sql/twophase', + ], + 'test_kwargs': { + 'depends': ecpg_test_dependencies, + }, + 'regress_args': ecpg_regress_args, + }, +} diff --git a/src/interfaces/ecpg/test/pgtypeslib/meson.build b/src/interfaces/ecpg/test/pgtypeslib/meson.build new file mode 100644 index 00000000000..2957f12abfc --- /dev/null +++ b/src/interfaces/ecpg/test/pgtypeslib/meson.build @@ -0,0 +1,21 @@ +pgc_files = [ + 'dt_test', + 'dt_test2', + 'num_test', + 'num_test2', + 'nan_test', +] + +foreach pgc_file : pgc_files + exe_input = custom_target('@0@.c'.format(pgc_file), + input: '@0@.pgc'.format(pgc_file), + command: ecpg_preproc_test_command_start + + ecpg_preproc_test_command_end, + kwargs: ecpg_preproc_kw, + ) + + ecpg_test_dependencies += executable(pgc_file, + exe_input, + kwargs: ecpg_test_exec_kw, + ) +endforeach diff --git a/src/interfaces/ecpg/test/preproc/meson.build b/src/interfaces/ecpg/test/preproc/meson.build new file mode 100644 index 00000000000..0608df2f2a2 --- /dev/null +++ b/src/interfaces/ecpg/test/preproc/meson.build @@ -0,0 +1,37 @@ +pgc_files = [ + 'array_of_struct', + 'autoprep', + 'comment', + 'cursor', + 'define', + 'init', + 'outofscope', + 'pointer_to_struct', + 'strings', + 'type', + 'variable', + 'whenever', + 'whenever_do_continue', +] + +pgc_extra_flags = { + 'array_of_struct': ['-c'], + 'pointer_to_struct': ['-c'], + 'autoprep': ['-r', 'prepare'], + 'strings': ['-i'], +} + +foreach pgc_file : pgc_files + exe_input = custom_target('@0@.c'.format(pgc_file), + input: '@0@.pgc'.format(pgc_file), + command: ecpg_preproc_test_command_start + + pgc_extra_flags.get(pgc_file, []) + + ecpg_preproc_test_command_end, + kwargs: ecpg_preproc_kw, + ) + + ecpg_test_dependencies += executable(pgc_file, + exe_input, + kwargs: ecpg_test_exec_kw, + ) +endforeach diff --git a/src/interfaces/ecpg/test/sql/meson.build b/src/interfaces/ecpg/test/sql/meson.build new file mode 100644 index 00000000000..bec7d4ed8f6 --- /dev/null +++ b/src/interfaces/ecpg/test/sql/meson.build @@ -0,0 +1,46 @@ +pgc_files = [ + 'array', + 'binary', + 'bytea', + 'code100', + 'copystdout', + 'createtableas', + 'declare', + 'define', + 'desc', + 'describe', + 'dynalloc', + 'dynalloc2', + 'dyntest', + 'execute', + 'fetch', + 'func', + 'indicators', + 'insupd', + 'oldexec', + 'parser', + 'prepareas', + 'quote', + 'show', + 'sqlda', + 'twophase', +] + +pgc_extra_flags = { + 'oldexec': ['-r', 'questionmarks'], +} + +foreach pgc_file : pgc_files + exe_input = custom_target('@0@.c'.format(pgc_file), + input: '@0@.pgc'.format(pgc_file), + command: ecpg_preproc_test_command_start + + pgc_extra_flags.get(pgc_file, []) + + ecpg_preproc_test_command_end, + kwargs: ecpg_preproc_kw, + ) + + ecpg_test_dependencies += executable(pgc_file, + exe_input, + kwargs: ecpg_test_exec_kw, + ) +endforeach diff --git a/src/interfaces/ecpg/test/thread/meson.build b/src/interfaces/ecpg/test/thread/meson.build new file mode 100644 index 00000000000..2f1629e266b --- /dev/null +++ b/src/interfaces/ecpg/test/thread/meson.build @@ -0,0 +1,21 @@ +pgc_files = [ + 'thread_implicit', + 'thread', + 'prep', + 'descriptor', + 'alloc', +] + +foreach pgc_file : pgc_files + exe_input = custom_target('@0@.c'.format(pgc_file), + input: '@0@.pgc'.format(pgc_file), + command: ecpg_preproc_test_command_start + + ecpg_preproc_test_command_end, + kwargs: ecpg_preproc_kw, + ) + + ecpg_test_dependencies += executable(pgc_file, + exe_input, + kwargs: ecpg_test_exec_kw + {'dependencies': [frontend_code, libpq, thread_dep,]}, + ) +endforeach diff --git a/src/interfaces/libpq/meson.build b/src/interfaces/libpq/meson.build new file mode 100644 index 00000000000..bc047e00d62 --- /dev/null +++ b/src/interfaces/libpq/meson.build @@ -0,0 +1,108 @@ +# test/ is entered via top-level meson.build, that way it can use the default +# args for executables (which depend on libpq). + +libpq_sources = files( + 'fe-auth-scram.c', + 'fe-auth.c', + 'fe-connect.c', + 'fe-exec.c', + 'fe-lobj.c', + 'fe-misc.c', + 'fe-print.c', + 'fe-protocol3.c', + 'fe-secure.c', + 'fe-trace.c', + 'legacy-pqsignal.c', + 'libpq-events.c', + 'pqexpbuffer.c', +) + +if host_system == 'windows' + libpq_sources += files('pthread-win32.c', 'win32.c') +endif + +if ssl.found() + libpq_sources += files('fe-secure-common.c') + libpq_sources += files('fe-secure-openssl.c') +endif + +if gssapi.found() + libpq_sources += files( + 'fe-gssapi-common.c', + 'fe-secure-gssapi.c', + ) +endif + +export_file = custom_target('libpq.exports', + kwargs: gen_export_kwargs, +) + +# port needs to be in include path due to pthread-win32.h +libpq_inc = include_directories('.', '../../port') + +libpq_st = static_library('libpq', + libpq_sources, + pic: true, + include_directories: [libpq_inc, postgres_inc], + c_args: ['-DSO_MAJOR_VERSION=5'], + dependencies: libpq_deps, + kwargs: default_lib_args, +) + +# not using both_libraries here, causes problems with precompiled headers and +# resource files with msbuild +libpq_so = shared_library('libpq', + dependencies: libpq_deps, + include_directories: [libpq_inc, postgres_inc], + c_args: ['-DSO_MAJOR_VERSION=5'], + link_whole: libpq_st, + version: '5.' + pg_version_major.to_string(), + soversion: host_system != 'windows' ? '5' : '', + darwin_versions: ['5', '5.' + pg_version_major.to_string()], + link_depends: export_file, + link_args: export_fmt.format(export_file.full_path()), + kwargs: default_lib_args, +) + +libpq = declare_dependency( + link_with: [libpq_so], + include_directories: [include_directories('.')] +) + +pkgconfig.generate( + libpq_so, + name: 'libpq', + description: 'PostgreSQL libpq library', + url: pg_url, +) + +install_headers( + 'libpq-fe.h', + 'libpq-events.h', +) + +install_headers( + 'libpq-int.h', + 'pqexpbuffer.h', + 'fe-auth-sasl.h', + install_dir: dir_include_internal, +) +install_data('pg_service.conf.sample', + install_dir: dir_data, +) + + +tests += { + 'name': 'libpq', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_uri.pl', + 't/002_api.pl', + ], + 'env': {'with_ssl': get_option('ssl')}, + }, +} + +subdir('po', if_found: libintl) diff --git a/src/interfaces/libpq/po/meson.build b/src/interfaces/libpq/po/meson.build new file mode 100644 index 00000000000..eed91110fd6 --- /dev/null +++ b/src/interfaces/libpq/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('libpq' + '5' + '-' + pg_version_major.to_string()) diff --git a/src/interfaces/libpq/test/meson.build b/src/interfaces/libpq/test/meson.build new file mode 100644 index 00000000000..16f94c1ed8b --- /dev/null +++ b/src/interfaces/libpq/test/meson.build @@ -0,0 +1,15 @@ +executable('libpq_uri_regress', + files('libpq_uri_regress.c'), + dependencies: [frontend_code, libpq], + kwargs: default_bin_args + { + 'install': false, + } +) + +executable('libpq_testclient', + files('libpq_testclient.c'), + dependencies: [frontend_code, libpq], + kwargs: default_bin_args + { + 'install': false, + } +) diff --git a/src/interfaces/meson.build b/src/interfaces/meson.build new file mode 100644 index 00000000000..73fffbee394 --- /dev/null +++ b/src/interfaces/meson.build @@ -0,0 +1,2 @@ +# NB: libpq is entered directly from the toplevel meson file +subdir('ecpg') diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 00000000000..b515af15bfa --- /dev/null +++ b/src/meson.build @@ -0,0 +1,12 @@ +# libraries that other subsystems might depend upon first, in their respective +# dependency order + +subdir('timezone') + +subdir('backend') + +subdir('bin') + +subdir('pl') + +subdir('interfaces') diff --git a/src/pl/meson.build b/src/pl/meson.build new file mode 100644 index 00000000000..d9a57465441 --- /dev/null +++ b/src/pl/meson.build @@ -0,0 +1,5 @@ +subdir('plpgsql') + +subdir('plperl') +subdir('plpython') +subdir('tcl') diff --git a/src/pl/plperl/meson.build b/src/pl/plperl/meson.build new file mode 100644 index 00000000000..73b733dd50b --- /dev/null +++ b/src/pl/plperl/meson.build @@ -0,0 +1,90 @@ +if not perl_dep.found() + subdir_done() +endif + +plperl_sources = files( + 'plperl.c', +) + +subppdir = run_command(perl, '-e', 'use List::Util qw(first); print first { -r "$_/ExtUtils/xsubpp" } @INC', + check: true).stdout() +xsubpp = '@0@/ExtUtils/xsubpp'.format(subppdir) +typemap = '@0@/ExtUtils/typemap'.format(privlibexp) + +plperl_sources += custom_target('perlchunks.h', + input: files('plc_perlboot.pl', 'plc_trusted.pl'), + output: 'perlchunks.h', + capture: true, + command: [perl, files('text2macro.pl'), '--strip=^(\#.*|\s*)$', '@INPUT@'] +) + +plperl_sources += custom_target('plperl_opmask.h', + input: files('plperl_opmask.pl'), + output: 'plperl_opmask.h', + command: [perl, '@INPUT@', '@OUTPUT@'] +) + +foreach n : ['SPI', 'Util'] + xs = files(n + '.xs') + xs_c_name = n + '.c' + xs_c = custom_target(xs_c_name, + input: xs, + output: xs_c_name, + command: [perl, xsubpp, '-typemap', typemap, '-output', '@OUTPUT@', '@INPUT@'] + ) + plperl_sources += xs_c +endforeach + +plperl_inc = include_directories('.') +plperl = shared_module('plperl', + plperl_sources, + include_directories: [plperl_inc, postgres_inc], + kwargs: pg_mod_args + { + 'dependencies': [perl_dep, pg_mod_args['dependencies']], + 'install_rpath': ':'.join(mod_install_rpaths + ['@0@/CORE'.format(archlibexp)]), + 'build_rpath': '@0@/CORE'.format(archlibexp), + }, +) +pl_targets += plperl + +install_data( + 'plperl.control', + 'plperl--1.0.sql', + install_dir: dir_data_extension, +) + +install_data( + 'plperlu.control', + 'plperlu--1.0.sql', + install_dir: dir_data_extension, +) + +install_headers( + 'plperl.h', + 'ppport.h', + install_dir: dir_include_server, +) + +tests += { + 'name': 'plperl', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'plperl_setup', + 'plperl', + 'plperl_lc', + 'plperl_trigger', + 'plperl_shared', + 'plperl_elog', + 'plperl_util', + 'plperl_init', + 'plperlu', + 'plperl_array', + 'plperl_call', + 'plperl_transaction', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/pl/plperl/po/meson.build b/src/pl/plperl/po/meson.build new file mode 100644 index 00000000000..fe0a715bdf0 --- /dev/null +++ b/src/pl/plperl/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('plperl-' + pg_version_major.to_string()) diff --git a/src/pl/plpgsql/meson.build b/src/pl/plpgsql/meson.build new file mode 100644 index 00000000000..9537275d67c --- /dev/null +++ b/src/pl/plpgsql/meson.build @@ -0,0 +1 @@ +subdir('src') diff --git a/src/pl/plpgsql/src/meson.build b/src/pl/plpgsql/src/meson.build new file mode 100644 index 00000000000..dd499fdd151 --- /dev/null +++ b/src/pl/plpgsql/src/meson.build @@ -0,0 +1,84 @@ +plpgsql_sources = files( + 'pl_comp.c', + 'pl_exec.c', + 'pl_funcs.c', + 'pl_handler.c', + 'pl_scanner.c', +) + +pl_gram = custom_target('gram', + input: 'pl_gram.y', + kwargs: bison_kw, +) +generated_sources += pl_gram.to_list() +plpgsql_sources += pl_gram + +gen_plerrcodes = files('generate-plerrcodes.pl') +pl_errcodes = custom_target('plerrcodes', + input: ['../../../../src/backend/utils/errcodes.txt'], + output: ['plerrcodes.h'], + command: [perl, gen_plerrcodes, '@INPUT0@'], + capture: true, +) +generated_sources += pl_errcodes +plpgsql_sources += pl_errcodes + +gen_keywordlist = files('../../../../src/tools/gen_keywordlist.pl') +pl_reserved = custom_target('pl_reserved_kwlist', + input: ['pl_reserved_kwlist.h'], + output: ['pl_reserved_kwlist_d.h'], + command: [perl, '-I', '@SOURCE_ROOT@/src/tools', gen_keywordlist, '--output', '@OUTDIR@', '--varname', 'ReservedPLKeywords', '@INPUT@'] +) +generated_sources += pl_reserved +plpgsql_sources += pl_reserved + +pl_unreserved = custom_target('pl_unreserved_kwlist', + input: ['pl_unreserved_kwlist.h'], + output: ['pl_unreserved_kwlist_d.h'], + command: [perl, '-I', '@SOURCE_ROOT@/src/tools', gen_keywordlist, '--output', '@OUTDIR@', '--varname', 'UnreservedPLKeywords', '@INPUT@'] +) +generated_sources += pl_unreserved +plpgsql_sources += pl_unreserved + +plpgsql = shared_module('plpgsql', + plpgsql_sources, + include_directories: include_directories('.'), + kwargs: pg_mod_args, +) +pl_targets += plpgsql + +install_data( + 'plpgsql.control', + 'plpgsql--1.0.sql', + install_dir: dir_data_extension, +) + +install_headers( + 'plpgsql.h', + install_dir: dir_include_server +) + + +tests += { + 'name': 'plpgsql', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'plpgsql_array', + 'plpgsql_call', + 'plpgsql_control', + 'plpgsql_copy', + 'plpgsql_domain', + 'plpgsql_record', + 'plpgsql_cache', + 'plpgsql_simple', + 'plpgsql_transaction', + 'plpgsql_trap', + 'plpgsql_trigger', + 'plpgsql_varprops', + ], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/pl/plpgsql/src/po/meson.build b/src/pl/plpgsql/src/po/meson.build new file mode 100644 index 00000000000..29e0b74488f --- /dev/null +++ b/src/pl/plpgsql/src/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('plpgsql-' + pg_version_major.to_string()) diff --git a/src/pl/plpython/meson.build b/src/pl/plpython/meson.build new file mode 100644 index 00000000000..366b3b171ac --- /dev/null +++ b/src/pl/plpython/meson.build @@ -0,0 +1,99 @@ +if not python3_dep.found() + subdir_done() +endif + +plpython_sources = files( + 'plpy_cursorobject.c', + 'plpy_elog.c', + 'plpy_exec.c', + 'plpy_main.c', + 'plpy_planobject.c', + 'plpy_plpymodule.c', + 'plpy_procedure.c', + 'plpy_resultobject.c', + 'plpy_spi.c', + 'plpy_subxactobject.c', + 'plpy_typeio.c', + 'plpy_util.c', +) + +plpython_sources += custom_target('spiexceptions.h', + input: files('../../backend/utils/errcodes.txt'), + output: 'spiexceptions.h', + command: [perl, files('generate-spiexceptions.pl'), '@INPUT@'], + capture: true, +) + + +# FIXME: need to duplicate import library ugliness? +plpython_inc = include_directories('.') + +plpython = shared_module('plpython3', + plpython_sources, + include_directories: [plpython_inc, postgres_inc], + kwargs: pg_mod_args + { + 'dependencies': [python3_dep, pg_mod_args['dependencies']], + }, +) +pl_targets += plpython + +# FIXME: Only install the relevant versions +install_data( + 'plpython3u.control', + 'plpython3u--1.0.sql', + install_dir: dir_data_extension, +) + +install_headers( + 'plpy_cursorobject.h', + 'plpy_elog.h', + 'plpy_exec.h', + 'plpy_main.h', + 'plpy_planobject.h', + 'plpy_plpymodule.h', + 'plpy_procedure.h', + 'plpy_resultobject.h', + 'plpy_spi.h', + 'plpy_subxactobject.h', + 'plpy_typeio.h', + 'plpy_util.h', + 'plpython.h', + install_dir: dir_include_server, +) + +plpython_regress = [ + 'plpython_schema', + 'plpython_populate', + 'plpython_test', + 'plpython_do', + 'plpython_global', + 'plpython_import', + 'plpython_spi', + 'plpython_newline', + 'plpython_void', + 'plpython_call', + 'plpython_params', + 'plpython_setof', + 'plpython_record', + 'plpython_trigger', + 'plpython_types', + 'plpython_error', + 'plpython_ereport', + 'plpython_unicode', + 'plpython_quote', + 'plpython_composite', + 'plpython_subtransaction', + 'plpython_transaction', + 'plpython_drop', +] + +tests += { + 'name': 'plpython', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': plpython_regress, + }, +} + +subdir('po', if_found: libintl) diff --git a/src/pl/plpython/po/meson.build b/src/pl/plpython/po/meson.build new file mode 100644 index 00000000000..542e27fbe1f --- /dev/null +++ b/src/pl/plpython/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('plpython-' + pg_version_major.to_string()) diff --git a/src/pl/tcl/meson.build b/src/pl/tcl/meson.build new file mode 100644 index 00000000000..9b6addd7fd5 --- /dev/null +++ b/src/pl/tcl/meson.build @@ -0,0 +1,55 @@ +if not tcl_dep.found() + subdir_done() +endif + +pltcl_sources = files( + 'pltcl.c', +) + +gen_pltclerrcodes = files('generate-pltclerrcodes.pl') +pltcl_sources += custom_target('pltclerrcodes.h', + input: files('../../backend/utils/errcodes.txt'), + output: 'pltclerrcodes.h', + capture: true, + command: [perl, gen_pltclerrcodes, '@INPUT@'] +) + +pltcl = shared_module('pltcl', + pltcl_sources, + include_directories: [include_directories('.'), postgres_inc], + kwargs: pg_mod_args + { + 'dependencies': [tcl_dep, pg_mod_args['dependencies']], + }, +) +pl_targets += pltcl + +install_data( + 'pltcl.control', + 'pltcl--1.0.sql', + 'pltclu.control', + 'pltclu--1.0.sql', + install_dir: dir_data_extension, +) + +pltcl_regress = [ + 'pltcl_setup', + 'pltcl_queries', + 'pltcl_trigger', + 'pltcl_call', + 'pltcl_start_proc', + 'pltcl_subxact', + 'pltcl_unicode', + 'pltcl_transaction', +] + +tests += { + 'name': 'pltcl', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': pltcl_regress, + 'regress_args': ['--load-extension=pltcl'], + }, +} + +subdir('po', if_found: libintl) diff --git a/src/pl/tcl/po/meson.build b/src/pl/tcl/po/meson.build new file mode 100644 index 00000000000..cc23ef1eb3b --- /dev/null +++ b/src/pl/tcl/po/meson.build @@ -0,0 +1 @@ +i18n.gettext('pltcl-' + pg_version_major.to_string()) diff --git a/src/port/meson.build b/src/port/meson.build new file mode 100644 index 00000000000..ced2e014db8 --- /dev/null +++ b/src/port/meson.build @@ -0,0 +1,184 @@ +pgport_sources = [ + 'bsearch_arg.c', + 'chklocale.c', + 'inet_net_ntop.c', + 'noblock.c', + 'path.c', + 'pg_bitutils.c', + 'pg_strong_random.c', + 'pgcheckdir.c', + 'pgmkdirp.c', + 'pgsleep.c', + 'pgstrcasecmp.c', + 'pgstrsignal.c', + 'pqsignal.c', + 'qsort.c', + 'qsort_arg.c', + 'quotes.c', + 'snprintf.c', + 'strerror.c', + 'tar.c', + 'thread.c', +] + +if host_system == 'windows' + pgport_sources += files( + 'dirmod.c', + 'kill.c', + 'open.c', + 'system.c', + 'win32dlopen.c', + 'win32env.c', + 'win32error.c', + 'win32fdatasync.c', + 'win32getrusage.c', + 'win32link.c', + 'win32ntdll.c', + 'win32pread.c', + 'win32pwrite.c', + 'win32security.c', + 'win32setlocale.c', + 'win32stat.c', + ) +endif + +if cc.get_id() == 'msvc' + pgport_sources += files( + 'dirent.c', + 'win32gettimeofday.c', + ) +endif + +# Replacement functionality to be built if corresponding configure symbol +# is false +replace_funcs_neg = [ + ['explicit_bzero'], + ['getopt'], + ['getopt_long'], + ['getpeereid'], + ['inet_aton'], + ['mkdtemp'], + ['preadv', 'HAVE_DECL_PREADV'], + ['pwritev', 'HAVE_DECL_PWRITEV'], + ['strlcat'], + ['strlcpy'], + ['strnlen'], +] + +if host_system != 'windows' + replace_funcs_neg += [['pthread_barrier_wait']] +endif + +# Replacement functionality to be built if corresponding configure symbol +# is true +replace_funcs_pos = [ + # x86/x64 + ['pg_crc32c_sse42', 'USE_SSE42_CRC32C'], + ['pg_crc32c_sse42', 'USE_SSE42_CRC32C_WITH_RUNTIME_CHECK', 'crc'], + ['pg_crc32c_sse42_choose', 'USE_SSE42_CRC32C_WITH_RUNTIME_CHECK'], + ['pg_crc32c_sb8', 'USE_SSE42_CRC32C_WITH_RUNTIME_CHECK'], + + # arm / aarch64 + ['pg_crc32c_armv8', 'USE_ARMV8_CRC32C'], + ['pg_crc32c_armv8', 'USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK', 'crc'], + ['pg_crc32c_armv8_choose', 'USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK'], + ['pg_crc32c_sb8', 'USE_ARMV8_CRC32C_WITH_RUNTIME_CHECK'], + + # generic fallback + ['pg_crc32c_sb8', 'USE_SLICING_BY_8_CRC32C'], +] + +pgport_cflags = {'crc': cflags_crc} +pgport_sources_cflags = {'crc': []} + +foreach f : replace_funcs_neg + func = f.get(0) + varname = f.get(1, 'HAVE_@0@'.format(func.to_upper())) + filename = '@0@.c'.format(func) + + val = '@0@'.format(cdata.get(varname, 'false')) + if val == 'false' or val == '0' + pgport_sources += files(filename) + endif +endforeach + +foreach f : replace_funcs_pos + func = f.get(0) + varname = f.get(1, 'HAVE_@0@'.format(func.to_upper())) + filename = '@0@.c'.format(func) + + val = '@0@'.format(cdata.get(varname, 'false')) + if val == 'true' or val == '1' + src = files(filename) + if f.length() > 2 + pgport_sources_cflags += {f[2]: pgport_sources_cflags[f[2]] + src} + else + pgport_sources += src + endif + endif +endforeach + + +if (host_system == 'windows' or host_system == 'cygwin') and \ + (cc.get_id() != 'msvc' or cc.version().version_compare('<14.0')) + + # Cygwin and (apparently, based on test results) Mingw both + # have a broken strtof(), so substitute its implementation. + # That's not a perfect fix, since it doesn't avoid double-rounding, + # but we have no better options. + pgport_sources += files('strtof.c') + message('On @0@ with compiler @1@ @2@ we will use our strtof wrapper.'.format( + host_system, cc.get_id(), cc.version())) +endif + + + +# Build pgport once for backend, once for use in frontend binaries, and once +# for use in shared libraries +pgport = {} +pgport_variants = { + '_srv': internal_lib_args + { + 'dependencies': [backend_port_code], + }, + '': default_lib_args + { + 'dependencies': [frontend_port_code], + }, + '_shlib': default_lib_args + { + 'pic': true, + 'dependencies': [frontend_port_code], + }, +} + +foreach name, opts : pgport_variants + + # Build internal static libraries for sets of files that need to be built + # with different cflags + cflag_libs = [] + foreach cflagname, sources : pgport_sources_cflags + if sources.length() == 0 + continue + endif + c_args = opts.get('c_args', []) + pgport_cflags[cflagname] + cflag_libs += static_library('libpgport@0@_@1@'.format(name, cflagname), + sources, + kwargs: opts + { + 'c_args': c_args, + 'build_by_default': false, + 'install': false, + }, + ) + endforeach + + lib = static_library('libpgport@0@'.format(name), + pgport_sources, + link_with: cflag_libs, + kwargs: opts + { + 'dependencies': opts['dependencies'] + [ssl], + } + ) + pgport += {name: lib} +endforeach + +pgport_srv = pgport['_srv'] +pgport_static = pgport[''] +pgport_shlib = pgport['_shlib'] diff --git a/src/test/authentication/meson.build b/src/test/authentication/meson.build new file mode 100644 index 00000000000..2374028cbda --- /dev/null +++ b/src/test/authentication/meson.build @@ -0,0 +1,11 @@ +tests += { + 'name': 'authentication', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_password.pl', + 't/002_saslprep.pl', + ], + }, +} diff --git a/src/test/icu/meson.build b/src/test/icu/meson.build new file mode 100644 index 00000000000..5a4f53f37ff --- /dev/null +++ b/src/test/icu/meson.build @@ -0,0 +1,11 @@ +tests += { + 'name': 'icu', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/010_database.pl', + ], + 'env': {'with_icu': icu.found() ? 'yes' : 'no'}, + }, +} diff --git a/src/test/isolation/meson.build b/src/test/isolation/meson.build new file mode 100644 index 00000000000..c7656fd4609 --- /dev/null +++ b/src/test/isolation/meson.build @@ -0,0 +1,58 @@ +# pg_regress_c helpfully provided by regress/meson.build + +isolation_sources = pg_regress_c + files( + 'isolation_main.c', +) + +isolationtester_sources = files( + 'isolationtester.c', +) + +spec_scanner = custom_target('specscanner', + input: 'specscanner.l', + output: 'specscanner.c', + command: flex_cmd, +) +isolationtester_sources += spec_scanner +generated_sources += spec_scanner + +spec_parser = custom_target('specparse', + input: 'specparse.y', + kwargs: bison_kw, +) +isolationtester_sources += spec_parser +generated_sources += spec_parser.to_list() + +pg_isolation_regress = executable('pg_isolation_regress', + isolation_sources, + c_args: pg_regress_cflags, + include_directories: pg_regress_inc, + dependencies: frontend_code, + kwargs: default_bin_args + { + 'install_dir': dir_pgxs / 'src/test/isolation', + }, +) +bin_targets += pg_isolation_regress + +isolationtester = executable('isolationtester', + isolationtester_sources, + include_directories: include_directories('.'), + dependencies: [frontend_code, libpq], + kwargs: default_bin_args + { + 'install_dir': dir_pgxs / 'src/test/isolation', + }, +) +bin_targets += isolationtester + +tests += { + 'name': 'main', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'isolation': { + 'schedule': files('isolation_schedule'), + 'test_kwargs': { + 'priority': 40, + 'timeout': 1000, + }, + }, +} diff --git a/src/test/kerberos/meson.build b/src/test/kerberos/meson.build new file mode 100644 index 00000000000..7e2b6733fcc --- /dev/null +++ b/src/test/kerberos/meson.build @@ -0,0 +1,15 @@ +tests += { + 'name': 'kerberos', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'test_kwargs': {'priority': 40}, # kerberos tests are slow, start early + 'tests': [ + 't/001_auth.pl', + ], + 'env': { + 'with_gssapi': gssapi.found() ? 'yes' : 'no', + 'with_krb_srvnam': 'postgres', + }, + }, +} diff --git a/src/test/ldap/meson.build b/src/test/ldap/meson.build new file mode 100644 index 00000000000..2211bd5e3ec --- /dev/null +++ b/src/test/ldap/meson.build @@ -0,0 +1,11 @@ +tests += { + 'name': 'ldap', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_auth.pl', + ], + 'env': {'with_ldap': ldap.found() ? 'yes' : 'no'}, + }, +} diff --git a/src/test/meson.build b/src/test/meson.build new file mode 100644 index 00000000000..241d9d48aa5 --- /dev/null +++ b/src/test/meson.build @@ -0,0 +1,25 @@ +subdir('regress') +subdir('isolation') + +subdir('authentication') +subdir('recovery') +subdir('subscription') +subdir('modules') + +if ssl.found() + subdir('ssl') +endif + +if ldap.found() + subdir('ldap') +endif + +if gssapi.found() + subdir('kerberos') +endif + +if icu.found() + subdir('icu') +endif + +subdir('perl') diff --git a/src/test/modules/brin/meson.build b/src/test/modules/brin/meson.build new file mode 100644 index 00000000000..58254d093a4 --- /dev/null +++ b/src/test/modules/brin/meson.build @@ -0,0 +1,16 @@ +tests += { + 'name': 'brin', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'isolation': { + 'specs': [ + 'summarization-and-inprogress-insertion', + ], + }, + 'tap': { + 'tests': [ + 't/01_workitems.pl', + 't/02_wal_consistency.pl', + ], + }, +} diff --git a/src/test/modules/commit_ts/meson.build b/src/test/modules/commit_ts/meson.build new file mode 100644 index 00000000000..60cb12164d2 --- /dev/null +++ b/src/test/modules/commit_ts/meson.build @@ -0,0 +1,18 @@ +tests += { + 'name': 'commit_ts', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'commit_timestamp', + ], + }, + 'tap': { + 'tests': [ + 't/001_base.pl', + 't/002_standby.pl', + 't/003_standby_2.pl', + 't/004_restart.pl', + ], + }, +} diff --git a/src/test/modules/delay_execution/meson.build b/src/test/modules/delay_execution/meson.build new file mode 100644 index 00000000000..cf4bdaba637 --- /dev/null +++ b/src/test/modules/delay_execution/meson.build @@ -0,0 +1,18 @@ +# FIXME: prevent install during main install, but not during test :/ +delay_execution = shared_module('delay_execution', + ['delay_execution.c'], + kwargs: pg_mod_args, +) +testprep_targets += delay_execution + +tests += { + 'name': 'delay_execution', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'isolation': { + 'specs': [ + 'partition-addition', + 'partition-removal-1', + ], + }, +} diff --git a/src/test/modules/dummy_index_am/meson.build b/src/test/modules/dummy_index_am/meson.build new file mode 100644 index 00000000000..56ff5f48001 --- /dev/null +++ b/src/test/modules/dummy_index_am/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +dummy_index_am = shared_module('dummy_index_am', + ['dummy_index_am.c'], + kwargs: pg_mod_args, +) +testprep_targets += dummy_index_am + +install_data( + 'dummy_index_am.control', + 'dummy_index_am--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'dummy_index_am', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'reloptions', + ], + }, +} diff --git a/src/test/modules/dummy_seclabel/meson.build b/src/test/modules/dummy_seclabel/meson.build new file mode 100644 index 00000000000..21b7cf8f353 --- /dev/null +++ b/src/test/modules/dummy_seclabel/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +dummy_seclabel = shared_module('dummy_seclabel', + ['dummy_seclabel.c'], + kwargs: pg_mod_args, +) +testprep_targets += dummy_seclabel + +install_data( + 'dummy_seclabel.control', + 'dummy_seclabel--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'dummy_seclabel', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'dummy_seclabel', + ], + }, +} diff --git a/src/test/modules/libpq_pipeline/meson.build b/src/test/modules/libpq_pipeline/meson.build new file mode 100644 index 00000000000..8384b6e3b2a --- /dev/null +++ b/src/test/modules/libpq_pipeline/meson.build @@ -0,0 +1,21 @@ +libpq_pipeline = executable('libpq_pipeline', + files( + 'libpq_pipeline.c', + ), + dependencies: [frontend_code, libpq], + kwargs: default_bin_args + { + 'install': false, + }, +) +testprep_targets += libpq_pipeline + +tests += { + 'name': 'libpq_pipeline', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_libpq_pipeline.pl', + ], + }, +} diff --git a/src/test/modules/meson.build b/src/test/modules/meson.build new file mode 100644 index 00000000000..a80e6e2ce29 --- /dev/null +++ b/src/test/modules/meson.build @@ -0,0 +1,27 @@ +subdir('brin') +subdir('commit_ts') +subdir('delay_execution') +subdir('dummy_index_am') +subdir('dummy_seclabel') +subdir('libpq_pipeline') +subdir('plsample') +subdir('snapshot_too_old') +subdir('spgist_name_ops') +subdir('ssl_passphrase_callback') +subdir('test_bloomfilter') +subdir('test_ddl_deparse') +subdir('test_extensions') +subdir('test_ginpostinglist') +subdir('test_integerset') +subdir('test_lfind') +subdir('test_misc') +subdir('test_oat_hooks') +subdir('test_parser') +subdir('test_pg_dump') +subdir('test_predtest') +subdir('test_rbtree') +subdir('test_regex') +subdir('test_rls_hooks') +subdir('test_shm_mq') +subdir('unsafe_tests') +subdir('worker_spi') diff --git a/src/test/modules/plsample/meson.build b/src/test/modules/plsample/meson.build new file mode 100644 index 00000000000..45de3f1990d --- /dev/null +++ b/src/test/modules/plsample/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +plsample = shared_module('plsample', + ['plsample.c'], + kwargs: pg_mod_args, +) +testprep_targets += plsample + +install_data( + 'plsample.control', + 'plsample--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'plsample', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'plsample', + ], + }, +} diff --git a/src/test/modules/snapshot_too_old/meson.build b/src/test/modules/snapshot_too_old/meson.build new file mode 100644 index 00000000000..efd3f1f113b --- /dev/null +++ b/src/test/modules/snapshot_too_old/meson.build @@ -0,0 +1,14 @@ +tests += { + 'name': 'snapshot_too_old', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'isolation': { + 'test_kwargs': {'priority': 40}, # sto tests are slow, start early + 'specs': [ + 'sto_using_cursor', + 'sto_using_select', + 'sto_using_hash_index', + ], + 'regress_args': ['--temp-config', files('sto.conf')], + }, +} diff --git a/src/test/modules/spgist_name_ops/meson.build b/src/test/modules/spgist_name_ops/meson.build new file mode 100644 index 00000000000..857fc7e140e --- /dev/null +++ b/src/test/modules/spgist_name_ops/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +spgist_name_ops = shared_module('spgist_name_ops', + ['spgist_name_ops.c'], + kwargs: pg_mod_args, +) +testprep_targets += spgist_name_ops + +install_data( + 'spgist_name_ops.control', + 'spgist_name_ops--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'spgist_name_ops', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'spgist_name_ops', + ], + }, +} diff --git a/src/test/modules/ssl_passphrase_callback/meson.build b/src/test/modules/ssl_passphrase_callback/meson.build new file mode 100644 index 00000000000..a57bd0693a3 --- /dev/null +++ b/src/test/modules/ssl_passphrase_callback/meson.build @@ -0,0 +1,48 @@ +if not ssl.found() + subdir_done() +endif + +# FIXME: prevent install during main install, but not during test :/ +ssl_passphrase_callback = shared_module('ssl_passphrase_func', + ['ssl_passphrase_func.c'], + kwargs: pg_mod_args + { + 'dependencies': [ssl, pg_mod_args['dependencies']], + }, +) +testprep_targets += ssl_passphrase_callback + +# Targets to generate or remove the ssl certificate and key. Need to be copied +# to the source afterwards. Normally not needed. + +openssl = find_program('openssl', native: true, required: false) + +if openssl.found() + cert = custom_target('server.crt', + output: ['server.crt', 'server.ckey'], + command: [openssl, 'req', '-new', '-x509', '-days', '10000', '-nodes', '-out', '@OUTPUT0@', + '-keyout', '@OUTPUT1@', '-subj', '/CN=localhost'], + build_by_default: false, + install: false, + ) + + # needs to agree with what's in the test script + pass = 'FooBaR1' + + custom_target('server.key', + input: [cert[1]], + output: ['server.key'], + command: [openssl, 'rsa', '-aes256', '-in', '@INPUT0@', '-out', '@OUTPUT0@', '-passout', 'pass:@0@'.format(pass)] + ) +endif + +tests += { + 'name': 'ssl_passphrase_callback', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_testfunc.pl', + ], + 'env': {'with_ssl': 'openssl'}, + }, +} diff --git a/src/test/modules/test_bloomfilter/meson.build b/src/test/modules/test_bloomfilter/meson.build new file mode 100644 index 00000000000..945eb5a70c4 --- /dev/null +++ b/src/test/modules/test_bloomfilter/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +test_bloomfilter = shared_module('test_bloomfilter', + ['test_bloomfilter.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_bloomfilter + +install_data( + 'test_bloomfilter.control', + 'test_bloomfilter--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_bloomfilter', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_bloomfilter', + ], + }, +} diff --git a/src/test/modules/test_ddl_deparse/meson.build b/src/test/modules/test_ddl_deparse/meson.build new file mode 100644 index 00000000000..81ad5adc526 --- /dev/null +++ b/src/test/modules/test_ddl_deparse/meson.build @@ -0,0 +1,43 @@ +# FIXME: prevent install during main install, but not during test :/ +test_ddl_deparse = shared_module('test_ddl_deparse', + ['test_ddl_deparse.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_ddl_deparse + +install_data( + 'test_ddl_deparse.control', + 'test_ddl_deparse--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_ddl_deparse', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_ddl_deparse', + 'create_extension', + 'create_schema', + 'create_type', + 'create_conversion', + 'create_domain', + 'create_sequence_1', + 'create_table', + 'create_transform', + 'alter_table', + 'create_view', + 'create_trigger', + 'create_rule', + 'comment_on', + 'alter_function', + 'alter_sequence', + 'alter_ts_config', + 'alter_type_enum', + 'opfamily', + 'defprivs', + 'matviews', + ], + }, +} diff --git a/src/test/modules/test_extensions/meson.build b/src/test/modules/test_extensions/meson.build new file mode 100644 index 00000000000..e95a9f2e7eb --- /dev/null +++ b/src/test/modules/test_extensions/meson.build @@ -0,0 +1,45 @@ +# FIXME: prevent install during main install, but not during test :/ +install_data( + 'test_ext1--1.0.sql', + 'test_ext1.control', + 'test_ext2--1.0.sql', + 'test_ext2.control', + 'test_ext3--1.0.sql', + 'test_ext3.control', + 'test_ext4--1.0.sql', + 'test_ext4.control', + 'test_ext5--1.0.sql', + 'test_ext5.control', + 'test_ext6--1.0.sql', + 'test_ext6.control', + 'test_ext7--1.0--2.0.sql', + 'test_ext7--1.0.sql', + 'test_ext7.control', + 'test_ext8--1.0.sql', + 'test_ext8.control', + 'test_ext_cine--1.0.sql', + 'test_ext_cine--1.0--1.1.sql', + 'test_ext_cine.control', + 'test_ext_cor--1.0.sql', + 'test_ext_cor.control', + 'test_ext_cyclic1--1.0.sql', + 'test_ext_cyclic1.control', + 'test_ext_cyclic2--1.0.sql', + 'test_ext_cyclic2.control', + 'test_ext_evttrig--1.0--2.0.sql', + 'test_ext_evttrig--1.0.sql', + 'test_ext_evttrig.control', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_extensions', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_extensions', + 'test_extdepend', + ], + }, +} diff --git a/src/test/modules/test_ginpostinglist/meson.build b/src/test/modules/test_ginpostinglist/meson.build new file mode 100644 index 00000000000..abf0a3b0430 --- /dev/null +++ b/src/test/modules/test_ginpostinglist/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +test_ginpostinglist = shared_module('test_ginpostinglist', + ['test_ginpostinglist.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_ginpostinglist + +install_data( + 'test_ginpostinglist.control', + 'test_ginpostinglist--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_ginpostinglist', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_ginpostinglist', + ], + }, +} diff --git a/src/test/modules/test_integerset/meson.build b/src/test/modules/test_integerset/meson.build new file mode 100644 index 00000000000..c32c469c69a --- /dev/null +++ b/src/test/modules/test_integerset/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +test_integerset = shared_module('test_integerset', + ['test_integerset.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_integerset + +install_data( + 'test_integerset.control', + 'test_integerset--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_integerset', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_integerset', + ], + }, +} diff --git a/src/test/modules/test_lfind/meson.build b/src/test/modules/test_lfind/meson.build new file mode 100644 index 00000000000..a388de1156a --- /dev/null +++ b/src/test/modules/test_lfind/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +test_lfind = shared_module('test_lfind', + ['test_lfind.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_lfind + +install_data( + 'test_lfind.control', + 'test_lfind--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_lfind', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_lfind', + ], + }, +} diff --git a/src/test/modules/test_misc/meson.build b/src/test/modules/test_misc/meson.build new file mode 100644 index 00000000000..cfc830ff399 --- /dev/null +++ b/src/test/modules/test_misc/meson.build @@ -0,0 +1,12 @@ +tests += { + 'name': 'test_misc', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'tests': [ + 't/001_constraint_validation.pl', + 't/002_tablespace.pl', + 't/003_check_guc.pl', + ], + }, +} diff --git a/src/test/modules/test_oat_hooks/meson.build b/src/test/modules/test_oat_hooks/meson.build new file mode 100644 index 00000000000..5faf0459777 --- /dev/null +++ b/src/test/modules/test_oat_hooks/meson.build @@ -0,0 +1,18 @@ +# FIXME: prevent install during main install, but not during test :/ +test_oat_hooks = shared_module('test_oat_hooks', + ['test_oat_hooks.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_oat_hooks + +tests += { + 'name': 'test_oat_hooks', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_oat_hooks', + ], + 'regress_args': ['--no-locale', '--encoding=UTF8'], + }, +} diff --git a/src/test/modules/test_parser/meson.build b/src/test/modules/test_parser/meson.build new file mode 100644 index 00000000000..b59960f615e --- /dev/null +++ b/src/test/modules/test_parser/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +test_parser = shared_module('test_parser', + ['test_parser.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_parser + +install_data( + 'test_parser.control', + 'test_parser--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_parser', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_parser', + ], + }, +} diff --git a/src/test/modules/test_pg_dump/meson.build b/src/test/modules/test_pg_dump/meson.build new file mode 100644 index 00000000000..41021829f3a --- /dev/null +++ b/src/test/modules/test_pg_dump/meson.build @@ -0,0 +1,22 @@ +# FIXME: prevent install during main install, but not during test :/ +install_data( + 'test_pg_dump.control', + 'test_pg_dump--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_pg_dump', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_pg_dump', + ], + }, + 'tap': { + 'tests': [ + 't/001_base.pl', + ], + }, +} diff --git a/src/test/modules/test_predtest/meson.build b/src/test/modules/test_predtest/meson.build new file mode 100644 index 00000000000..1cfa84b3609 --- /dev/null +++ b/src/test/modules/test_predtest/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +test_predtest = shared_module('test_predtest', + ['test_predtest.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_predtest + +install_data( + 'test_predtest.control', + 'test_predtest--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_predtest', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_predtest', + ], + }, +} diff --git a/src/test/modules/test_rbtree/meson.build b/src/test/modules/test_rbtree/meson.build new file mode 100644 index 00000000000..34cbc3e1624 --- /dev/null +++ b/src/test/modules/test_rbtree/meson.build @@ -0,0 +1,23 @@ +# FIXME: prevent install during main install, but not during test :/ +test_rbtree = shared_module('test_rbtree', + ['test_rbtree.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_rbtree + +install_data( + 'test_rbtree.control', + 'test_rbtree--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_rbtree', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_rbtree', + ], + }, +} diff --git a/src/test/modules/test_regex/meson.build b/src/test/modules/test_regex/meson.build new file mode 100644 index 00000000000..867a64e57c3 --- /dev/null +++ b/src/test/modules/test_regex/meson.build @@ -0,0 +1,24 @@ +# FIXME: prevent install during main install, but not during test :/ +test_regex = shared_module('test_regex', + ['test_regex.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_regex + +install_data( + 'test_regex.control', + 'test_regex--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_regex', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_regex', + 'test_regex_utf8', + ], + }, +} diff --git a/src/test/modules/test_rls_hooks/meson.build b/src/test/modules/test_rls_hooks/meson.build new file mode 100644 index 00000000000..80d8adda332 --- /dev/null +++ b/src/test/modules/test_rls_hooks/meson.build @@ -0,0 +1,17 @@ +# FIXME: prevent install during main install, but not during test :/ +test_rls_hooks = shared_module('test_rls_hooks', + ['test_rls_hooks.c'], + kwargs: pg_mod_args, +) +testprep_targets += test_rls_hooks + +tests += { + 'name': 'test_rls_hooks', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_rls_hooks', + ], + }, +} diff --git a/src/test/modules/test_shm_mq/meson.build b/src/test/modules/test_shm_mq/meson.build new file mode 100644 index 00000000000..b663543d616 --- /dev/null +++ b/src/test/modules/test_shm_mq/meson.build @@ -0,0 +1,27 @@ +# FIXME: prevent install during main install, but not during test :/ +test_shm_mq = shared_module('test_shm_mq', + files( + 'setup.c', + 'test.c', + 'worker.c', + ), + kwargs: pg_mod_args, +) +testprep_targets += test_shm_mq + +install_data( + 'test_shm_mq.control', + 'test_shm_mq--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'test_shm_mq', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'test_shm_mq', + ], + }, +} diff --git a/src/test/modules/unsafe_tests/meson.build b/src/test/modules/unsafe_tests/meson.build new file mode 100644 index 00000000000..d69b0e7ce44 --- /dev/null +++ b/src/test/modules/unsafe_tests/meson.build @@ -0,0 +1,11 @@ +tests += { + 'name': 'unsafe_tests', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'rolenames', + 'alter_system_table', + ], + }, +} diff --git a/src/test/modules/worker_spi/meson.build b/src/test/modules/worker_spi/meson.build new file mode 100644 index 00000000000..32acad883b2 --- /dev/null +++ b/src/test/modules/worker_spi/meson.build @@ -0,0 +1,26 @@ +# FIXME: prevent install during main install, but not during test :/ +test_worker_spi = shared_module('worker_spi', + files( + 'worker_spi.c', + ), + kwargs: pg_mod_args, +) +testprep_targets += test_worker_spi + +install_data( + 'worker_spi.control', + 'worker_spi--1.0.sql', + kwargs: contrib_data_args, +) + +tests += { + 'name': 'worker_spi', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'sql': [ + 'worker_spi', + ], + 'regress_args': ['--temp-config', files('dynamic.conf'), '--dbname=contrib_regression'], + }, +} diff --git a/src/test/perl/meson.build b/src/test/perl/meson.build new file mode 100644 index 00000000000..901bae7a564 --- /dev/null +++ b/src/test/perl/meson.build @@ -0,0 +1,12 @@ +# could use install_data's preserve_path option in >=0.64.0 + +install_data( + 'PostgreSQL/Version.pm', + install_dir: dir_pgxs / 'src/test/perl/PostgreSQL') + +install_data( + 'PostgreSQL/Test/Utils.pm', + 'PostgreSQL/Test/SimpleTee.pm', + 'PostgreSQL/Test/RecursiveCopy.pm', + 'PostgreSQL/Test/Cluster.pm', + install_dir: dir_pgxs / 'src/test/perl/PostgreSQL/Test') diff --git a/src/test/recovery/meson.build b/src/test/recovery/meson.build new file mode 100644 index 00000000000..b0e398363f7 --- /dev/null +++ b/src/test/recovery/meson.build @@ -0,0 +1,43 @@ +tests += { + 'name': 'recovery', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'test_kwargs': {'priority': 40}, # recovery tests are slow, start early + 'tests': [ + 't/001_stream_rep.pl', + 't/002_archiving.pl', + 't/003_recovery_targets.pl', + 't/004_timeline_switch.pl', + 't/005_replay_delay.pl', + 't/006_logical_decoding.pl', + 't/007_sync_rep.pl', + 't/008_fsm_truncation.pl', + 't/009_twophase.pl', + 't/010_logical_decoding_timelines.pl', + 't/011_crash_recovery.pl', + 't/012_subtransactions.pl', + 't/013_crash_restart.pl', + 't/014_unlogged_reinit.pl', + 't/015_promotion_pages.pl', + 't/016_min_consistency.pl', + 't/017_shm.pl', + 't/018_wal_optimize.pl', + 't/019_replslot_limit.pl', + 't/020_archive_status.pl', + 't/021_row_visibility.pl', + 't/022_crash_temp_files.pl', + 't/023_pitr_prepared_xact.pl', + 't/024_archive_recovery.pl', + 't/025_stuck_on_old_timeline.pl', + 't/026_overwrite_contrecord.pl', + 't/027_stream_regress.pl', + 't/028_pitr_timelines.pl', + 't/029_stats_restart.pl', + 't/030_stats_cleanup_replica.pl', + 't/031_recovery_conflict.pl', + 't/032_relfilenode_reuse.pl', + 't/033_replay_tsp_drops.pl', + ], + }, +} diff --git a/src/test/regress/meson.build b/src/test/regress/meson.build new file mode 100644 index 00000000000..fd8ee995b79 --- /dev/null +++ b/src/test/regress/meson.build @@ -0,0 +1,62 @@ +# also used by isolationtester and ecpg tests +pg_regress_c = files('pg_regress.c') +pg_regress_inc = include_directories('.') + +regress_sources = pg_regress_c + files( + 'pg_regress_main.c' +) + +pg_regress_cflags = ['-DHOST_TUPLE="frak"', '-DSHELLPROG="/bin/sh"'] + +pg_regress = executable('pg_regress', + regress_sources, + c_args: pg_regress_cflags, + dependencies: [frontend_code], + kwargs: default_bin_args + { + 'install_dir': dir_pgxs / 'src/test/regress', + }, +) +bin_targets += pg_regress + +regress_module = shared_module('regress', + ['regress.c'], + kwargs: pg_mod_args + { + 'install': false, + }, +) +testprep_targets += regress_module + +# Get some extra C modules from contrib/spi but mark them as not to be +# installed. +# FIXME: avoid the duplication. + +autoinc_regress = shared_module('autoinc', + ['../../../contrib/spi/autoinc.c'], + kwargs: pg_mod_args + { + 'install': false, + }, +) +testprep_targets += autoinc_regress + +refint_regress = shared_module('refint', + ['../../../contrib/spi/refint.c'], + c_args: refint_cflags, + kwargs: pg_mod_args + { + 'install': false, + }, +) +testprep_targets += refint_regress + + +tests += { + 'name': 'main', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'regress': { + 'schedule': files('parallel_schedule'), + 'test_kwargs': { + 'priority': 50, + 'timeout': 1000, + }, + }, +} diff --git a/src/test/ssl/meson.build b/src/test/ssl/meson.build new file mode 100644 index 00000000000..e2f021d884a --- /dev/null +++ b/src/test/ssl/meson.build @@ -0,0 +1,13 @@ +tests += { + 'name': 'ssl', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'env': {'with_ssl': get_option('ssl')}, + 'tests': [ + 't/001_ssltests.pl', + 't/002_scram.pl', + 't/003_sslinfo.pl', + ], + }, +} diff --git a/src/test/subscription/meson.build b/src/test/subscription/meson.build new file mode 100644 index 00000000000..85d1dd92951 --- /dev/null +++ b/src/test/subscription/meson.build @@ -0,0 +1,42 @@ +tests += { + 'name': 'subscription', + 'sd': meson.current_source_dir(), + 'bd': meson.current_build_dir(), + 'tap': { + 'env': {'with_icu': icu.found() ? 'yes' : 'no'}, + 'tests': [ + 't/001_rep_changes.pl', + 't/002_types.pl', + 't/003_constraints.pl', + 't/004_sync.pl', + 't/005_encoding.pl', + 't/006_rewrite.pl', + 't/007_ddl.pl', + 't/008_diff_schema.pl', + 't/009_matviews.pl', + 't/010_truncate.pl', + 't/011_generated.pl', + 't/012_collation.pl', + 't/013_partition.pl', + 't/014_binary.pl', + 't/015_stream.pl', + 't/016_stream_subxact.pl', + 't/017_stream_ddl.pl', + 't/018_stream_subxact_abort.pl', + 't/019_stream_subxact_ddl_abort.pl', + 't/020_messages.pl', + 't/021_twophase.pl', + 't/022_twophase_cascade.pl', + 't/023_twophase_stream.pl', + 't/024_add_drop_pub.pl', + 't/025_rep_changes_for_schema.pl', + 't/026_stats.pl', + 't/027_nosuperuser.pl', + 't/028_row_filter.pl', + 't/029_on_error.pl', + 't/030_origin.pl', + 't/031_column_list.pl', + 't/100_bugs.pl', + ], + }, +} diff --git a/src/timezone/meson.build b/src/timezone/meson.build new file mode 100644 index 00000000000..16f082ecfa8 --- /dev/null +++ b/src/timezone/meson.build @@ -0,0 +1,48 @@ +# files to build into backend +timezone_sources = files( + 'localtime.c', + 'pgtz.c', + 'strftime.c', +) + + +timezone_inc = include_directories('.') + +timezone_localtime_source = files('localtime.c') + +# files needed to build zic utility program +zic_sources = files( + 'zic.c' +) + +# we now distribute the timezone data as a single file +tzdata = files( + 'data/tzdata.zi' +) + + +if get_option('system_tzdata') == '' + # FIXME: For cross builds, it would need a native built libpgport/pgcommon to + # build our zic. But for that we'd need to run a good chunk of the configure + # tests both natively and cross. Unclear if it's worth it. + if meson.is_cross_build() + zic = find_program(get_option('ZIC'), native: true, required: true) + else + zic = executable('zic', zic_sources, + dependencies: [frontend_code], + kwargs: default_bin_args + {'install': false} + ) + endif + + tzdata = custom_target('tzdata', + input: tzdata, + output: ['timezone'], + command: [zic, '-d', '@OUTPUT@', '@INPUT@'], + install: true, + install_dir: dir_data, + ) + + bin_targets += tzdata +endif + +subdir('tznames') diff --git a/src/timezone/tznames/meson.build b/src/timezone/tznames/meson.build new file mode 100644 index 00000000000..7e0a682bd9e --- /dev/null +++ b/src/timezone/tznames/meson.build @@ -0,0 +1,21 @@ +tznames = files( + 'Africa.txt', + 'America.txt', + 'Antarctica.txt', + 'Asia.txt', + 'Atlantic.txt', + 'Australia.txt', + 'Etc.txt', + 'Europe.txt', + 'Indian.txt', + 'Pacific.txt', +) + +tznames_sets = files( + 'Default', + 'Australia', + 'India') + +install_data(tznames, tznames_sets, + install_dir: dir_data / 'timezonesets', +) diff --git a/src/tools/find_meson b/src/tools/find_meson new file mode 100755 index 00000000000..50e501a8011 --- /dev/null +++ b/src/tools/find_meson @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 +# +# Returns the path to the meson binary, for cases where we need to call it as +# part of the build, e.g. to install into tmp_install/ for the tests. + +import os +import shlex +import sys + +to_print = [] + +if 'MUON_PATH' in os.environ: + to_print += ['muon', os.environ['MUON_PATH']] +else: + mesonintrospect = os.environ['MESONINTROSPECT'] + components = shlex.split(mesonintrospect) + + if len(components) < 2: + print('expected more than two components, got: %s' % components) + sys.exit(1) + + if components[-1] != 'introspect': + print('expected introspection at the end') + sys.exit(1) + + to_print += ['meson'] + components[:-1] + +print('\n'.join(to_print), end='') + +sys.exit(0) diff --git a/src/tools/gen_export.pl b/src/tools/gen_export.pl new file mode 100644 index 00000000000..68b3ab86614 --- /dev/null +++ b/src/tools/gen_export.pl @@ -0,0 +1,81 @@ +use strict; +use warnings; +use Getopt::Long; + +my $format; +my $libname; +my $input; +my $output; + +GetOptions( + 'format:s' => \$format, + 'libname:s' => \$libname, + 'input:s' => \$input, + 'output:s' => \$output) or die "wrong arguments"; + +if (not ($format eq 'aix' or $format eq 'darwin' or $format eq 'gnu' or $format eq 'win')) +{ + die "$0: $format is not yet handled (only aix, darwin, gnu, win are)\n"; +} + +open(my $input_handle, '<', $input) + or die "$0: could not open input file '$input': $!\n"; + +open(my $output_handle, '>', $output) + or die "$0: could not open output file '$output': $!\n"; + + +if ($format eq 'gnu') +{ + print $output_handle "{ + global: +"; +} +elsif ($format eq 'win') +{ + # XXX: Looks like specifying LIBRARY $libname is optional, which makes it + # easier to build a generic command for generating export files... + if ($libname) + { + print $output_handle "LIBRARY $libname\n"; + } + print $output_handle "EXPORTS\n"; +} + +while (<$input_handle>) +{ + if (/^#/) + { + # don't do anything with a comment + } + elsif (/^(\S+)\s+(\S+)/) + { + if ($format eq 'aix') + { + print $output_handle "$1\n"; + } + elsif ($format eq 'darwin') + { + print $output_handle "_$1\n"; + } + elsif ($format eq 'gnu') + { + print $output_handle " $1;\n"; + } + elsif ($format eq 'win') + { + print $output_handle "$1 @ $2\n"; + } + } + else + { + die "$0: unexpected line $_\n"; + } +} + +if ($format eq 'gnu') +{ + print $output_handle " local: *; +}; +"; +} diff --git a/src/tools/pgflex b/src/tools/pgflex new file mode 100755 index 00000000000..baabe2df1c8 --- /dev/null +++ b/src/tools/pgflex @@ -0,0 +1,85 @@ +#!/usr/bin/env python3 + +# +# Wrapper around flex that: +# - ensures lex.backup is created in a private directory +# - can error out if lex.backup is created (--no-backup) +# - can fix warnings (--fix-warnings) +# - works around concurrency issues with win_flex.exe: +# https://github.com/lexxmark/winflexbison/issues/86 + +import argparse +import os +import subprocess +import sys +from os.path import abspath + +parser = argparse.ArgumentParser() + +parser.add_argument('--flex', type=abspath, required=True) +parser.add_argument('--perl', type=abspath, required=True) +parser.add_argument('--builddir', type=abspath, required=True) +parser.add_argument('--srcdir', type=abspath, required=True) +parser.add_argument('--privatedir', type=abspath, required=True, + help='private directory for target') + +parser.add_argument('-o', dest='output_file', type=abspath, required=True, + help='output file') +parser.add_argument('-i', dest='input_file', type=abspath, help='input file') + + +parser.add_argument('--fix-warnings', action='store_true', + help='whether to fix warnings in generated file') +parser.add_argument('--no-backup', action='store_true', + help='whether no_backup is enabled or not') + +parser.add_argument('flex_flags', nargs='*', help='flags passed on to flex') + +args = parser.parse_args() + +# Since 'lex.backup' is always named that and ninja uses the top level build +# directory as current directory for all commands, change directory to +# temporary directory to avoid conflicts between concurrent flex +# invocations. Only unreleased versions of flex have an argument to change +# lex.filename to be named differently. +if not os.path.isdir(args.privatedir): + os.mkdir(args.privatedir) +os.chdir(args.privatedir) + +# win_flex.exe generates names in a racy way, sometimes leading to random +# "error deleting file" failures and sometimes to intermingled file +# contents. Set FLEX_TMP_DIR to the target private directory to avoid +# that. That environment variable isn't consulted on other platforms, so we +# don't even need to make this conditional. +env = {'FLEX_TMP_DIR': args.privatedir} + +# build flex invocation +command = [args.flex, '-o', args.output_file] +if args.no_backup: + command += ['-b'] +command += args.flex_flags +command += [args.input_file] + +# create .c file from .l file +sp = subprocess.run(command, env=env) +if sp.returncode != 0: + sys.exit(sp.returncode) + +# check lex.backup +if args.no_backup: + with open('lex.backup') as lex: + if len(lex.readlines()) != 1: + sys.exit('Scanner requires backup; see lex.backup.') + os.remove('lex.backup') + +# fix warnings +if args.fix_warnings: + fix_warning_script = os.path.join(args.srcdir, + 'src/tools/fix-old-flex-code.pl') + + command = [args.perl, fix_warning_script, args.output_file] + sp = subprocess.run(command) + if sp.returncode != 0: + sys.exit(sp.returncode) + +sys.exit(0) diff --git a/src/tools/testwrap b/src/tools/testwrap new file mode 100755 index 00000000000..7a64fe76a2d --- /dev/null +++ b/src/tools/testwrap @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 + +import argparse +import shutil +import subprocess +import os +import sys + +parser = argparse.ArgumentParser() + +parser.add_argument('--srcdir', help='source directory of test', type=str) +parser.add_argument('--basedir', help='base directory of test', type=str) +parser.add_argument('--testgroup', help='test group', type=str) +parser.add_argument('--testname', help='test name', type=str) +parser.add_argument('test_command', nargs='*') + +args = parser.parse_args() + +testdir = '{}/testrun/{}/{}'.format( + args.basedir, args.testgroup, args.testname) + +print('# executing test in {} group {} test {}'.format( + testdir, args.testgroup, args.testname)) +sys.stdout.flush() + +if os.path.exists(testdir) and os.path.isdir(testdir): + shutil.rmtree(testdir) +os.makedirs(testdir) + +os.chdir(args.srcdir) + +# mark test as having started +open(os.path.join(testdir, 'test.start'), 'x') + +env_dict = {**os.environ, + 'TESTDATADIR': os.path.join(testdir, 'data'), + 'TESTLOGDIR': os.path.join(testdir, 'log')} + +sp = subprocess.run(args.test_command, env=env_dict) + +if sp.returncode == 0: + print('# test succeeded') + open(os.path.join(testdir, 'test.success'), 'x') +else: + print('# test failed') + open(os.path.join(testdir, 'test.fail'), 'x') +sys.exit(sp.returncode) |