From 2e21b218db0e979d56b7b6027854a86ad7ffc96b Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 6 May 2024 08:45:22 +0200 Subject: Add libbutl-pkg-config source subdirectory This is an additional (to libbutl) utility library which contains the source code of libpkg-config configured and tuned for our needs. --- build/export.build | 34 +++++++++----- libbutl-pkg-config/README-DEV | 30 +++++++++++++ libbutl-pkg-config/buildfile | 65 +++++++++++++++++++++++++++ libbutl-pkg-config/libpkg-config/argvsplit.c | 1 + libbutl-pkg-config/libpkg-config/bsdstubs.c | 1 + libbutl-pkg-config/libpkg-config/cache.c | 1 + libbutl-pkg-config/libpkg-config/client.c | 1 + libbutl-pkg-config/libpkg-config/config.h | 41 +++++++++++++++++ libbutl-pkg-config/libpkg-config/dependency.c | 1 + libbutl-pkg-config/libpkg-config/export.h | 1 + libbutl-pkg-config/libpkg-config/fileio.c | 1 + libbutl-pkg-config/libpkg-config/fragment.c | 1 + libbutl-pkg-config/libpkg-config/list.h | 1 + libbutl-pkg-config/libpkg-config/parser.c | 1 + libbutl-pkg-config/libpkg-config/path.c | 1 + libbutl-pkg-config/libpkg-config/pkg-config.h | 1 + libbutl-pkg-config/libpkg-config/pkg.c | 1 + libbutl-pkg-config/libpkg-config/stdinc.h | 1 + libbutl-pkg-config/libpkg-config/tuple.c | 1 + libbutl-pkg-config/libpkg-config/version.h | 37 +++++++++++++++ tests/build/root.build | 5 ++- tests/pkg-config/buildfile | 6 +++ tests/pkg-config/driver.c | 1 + tests/pkg-config/testscript | 1 + 24 files changed, 223 insertions(+), 12 deletions(-) create mode 100644 libbutl-pkg-config/README-DEV create mode 100644 libbutl-pkg-config/buildfile create mode 120000 libbutl-pkg-config/libpkg-config/argvsplit.c create mode 120000 libbutl-pkg-config/libpkg-config/bsdstubs.c create mode 120000 libbutl-pkg-config/libpkg-config/cache.c create mode 120000 libbutl-pkg-config/libpkg-config/client.c create mode 100644 libbutl-pkg-config/libpkg-config/config.h create mode 120000 libbutl-pkg-config/libpkg-config/dependency.c create mode 120000 libbutl-pkg-config/libpkg-config/export.h create mode 120000 libbutl-pkg-config/libpkg-config/fileio.c create mode 120000 libbutl-pkg-config/libpkg-config/fragment.c create mode 120000 libbutl-pkg-config/libpkg-config/list.h create mode 120000 libbutl-pkg-config/libpkg-config/parser.c create mode 120000 libbutl-pkg-config/libpkg-config/path.c create mode 120000 libbutl-pkg-config/libpkg-config/pkg-config.h create mode 120000 libbutl-pkg-config/libpkg-config/pkg.c create mode 120000 libbutl-pkg-config/libpkg-config/stdinc.h create mode 120000 libbutl-pkg-config/libpkg-config/tuple.c create mode 100644 libbutl-pkg-config/libpkg-config/version.h create mode 100644 tests/pkg-config/buildfile create mode 120000 tests/pkg-config/driver.c create mode 120000 tests/pkg-config/testscript diff --git a/build/export.build b/build/export.build index 5f921cb..e7dfa5b 100644 --- a/build/export.build +++ b/build/export.build @@ -1,21 +1,35 @@ # file : build/export.build # license : MIT; see accompanying LICENSE file -if ($name($import.target) == 'butl-odb') +switch $name($import.target) { - $out_root/ + case 'butl-odb' { - include libbutl-odb/ + $out_root/ + { + include libbutl-odb/ + } + + export $out_root/libbutl-odb/$import.target } - export $out_root/libbutl-odb/$import.target -} -else -{ - $out_root/ + case 'butl-pkg-config' { - include libbutl/ + $out_root/ + { + include libbutl-pkg-config/ + } + + export $out_root/libbutl-pkg-config/$import.target } - export $out_root/libbutl/$import.target + default + { + $out_root/ + { + include libbutl/ + } + + export $out_root/libbutl/$import.target + } } diff --git a/libbutl-pkg-config/README-DEV b/libbutl-pkg-config/README-DEV new file mode 100644 index 0000000..eba196e --- /dev/null +++ b/libbutl-pkg-config/README-DEV @@ -0,0 +1,30 @@ +Excluded/replaced/relocated upstream files/directories: + - libpkg-config/libbpkg-config/{.gitignore, buildfile} + + - libpkg-config/libbpkg-config/version.h.in + - libpkg-config/libbpkg-config/version.h -- replace with pre-generated for + submodule commit + + - libpkg-config/libbpkg-config/config.h.in + - libpkg-config/libbpkg-config/config.h -- replace with pre-generated with + empty system/default path (we + do/should not use them). + +Submodule update procedure (similar to updating to a new version of a +third-party package): + +1. Update submodule: + + https://build2.org/stage/build2-toolchain/doc/build2-toolchain-packaging.xhtml#core-version-management-new-version-submodule + +2. Review upstream changes: + + https://build2.org/stage/build2-toolchain/doc/build2-toolchain-packaging.xhtml#core-version-management-new-version-review + + Look for: + + - files to add/remove (see above) + - changes to buildfiles that would need to be replicated (including to + root.build) + +3. Replace verison.h, config.h with pre-generated for this submodule commit. diff --git a/libbutl-pkg-config/buildfile b/libbutl-pkg-config/buildfile new file mode 100644 index 0000000..27159b3 --- /dev/null +++ b/libbutl-pkg-config/buildfile @@ -0,0 +1,65 @@ +# file : libbutl-pkg-config/buildfile +# license : MIT; see accompanying LICENSE file + +windows = ($c.target.class == 'windows') + +msvc_runtime = ($c.target.system == 'win32-msvc') + +msvc = ($c.class == 'msvc') +clang_msvc = ($c.id.type == 'clang' && $msvc_runtime) + +lib{butl-pkg-config}: libpkg-config/{h c}{*} + +# Build options. +# +c.poptions =+ "-I$src_base" + +obja{*}: c.poptions += -DLIBPKG_CONFIG_STATIC_BUILD +objs{*}: c.poptions += -DLIBPKG_CONFIG_SHARED_BUILD + +# Disable warnings. +# +if $msvc + c.coptions += /wd4996 /wd4267 +elif $clang_msvc + c.coptions += -Wno-deprecated-declarations -Wno-unused-function + +if $windows + c.libs += ($msvc_runtime ? advapi32.lib : -ladvapi32) + +# Export options. +# +lib{butl-pkg-config}: c.export.poptions = "-I$src_base" +liba{butl-pkg-config}: c.export.poptions += -DLIBPKG_CONFIG_STATIC +libs{butl-pkg-config}: c.export.poptions += -DLIBPKG_CONFIG_SHARED + +# For pre-releases use the complete version to make sure they cannot be used +# in place of another pre-release or the final version. See the version module +# for details on the version.* variable values. +# +if $version.pre_release + lib{butl-pkg-config}: bin.lib.version = @"-$version.project_id" +else + lib{butl-pkg-config}: bin.lib.version = @"-$version.major.$version.minor" + +# Install into the libbutl/pkg-config/ subdirectory of, say, /usr/include +# recreate subdirectories (so we end up with +# libbutl/pkg-config/libpkg-config/...>). Arrange via pkg-config to be able to +# include headers as . +# +# The reason we add an extra pkg-config/ subdirectory instead of installing +# directly into libbutl/ is because adding -I for libbutl/ will make all the +# libbutl headers includable without a prefix and thus prone to clashes. +# +h{*}: +{ + install = include/libbutl/pkg-config/ + install.subdirs = true +} + +libpkg-config/ +{ + h{config}@./ h{stdinc}@./: install = false +} + +lib{butl-pkg-config}: c.pkgconfig.include = include/libbutl/pkg-config/ diff --git a/libbutl-pkg-config/libpkg-config/argvsplit.c b/libbutl-pkg-config/libpkg-config/argvsplit.c new file mode 120000 index 0000000..59f933e --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/argvsplit.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/argvsplit.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/bsdstubs.c b/libbutl-pkg-config/libpkg-config/bsdstubs.c new file mode 120000 index 0000000..53c3669 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/bsdstubs.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/bsdstubs.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/cache.c b/libbutl-pkg-config/libpkg-config/cache.c new file mode 120000 index 0000000..04f55e2 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/cache.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/cache.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/client.c b/libbutl-pkg-config/libpkg-config/client.c new file mode 120000 index 0000000..d705a55 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/client.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/client.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/config.h b/libbutl-pkg-config/libpkg-config/config.h new file mode 100644 index 0000000..c1c5e8d --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/config.h @@ -0,0 +1,41 @@ +/* file : libpkg-config/config.h.in -*- C -*- + * license : ISC; see accompanying COPYING file + */ +#ifndef LIBPKG_CONFIG_CONFIG_H +#define LIBPKG_CONFIG_CONFIG_H + +#if defined(__linux__) +# include /* __GLIBC__, __GLIBC_MINOR__ */ +#endif + +/* + * strndup() is not present on Windows while strl*() are only present on + * *BSD and MacOS. + * + */ +#if !defined(_WIN32) +# define HAVE_STRNDUP 1 +#endif + +/* + * GNU libc added strlcpy() and strlcat() in version 2.38 (in anticipation + * of their addition to POSIX). + */ +#if defined(__FreeBSD__) || \ + defined(__OpenBSD__) || \ + defined(__NetBSD__) || \ + defined(__APPLE__) || \ + (defined(__GLIBC__) && \ + defined(__GLIBC_MINOR__) && \ + (__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 38)) +# define HAVE_STRLCPY 1 +# define HAVE_STRLCAT 1 +#endif + +#define LIBPKG_CONFIG_PROJECT_URL "https://github.com/build2/libpkg-config" + +#define PKG_CONFIG_DEFAULT_PATH "" +#define SYSTEM_INCLUDEDIR "" +#define SYSTEM_LIBDIR "" + +#endif /* LIBPKG_CONFIG_CONFIG_H */ diff --git a/libbutl-pkg-config/libpkg-config/dependency.c b/libbutl-pkg-config/libpkg-config/dependency.c new file mode 120000 index 0000000..2e12a02 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/dependency.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/dependency.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/export.h b/libbutl-pkg-config/libpkg-config/export.h new file mode 120000 index 0000000..d3bf554 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/export.h @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/export.h \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/fileio.c b/libbutl-pkg-config/libpkg-config/fileio.c new file mode 120000 index 0000000..65935f3 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/fileio.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/fileio.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/fragment.c b/libbutl-pkg-config/libpkg-config/fragment.c new file mode 120000 index 0000000..826d666 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/fragment.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/fragment.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/list.h b/libbutl-pkg-config/libpkg-config/list.h new file mode 120000 index 0000000..861f4d3 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/list.h @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/list.h \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/parser.c b/libbutl-pkg-config/libpkg-config/parser.c new file mode 120000 index 0000000..87c341e --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/parser.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/parser.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/path.c b/libbutl-pkg-config/libpkg-config/path.c new file mode 120000 index 0000000..b710dec --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/path.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/path.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/pkg-config.h b/libbutl-pkg-config/libpkg-config/pkg-config.h new file mode 120000 index 0000000..9a41ca6 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/pkg-config.h @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/pkg-config.h \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/pkg.c b/libbutl-pkg-config/libpkg-config/pkg.c new file mode 120000 index 0000000..74f6be5 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/pkg.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/pkg.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/stdinc.h b/libbutl-pkg-config/libpkg-config/stdinc.h new file mode 120000 index 0000000..f433ee0 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/stdinc.h @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/stdinc.h \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/tuple.c b/libbutl-pkg-config/libpkg-config/tuple.c new file mode 120000 index 0000000..7224e23 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/tuple.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/libpkg-config/tuple.c \ No newline at end of file diff --git a/libbutl-pkg-config/libpkg-config/version.h b/libbutl-pkg-config/libpkg-config/version.h new file mode 100644 index 0000000..ef000f5 --- /dev/null +++ b/libbutl-pkg-config/libpkg-config/version.h @@ -0,0 +1,37 @@ +#ifndef LIBPKG_CONFIG_VERSION_H +#define LIBPKG_CONFIG_VERSION_H + +/* The numeric version format is AAAAABBBBBCCCCCDDDE where: + * + * AAAAA - major version number + * BBBBB - minor version number + * CCCCC - bugfix version number + * DDD - alpha / beta (DDD + 500) version number + * E - final (0) / snapshot (1) + * + * When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example: + * + * Version AAAAABBBBBCCCCCDDDE + * + * 0.1.0 0000000001000000000 + * 0.1.2 0000000001000020000 + * 1.2.3 0000100002000030000 + * 2.2.0-a.1 0000200001999990010 + * 3.0.0-b.2 0000299999999995020 + * 2.2.0-a.1.z 0000200001999990011 + */ +#define LIBPKG_CONFIG_VERSION 1000010001ULL +#define LIBPKG_CONFIG_VERSION_STR "0.1.2-a.0.20230830042926.81bc60b38195" +#define LIBPKG_CONFIG_VERSION_ID "0.1.2-a.0.81bc60b38195" +#define LIBPKG_CONFIG_VERSION_FULL "0.1.2-a.0.20230830042926.81bc60b38195" + +#define LIBPKG_CONFIG_VERSION_MAJOR 0 +#define LIBPKG_CONFIG_VERSION_MINOR 1 +#define LIBPKG_CONFIG_VERSION_PATCH 2 + +#define LIBPKG_CONFIG_PRE_RELEASE true + +#define LIBPKG_CONFIG_SNAPSHOT_SN 20230830042926ULL +#define LIBPKG_CONFIG_SNAPSHOT_ID "81bc60b38195" + +#endif /* LIBPKG_CONFIG_VERSION_H */ diff --git a/tests/build/root.build b/tests/build/root.build index 515e1c9..5ce7156 100644 --- a/tests/build/root.build +++ b/tests/build/root.build @@ -4,15 +4,16 @@ cxx.std = latest using cxx +using c hxx{*}: extension = hxx cxx{*}: extension = cxx if ($cxx.target.system == 'win32-msvc') - cxx.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS + cc.poptions += -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS if ($cxx.class == 'msvc') - cxx.coptions += /wd4251 /wd4275 /wd4800 + cc.coptions += /wd4251 /wd4275 /wd4800 elif ($cxx.id == 'gcc') { cxx.coptions += -Wno-maybe-uninitialized -Wno-free-nonheap-object \ diff --git a/tests/pkg-config/buildfile b/tests/pkg-config/buildfile new file mode 100644 index 0000000..896b916 --- /dev/null +++ b/tests/pkg-config/buildfile @@ -0,0 +1,6 @@ +# file : tests/pkg-config/buildfile +# license : MIT; see accompanying LICENSE file + +import libs = libbutl%lib{butl-pkg-config} + +exe{driver}: {h c}{*} $libs testscript diff --git a/tests/pkg-config/driver.c b/tests/pkg-config/driver.c new file mode 120000 index 0000000..2e6f14a --- /dev/null +++ b/tests/pkg-config/driver.c @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/tests/basic/driver.c \ No newline at end of file diff --git a/tests/pkg-config/testscript b/tests/pkg-config/testscript new file mode 120000 index 0000000..628bd41 --- /dev/null +++ b/tests/pkg-config/testscript @@ -0,0 +1 @@ +../../upstream/libpkg-config/libpkg-config/tests/basic/testscript \ No newline at end of file -- cgit v1.1