Compare commits

..

No commits in common. "master" and "pkgconf-1.4.1" have entirely different histories.

100 changed files with 1963 additions and 5640 deletions

3
.github/FUNDING.yml vendored
View File

@ -1,3 +0,0 @@
github: kaniini
patreon: kaniini
liberapay: kaniini

View File

@ -1,153 +0,0 @@
name: test
on:
push:
pull_request:
jobs:
msys2:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
include: [
{ msystem: MINGW64, arch: x86_64},
{ msystem: MINGW32, arch: i686}
]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: setup-msys2
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
install: >-
mingw-w64-${{ matrix.arch }}-meson
mingw-w64-${{ matrix.arch }}-ninja
mingw-w64-${{ matrix.arch }}-gcc
- name: Build
shell: msys2 {0}
run: |
# the code assumes msvc style printf atm
export CFLAGS=-D__USE_MINGW_ANSI_STDIO=0
meson -Dtests=disabled _build
meson compile -C _build
debian-meson:
runs-on: ubuntu-latest
container:
image: debian:testing
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update system and add dependencies
run: |
apt-get update
apt-get install -y kyua atf-sh build-essential meson
- name: Build
run: |
meson _build -Dwerror=true
meson compile -C _build
- name: Run tests
run: |
meson test -v -C _build
debian-meson-asan:
runs-on: ubuntu-latest
container:
image: debian:testing
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update system and add dependencies
run: |
apt-get update
apt-get install -y kyua atf-sh build-essential meson
- name: Build
run: |
meson _build -Db_sanitize=address
meson compile -C _build
- name: Run tests
run: |
meson test -v -C _build
env:
ASAN_OPTIONS: "exitcode=7"
debian-autotools:
runs-on: ubuntu-latest
container:
image: debian:testing
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update system and add dependencies
run: |
apt-get update
apt-get install -y kyua atf-sh build-essential autoconf libtool
- name: Build
run: |
./autogen.sh
./configure
make -j9
- name: Run tests
run: |
make distcheck
alpine-meson:
runs-on: ubuntu-latest
container:
image: alpine
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update system and add dependencies
run: |
apk update
apk add kyua atf build-base meson
- name: Build
run: |
meson _build -Dwerror=true
meson compile -C _build
- name: Run tests
run: |
meson test -v -C _build
alpine-autotools:
runs-on: ubuntu-latest
container:
image: alpine
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Update system and add dependencies
run: |
apk update
apk add kyua atf build-base autoconf automake libtool xz gzip
- name: Build
run: |
./autogen.sh
./configure
make -j9
- name: Run tests
run: |
make distcheck

49
.gitignore vendored
View File

@ -1,19 +1,13 @@
Makefile
Makefile.in
.dirstamp
stamp-h*
*.h.in~
*.o
*.og
*.op
*.lo
*.gcno
*.gcda
*.gcov
core
.gdb_history
.libs
.deps
*.exe
@ -22,8 +16,8 @@ core
*.orig
*.patch
*.rej
/tests/run.sh
# autoconf stuff
/aclocal.m4
/autom4te.cache/
/buildsys.mk
@ -32,47 +26,8 @@ core
/config.log
/config.status
/configure
/compile
/config.guess
/config.sub
/depcomp
/install-sh
/missing
# programs
/bomtool
/pkgconf
/pkgconf-gcov
/pkgconf-profile
# libtool
/libtool
/ltmain.sh
/libpkgconf.la
/m4/libtool.m4
/m4/lt~obsolete.m4
/m4/ltoptions.m4
/m4/ltsugar.m4
/m4/ltversion.m4
# pkgconfig file
/libpkgconf.pc
# autoheader
/libpkgconf/config.h
/libpkgconf/config.h.in
# tests
/Kyuafile
/tests/Kyuafile
/tests/basic
/tests/builtins
/tests/conflicts
/tests/framework
/tests/parser
/tests/provides
/tests/regress
/tests/requires
/tests/sysroot
/tests/test_env.sh
/tests/version
Makefile

View File

@ -1 +0,0 @@
Ariadne Conill <ariadne@dereferenced.org> <nenolod@dereferenced.org>

44
.travis.yml Normal file
View File

@ -0,0 +1,44 @@
language: c
compiler:
- clang
- gcc
sudo: required
before_install:
- scripts/install_deps.sh
- echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-
script:
- if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then sh ./autogen.sh ; fi
- if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then ./configure ; fi
- if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then cp tests/parser.sh tests/parser; chmod +x tests/parser; make; tests/parser escaped_backslash ; fi
- if [ "${COVERITY_SCAN_BRANCH}" != 1 ]; then make distcheck ; fi
notifications:
email: false
irc:
channels:
- "irc.freenode.org#pkgconf"
on_success: change
on_failure: always
env:
global:
# The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
# via the "travis encrypt" command using the project repo's public key
- secure: "blUnmLjOjZ1l9jSUff2gka+O6zI82wOMF/6zk6domstMjWbdRQFuEijkAngLyRYa/6uwbNQezqktJficEOvnU5kjq/IVUPkVTWR/nwhZdOpB4ksllpEWX6LH90HqxEaMqGZEaqPEG5uCYW+8pwTgWesPVzc0TF552WNoh4swAhs="
addons:
apt:
packages:
- liblua5.2-dev
coverity_scan:
project:
name: "pkgconf/pkgconf"
description: "package compiler and linker metadata toolkit"
notification_email: nenolod@dereferenced.org
build_command_prepend: "sh autogen.sh; ./configure"
build_command: make
branch_pattern: coverity

View File

@ -1,75 +0,0 @@
pipeline:
debian-meson:
image: debian:testing
commands:
- apt-get update
- apt-get install -y kyua atf-sh build-essential meson
- meson _build -Dwerror=true
- meson compile -C _build
- meson test -v -C _build
when:
matrix:
IMAGE: debian
BUILD: meson
debian-meson-asan:
image: debian:testing
environment:
- ASAN_OPTIONS="exitcode=7"
commands:
- apt-get update
- apt-get install -y kyua atf-sh build-essential meson
- meson _build -Db_sanitize=address
- meson compile -C _build
- meson test -v -C _build
when:
matrix:
IMAGE: debian
BUILD: meson
debian-autotools:
image: debian:testing
commands:
- apt-get update
- apt-get install -y kyua atf-sh build-essential autoconf libtool
- ./autogen.sh
- ./configure
- make -j
- make distcheck
when:
matrix:
IMAGE: debian
BUILD: autotools
alpine-meson:
image: alpine
commands:
- apk add -U --no-cache kyua atf build-base meson
- meson _build -Dwerror=true
- meson compile -C _build
- meson test -v -C _build
when:
matrix:
IMAGE: alpine
BUILD: meson
alpine-autotools:
image: alpine
commands:
- apk add -U --no-cache kyua atf build-base autoconf automake libtool xz gzip
- ./autogen.sh
- ./configure
- make -j
- make distcheck
when:
matrix:
IMAGE: alpine
BUILD: autotools
matrix:
IMAGE:
- debian
- alpine
BUILD:
- meson
- autotools

43
AUTHORS
View File

@ -1,41 +1,4 @@
A. Wilcox <AWilcox@Wilcox-Tech.com>
Alexander Tsoy <alexander@tsoy.me>
Alexpux <alexey.pawlow@gmail.com>
Alon Bar-Lev <alon.barlev@gmail.com>
Alyx <alyx@malkier.net>
Ariadne Conill <ariadne@dereferenced.org>
Baptiste Daroussin <bapt@FreeBSD.org>
Baptiste Daroussin <bapt@gandi.net>
Bryan Drewery <bryan@shatow.net>
Dag-Erling Smørgrav <des@des.no>
Dan Kegel <dank@kegel.com>
Dan Kegel <dank@oblong.com>
Dan Nicholson <dbn.lists@gmail.com>
David Michael <fedora.dm0@gmail.com>
Emil Renner Berthing <esmil@mailme.dk>
Fabian Groffen <grobian@gentoo.org>
Graham Ollis <plicease@cpan.org>
Gregor Richards <Richards@codu.org>
Ignacio Casal Quinteiro <qignacio@amazon.com>
Igor Gnatenko <ignatenko@redhat.com>
Issam Maghni <concatime@users.noreply.github.com>
JD Horelick <jdhore1@gmail.com>
Jason Dusek <jason.dusek@gmail.com>
Javier Viguera <javier.viguera@digi.com>
Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
John Hein <jhgit@users.github.com>
Jussi Pakkanen <jpakkane@gmail.com>
Leorize <alaviss@users.noreply.github.com>
Luca Barbato <lu_zero@gentoo.org>
Marcin Wojdyr <wojdyr@gmail.com>
Maxin B. John <maxinbjohn@users.noreply.github.com>
Michał Górny <mgorny@gentoo.org>
Mike Frysinger <vapier@gentoo.org>
Seungha Yang <seungha.yang@navercorp.com>
TingPing <tingping@tingping.se>
Tobias Kortkamp <t6@users.noreply.github.com>
Tony Theodore <tonyt@logyst.com>
Volker Braun <vbraun.name@gmail.com>
Yu Kobayashi <yukoba@accelart.jp>
orbea <orbea@fredslev.dk>
✈ Graham ✈ <plicease@cpan.org>
Jeff Horelick <jdhore@gentoo.org>
Michał Górny <mgorny@gentoo.org
William Pitcock <nenolod@atheme.org>

131
CMakeLists.txt Normal file
View File

@ -0,0 +1,131 @@
# CMake configuration for pkgconf
#
# Caution: this assumes you don't set CMAKE_BUILD_TYPE
#
# FIXME: this isn't a native cmake approach, it's just a straight translation
# of configure.ac + Makefile.am, barely good enough to work on Linux, Mac, and Windows.
# Require recent cmake, but not so recent that Ubuntu 16.04 users have to upgrade.
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1 FATAL_ERROR)
PROJECT(pkgconf C)
SET(PACKAGE_BUGREPORT http://github.com/pkgconf/pkgconf/issues)
SET(PACKAGE_NAME pkgconf)
SET(PACKAGE_VERSION 1.3.7)
SET(LIBPKGCONF_VERSION "3.0.0")
SET(LIBPKGCONF_SOVERSION 3)
#-------- GNU directory variables ---------
SET(abs_top_srcdir ${pkgconf_SOURCE_DIR})
SET(prefix ${CMAKE_INSTALL_PREFIX})
SET(exec_prefix ${prefix})
SET(datarootdir ${prefix}/share)
SET(datadir ${datarootdir})
SET(libdir ${prefix}/lib)
SET(includedir ${prefix}/include)
#-------- User-settable options ---------
# FIXME: this is overridden in get_default_pkgconfig_path() on windows, but not in test_env.sh.in?!
SET(pkg_config_dir "${libdir}/pkgconfig:${datadir}/pkgconfig" CACHE STRING "specify the places where pc files will be found")
SET(PKGCONFIGDIR "${pkg_config_dir}")
SET(pkg_default_dir "${PKGCONFIGDIR}") # c'mon, make up your mind
SET(system_libdir "${libdir}" CACHE STRING "specify the system library directory (default LIBDIR)")
SET(SYSTEM_LIBDIR "${system_libdir}")
SET(system_includedir "${includedir}" CACHE STRING "specify the system include directory (default INCLUDEDIR)")
SET(SYSTEM_INCLUDEDIR "${system_includedir}")
#-------- Probe system ---------
INCLUDE (CheckIncludeFiles)
CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
INCLUDE (CheckFunctionExists)
CHECK_FUNCTION_EXISTS(strlcpy HAVE_STRLCPY)
CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT)
CHECK_FUNCTION_EXISTS(strndup HAVE_STRNDUP)
CHECK_FUNCTION_EXISTS(cygwin_conv_path HAVE_CYGWIN_CONV_PATH)
#-------- Generate source files ---------
CONFIGURE_FILE(libpkgconf/config.h.cmake.in libpkgconf/config.h @ONLY)
#-------- Configure common compiler options --------
IF (WIN32)
# Make warnings fatal... but ignore C4996: 'strdup' two different ways
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX /wd4996")
# Ignore warning C4996: 'strncpy'
ADD_DEFINITIONS("-D_CRT_SECURE_NO_WARNINGS=1")
ELSE()
INCLUDE(CheckCCompilerFlag)
CHECK_C_COMPILER_FLAG("-Wall" COMPILER_HAS_WALL)
IF (COMPILER_HAS_WALL)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
ENDIF()
CHECK_C_COMPILER_FLAG("-Wextra" COMPILER_HAS_WEXTRA)
IF (COMPILER_HAS_WEXTRA)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra")
ENDIF()
CHECK_C_COMPILER_FLAG("-Wformat=2" COMPILER_HAS_WFORMAT)
IF (COMPILER_HAS_WFORMAT)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wformat=2")
ENDIF()
CHECK_C_COMPILER_FLAG("-std=gnu99" COMPILER_HAS_STD_GNU99)
CHECK_C_COMPILER_FLAG("-std=c99" COMPILER_HAS_STD_C99)
IF (COMPILER_HAS_STD_GNU99)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
ELSEIF (COMPILER_HAS_STD_C99)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
ENDIF()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g")
ENDIF()
INCLUDE_DIRECTORIES(${pkgconf_SOURCE_DIR} ${pkgconf_BINARY_DIR})
ADD_DEFINITIONS(-DPKG_DEFAULT_PATH=\"${pkg_default_dir}\")
ADD_DEFINITIONS(-DSYSTEM_INCLUDEDIR=\"${system_includedir}\")
ADD_DEFINITIONS(-DSYSTEM_LIBDIR=\"${system_libdir}\")
#-------- Build and install library --------
# Place shared libraries in same place as binary, for ease of setting PATH in test_env.sh
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${pkgconf_BINARY_DIR})
ADD_SUBDIRECTORY(libpkgconf)
#-------- Build and install executable --------
INCLUDE_DIRECTORIES(${libpkgconf_BINARY_DIR})
ADD_EXECUTABLE(pkgconf main.c getopt_long.c renderer-msvc.c)
TARGET_LINK_LIBRARIES(pkgconf libpkgconf)
INSTALL(TARGETS pkgconf DESTINATION bin)
#-------- Tests ---------
ENABLE_TESTING()
# Handy that these files need configuring; cygwin atf doesn't like windows line endings, and NEWLINE_STYLE helps.
FOREACH(file Kyuafile tests/Kyuafile tests/test_env.sh)
CONFIGURE_FILE(${file}.in ${file} @ONLY NEWLINE_STYLE UNIX)
ENDFOREACH()
SET(test_scripts
tests/basic
tests/builtins
tests/conflicts
tests/framework
tests/parser
tests/provides
tests/regress
tests/requires
tests/sysroot
tests/version
)
# Handy that these files need configuring; cygwin atf doesn't like windows line endings, and NEWLINE_STYLE helps.
FOREACH(file ${test_scripts})
CONFIGURE_FILE(${file}.sh ${file} @ONLY NEWLINE_STYLE UNIX)
ENDFOREACH()
ADD_TEST(kyua kyua --config=none test)

View File

@ -1,27 +0,0 @@
# pkgconf Code of Conduct
We invite and encourage everybody to express their opinions on relevant
topics. All participants should at all times feel at ease to do so without
fearing any form of attack, reprisal or harassment. We ask everybody to be
respectful and considerate towards each other, especially when attempting
to provide constructive criticism.
To foster tolerance, respect and hospitality in our community, we agree not
to engage in discriminatory, disparaging or offensive speech or actions,
including as to (but not limited to) gender, sexuality, race, nationality,
religion or profession. We are a community of many different nationalities
and backgrounds, and we cherish our strength in diversity.
## Reporting incidents
Please report any incidents which may be perceived as violations to
`ariadne+conduct@dereferenced.org`. Incidents will be investigated and,
if warranted, acted upon.
## Credits
This CoC is derived from the [FSFE Code of Conduct][fsfe-coc].
[fsfe-coc]: https://fsfe.org/about/codeofconduct.en.html

View File

@ -5,30 +5,24 @@ includedir = @includedir@
system_includedir = @SYSTEM_INCLUDEDIR@
system_libdir = @SYSTEM_LIBDIR@
pkg_default_dir = @PKG_DEFAULT_PATH@
personality_dir = @PERSONALITY_PATH@
pkgconfigdir = $(libdir)/pkgconfig
nodist_pkgconfig_DATA = libpkgconf.pc
AM_CFLAGS = -DPERSONALITY_PATH=\"$(personality_dir)\" -DPKG_DEFAULT_PATH=\"$(pkg_default_dir)\" -DSYSTEM_INCLUDEDIR=\"$(system_includedir)\" -DSYSTEM_LIBDIR=\"$(system_libdir)\"
AM_CFLAGS = -DPKG_DEFAULT_PATH=\"$(pkg_default_dir)\" -DSYSTEM_INCLUDEDIR=\"$(system_includedir)\" -DSYSTEM_LIBDIR=\"$(system_libdir)\"
bin_PROGRAMS = pkgconf bomtool
bin_PROGRAMS = pkgconf
lib_LTLIBRARIES = libpkgconf.la
EXTRA_DIST = pkg.m4 \
meson.build \
meson_options.txt \
libpkgconf/meson.build \
libpkgconf/config.h.meson \
CMakeLists.txt \
libpkgconf/CMakeLists.txt \
libpkgconf/win-dirent.h \
tests/lib-relocatable/lib/pkgconfig/foo.pc \
tests/lib1/argv-parse-2.pc \
tests/lib1/billion-laughs.pc \
tests/lib1/dos-lineendings.pc \
tests/lib1/paren-quoting.pc \
tests/lib1/argv-parse-3.pc \
tests/lib1/foo.pc \
tests/lib1/foobar.pc \
tests/lib1/unavailable-provider.pc \
tests/lib1/prefix-foo1.pc \
tests/lib1/argv-parse.pc \
tests/lib1/framework-1.pc \
@ -50,7 +44,6 @@ EXTRA_DIST = pkg.m4 \
tests/lib1/sysroot-dir.pc \
tests/lib1/circular-2.pc \
tests/lib1/multiline.pc \
tests/lib1/multiline-bogus.pc \
tests/lib1/tilde-quoting.pc \
tests/lib1/circular-3.pc \
tests/lib1/no-trailing-newline.pc \
@ -64,7 +57,6 @@ EXTRA_DIST = pkg.m4 \
tests/lib3/bar.pc \
tests/lib1/conflicts.pc \
tests/lib1/omg-uninstalled.pc \
tests/lib1/omg-sysroot-uninstalled.pc \
tests/lib1/isystem.pc \
tests/lib1/idirafter.pc \
tests/lib1/idirafter-ordering.pc \
@ -80,7 +72,6 @@ EXTRA_DIST = pkg.m4 \
tests/lib1/fragment-collision-intermediary.pc \
tests/lib1/fragment-collision-1.pc \
tests/lib1/fragment-collision-2.pc \
tests/lib1/fragment-comment.pc \
tests/lib1/fragment-escaping-1.pc \
tests/lib1/fragment-escaping-2.pc \
tests/lib1/fragment-escaping-3.pc \
@ -91,25 +82,9 @@ EXTRA_DIST = pkg.m4 \
tests/lib1/fragment-quoting-7.pc \
tests/lib1/malformed-1.pc \
tests/lib1/malformed-quoting.pc \
tests/lib1/malformed-version.pc \
tests/lib1/metapackage.pc \
tests/lib1/metapackage-1.pc \
tests/lib1/metapackage-2.pc \
tests/lib1/metapackage-3.pc \
tests/lib1/explicit-sysroot.pc \
tests/lib1/escaped-backslash.pc \
tests/lib1/cflags-internal.pc \
tests/lib1/requires-internal.pc \
tests/lib1/requires-internal-2.pc \
tests/lib1/requires-internal-missing.pc \
tests/lib1/requires-internal-collision.pc \
tests/lib1/tuple-quoting.pc \
tests/lib1/empty-tuple.pc \
tests/lib1/orphaned-requires-private.pc \
tests/lib1/sysroot-dir-2.pc \
tests/lib1/sysroot-dir-3.pc \
tests/lib1/sysroot-dir-4.pc \
tests/lib1/sysroot-dir-5.pc \
tests/test_env.sh \
$(test_scripts) \
doc/conf.py \
doc/extract.py \
@ -126,7 +101,7 @@ EXTRA_DIST = pkg.m4 \
doc/libpkgconf-queue.rst \
doc/libpkgconf-tuple.rst
test_scripts= tests/meson.build \
test_scripts= \
tests/basic.sh \
tests/builtins.sh \
tests/conflicts.sh \
@ -138,8 +113,7 @@ test_scripts= tests/meson.build \
tests/sysroot.sh \
tests/version.sh
test_sh = $(filter-out tests/meson.build, $(test_scripts))
check_SCRIPTS = $(test_sh:.sh=)
check_SCRIPTS= $(test_scripts:.sh=)
SUFFIXES= .sh
@ -156,32 +130,18 @@ libpkgconf_la_SOURCES = \
libpkgconf/tuple.c \
libpkgconf/dependency.c \
libpkgconf/queue.c \
libpkgconf/path.c \
libpkgconf/personality.c \
libpkgconf/parser.c
libpkgconf_la_LDFLAGS = -no-undefined -version-info 5:0:0 -export-symbols-regex '^pkgconf_'
libpkgconf/path.c
libpkgconf_la_LDFLAGS = -no-undefined -version-info 3:0:0 -export-symbols-regex '^pkgconf_'
dist_man_MANS = \
man/pkgconf.1 \
man/pkg.m4.7 \
man/pc.5 \
man/pkgconf-personality.5
man/pc.5
pkgconf_LDADD = libpkgconf.la
pkgconf_SOURCES = \
cli/main.c \
cli/getopt_long.c \
cli/renderer-msvc.c
pkgconf_CPPFLAGS = -I$(top_srcdir)/libpkgconf -I$(top_srcdir)/cli
noinst_HEADERS = \
cli/getopt_long.h \
cli/renderer-msvc.h
bomtool_LDADD = libpkgconf.la
bomtool_SOURCES = \
cli/bomtool/main.c \
cli/getopt_long.c
bomtool_CPPFLAGS = -I$(top_srcdir)/libpkgconf -I$(top_srcdir)/cli -I$(top_srcdir)/cli/bomtool
pkgconf_SOURCES = main.c getopt_long.c renderer-msvc.c
pkgconf_CPPFLAGS = -Ilibpkgconf
noinst_HEADERS = getopt_long.h renderer-msvc.h
dist_doc_DATA = README.md AUTHORS

View File

@ -1,77 +0,0 @@
# Copyright (c) 2019 William Pitcock <nenolod@dereferenced.org>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# This software is provided 'as is' and without any warranty, express or
# implied. In no event shall the authors be liable for any damages arising
# from the use of this software.
# pkgconf-lite is a staticly-linked version of pkgconf that does not include
# all features, notably it does not include cross-compile support and MSVC
# support. It does not include the libpkgconf library.
SRCS = \
libpkgconf/argvsplit.c \
libpkgconf/audit.c \
libpkgconf/bsdstubs.c \
libpkgconf/cache.c \
libpkgconf/client.c \
libpkgconf/dependency.c \
libpkgconf/fileio.c \
libpkgconf/fragment.c \
libpkgconf/parser.c \
libpkgconf/path.c \
libpkgconf/personality.c \
libpkgconf/pkg.c \
libpkgconf/queue.c \
libpkgconf/tuple.c \
cli/getopt_long.c \
cli/main.c
OBJS = ${SRCS:.c=.o}
CFLAGS = ${STATIC} -DPKGCONF_LITE -I. -Ilibpkgconf -Icli -DSYSTEM_LIBDIR=\"${SYSTEM_LIBDIR}\" -DSYSTEM_INCLUDEDIR=\"${SYSTEM_INCLUDEDIR}\" -DPKG_DEFAULT_PATH=\"${PKG_DEFAULT_PATH}\"
STATIC =
STRIP = strip
all: pkgconf-lite
libpkgconf/config.h:
@echo '#define PACKAGE_NAME "pkgconf-lite"' >> $@
@echo '#define PACKAGE_BUGREPORT "https://git.dereferenced.org/pkgconf/pkgconf/issues"' >> $@
@echo '#define PACKAGE_VERSION "2.2.0"' >> $@
@echo '#define PACKAGE PACKAGE_NAME " " PACKAGE_VERSION' >> $@
@echo '#define HAVE_STRLCPY' >> $@
@echo '#define HAVE_STRLCAT' >> $@
@echo '#define HAVE_STRNDUP' >> $@
pkgconf-lite: preflight libpkgconf/config.h ${OBJS}
${CC} ${STATIC} -o $@ ${OBJS}
${STRIP} $@
clean:
rm -f libpkgconf/config.h
rm -f ${OBJS}
rm -f pkgconf-lite
preflight: preflight-system-libdir preflight-system-includedir preflight-pkg-default-path
preflight-system-libdir:
@if test -z "${SYSTEM_LIBDIR}"; then \
echo "SYSTEM_LIBDIR not set."; \
exit 1; \
fi
preflight-system-includedir:
@if test -z "${SYSTEM_INCLUDEDIR}"; then \
echo "SYSTEM_INCLUDEDIR not set."; \
exit 1; \
fi
preflight-pkg-default-path:
@if test -z "${PKG_DEFAULT_PATH}"; then \
echo "PKG_DEFAULT_PATH not set."; \
exit 1; \
fi
.PHONY: preflight preflight-system-libdir preflight-system-includedir preflight-pkg-default-path clean

470
NEWS
View File

@ -1,464 +1,12 @@
Changes from previous version of pkgconf
========================================
Changes from 2.1.1 to 2.2.0:
----------------------------
* libpkgconf SOVERSION is now 5.
* Significant solver rework to flatten both requires and requires.private
dependencies in a single pass. Improves performance slightly and ensures
proper dependency order.
Patches by Kai Pastor.
* Improve `--digraph` output to reflect more of the solver's state in the
rendered dependency graph.
Patches by Kai Pastor.
* Do not reference the graph root by name when presenting error messages about
directly requested dependency nodes.
Patch by Kai Pastor.
Changes from 2.1.0 to 2.1.1:
----------------------------
* Documentation fixes from Sam James and Stefan Weil.
* Fix --modversion with constraints.
Patch by Kai Pastor.
* Reintroduce an optimization to the dependency graph walker which avoids
revisiting already visited nodes.
Patch by Yi Chou with some modifications.
* Add a regression test to check that the dependency flattener is working
as expected.
Patch by Kai Pastor.
Changes from 2.0.3 to 2.1.0:
----------------------------
* Do not flatten the solver solution into the original world used as
input to the solver.
Patches by Kai Pastor.
* Fix warnings with GCC 14 -Walloc-size.
Patch by Sam James.
* Add --solution to the pkgconf CLI to dump the solver state.
* Improve the --digraph output to clarify cancelled edges in a given
solution.
* Demote requires dependencies to requires.private when a parent
dependency is pulled in via requires.private.
* Trim trailing whitespace when processing package arguments.
Patch by Colin Gillespie.
* Avoid strncmp() in --modversion version comparison.
Patch by Colin Gillespie.
* Update autoconf compile flag checking macro.
Patch by Peter Kokot.
* Add system default path configuration to Meson.
Patch by L. E. Segovia.
* Fix order of PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH element processing.
Changes from 2.0.2 to 2.0.3:
----------------------------
* Fix some edge-cases with the new `--modversion` implementation
and add additional regression tests.
Patch by Colin Gillespie.
* Fix some format specifiers to use PRIu64 in debug tracing.
Changes from 2.0.1 to 2.0.2:
----------------------------
* Fix long-standing bug where package identifiers for "uninstalled"
packages incorrectly included the "-uninstalled" suffix.
This was exposed by the recent change to `--modversion` in 2.0.1.
Changes from 2.0.0 to 2.0.1:
----------------------------
* The behavior of --modversion was largely reverted back to the traditional
pkg-config behavior, but still operates on a solved dependency graph.
The order of --modversion output is based on the dependency resolution
queue which is passed to the solver, which itself generally maps to the
order of the constrants provided on the command line.
* A new flag, --verbose, has been added. When used with `--modversion`, it
is possible to disambiguate which version belongs to which module:
% pkgconf --modversion --verbose foo bar
foo: 1.2.3
bar: 1.3
Changes from 1.9.5 to 2.0.0:
----------------------------
* When flattening the dependency graph, retain the latest seen edges
rather than the earliest.
* Fix a long-standing bug where the dependency resolution queue was
evaluated in reverse. This bug masked the aforementioned dependency
flattening bug in many cases.
* Fix handling of --with-path, which was appending paths to the search
list rather than prepending them as intended.
* Error when --modversion is requested with more than one package, as
the output is ambiguous.
Changes from 1.9.4 to 1.9.5:
----------------------------
* Fix incorrect assumptions involving the use of ctype(3) functions.
Patch by Taylor R Campbell.
* Fix detection of provided functions on autoconf.
Patches by Harmen Stoppels.
* Fix deletion of tests/meson.build by the autoconf build system.
Patch by h30032433.
* Fix quoting rules in argvsplit.c.
Patch by huyubiao.
* Update libpkgconf documentation and documentation building scripts.
Patches by Andrew Shadura.
* Enforce maximum package count correctly for --modversion.
Changes from 1.9.3 to 1.9.4:
----------------------------
* Fix a buffer overflow vulnerability involving very large variable expansions.
CVE-2023-24056
* Fix a bunch of minor regressions with the solver.
* Create separate solutions for `--cflags` and `--libs` when `--static` is not
used.
* Remove final trailing whitespace in pkgconf_fragment_render_buf().
* Revert broken pkg.m4 change involving querying module versions in
PKG_CHECK_MODULES.
* Fix handling of tildes in version strings.
* Various C99 formatting string fixes involving SIZE_FMT_SPECIFIER.
Changes from 1.9.2 to 1.9.3:
----------------------------
* Fix a bunch of minor code issues pointed out using Clang static analyzer.
* New API: pkgconf_solution_free(), which frees a compiled solution graph.
* Fix behavior when overriding global variables with `--define-variable`.
Changes from 1.9.1 to 1.9.2:
----------------------------
* Do not try to break dependency cycles across dependency lists. This causes
the solved graph to sometimes miss required dependency nodes because the
solver detected an incorrect dependency cycle.
* New API: pkgconf_queue_solve(), which replaces pkgconf_queue_apply().
pkgconf_queue_apply is now deprecated and should not be used in new code.
Changes from 1.9.0 to 1.9.1:
----------------------------
* Skip graph flattening and traversal for query types which only make sense
for a single pkg-config module.
The old solver walked these graphs with --maximum-traverse-depth=1 in
these cases, but this is no longer helpful because the graph is flattened
by the new solver.
Changes from 1.8.0 to 1.9.0:
----------------------------
* pkgconf 1.9.0 is the first testing release in the pkgconf 2.0 development
series. While it is believed to be suitable for production, there may be
bugs due to the overall redesign of the solver and other initiatives.
Additionally, a future release of pkgconf plans will have additional ABI
breaks for the libpkgconf library before the pkgconf 2.0 release is cut.
* There is now a new solver that is designed to provide higher performance
with complicated graphs, which works by flattening the dependency graph
into a smaller set of dependencies. This graph can then be evaluated
instead of the original dependency graph without having to visit every
edge in the graph.
NOTE: This solver, while providing significant performance improvements,
does so, at the cost of changed behavior for some edge cases (such as
circular dependencies).
* Bug fixes:
- Resolved several memory leaks with edge cases when using libpkgconf
directly.
- pkgconf CLI now consistently frees libpkgconf resources under all
circumstances.
- SYSROOT rules are no longer applied to `-uninstalled` packages by
default. Use `PKG_CONFIG_PKGCONF1_SYSROOT_RULES` for legacy behavior.
* A new `--license` selector has been added to the pkgconf CLI. This uses
SPDX expressions which can be set as the `License` field in `.pc` files.
See the `pc(5)` manpage for more information.
* The canonical location for pkgconf maintenance going forward is
<https://gitea.treehouse.systems/ariadne/pkgconf>. This is presently
mirrored to GitHub for user convenience, but that mirroring will
be terminated at some point (due to GitHub Copilot).
Changes from 1.7.4 to 1.8.0:
----------------------------
* This is the last planned maintenance branch. I see pkgconf as basically
a finished tool at this point, and very few people were ultimately interested
in libpkgconf. So, from here on out, it will just be bug fixes only and
very minor enhancements.
* Bug fixes:
- Improved path handling on Windows to conform to what the MSYS2
and Cygwin teams were already modifying pkgconf to do.
Patches by Christoph Reiter.
- Fix a minor memory leak relating to cross-personalities.
Patch by Stone Tickle.
- Fix static builds for Windows on Meson.
Patch by Alexander Neumann.
- Fix some edge cases with --redefine-prefix.
Patch by midipix.
- Do not prepend sysroot_dir if the .pc file does not exist in the
sysroot.
Patch by Sandro Mani.
- Do not perform path filtering on default system include and library
path lists. This fixes consistency with other mechanisms that modify
these path lists.
* Enhancements:
- Document the --validate option in the manpage.
Patch by orbea.
Changes from 1.7.3 to 1.7.4:
----------------------------
* Bug fixes:
- Fix null-dereference crash when pulling a malformed 'uninstalled'
.pc file into a dependency tree. Patch by Tobias Stöckmann.
- Fix truncation of comment characters when quoted.
- Fix handling of .pc module names in --list-all on Windows.
Patch by Ryan Scott.
- Handle platforms where realpath(3) requires a pre-allocated buffer.
Patch by Fabian Groffen.
- Fix version whitespace warning.
Patch by Christoph Reiter.
* Enhancements:
- Rewrite DOS paths on native Windows builds that don't use
Cygwin/MSYS.
- Add WantDefaultPure cross-compiler personality option.
- Prefer --static --pure linking on Windows.
- Add PKG_CONFIG_DONT_DEFINE_PREFIX environment variable.
Patch by Jeff Moguillansky.
- Many improvements when building pkgconf with Meson.
Patches by Christoph Reiter.
Changes from 1.7.2 to 1.7.3:
----------------------------
* Bug fixes:
- Fix a possible out of boundary write when evaluating dependencies.
Patch by Tobias Stöckmann.
- Fix escaping logic on Windows. Patch by Vincent Torri.
- Fix out of boundary reads and writes with a malformed fragment.
Patches by Tobias Stöckmann.
- Fix a possible out of boundary write when evaluating tuples.
Patch by Tobias Stöckmann.
Changes from 1.7.1 to 1.7.2:
----------------------------
* Bug fixes:
- Fix a windows-specific crash relating to path fixups.
Changes from 1.7.0 to 1.7.1:
----------------------------
* Bug fixes:
- Fix a possible out of boundary access in the parser for the
cross-compile database. Patch by Tobias Stöckmann.
- Missing files for building with Meson are now included in the
tarball. Patch by Neal Gompa.
- Fix calculation of package atoms on Windows with paths that
use both directory separator characters.
Changes from 1.6.3 to 1.7.0:
----------------------------
* Bug fixes:
- Fix a possible buffer overflow involving newline escaping.
Patch by Tobias Stöckmann.
- Fix an out of boundary access in the parser.
Patch by Tobias Stöckmann.
- Fix leakage of strcmp() result value in pkgconf_compare_version()
responses.
- Return the default personality if loading a cross-compile
personality file failed.
- Do not complain about newlines when validating package versions.
- Properly detect strndup() on Windows when building with Meson.
* Enhancements:
- A new --shared option and WantDefaultStatic cross-compile
configuration option have been added. This allows for toolchains
to specify that static linking should be used by default.
- Support for the PKG_CONFIG_MSVC_SYNTAX environment variable has
been added. Patch by Dan Kegel.
- Support for the PKGCONF_PKG_PKGF_DONT_MERGE_SPECIAL_FRAGMENTS
client flag which disables emulation of freedesktop.org pkg-config
fragment merging semantics has been added.
Patch by Karen Arutyunov.
Changes from 1.6.2 to 1.6.3:
----------------------------
* Bug fixes:
- Properly tokenize versions. Versions cannot logically contain
whitespace, as dependency-lists would not properly tokenize if
they could. A diagnostic is generated for malformed version
strings containing whitespace when --validate is used.
* Enhancements:
- CMake support has been dropped. Use Meson to build on Windows.
Changes from 1.6.1 to 1.6.2:
----------------------------
* Bug fixes:
- Fixed a memory leak when deduplicating paths.
- Fixed strndup-related build regression on Windows.
* Enhancements:
- Added pkgconf-lite variant. pkgconf-lite is a stripped down
variant of pkgconf that only includes pkg-config features.
- Added --modversion description to pkgconf(1) man page.
Changes from 1.6.0 to 1.6.1:
----------------------------
* Bug fixes:
- Fixed an issue where a personality may not be properly selected
due to argv[0] containing a full path.
- Fixed a regression where having an empty PKG_CONFIG_LIBDIR
environment variable would not eliminate the default search
paths.
- Use POSIX realpath(3) instead of readlink() for deduplicating the
search path. Use _fullpath() on Windows for the same purpose.
- The dequoting logic for tuples has been improved to ensure that
quotes *inside* a value remain quoted when necessary.
Changes from 1.5.4 to 1.6.0:
----------------------------
* Bug fixes:
- Fixed issue where packages which referenced missing packages in
Requires.private may have crashed due to memory corruption issues
in some circumstances.
- Fixed warnings reported by GCC 8 diagnostics.
* Enhancements:
- Add LIBPKGCONF_VERSION and LIBPKGCONF_VERSION_STR macros for
determining libpkgconf version.
- Add pkgconf_fragment_copy_list() to copy a fragment list to
another fragment list.
Changes from 1.5.3 to 1.5.4:
----------------------------
* Bug fixes:
- fix build on Windows with Meson
- fix edge cases for path canonicalization (especially on Windows)
Changes from 1.5.2 to 1.5.3:
----------------------------
* Security fixes:
- Fix edge cases involving dequoting zero-length tuples that can lead to a
buffer overflow under the right circumstances. Thanks to A. Wilcox for
reporting and supplying a patch. (MR 3)
Changes from 1.5.1 to 1.5.2:
----------------------------
* Bug fixes:
- Ensure environment variables override values learned from personality files
or built-in defaults.
* Documentation enhancements:
- Add pkgconf-personality(5) manpage documenting the personality file format.
Changes from 1.5.0 to 1.5.1:
----------------------------
* Bug fixes:
- fixed a crash with some invalid multi-line .pc files
Changes from 1.4.2 to 1.5.0:
---------------------------
* Administrative:
- The git repository has moved to <https://git.dereferenced.org/pkgconf/pkgconf>,
due to the acquisition of GitHub by Microsoft.
* Overall enhancements:
- pkgconf now supports the proposed Requires.internal pkg-config extension,
by merging it with the Requires.private list (there is no functional difference
between the two in our resolver implementation)
- Support for cross-compilation personalities have been added. To make use of this
functionality, create a file in the new personality.d directory that sits inside
the pkgconfig directory. The personality file format is described in
pc-personality(5). (github #166)
- Support for Haiku has been added, including interpretation of BELIBRARIES and
other toolchain specifics. (github #180)
- Testsuite support can be disabled when building with Meson. (github #175)
* Bug fixes:
- tuples are now appropriately dequoted when added by the parser (github #186).
* Various Windows enhancements:
- CMake supports building with GCC on Windows. (github #179)
- Prefix rewriting has been improved. (github #177)
- PKGCONF_API support has been implemented when building with Meson,
allowing Meson to be used to build pkgconf on Windows. (github #174)
* Documentation fixes:
- The manpages have been linted and fixed. (github #181, #182, #183)
- The description of pkgconf --exists has been corrected. (github #173)
Changes from 1.4.1 to 1.4.2:
----------------------------
* Bug fixes:
- ensure pkgconf_dependency_t nodes have a solution marked when satisfied
by an indirect provider (github #172)
Changes from 1.4.0 to 1.4.1:
----------------------------
* Bug fixes:
- revert some quoting changes because they don't work well with certain
GCC edge cases (github #168)
GCC edge cases (#168)
* Enhancements:
- add limited support for --cflags with --msvc-syntax
@ -582,14 +130,14 @@ Changes from 1.2.0 to 1.3.0:
* Features:
- pkgconf --debug now provides a facility for tracing most relevant libpkgconf operations
- libpkgconf: add warn and trace handlers for warnings
- replace realpath() with faster, lighter weight path normalization function (github #112)
- replace realpath() with faster, lighter weight path normalization function (#112)
- pkgconf CLI now emulates pkg-config quoting rules precisely, while allowing direct access
to the actual fragments via libpkgconf
* Bug fixes:
- pkg: properly separate static and virtual packages so they are not inappropriately
optimized out of the dependency graph (github #108)
- argvsplit: do not consider ' and " to have similar rules to escape sequences (github #111)
optimized out of the dependency graph (#108)
- argvsplit: do not consider ' and " to have similar rules to escape sequences (#111)
- pkg: strip trailing whitespace when parsing .pc files
* Enhancements:
@ -597,8 +145,7 @@ Changes from 1.2.0 to 1.3.0:
- many code fixes spotted by coverity
- add PKG_CONFIG_DONT_RELOCATE_PATHS and --dont-relocate-paths environment variables to
disable path relocation feature if needed
- remove extra whitespace that was present for compatibility with older pkg-config releases
(github #113)
- remove extra whitespace that was present for compatibility with older pkg-config releases (#113)
Changes from 1.1.0 to 1.2.0:
----------------------------
@ -641,18 +188,17 @@ Changes from 1.0.1 to 1.1.0:
- filter duplicate PKG_CONFIG_PATH (and other) entries by inode
* Bug fixes:
- fragments: fix another edge case involving empty tokens being concatenated onto previous tokens
(github #99)
- fragments: fix another edge case involving empty tokens being concatenated onto previous tokens (#99)
- libpkgconf: remove dependencies on config.h in public headers
Changes from 1.0.0 to 1.0.1:
----------------------------
* Enhancements:
- new stub implementation of --print-provides (github #95)
- new stub implementation of --print-provides (#95)
* Bug fixes:
- fragments: fix an edge case involving path-only fragments and PKG_CONFIG_SYSROOT_DIR (github #94)
- fragments: fix an edge case involving path-only fragments and PKG_CONFIG_SYSROOT_DIR (#94)
Changes from 0.9.12 to 1.0.0:
-----------------------------

View File

@ -1,11 +1,11 @@
# pkgconf [![test](https://github.com/pkgconf/pkgconf/actions/workflows/test.yml/badge.svg)](https://github.com/pkgconf/pkgconf/actions/workflows/test.yml)
# pkgconf [![Build Status](https://travis-ci.org/pkgconf/pkgconf.svg?branch=master)](https://travis-ci.org/pkgconf/pkgconf) [![Documentation Status](https://readthedocs.org/projects/pkgconf/badge/?version=latest)](http://pkgconf.readthedocs.io/en/latest/?badge=latest)
`pkgconf` is a program which helps to configure compiler and linker flags for
development libraries. It is similar to pkg-config from freedesktop.org.
`libpkgconf` is a library which provides access to most of `pkgconf`'s functionality,
to allow other tooling such as compilers and IDEs to discover and use libraries
configured by pkgconf.
`libpkgconf` is a library which provides access to most of `pkgconf`'s functionality, to allow
other tooling such as compilers and IDEs to discover and use libraries configured by
pkgconf.
## using `pkgconf` with autotools
@ -41,7 +41,7 @@ to improve this behaviour.
As of the 1.1 series, pkgconf also fully implements support for `Provides` rules,
while pkg-config does not. pkg-config only provides the `--print-provides` functionality
as a stub. There are other intentional implementation differences in pkgconf's dependency
resolver versus pkg-config's dependency resolver in terms of completeness and correctness,
resolver verses pkg-config's dependency resolver in terms of completeness and correctness,
such as, for example, how `Conflicts` rules are processed.
## linker flags optimization
@ -50,7 +50,7 @@ As previously mentioned, pkgconf makes optimizations to the linker flags in both
case of static and shared linking in order to avoid overlinking binaries and also
simplifies the `CFLAGS` and `LIBS` output of the pkgconf tool for improved readability.
This functionality depends on the pkg-config module properly declaring its dependency
This functionality depends on the pkg-config module properly declaring it's dependency
tree instead of using `Libs` and `Cflags` fields to directly link against other modules
which have pkg-config metadata files installed.
@ -60,10 +60,6 @@ Doing so is discouraged by the [freedesktop tutorial][fd-tut] anyway.
## compatibility with pkg-config
I really hate that I have to have this section, I like being a nice person, but we
unfortunately have to say this because otherwise we get passive-aggressive people who
try to argue with us about what pkg-config compatibility means.
We do not provide bug-level compatibility with pkg-config.
What that means is, if you feel that there is a legitimate regression versus pkg-config,
@ -71,26 +67,6 @@ do let us know, but also make sure that the .pc files are valid and follow the r
the [pkg-config tutorial][fd-tut], as most likely fixing them to follow the specified
rules will solve the problem.
Additionally, **we do not consider pkgconf doing what you tell it to do, in cases for
which pkg-config fails to do so, to be a bug**.
If, for example, you use environment variables such as `PKG_CONFIG_SYSTEM_[INCLUDE|LIBRARY]_PATH`
and then find yourself surprised that `pkgconf` is stripping `-I` and `-L` flags relating
to those paths, it is not a `pkgconf` problem -- `pkgconf` is doing exactly what you told
it to do.
We will reject bugs like this, and if someone insists on fixing such a non-bug, this
constitutes a violation of our [Code of Conduct](CODE_OF_CONDUCT.md), which may be
addressed by banning from this repository.
## debug output
Please use only the stable interfaces to query pkg-config. Do not screen-scrape the
output from `--debug`: this is sent to `stderr` for a reason, it is not intended to be
scraped. The `--debug` output is **not** a stable interface, and should **never** be
depended on as a source of information. If you need a stable interface to query pkg-config
which is not covered, please get in touch.
## compiling `pkgconf` and `libpkgconf` on UNIX
pkgconf is basically compiled the same way any other autotools-based project is
@ -112,16 +88,17 @@ flags like so:
$ make
$ sudo make install
## compiling `pkgconf` and `libpkgconf` with Meson (usually for Windows)
## compiling `pkgconf` and `libpkgconf` with CMake (usually for Windows)
pkgconf is compiled using CMake on Windows. In theory, you could also use CMake to build
on UNIX, but this is not recommended at this time as it pkgconf is typically built much earlier
than CMake.
pkgconf is compiled using [Meson](https://mesonbuild.com) on Windows. In theory, you could also use
Meson to build on UNIX, but this is not recommended at this time as pkgconf is typically built
much earlier than Meson.
$ meson setup build -Dtests=disabled
$ meson compile -C build
$ meson install -C build
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
There are a few defines such as SYSTEM_LIBDIR, PKGCONFIGDIR and SYSTEM_INCLUDEDIR.
However, on Windows, the default PKGCONFIGDIR value is usually overridden at runtime based
@ -137,13 +114,13 @@ to make this determination themselves.
## release tarballs
Release tarballs are available at <https://distfiles.ariadne.space/pkgconf/>.
Please only use the tarballs from distfiles.ariadne.space.
Release tarballs are available at <https://distfiles.dereferenced.org/pkgconf/>.
## contacts
Please do not use the github tarballs as they are not pristine (instead generated by github everytime
a download occurs).
You can report bugs at <https://github.com/pkgconf/pkgconf/issues>.
## reporting bugs
There is a mailing list at <https://lists.sr.ht/~kaniini/pkgconf>.
See <https://github.com/pkgconf/pkgconf/issues>.
You can contact us via IRC at `#pkgconf` at `irc.oftc.net`.
Also you can contact us at `#pkgconf` at `irc.freenode.net`.

View File

@ -1,365 +0,0 @@
/*
* bomtool/main.c
* main() routine, printer functions
*
* Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019
* pkgconf authors (see AUTHORS).
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* This software is provided 'as is' and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising
* from the use of this software.
*/
#include "libpkgconf/config.h"
#include <libpkgconf/stdinc.h>
#include <libpkgconf/libpkgconf.h>
#include "getopt_long.h"
#define PKG_VERSION (((uint64_t) 1) << 1)
#define PKG_ABOUT (((uint64_t) 1) << 2)
#define PKG_HELP (((uint64_t) 1) << 3)
static const char *spdx_version = "SPDX-2.2";
static const char *bom_license = "CC0-1.0";
static const char *document_ref = "SPDXRef-DOCUMENT";
static pkgconf_client_t pkg_client;
static uint64_t want_flags;
static size_t maximum_package_count = 0;
static int maximum_traverse_depth = 2000;
FILE *error_msgout = NULL;
static bool
error_handler(const char *msg, const pkgconf_client_t *client, void *data)
{
(void) client;
(void) data;
fprintf(error_msgout, "%s", msg);
return true;
}
static const char *
sbom_spdx_identity(pkgconf_pkg_t *pkg)
{
static char buf[PKGCONF_ITEM_SIZE];
snprintf(buf, sizeof buf, "%sC64%s", pkg->id, pkg->version);
return buf;
}
static const char *
sbom_name(pkgconf_pkg_t *world)
{
static char buf[PKGCONF_BUFSIZE];
pkgconf_node_t *node;
pkgconf_strlcpy(buf, "SBOM-SPDX", sizeof buf);
PKGCONF_FOREACH_LIST_ENTRY(world->required.head, node)
{
pkgconf_dependency_t *dep = node->data;
pkgconf_pkg_t *match = dep->match;
if (!dep->match)
continue;
pkgconf_strlcat(buf, "-", sizeof buf);
pkgconf_strlcat(buf, sbom_spdx_identity(match), sizeof buf);
}
return buf;
}
static void
write_sbom_header(pkgconf_client_t *client, pkgconf_pkg_t *world)
{
(void) client;
(void) world;
printf("SPDXVersion: %s\n", spdx_version);
printf("DataLicense: %s\n", bom_license);
printf("SPDXID: %s\n", document_ref);
printf("DocumentName: %s\n", sbom_name(world));
printf("DocumentNamespace: https://spdx.org/spdxdocs/bomtool-%s\n", PACKAGE_VERSION);
printf("Creator: Tool: bomtool %s\n", PACKAGE_VERSION);
printf("\n\n");
}
static const char *
sbom_identity(pkgconf_pkg_t *pkg)
{
static char buf[PKGCONF_ITEM_SIZE];
snprintf(buf, sizeof buf, "%s@%s", pkg->id, pkg->version);
return buf;
}
static void
write_sbom_package(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused)
{
(void) client;
(void) unused;
if (pkg->flags & PKGCONF_PKG_PROPF_VIRTUAL)
return;
printf("##### Package: %s\n\n", sbom_identity(pkg));
printf("PackageName: %s\n", sbom_identity(pkg));
printf("SPDXID: SPDXRef-Package-%s\n", sbom_spdx_identity(pkg));
printf("PackageVersion: %s\n", pkg->version);
printf("PackageDownloadLocation: NOASSERTION\n");
printf("PackageVerificationCode: NOASSERTION\n");
/* XXX: What about projects? */
if (pkg->maintainer != NULL)
printf("PackageSupplier: Person: %s\n", pkg->maintainer);
if (pkg->url != NULL)
printf("PackageHomePage: %s\n", pkg->url);
printf("PackageLicenseDeclared: %s\n", pkg->license != NULL ? pkg->license : "NOASSERTION");
if (pkg->copyright != NULL)
printf("PackageCopyrightText: <text>%s</text>\n", pkg->copyright);
if (pkg->description != NULL)
printf("PackageSummary: <text>%s</text>\n", pkg->description);
printf("\n\n");
}
static void
write_sbom_relationships(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused)
{
(void) client;
(void) unused;
char baseref[PKGCONF_ITEM_SIZE];
pkgconf_node_t *node;
if (pkg->flags & PKGCONF_PKG_PROPF_VIRTUAL)
return;
snprintf(baseref, sizeof baseref, "SPDXRef-Package-%sC64%s", pkg->id, pkg->version);
PKGCONF_FOREACH_LIST_ENTRY(pkg->required.head, node)
{
pkgconf_dependency_t *dep = node->data;
pkgconf_pkg_t *match = dep->match;
if (!dep->match)
continue;
printf("Relationship: %s DEPENDS_ON SPDXRef-Package-%s\n", baseref, sbom_spdx_identity(match));
printf("Relationship: SPDXRef-Package-%s DEPENDENCY_OF %s\n", sbom_spdx_identity(match), baseref);
}
PKGCONF_FOREACH_LIST_ENTRY(pkg->requires_private.head, node)
{
pkgconf_dependency_t *dep = node->data;
pkgconf_pkg_t *match = dep->match;
if (!dep->match)
continue;
printf("Relationship: %s DEPENDS_ON SPDXRef-Package-%s\n", baseref, sbom_spdx_identity(match));
printf("Relationship: SPDXRef-Package-%s DEV_DEPENDENCY_OF %s\n", sbom_spdx_identity(match), baseref);
}
if (pkg->required.head != NULL || pkg->requires_private.head != NULL)
printf("\n\n");
}
static bool
generate_sbom_from_world(pkgconf_client_t *client, pkgconf_pkg_t *world)
{
int eflag;
pkgconf_node_t *node;
write_sbom_header(client, world);
eflag = pkgconf_pkg_traverse(client, world, write_sbom_package, NULL, maximum_traverse_depth, 0);
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
eflag = pkgconf_pkg_traverse(client, world, write_sbom_relationships, NULL, maximum_traverse_depth, 0);
if (eflag != PKGCONF_PKG_ERRF_OK)
return false;
PKGCONF_FOREACH_LIST_ENTRY(world->required.head, node)
{
pkgconf_dependency_t *dep = node->data;
pkgconf_pkg_t *match = dep->match;
if (!dep->match)
continue;
printf("Relationship: %s DESCRIBES SPDXRef-Package-%s\n", document_ref, sbom_spdx_identity(match));
}
return true;
}
static int
version(void)
{
printf("bomtool %s\n", PACKAGE_VERSION);
return EXIT_SUCCESS;
}
static int
about(void)
{
printf("bomtool (%s %s)\n", PACKAGE_NAME, PACKAGE_VERSION);
printf("Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021\n");
printf(" pkgconf authors (see AUTHORS in documentation directory).\n\n");
printf("Permission to use, copy, modify, and/or distribute this software for any\n");
printf("purpose with or without fee is hereby granted, provided that the above\n");
printf("copyright notice and this permission notice appear in all copies.\n\n");
printf("This software is provided 'as is' and without any warranty, express or\n");
printf("implied. In no event shall the authors be liable for any damages arising\n");
printf("from the use of this software.\n\n");
printf("Report bugs at <%s>.\n", PACKAGE_BUGREPORT);
return EXIT_SUCCESS;
}
static int
usage(void)
{
printf("usage: bomtool [--flags] [modules]\n");
printf("\nbasic options:\n\n");
printf(" --help this message\n");
printf(" --about print bomtool version and license to stdout\n");
printf(" --version print bomtool version to stdout\n");
return EXIT_SUCCESS;
}
int
main(int argc, char *argv[])
{
int ret = EXIT_SUCCESS;
pkgconf_list_t pkgq = PKGCONF_LIST_INITIALIZER;
unsigned int want_client_flags = PKGCONF_PKG_PKGF_SEARCH_PRIVATE;
pkgconf_cross_personality_t *personality = pkgconf_cross_personality_default();
pkgconf_pkg_t world = {
.id = "virtual:world",
.realname = "virtual world package",
.flags = PKGCONF_PKG_PROPF_STATIC | PKGCONF_PKG_PROPF_VIRTUAL,
};
error_msgout = stderr;
struct pkg_option options[] = {
{ "version", no_argument, &want_flags, PKG_VERSION, },
{ "about", no_argument, &want_flags, PKG_ABOUT, },
{ "help", no_argument, &want_flags, PKG_HELP, },
{ NULL, 0, NULL, 0 }
};
while ((ret = pkg_getopt_long_only(argc, argv, "", options, NULL)) != -1)
{
switch (ret)
{
case '?':
case ':':
return EXIT_FAILURE;
default:
break;
}
}
pkgconf_client_init(&pkg_client, error_handler, NULL, personality);
/* we have determined what features we want most likely. in some cases, we override later. */
pkgconf_client_set_flags(&pkg_client, want_client_flags);
/* at this point, want_client_flags should be set, so build the dir list */
pkgconf_client_dir_list_build(&pkg_client, personality);
if ((want_flags & PKG_ABOUT) == PKG_ABOUT)
return about();
if ((want_flags & PKG_VERSION) == PKG_VERSION)
return version();
if ((want_flags & PKG_HELP) == PKG_HELP)
return usage();
while (1)
{
const char *package = argv[pkg_optind];
if (package == NULL)
break;
/* check if there is a limit to the number of packages allowed to be included, if so and we have hit
* the limit, stop adding packages to the queue.
*/
if (maximum_package_count > 0 && pkgq.length > maximum_package_count)
break;
while (isspace((unsigned char)package[0]))
package++;
/* skip empty packages */
if (package[0] == '\0') {
pkg_optind++;
continue;
}
if (argv[pkg_optind + 1] == NULL || !PKGCONF_IS_OPERATOR_CHAR(*(argv[pkg_optind + 1])))
{
pkgconf_queue_push(&pkgq, package);
pkg_optind++;
}
else
{
char packagebuf[PKGCONF_BUFSIZE];
snprintf(packagebuf, sizeof packagebuf, "%s %s %s", package, argv[pkg_optind + 1], argv[pkg_optind + 2]);
pkg_optind += 3;
pkgconf_queue_push(&pkgq, packagebuf);
}
}
if (pkgq.head == NULL)
{
fprintf(stderr, "Please specify at least one package name on the command line.\n");
ret = EXIT_FAILURE;
goto out;
}
ret = EXIT_SUCCESS;
if (!pkgconf_queue_solve(&pkg_client, &pkgq, &world, maximum_traverse_depth))
{
ret = EXIT_FAILURE;
goto out;
}
if (!generate_sbom_from_world(&pkg_client, &world))
{
ret = EXIT_FAILURE;
goto out;
}
out:
pkgconf_solution_free(&pkg_client, &world);
pkgconf_queue_free(&pkgq);
pkgconf_cross_personality_deinit(personality);
pkgconf_client_deinit(&pkg_client);
return ret;
}

View File

@ -11,10 +11,10 @@ dnl This software is provided 'as is' and without any warranty, express or
dnl implied. In no event shall the authors be liable for any damages arising
dnl from the use of this software.
AC_PREREQ([2.71])
AC_INIT([pkgconf],[2.2.0],[https://github.com/pkgconf/pkgconf/issues/new])
AC_CONFIG_SRCDIR([cli/main.c])
AC_CONFIG_MACRO_DIR([m4])
AC_PREREQ([2.68])
AC_INIT([pkgconf], [1.4.1], [http://github.com/pkgconf/pkgconf/issues])
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_MACRO_DIRS([m4])
AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"])
AX_CHECK_COMPILE_FLAG([-Wextra], [CFLAGS="$CFLAGS -Wextra"])
AX_CHECK_COMPILE_FLAG([-Wformat=2], [CFLAGS="$CFLAGS -Wformat=2"])
@ -22,8 +22,7 @@ AX_CHECK_COMPILE_FLAG([-std=gnu99], [CFLAGS="$CFLAGS -std=gnu99"], [
AX_CHECK_COMPILE_FLAG([-std=c99], [CFLAGS="$CFLAGS -std=c99"])
])
AC_CONFIG_HEADERS([libpkgconf/config.h])
AC_CHECK_DECLS([strlcpy, strlcat, strndup], [], [], [[#include <string.h>]])
AC_CHECK_DECLS([reallocarray])
AC_CHECK_FUNCS([strlcpy strlcat strndup cygwin_conv_path])
AC_CHECK_HEADERS([sys/stat.h])
AM_INIT_AUTOMAKE([foreign dist-xz subdir-objects])
AM_SILENT_RULES([yes])
@ -31,26 +30,19 @@ LT_INIT
AC_SYS_LARGEFILE
AC_ARG_WITH([personality-dir],[AS_HELP_STRING([--with-personality-dir],[specify
the place where cross-compile personality files will be found])],
PERSONALITY_PATH="$withval",
PERSONALITY_PATH="${datadir}/pkgconfig/personality.d:${sysconfdir}/pkgconfig/personality.d")
AC_SUBST([PERSONALITY_PATH])
AC_ARG_WITH([pkg-config-dir],[AS_HELP_STRING([--with-pkg-config-dir],[specify
AC_ARG_WITH([pkg-config-dir],[AC_HELP_STRING([--with-pkg-config-dir],[specify
the place where pc files will be found])],PKG_DEFAULT_PATH="$withval",
PKG_DEFAULT_PATH="${libdir}/pkgconfig:${datadir}/pkgconfig")
AC_SUBST([PKG_DEFAULT_PATH])
AC_ARG_WITH([system-libdir],[AS_HELP_STRING([--with-system-libdir],[specify the
AC_ARG_WITH([system-libdir],[AC_HELP_STRING([--with-system-libdir],[specify the
system library directory (default LIBDIR)])],
SYSTEM_LIBDIR="$withval", SYSTEM_LIBDIR="${libdir}")
AC_SUBST([SYSTEM_LIBDIR])
AC_ARG_WITH([system-includedir],[AS_HELP_STRING([--with-system-includedir],[specify the
AC_ARG_WITH([system-includedir],[AC_HELP_STRING([--with-system-includedir],[specify the
system include directory (default INCLUDEDIR)])],
SYSTEM_INCLUDEDIR="$withval", SYSTEM_INCLUDEDIR="${includedir}")

View File

@ -70,21 +70,21 @@ def extract_comments(filename):
while True:
char = source_file.read(1)
if not char:
if state == 3 or state == 4:
if state is 3 or state is 4:
raise UnterminatedCommentError()
if state == 2:
if state is 2:
# Was in single line comment. Create comment.
comment = Comment(current_comment, line_counter, False)
comments.append(comment)
return comments
if state == 0:
if state is 0:
# Waiting for comment start character or beginning of
# string.
if char == '/':
state = 1
elif char == '"':
state = 5
elif state == 1:
elif state is 1:
# Found comment start character, classify next character and
# determine if single or multiline comment.
if char == '/':
@ -94,7 +94,7 @@ def extract_comments(filename):
state = 3
else:
state = 0
elif state == 2:
elif state is 2:
# In single line comment, read characters until EOL.
if char == '\n':
comment = Comment(current_comment, line_counter, False)
@ -103,14 +103,14 @@ def extract_comments(filename):
state = 0
else:
current_comment += char
elif state == 3:
elif state is 3:
# In multi-line comment, add characters until '*'
# encountered.
if char == '*':
state = 4
else:
current_comment += char
elif state == 4:
elif state is 4:
# In multi-line comment with asterisk found. Determine if
# comment is ending.
if char == '/':
@ -125,13 +125,13 @@ def extract_comments(filename):
if char != '*':
current_comment += char
state = 3
elif state == 5:
elif state is 5:
# In string literal, expect literal end or escape char.
if char == '"':
state = 0
elif char == '\\':
state = 6
elif state == 6:
elif state is 6:
# In string literal, escaping current char.
state = 5
if char == '\n':

View File

@ -9,32 +9,21 @@ in parallel.
Client objects are not thread safe, in other words, a client object should not be shared across
thread boundaries.
.. c:function:: void pkgconf_client_dir_list_build(pkgconf_client_t *client)
Bootstraps the package search paths. If the ``PKGCONF_PKG_PKGF_ENV_ONLY`` `flag` is set on the client,
then only the ``PKG_CONFIG_PATH`` environment variable will be used, otherwise both the
``PKG_CONFIG_PATH`` and ``PKG_CONFIG_LIBDIR`` environment variables will be used.
:param pkgconf_client_t* client: The pkgconf client object to bootstrap.
:return: nothing
.. c:function:: void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
.. c:function:: void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler)
Initialise a pkgconf client object.
:param pkgconf_client_t* client: The client to initialise.
:param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
:param void* error_handler_data: user data passed to optional error handler
:param pkgconf_cross_personality_t* personality: the cross-compile personality to use for defaults
:return: nothing
.. c:function:: pkgconf_client_t* pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
.. c:function:: pkgconf_client_t* pkgconf_client_new(pkgconf_error_handler_func_t error_handler)
Allocate and initialise a pkgconf client object.
:param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
:param void* error_handler_data: user data passed to optional error handler
:param pkgconf_cross_personality_t* personality: cross-compile personality to use
:return: A pkgconf client object.
:rtype: pkgconf_client_t*
@ -108,14 +97,11 @@ thread boundaries.
:return: true if the warn handler processed the message, else false.
:rtype: bool
.. c:function:: bool pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t len, const char *funcname, const char *format, ...)
.. c:function:: bool pkgconf_trace(const pkgconf_client_t *client, const char *format, ...)
Report a message to a client-registered trace handler.
:param pkgconf_client_t* client: The pkgconf client object to report the trace message to.
:param char* filename: The file the function is in.
:param size_t lineno: The line number currently being executed.
:param char* funcname: The function name to use.
:param char* format: A printf-style format string to use for formatting the trace message.
:return: true if the trace handler processed the message, else false.
:rtype: bool

View File

@ -14,7 +14,6 @@ The `dependency` module provides support for building `dependency lists` (the ba
:param char* package: The package `atom` to set on the dependency node.
:param char* version: The package `version` to set on the dependency node.
:param pkgconf_pkg_comparator_t compare: The comparison operator to set on the dependency node.
:param uint flags: Any flags to attach to the dependency node.
:return: A dependency node.
:rtype: pkgconf_dependency_t *
@ -26,32 +25,9 @@ The `dependency` module provides support for building `dependency lists` (the ba
:param pkgconf_dependency_t* tail: The dependency node to add to the tail of the dependency list.
:return: nothing
.. c:function:: void pkgconf_dependency_free_one(pkgconf_dependency_t *dep)
Frees a dependency node.
:param pkgconf_dependency_t* dep: The dependency node to free.
:return: nothing
.. c:function:: pkgconf_dependency_t *pkgconf_dependency_ref(pkgconf_client_t *owner, pkgconf_dependency_t *dep)
Increases a dependency node's refcount.
:param pkgconf_client_t* owner: The client object which owns the memory of this dependency node.
:param pkgconf_dependency_t* dep: The dependency to increase the refcount of.
:return: the dependency node on success, else NULL
.. c:function:: void pkgconf_dependency_unref(pkgconf_client_t *owner, pkgconf_dependency_t *dep)
Decreases a dependency node's refcount and frees it if necessary.
:param pkgconf_client_t* owner: The client object which owns the memory of this dependency node.
:param pkgconf_dependency_t* dep: The dependency to decrease the refcount of.
:return: nothing
.. c:function:: void pkgconf_dependency_free(pkgconf_list_t *list)
Release a dependency list and its child dependency nodes.
Release a dependency list and it's child dependency nodes.
:param pkgconf_list_t* list: The dependency list to release.
:return: nothing
@ -65,7 +41,6 @@ The `dependency` module provides support for building `dependency lists` (the ba
:param pkgconf_client_t* client: The client object that owns the package this dependency list belongs to.
:param pkgconf_list_t* deplist_head: The dependency list to populate with dependency nodes.
:param char* depends: The dependency data to parse.
:param uint flags: Any flags to attach to the dependency nodes.
:return: nothing
.. c:function:: void pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist, const char *depends)
@ -78,13 +53,4 @@ The `dependency` module provides support for building `dependency lists` (the ba
:param pkgconf_pkg_t* pkg: The package object that owns this dependency list.
:param pkgconf_list_t* deplist: The dependency list to populate with dependency nodes.
:param char* depends: The dependency data to parse.
:param uint flags: Any flags to attach to the dependency nodes.
:return: nothing
.. c:function:: pkgconf_dependency_t *pkgconf_dependency_copy(pkgconf_client_t *client, const pkgconf_dependency_t *dep)
Copies a dependency node to a new one.
:param pkgconf_client_t* client: The client object that will own this dependency.
:param pkgconf_dependency_t* dep: The dependency node to copy.
:return: a pointer to a new dependency node, else NULL

View File

@ -6,14 +6,13 @@ The `fragment` module provides low-level management and rendering of fragment li
`fragment list` contains various `fragments` of text (such as ``-I /usr/include``) in a matter
which is composable, mergeable and reorderable.
.. c:function:: void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string, unsigned int flags)
.. c:function:: void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string)
Adds a `fragment` of text to a `fragment list`, possibly modifying the fragment if a sysroot is set.
:param pkgconf_client_t* client: The pkgconf client being accessed.
:param pkgconf_list_t* list: The fragment list.
:param char* string: The string of text to add as a fragment to the fragment list.
:param uint flags: Parsing-related flags for the package.
:return: nothing
.. c:function:: bool pkgconf_fragment_has_system_dir(const pkgconf_client_t *client, const pkgconf_fragment_t *frag)
@ -37,16 +36,6 @@ which is composable, mergeable and reorderable.
:param bool is_private: Whether the fragment list is a `private` fragment list (static linking).
:return: nothing
.. c:function:: void pkgconf_fragment_copy_list(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_list_t *base)
Copies a `fragment list` to another `fragment list`, possibly removing a previous copy of the fragments
in a process known as `mergeback`.
:param pkgconf_client_t* client: The pkgconf client being accessed.
:param pkgconf_list_t* list: The list the fragments are being added to.
:param pkgconf_list_t* base: The list the fragments are being copied from.
:return: nothing
.. c:function:: void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func)
Copies a `fragment list` to another `fragment list` which match a user-specified filtering function.
@ -58,25 +47,23 @@ which is composable, mergeable and reorderable.
:param void* data: Optional data to pass to the filter function.
:return: nothing
.. c:function:: size_t pkgconf_fragment_render_len(const pkgconf_list_t *list, bool escape, const pkgconf_fragment_render_ops_t *ops)
.. c:function:: size_t pkgconf_fragment_render_len(const pkgconf_list_t *list)
Calculates the required memory to store a `fragment list` when rendered as a string.
:param pkgconf_list_t* list: The `fragment list` being rendered.
:param bool escape: Whether or not to escape special shell characters (deprecated).
:param pkgconf_fragment_render_ops_t* ops: An optional ops structure to use for custom renderers, else ``NULL``.
:param bool escape: Whether or not to escape special shell characters.
:return: the amount of bytes required to represent the `fragment list` when rendered
:rtype: size_t
.. c:function:: void pkgconf_fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t buflen, bool escape, const pkgconf_fragment_render_ops_t *ops)
.. c:function:: void pkgconf_fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t buflen)
Renders a `fragment list` into a buffer.
:param pkgconf_list_t* list: The `fragment list` being rendered.
:param char* buf: The buffer to render the fragment list into.
:param size_t buflen: The length of the buffer.
:param bool escape: Whether or not to escape special shell characters (deprecated).
:param pkgconf_fragment_render_ops_t* ops: An optional ops structure to use for custom renderers, else ``NULL``.
:param bool escape: Whether or not to escape special shell characters.
:return: nothing
.. c:function:: char *pkgconf_fragment_render(const pkgconf_list_t *list)
@ -84,8 +71,7 @@ which is composable, mergeable and reorderable.
Allocate memory and render a `fragment list` into it.
:param pkgconf_list_t* list: The `fragment list` being rendered.
:param bool escape: Whether or not to escape special shell characters (deprecated).
:param pkgconf_fragment_render_ops_t* ops: An optional ops structure to use for custom renderers, else ``NULL``.
:param bool escape: Whether or not to escape special shell characters.
:return: An allocated string containing the rendered `fragment list`.
:rtype: char *
@ -111,6 +97,5 @@ which is composable, mergeable and reorderable.
:param pkgconf_client_t* client: The pkgconf client being accessed.
:param pkgconf_list_t* list: The `fragment list` to add the fragment entries to.
:param pkgconf_list_t* vars: A list of variables to use for variable substitution.
:param uint flags: Any parsing flags to be aware of.
:param char* value: The string to parse into fragments.
:return: true on success, false on parse error

View File

@ -25,12 +25,12 @@ variables.
:return: number of path nodes added to the path list
:rtype: size_t
.. c:function:: size_t pkgconf_path_build_from_environ(const char *envvarname, const char *fallback, pkgconf_list_t *dirlist)
.. c:function:: size_t pkgconf_path_build_from_environ(const char *environ, const char *fallback, pkgconf_list_t *dirlist)
Adds the paths specified in an environment variable to a path list. If the environment variable is not set,
an optional default set of paths is added.
:param char* envvarname: The environment variable to look up.
:param char* environ: The environment variable to look up.
:param char* fallback: The fallback paths to use if the environment variable is not set.
:param pkgconf_list_t* dirlist: The path list to add the path nodes to.
:param bool filter: Whether to perform duplicate filtering.
@ -46,14 +46,6 @@ variables.
:return: true if the path list has a matching prefix, otherwise false
:rtype: bool
.. c:function:: void pkgconf_path_copy_list(pkgconf_list_t *dst, const pkgconf_list_t *src)
Copies a path list to another path list.
:param pkgconf_list_t* dst: The path list to copy to.
:param pkgconf_list_t* src: The path list to copy from.
:return: nothing
.. c:function:: void pkgconf_path_free(pkgconf_list_t *dirlist)
Releases any path nodes attached to the given path list.
@ -63,7 +55,7 @@ variables.
.. c:function:: bool pkgconf_path_relocate(char *buf, size_t buflen)
Relocates a path, possibly calling normpath() on it.
Relocates a path, possibly calling normpath() or cygwin_conv_path() on it.
:param char* buf: The path to relocate.
:param size_t buflen: The buffer length the path is contained in.

View File

@ -1,27 +0,0 @@
libpkgconf `personality` module
=========================
.. c:function:: const pkgconf_cross_personality_t *pkgconf_cross_personality_default(void)
Returns the default cross-compile personality.
Not thread safe.
:rtype: pkgconf_cross_personality_t*
:return: the default cross-compile personality
.. c:function:: void pkgconf_cross_personality_deinit(pkgconf_cross_personality_t *)
Decrements the count of default cross personality instances.
Not thread safe.
:rtype: void
.. c:function:: pkgconf_cross_personality_t *pkgconf_cross_personality_find(const char *triplet)
Attempts to find a cross-compile personality given a triplet.
:rtype: pkgconf_cross_personality_t*
:return: the default cross-compile personality

View File

@ -5,14 +5,22 @@ libpkgconf `pkg` module
The `pkg` module provides dependency resolution services and the overall `.pc` file parsing
routines.
.. c:function:: pkgconf_pkg_t *pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *filename, FILE *f, unsigned int flags)
.. c:function:: void pkgconf_pkg_dir_list_build(pkgconf_client_t *client)
Bootstraps the package search paths. If the ``PKGCONF_PKG_PKGF_ENV_ONLY`` `flag` is set on the client,
then only the ``PKG_CONFIG_PATH`` environment variable will be used, otherwise both the
``PKG_CONFIG_PATH`` and ``PKG_CONFIG_LIBDIR`` environment variables will be used.
:param pkgconf_client_t* client: The pkgconf client object to bootstrap.
:return: nothing
.. c:function:: pkgconf_pkg_t *pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *filename, FILE *f)
Parse a .pc file into a pkgconf_pkg_t object structure.
:param pkgconf_client_t* client: The pkgconf client object to use for dependency resolution.
:param char* filename: The filename of the package file (including full path).
:param FILE* f: The file object to read from.
:param uint flags: The flags to use when parsing.
:returns: A ``pkgconf_pkg_t`` object which contains the package data.
:rtype: pkgconf_pkg_t *
@ -68,7 +76,7 @@ routines.
:param char* a: The first version to compare in the pair.
:param char* b: The second version to compare in the pair.
:return: -1 if the first version is less than, 0 if both versions are equal, 1 if the second version is less than.
:return: -1 if the first version is greater, 0 if both versions are equal, 1 if the second version is greater.
:rtype: int
.. c:function:: pkgconf_pkg_t *pkgconf_builtin_pkg_get(const char *name)
@ -118,7 +126,7 @@ routines.
:return: On success, ``PKGCONF_PKG_ERRF_OK`` (0), else an error code.
:rtype: unsigned int
.. c:function:: unsigned int pkgconf_pkg_traverse(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth, unsigned int skip_flags)
.. c:function:: unsigned int pkgconf_pkg_traverse(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth)
Walk and resolve the dependency graph up to `maxdepth` levels.
@ -127,7 +135,6 @@ routines.
:param pkgconf_pkg_traverse_func_t func: A traversal function to call for each resolved node in the dependency graph.
:param void* data: An opaque pointer to data to be passed to the traversal function.
:param int maxdepth: The maximum depth to walk the dependency graph for. -1 means infinite recursion.
:param uint skip_flags: Skip over dependency nodes containing the specified flags. A setting of 0 skips no dependency nodes.
:return: ``PKGCONF_PKG_ERRF_OK`` on success, else an error code.
:rtype: unsigned int

View File

@ -33,32 +33,11 @@ Using the `queue` module functions is the recommended way of working with depend
:param pkgconf_list_t* list: The dependency resolution queue to release.
:return: nothing
.. c:function:: void pkgconf_solution_free(pkgconf_client_t *client, pkgconf_pkg_t *world, int maxdepth)
Removes references to package nodes contained in a solution.
:param pkgconf_client_t* client: The pkgconf client object to use for dependency resolution.
:param pkgconf_pkg_t* world: The root for the generated dependency graph. Should have PKGCONF_PKG_PROPF_VIRTUAL flag.
:returns: nothing
.. c:function:: bool pkgconf_queue_solve(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_pkg_t *world, int maxdepth)
Solves and flattens the dependency graph for the supplied dependency list.
:param pkgconf_client_t* client: The pkgconf client object to use for dependency resolution.
:param pkgconf_list_t* list: The list of dependency requests to consider.
:param pkgconf_pkg_t* world: The root for the generated dependency graph, provided by the caller. Should have PKGCONF_PKG_PROPF_VIRTUAL flag.
:param int maxdepth: The maximum allowed depth for the dependency resolver. A depth of -1 means unlimited.
:returns: true if the dependency resolver found a solution, otherwise false.
:rtype: bool
.. c:function:: void pkgconf_queue_apply(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, void *data)
Attempt to compile a dependency resolution queue into a dependency resolution problem, then attempt to solve the problem and
feed the solution to a callback function if a complete dependency graph is found.
This function should not be used in new code. Use pkgconf_queue_solve instead.
:param pkgconf_client_t* client: The pkgconf client object to use for dependency resolution.
:param pkgconf_list_t* list: The list of dependency requests to consider.
:param pkgconf_queue_apply_func_t func: The callback function to call if a solution is found by the dependency resolver.

View File

@ -64,14 +64,13 @@ attached to a given client object.
:return: the value of the variable or ``NULL``
:rtype: char *
.. c:function:: char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags)
.. c:function:: char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value)
Parse an expression for variable substitution.
:param pkgconf_client_t* client: The pkgconf client object to access.
:param pkgconf_list_t* list: The variable list to search for variables (along side the global variable list).
:param char* value: The ``key=value`` string to parse.
:param uint flags: Any flags to consider while parsing.
:return: the variable data with any variables substituted
:rtype: char *

View File

@ -11,7 +11,6 @@ libpkgconf - an API for managing `pkg-config` modules
libpkgconf-dependency
libpkgconf-fragment
libpkgconf-path
libpkgconf-personality
libpkgconf-pkg
libpkgconf-queue
libpkgconf-tuple

View File

@ -5,8 +5,7 @@ libdir=@libdir@
Name: libpkgconf
Description: a library for accessing and manipulating development framework configuration
URL: https://gitea.treehouse.systems/ariadne/pkgconf
License: ISC
URL: http://github.com/pkgconf/pkgconf
Version: @PACKAGE_VERSION@
CFlags: -I${includedir}/pkgconf
Libs: -L${libdir} -lpkgconf

34
libpkgconf/CMakeLists.txt Normal file
View File

@ -0,0 +1,34 @@
PROJECT(libpkgconf C)
# Enforce visibiliity restrictions when building shared libraries on Unix.
SET(CMAKE_CXX_VISIBILITY_PRESET hidden)
ADD_DEFINITIONS(-DLIBPKGCONF_EXPORT)
ADD_LIBRARY(libpkgconf SHARED
argvsplit.c
audit.c
bsdstubs.c
cache.c
client.c
dependency.c
fileio.c
fragment.c
path.c
pkg.c
queue.c
tuple.c
)
SET_TARGET_PROPERTIES(libpkgconf PROPERTIES VERSION ${LIBPKGCONF_VERSION} SOVERSION ${LIBPKGCONF_SOVERSION})
INSTALL(TARGETS libpkgconf
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
INSTALL(
FILES bsdstubs.h iter.h libpkgconf.h libpkgconf-api.h stdinc.h
DESTINATION include/libpkgconf
)
# Hypothesis: .pc files are a Unix thing, should always have unix line endings.
CONFIGURE_FILE(${pkgconf_SOURCE_DIR}/libpkgconf.pc.in libpkgconf.pc @ONLY NEWLINE_STYLE UNIX)
INSTALL(FILES ${libpkgconf_BINARY_DIR}/libpkgconf.pc DESTINATION lib/pkgconfig)

View File

@ -72,7 +72,7 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv)
memset(buf, 0, strlen(src) + 1);
*argv = calloc(argv_size, sizeof (void *));
*argv = calloc(sizeof (void *), argv_size);
(*argv)[argc_count] = dst_iter;
while (*src_iter)
@ -80,7 +80,7 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv)
if (escaped)
{
/* POSIX: only \CHAR is special inside a double quote if CHAR is {$, `, ", \, newline}. */
if (quote == '"')
if (quote == '\"')
{
if (!(*src_iter == '$' || *src_iter == '`' || *src_iter == '"' || *src_iter == '\\'))
*dst_iter++ = '\\';
@ -88,9 +88,7 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv)
*dst_iter++ = *src_iter;
}
else
{
*dst_iter++ = *src_iter;
}
escaped = false;
}
@ -103,7 +101,7 @@ pkgconf_argv_split(const char *src, int *argc, char ***argv)
else
*dst_iter++ = *src_iter;
}
else if (isspace((unsigned char)*src_iter))
else if (isspace((unsigned int)*src_iter))
{
if ((*argv)[argc_count] != NULL)
{

View File

@ -20,12 +20,11 @@
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <errno.h>
#include <libpkgconf/bsdstubs.h>
#include <libpkgconf/config.h>
#if !HAVE_DECL_STRLCPY
#ifndef HAVE_STRLCPY
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
@ -58,7 +57,7 @@ strlcpy(char *dst, const char *src, size_t siz)
}
#endif
#if !HAVE_DECL_STRLCAT
#ifndef HAVE_STRLCAT
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
@ -107,7 +106,7 @@ strlcat(char *dst, const char *src, size_t siz)
* from the use of this software.
*/
#if !HAVE_DECL_STRNDUP
#ifndef HAVE_STRNDUP
/*
* Creates a memory buffer and copies at most 'len' characters to it.
* If 'len' is less than the length of the source string, truncation occured.
@ -138,23 +137,3 @@ pkgconf_strndup(const char *src, size_t len)
{
return strndup(src, len);
}
#if !HAVE_DECL_REALLOCARRAY
void *
reallocarray(void *ptr, size_t m, size_t n)
{
if (n && m > -1 / n)
{
errno = ENOMEM;
return 0;
}
return realloc(ptr, m * n);
}
#endif
void *
pkgconf_reallocarray(void *ptr, size_t m, size_t n)
{
return reallocarray(ptr, m, n);
}

View File

@ -13,8 +13,8 @@
* from the use of this software.
*/
#ifndef LIBPKGCONF_BSDSTUBS_H
#define LIBPKGCONF_BSDSTUBS_H
#ifndef __BSDSTUBS_H__
#define __BSDSTUBS_H__
#include <libpkgconf/libpkgconf-api.h>
@ -25,7 +25,6 @@ extern "C" {
PKGCONF_API extern size_t pkgconf_strlcpy(char *dst, const char *src, size_t siz);
PKGCONF_API extern size_t pkgconf_strlcat(char *dst, const char *src, size_t siz);
PKGCONF_API extern char *pkgconf_strndup(const char *src, size_t len);
PKGCONF_API extern void *pkgconf_reallocarray(void *ptr, size_t m, size_t n);
#ifdef __cplusplus
}

View File

@ -16,8 +16,6 @@
#include <libpkgconf/stdinc.h>
#include <libpkgconf/libpkgconf.h>
#include <assert.h>
/*
* !doc
*
@ -31,46 +29,6 @@
* be shared across threads.
*/
static int
cache_member_cmp(const void *a, const void *b)
{
const char *key = a;
const pkgconf_pkg_t *pkg = *(void **) b;
return strcmp(key, pkg->id);
}
static int
cache_member_sort_cmp(const void *a, const void *b)
{
const pkgconf_pkg_t *pkgA = *(void **) a;
const pkgconf_pkg_t *pkgB = *(void **) b;
if (pkgA == NULL)
return 1;
if (pkgB == NULL)
return -1;
return strcmp(pkgA->id, pkgB->id);
}
static void
cache_dump(const pkgconf_client_t *client)
{
size_t i;
PKGCONF_TRACE(client, "dumping package cache contents");
for (i = 0; i < client->cache_count; i++)
{
const pkgconf_pkg_t *pkg = client->cache_table[i];
PKGCONF_TRACE(client, SIZE_FMT_SPECIFIER": %p(%s)",
i, pkg, pkg == NULL ? "NULL" : pkg->id);
}
}
/*
* !doc
*
@ -88,19 +46,17 @@ cache_dump(const pkgconf_client_t *client)
pkgconf_pkg_t *
pkgconf_cache_lookup(pkgconf_client_t *client, const char *id)
{
if (client->cache_table == NULL)
return NULL;
pkgconf_node_t *node;
pkgconf_pkg_t **pkg;
pkg = bsearch(id, client->cache_table,
client->cache_count, sizeof (void *),
cache_member_cmp);
if (pkg != NULL)
PKGCONF_FOREACH_LIST_ENTRY(client->pkg_cache.head, node)
{
PKGCONF_TRACE(client, "found: %s @%p", id, *pkg);
return pkgconf_pkg_ref(client, *pkg);
pkgconf_pkg_t *pkg = node->data;
if (!strcmp(pkg->id, id))
{
PKGCONF_TRACE(client, "found: %s @%p", id, pkg);
return pkgconf_pkg_ref(client, pkg);
}
}
PKGCONF_TRACE(client, "miss: %s", id);
@ -126,19 +82,12 @@ pkgconf_cache_add(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
return;
pkgconf_pkg_ref(client, pkg);
pkgconf_node_insert(&pkg->cache_iter, pkg, &client->pkg_cache);
PKGCONF_TRACE(client, "added @%p to cache", pkg);
/* mark package as cached */
pkg->flags |= PKGCONF_PKG_PROPF_CACHED;
++client->cache_count;
client->cache_table = pkgconf_reallocarray(client->cache_table,
client->cache_count, sizeof (void *));
client->cache_table[client->cache_count - 1] = pkg;
qsort(client->cache_table, client->cache_count,
sizeof(void *), cache_member_sort_cmp);
}
/*
@ -155,9 +104,6 @@ pkgconf_cache_add(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
void
pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
{
if (client->cache_table == NULL)
return;
if (pkg == NULL)
return;
@ -166,41 +112,7 @@ pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
PKGCONF_TRACE(client, "removed @%p from cache", pkg);
pkgconf_pkg_t **slot;
slot = bsearch(pkg->id, client->cache_table,
client->cache_count, sizeof (void *),
cache_member_cmp);
if (slot == NULL)
return;
(*slot)->flags &= ~PKGCONF_PKG_PROPF_CACHED;
pkgconf_pkg_unref(client, *slot);
*slot = NULL;
qsort(client->cache_table, client->cache_count,
sizeof(void *), cache_member_sort_cmp);
if (client->cache_table[client->cache_count - 1] != NULL)
{
PKGCONF_TRACE(client, "end of cache table refers to %p, not NULL",
client->cache_table[client->cache_count - 1]);
cache_dump(client);
abort();
}
client->cache_count--;
if (client->cache_count > 0)
{
client->cache_table = pkgconf_reallocarray(client->cache_table,
client->cache_count, sizeof(void *));
}
else
{
free(client->cache_table);
client->cache_table = NULL;
}
pkgconf_node_delete(&pkg->cache_iter, &client->pkg_cache);
}
/*
@ -217,15 +129,15 @@ pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
void
pkgconf_cache_free(pkgconf_client_t *client)
{
if (client->cache_table == NULL)
return;
pkgconf_node_t *iter, *iter2;
while (client->cache_count > 0)
pkgconf_cache_remove(client, client->cache_table[0]);
PKGCONF_FOREACH_LIST_ENTRY_SAFE(client->pkg_cache.head, iter2, iter)
{
pkgconf_pkg_t *pkg = iter->data;
pkgconf_pkg_unref(client, pkg);
}
free(client->cache_table);
client->cache_table = NULL;
client->cache_count = 0;
memset(&client->pkg_cache, 0, sizeof client->pkg_cache);
PKGCONF_TRACE(client, "cleared package cache");
}

View File

@ -13,9 +13,9 @@
* from the use of this software.
*/
#include <libpkgconf/config.h>
#include <libpkgconf/stdinc.h>
#include <libpkgconf/libpkgconf.h>
#include <libpkgconf/config.h>
/*
* !doc
@ -48,87 +48,37 @@ trace_path_list(const pkgconf_client_t *client, const char *desc, pkgconf_list_t
/*
* !doc
*
* .. c:function:: void pkgconf_client_dir_list_build(pkgconf_client_t *client)
*
* Bootstraps the package search paths. If the ``PKGCONF_PKG_PKGF_ENV_ONLY`` `flag` is set on the client,
* then only the ``PKG_CONFIG_PATH`` environment variable will be used, otherwise both the
* ``PKG_CONFIG_PATH`` and ``PKG_CONFIG_LIBDIR`` environment variables will be used.
*
* :param pkgconf_client_t* client: The pkgconf client object to bootstrap.
* :return: nothing
*/
void
pkgconf_client_dir_list_build(pkgconf_client_t *client, const pkgconf_cross_personality_t *personality)
{
pkgconf_path_build_from_environ("PKG_CONFIG_PATH", NULL, &client->dir_list, true);
if (!(client->flags & PKGCONF_PKG_PKGF_ENV_ONLY))
{
pkgconf_list_t dir_list = PKGCONF_LIST_INITIALIZER;
const pkgconf_list_t *prepend_list = &personality->dir_list;
if (getenv("PKG_CONFIG_LIBDIR") != NULL)
{
/* PKG_CONFIG_LIBDIR= should empty the search path entirely. */
(void) pkgconf_path_build_from_environ("PKG_CONFIG_LIBDIR", NULL, &dir_list, true);
prepend_list = &dir_list;
}
pkgconf_path_copy_list(&client->dir_list, prepend_list);
pkgconf_path_free(&dir_list);
}
}
/*
* !doc
*
* .. c:function:: void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
* .. c:function:: void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler)
*
* Initialise a pkgconf client object.
*
* :param pkgconf_client_t* client: The client to initialise.
* :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
* :param void* error_handler_data: user data passed to optional error handler
* :param pkgconf_cross_personality_t* personality: the cross-compile personality to use for defaults
* :return: nothing
*/
void
pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data)
{
client->error_handler_data = error_handler_data;
client->error_handler = error_handler;
client->auditf = NULL;
client->cache_table = NULL;
client->cache_count = 0;
#ifndef PKGCONF_LITE
if (client->trace_handler == NULL)
pkgconf_client_set_trace_handler(client, NULL, NULL);
#endif
pkgconf_client_set_error_handler(client, error_handler, error_handler_data);
pkgconf_client_set_warn_handler(client, NULL, NULL);
pkgconf_client_set_sysroot_dir(client, personality->sysroot_dir);
pkgconf_client_set_sysroot_dir(client, NULL);
pkgconf_client_set_buildroot_dir(client, NULL);
pkgconf_client_set_prefix_varname(client, NULL);
if(getenv("PKG_CONFIG_SYSTEM_LIBRARY_PATH") == NULL)
pkgconf_path_copy_list(&client->filter_libdirs, &personality->filter_libdirs);
else
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", NULL, &client->filter_libdirs, false);
if(getenv("PKG_CONFIG_SYSTEM_INCLUDE_PATH") == NULL)
pkgconf_path_copy_list(&client->filter_includedirs, &personality->filter_includedirs);
else
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", NULL, &client->filter_includedirs, false);
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_LIBRARY_PATH", SYSTEM_LIBDIR, &client->filter_libdirs, false);
pkgconf_path_build_from_environ("PKG_CONFIG_SYSTEM_INCLUDE_PATH", SYSTEM_INCLUDEDIR, &client->filter_includedirs, false);
/* GCC uses these environment variables to define system include paths, so we should check them. */
#ifdef __HAIKU__
pkgconf_path_build_from_environ("BELIBRARIES", NULL, &client->filter_libdirs, false);
#else
pkgconf_path_build_from_environ("LIBRARY_PATH", NULL, &client->filter_libdirs, false);
#endif
pkgconf_path_build_from_environ("CPATH", NULL, &client->filter_includedirs, false);
pkgconf_path_build_from_environ("C_INCLUDE_PATH", NULL, &client->filter_includedirs, false);
pkgconf_path_build_from_environ("CPLUS_INCLUDE_PATH", NULL, &client->filter_includedirs, false);
@ -148,21 +98,20 @@ pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error
/*
* !doc
*
* .. c:function:: pkgconf_client_t* pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
* .. c:function:: pkgconf_client_t* pkgconf_client_new(pkgconf_error_handler_func_t error_handler)
*
* Allocate and initialise a pkgconf client object.
*
* :param pkgconf_error_handler_func_t error_handler: An optional error handler to use for logging errors.
* :param void* error_handler_data: user data passed to optional error handler
* :param pkgconf_cross_personality_t* personality: cross-compile personality to use
* :return: A pkgconf client object.
* :rtype: pkgconf_client_t*
*/
pkgconf_client_t *
pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality)
pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data)
{
pkgconf_client_t *out = calloc(1, sizeof(pkgconf_client_t));
pkgconf_client_init(out, error_handler, error_handler_data, personality);
pkgconf_client_t *out = calloc(sizeof(pkgconf_client_t), 1);
pkgconf_client_init(out, error_handler, error_handler_data);
return out;
}
@ -375,7 +324,7 @@ pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t linen
size_t len;
va_list va;
if (client == NULL || client->trace_handler == NULL)
if (client == NULL)
return false;
len = snprintf(errbuf, sizeof errbuf, "%s:" SIZE_FMT_SPECIFIER " [%s]: ", filename, lineno, funcname);
@ -403,7 +352,7 @@ pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t linen
* :rtype: bool
*/
bool
pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, void *data)
pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data)
{
(void) msg;
(void) client;
@ -571,7 +520,6 @@ pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_handler
}
}
#ifndef PKGCONF_LITE
/*
* !doc
*
@ -612,4 +560,3 @@ pkgconf_client_set_trace_handler(pkgconf_client_t *client, pkgconf_error_handler
PKGCONF_TRACE(client, "installing default trace handler");
}
}
#endif

View File

@ -0,0 +1,8 @@
#cmakedefine HAVE_CYGWIN_CONV_PATH
#cmakedefine HAVE_STRLCAT
#cmakedefine HAVE_STRLCPY
#cmakedefine HAVE_STRNDUP
#cmakedefine HAVE_SYS_STAT_H
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"

View File

@ -1,5 +1,29 @@
/* libpkgconf/config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `cygwin_conv_path' function. */
#mesondefine HAVE_CYGWIN_CONV_PATH
/* Define to 1 if you have the <dlfcn.h> header file. */
#mesondefine HAVE_DLFCN_H
/* Define to 1 if you have the <inttypes.h> header file. */
#mesondefine HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#mesondefine HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#mesondefine HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#mesondefine HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#mesondefine HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#mesondefine HAVE_STRING_H
/* Define to 1 if you have the `strlcat' function. */
#mesondefine HAVE_STRLCAT
@ -9,20 +33,17 @@
/* Define to 1 if you have the `strndup' function. */
#mesondefine HAVE_STRNDUP
/* Define to 1 if you have the `reallocarray' function. */
#mesondefine HAVE_REALLOCARRAY
/* Define to 1 if you have the <sys/stat.h> header file. */
#mesondefine HAVE_SYS_STAT_H
/* Define to 1 if you have the `strlcat' function. */
#mesondefine HAVE_DECL_STRLCAT
/* Define to 1 if you have the <sys/types.h> header file. */
#mesondefine HAVE_SYS_TYPES_H
/* Define to 1 if you have the `strlcpy' function. */
#mesondefine HAVE_DECL_STRLCPY
/* Define to 1 if you have the <unistd.h> header file. */
#mesondefine HAVE_UNISTD_H
/* Define to 1 if you have the `strndup' function. */
#mesondefine HAVE_DECL_STRNDUP
/* Define to 1 if you have the `reallocarray' function. */
#mesondefine HAVE_DECL_REALLOCARRAY
/* Define to the sub-directory where libtool stores uninstalled libraries. */
#mesondefine LT_OBJDIR
/* Name of package */
#mesondefine PACKAGE
@ -65,4 +86,3 @@
#mesondefine PKG_DEFAULT_PATH
#mesondefine SYSTEM_INCLUDEDIR
#mesondefine SYSTEM_LIBDIR
#mesondefine PERSONALITY_PATH

View File

@ -52,96 +52,24 @@ dependency_to_str(const pkgconf_dependency_t *dep, char *buf, size_t buflen)
return buf;
}
/* find a colliding dependency that is coloured differently */
static inline pkgconf_dependency_t *
find_colliding_dependency(const pkgconf_dependency_t *dep, const pkgconf_list_t *list)
{
const pkgconf_node_t *n;
PKGCONF_FOREACH_LIST_ENTRY(list->head, n)
{
pkgconf_dependency_t *dep2 = n->data;
if (strcmp(dep->package, dep2->package))
continue;
if (dep->flags != dep2->flags)
return dep2;
}
return NULL;
}
static inline pkgconf_dependency_t *
add_or_replace_dependency_node(pkgconf_client_t *client, pkgconf_dependency_t *dep, pkgconf_list_t *list)
{
char depbuf[PKGCONF_ITEM_SIZE];
pkgconf_dependency_t *dep2 = find_colliding_dependency(dep, list);
/* there is already a node in the graph which describes this dependency */
if (dep2 != NULL)
{
char depbuf2[PKGCONF_ITEM_SIZE];
PKGCONF_TRACE(client, "dependency collision: [%s/%x] -- [%s/%x]",
dependency_to_str(dep, depbuf, sizeof depbuf), dep->flags,
dependency_to_str(dep2, depbuf2, sizeof depbuf2), dep2->flags);
/* prefer the uncoloured node, either dep or dep2 */
if (dep->flags && dep2->flags == 0)
{
PKGCONF_TRACE(client, "dropping dependency [%s]@%p because of collision", depbuf, dep);
pkgconf_dependency_unref(dep->owner, dep);
return NULL;
}
else if (dep2->flags && dep->flags == 0)
{
PKGCONF_TRACE(client, "dropping dependency [%s]@%p because of collision", depbuf2, dep2);
pkgconf_node_delete(&dep2->iter, list);
pkgconf_dependency_unref(dep2->owner, dep2);
}
else
/* If both dependencies have equal strength, we keep both, because of situations like:
* Requires: foo > 1, foo < 3
*
* If the situation is that both dependencies are literally equal, it is still harmless because
* fragment deduplication will handle the excessive fragments.
*/
PKGCONF_TRACE(client, "keeping both dependencies (harmless)");
}
PKGCONF_TRACE(client, "added dependency [%s] to list @%p; flags=%x", dependency_to_str(dep, depbuf, sizeof depbuf), list, dep->flags);
pkgconf_node_insert_tail(&dep->iter, pkgconf_dependency_ref(dep->owner, dep), list);
/* This dependency is intentionally unowned.
*
* Internally we have no use for the returned type, and usually just
* discard it. However, there is a publig pkgconf_dependency_add
* function, which references this return value before returning it,
* giving ownership at that point.
*/
return dep;
}
static inline pkgconf_dependency_t *
pkgconf_dependency_addraw(pkgconf_client_t *client, pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkgconf_pkg_comparator_t compare, unsigned int flags)
pkgconf_dependency_addraw(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, size_t package_sz, const char *version, size_t version_sz, pkgconf_pkg_comparator_t compare)
{
pkgconf_dependency_t *dep;
char depbuf[PKGCONF_ITEM_SIZE];
dep = calloc(1, sizeof(pkgconf_dependency_t));
dep = calloc(sizeof(pkgconf_dependency_t), 1);
dep->package = pkgconf_strndup(package, package_sz);
if (version_sz != 0)
dep->version = pkgconf_strndup(version, version_sz);
dep->compare = compare;
dep->flags = flags;
dep->owner = client;
dep->refcount = 0;
return add_or_replace_dependency_node(client, dep, list);
PKGCONF_TRACE(client, "added dependency [%s] to list @%p", dependency_to_str(dep, depbuf, sizeof depbuf), list);
pkgconf_node_insert_tail(&dep->iter, dep, list);
return dep;
}
/*
@ -156,17 +84,16 @@ pkgconf_dependency_addraw(pkgconf_client_t *client, pkgconf_list_t *list, const
* :param char* package: The package `atom` to set on the dependency node.
* :param char* version: The package `version` to set on the dependency node.
* :param pkgconf_pkg_comparator_t compare: The comparison operator to set on the dependency node.
* :param uint flags: Any flags to attach to the dependency node.
* :return: A dependency node.
* :rtype: pkgconf_dependency_t *
*/
pkgconf_dependency_t *
pkgconf_dependency_add(pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare, unsigned int flags)
pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare)
{
pkgconf_dependency_t *dep;
dep = pkgconf_dependency_addraw(client, list, package, strlen(package), version,
version != NULL ? strlen(version) : 0, compare, flags);
return pkgconf_dependency_ref(dep->owner, dep);
if (version != NULL)
return pkgconf_dependency_addraw(client, list, package, strlen(package), version, strlen(version), compare);
return pkgconf_dependency_addraw(client, list, package, strlen(package), NULL, 0, compare);
}
/*
@ -186,83 +113,12 @@ pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail)
pkgconf_node_insert_tail(&tail->iter, tail, list);
}
/*
* !doc
*
* .. c:function:: void pkgconf_dependency_free_one(pkgconf_dependency_t *dep)
*
* Frees a dependency node.
*
* :param pkgconf_dependency_t* dep: The dependency node to free.
* :return: nothing
*/
void
pkgconf_dependency_free_one(pkgconf_dependency_t *dep)
{
if (dep->match != NULL)
pkgconf_pkg_unref(dep->match->owner, dep->match);
if (dep->package != NULL)
free(dep->package);
if (dep->version != NULL)
free(dep->version);
free(dep);
}
/*
* !doc
*
* .. c:function:: pkgconf_dependency_t *pkgconf_dependency_ref(pkgconf_client_t *owner, pkgconf_dependency_t *dep)
*
* Increases a dependency node's refcount.
*
* :param pkgconf_client_t* owner: The client object which owns the memory of this dependency node.
* :param pkgconf_dependency_t* dep: The dependency to increase the refcount of.
* :return: the dependency node on success, else NULL
*/
pkgconf_dependency_t *
pkgconf_dependency_ref(pkgconf_client_t *client, pkgconf_dependency_t *dep)
{
if (client != dep->owner)
return NULL;
dep->refcount++;
PKGCONF_TRACE(client, "%s refcount@%p: %d", dep->package, dep, dep->refcount);
return dep;
}
/*
* !doc
*
* .. c:function:: void pkgconf_dependency_unref(pkgconf_client_t *owner, pkgconf_dependency_t *dep)
*
* Decreases a dependency node's refcount and frees it if necessary.
*
* :param pkgconf_client_t* owner: The client object which owns the memory of this dependency node.
* :param pkgconf_dependency_t* dep: The dependency to decrease the refcount of.
* :return: nothing
*/
void
pkgconf_dependency_unref(pkgconf_client_t *client, pkgconf_dependency_t *dep)
{
if (client != dep->owner)
return;
--dep->refcount;
PKGCONF_TRACE(client, "%s refcount@%p: %d", dep->package, dep, dep->refcount);
if (dep->refcount <= 0)
pkgconf_dependency_free_one(dep);
}
/*
* !doc
*
* .. c:function:: void pkgconf_dependency_free(pkgconf_list_t *list)
*
* Release a dependency list and its child dependency nodes.
* Release a dependency list and it's child dependency nodes.
*
* :param pkgconf_list_t* list: The dependency list to release.
* :return: nothing
@ -276,11 +132,17 @@ pkgconf_dependency_free(pkgconf_list_t *list)
{
pkgconf_dependency_t *dep = node->data;
pkgconf_node_delete(&dep->iter, list);
pkgconf_dependency_unref(dep->owner, dep);
}
if (dep->match != NULL)
pkgconf_pkg_unref(NULL, dep->match);
pkgconf_list_zero(list);
if (dep->package != NULL)
free(dep->package);
if (dep->version != NULL)
free(dep->version);
free(dep);
}
}
/*
@ -295,11 +157,10 @@ pkgconf_dependency_free(pkgconf_list_t *list)
* :param pkgconf_client_t* client: The client object that owns the package this dependency list belongs to.
* :param pkgconf_list_t* deplist_head: The dependency list to populate with dependency nodes.
* :param char* depends: The dependency data to parse.
* :param uint flags: Any flags to attach to the dependency nodes.
* :return: nothing
*/
void
pkgconf_dependency_parse_str(pkgconf_client_t *client, pkgconf_list_t *deplist_head, const char *depends, unsigned int flags)
pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *deplist_head, const char *depends)
{
parse_state_t state = OUTSIDE_MODULE;
pkgconf_pkg_comparator_t compare = PKGCONF_CMP_ANY;
@ -311,7 +172,6 @@ pkgconf_dependency_parse_str(pkgconf_client_t *client, pkgconf_list_t *deplist_h
char *vstart = NULL;
char *package = NULL, *version = NULL;
char *cnameptr = cmpname;
char *cnameend = cmpname + PKGCONF_ITEM_SIZE - 1;
memset(cmpname, '\0', sizeof cmpname);
@ -329,11 +189,11 @@ pkgconf_dependency_parse_str(pkgconf_client_t *client, pkgconf_list_t *deplist_h
break;
case INSIDE_MODULE_NAME:
if (isspace((unsigned char)*ptr))
if (isspace((unsigned int)*ptr))
{
const char *sptr = ptr;
while (*sptr && isspace((unsigned char)*sptr))
while (*sptr && isspace((unsigned int)*sptr))
sptr++;
if (*sptr == '\0')
@ -367,7 +227,7 @@ pkgconf_dependency_parse_str(pkgconf_client_t *client, pkgconf_list_t *deplist_h
if (state == OUTSIDE_MODULE)
{
pkgconf_dependency_addraw(client, deplist_head, package, package_sz, NULL, 0, compare, flags);
pkgconf_dependency_addraw(client, deplist_head, package, package_sz, NULL, 0, compare);
compare = PKGCONF_CMP_ANY;
package_sz = 0;
@ -379,8 +239,7 @@ pkgconf_dependency_parse_str(pkgconf_client_t *client, pkgconf_list_t *deplist_h
if (PKGCONF_IS_OPERATOR_CHAR(*ptr))
{
state = INSIDE_OPERATOR;
if (cnameptr < cnameend)
*cnameptr++ = *ptr;
*cnameptr++ = *ptr;
}
break;
@ -391,13 +250,13 @@ pkgconf_dependency_parse_str(pkgconf_client_t *client, pkgconf_list_t *deplist_h
state = AFTER_OPERATOR;
compare = pkgconf_pkg_comparator_lookup_by_name(cmpname);
}
else if (cnameptr < cnameend)
else
*cnameptr++ = *ptr;
break;
case AFTER_OPERATOR:
if (!isspace((unsigned char)*ptr))
if (!isspace((unsigned int)*ptr))
{
vstart = ptr;
state = INSIDE_VERSION;
@ -411,7 +270,7 @@ pkgconf_dependency_parse_str(pkgconf_client_t *client, pkgconf_list_t *deplist_h
version_sz = ptr - vstart;
state = OUTSIDE_MODULE;
pkgconf_dependency_addraw(client, deplist_head, package, package_sz, version, version_sz, compare, flags);
pkgconf_dependency_addraw(client, deplist_head, package, package_sz, version, version_sz, compare);
compare = PKGCONF_CMP_ANY;
cnameptr = cmpname;
@ -441,47 +300,13 @@ pkgconf_dependency_parse_str(pkgconf_client_t *client, pkgconf_list_t *deplist_h
* :param pkgconf_pkg_t* pkg: The package object that owns this dependency list.
* :param pkgconf_list_t* deplist: The dependency list to populate with dependency nodes.
* :param char* depends: The dependency data to parse.
* :param uint flags: Any flags to attach to the dependency nodes.
* :return: nothing
*/
void
pkgconf_dependency_parse(pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist, const char *depends, unsigned int flags)
pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist, const char *depends)
{
char *kvdepends = pkgconf_tuple_parse(client, &pkg->vars, depends, pkg->flags);
char *kvdepends = pkgconf_tuple_parse(client, &pkg->vars, depends);
pkgconf_dependency_parse_str(client, deplist, kvdepends, flags);
pkgconf_dependency_parse_str(client, deplist, kvdepends);
free(kvdepends);
}
/*
* !doc
*
* .. c:function:: pkgconf_dependency_t *pkgconf_dependency_copy(pkgconf_client_t *client, const pkgconf_dependency_t *dep)
*
* Copies a dependency node to a new one.
*
* :param pkgconf_client_t* client: The client object that will own this dependency.
* :param pkgconf_dependency_t* dep: The dependency node to copy.
* :return: a pointer to a new dependency node, else NULL
*/
pkgconf_dependency_t *
pkgconf_dependency_copy(pkgconf_client_t *client, const pkgconf_dependency_t *dep)
{
pkgconf_dependency_t *new_dep;
new_dep = calloc(1, sizeof(pkgconf_dependency_t));
new_dep->package = strdup(dep->package);
if (dep->version != NULL)
new_dep->version = strdup(dep->version);
new_dep->compare = dep->compare;
new_dep->flags = dep->flags;
new_dep->owner = client;
new_dep->refcount = 0;
if (dep->match != NULL)
new_dep->match = pkgconf_pkg_ref(client, dep->match);
return pkgconf_dependency_ref(client, new_dep);
}

View File

@ -20,7 +20,7 @@ char *
pkgconf_fgetline(char *line, size_t size, FILE *stream)
{
char *s = line;
char *end = line + size - 2;
char *end = line + size - 1;
bool quoted = false;
int c = '\0', c2;
@ -44,9 +44,6 @@ pkgconf_fgetline(char *line, size_t size, FILE *stream)
*s++ = c;
break;
}
else
*s++ = c;
quoted = false;
continue;
}

View File

@ -93,18 +93,15 @@ pkgconf_fragment_is_special(const char *string)
}
static inline void
pkgconf_fragment_munge(const pkgconf_client_t *client, char *buf, size_t buflen, const char *source, const char *sysroot_dir, unsigned int flags)
pkgconf_fragment_munge(const pkgconf_client_t *client, char *buf, size_t buflen, const char *source, const char *sysroot_dir)
{
*buf = '\0';
if (!(flags & PKGCONF_PKG_PROPF_UNINSTALLED) || (client->flags & PKGCONF_PKG_PKGF_PKGCONF1_SYSROOT_RULES))
{
if (sysroot_dir == NULL)
sysroot_dir = pkgconf_tuple_find_global(client, "pc_sysrootdir");
if (sysroot_dir == NULL)
sysroot_dir = pkgconf_tuple_find_global(client, "pc_sysrootdir");
if (sysroot_dir != NULL && pkgconf_fragment_should_munge(source, sysroot_dir))
pkgconf_strlcat(buf, sysroot_dir, buflen);
}
if (sysroot_dir != NULL && pkgconf_fragment_should_munge(source, sysroot_dir))
pkgconf_strlcat(buf, sysroot_dir, buflen);
pkgconf_strlcat(buf, source, buflen);
@ -113,40 +110,39 @@ pkgconf_fragment_munge(const pkgconf_client_t *client, char *buf, size_t buflen,
}
static inline char *
pkgconf_fragment_copy_munged(const pkgconf_client_t *client, const char *source, unsigned int flags)
pkgconf_fragment_copy_munged(const pkgconf_client_t *client, const char *source)
{
char mungebuf[PKGCONF_ITEM_SIZE];
pkgconf_fragment_munge(client, mungebuf, sizeof mungebuf, source, client->sysroot_dir, flags);
pkgconf_fragment_munge(client, mungebuf, sizeof mungebuf, source, client->sysroot_dir);
return strdup(mungebuf);
}
/*
* !doc
*
* .. c:function:: void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string, unsigned int flags)
* .. c:function:: void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string)
*
* Adds a `fragment` of text to a `fragment list`, possibly modifying the fragment if a sysroot is set.
*
* :param pkgconf_client_t* client: The pkgconf client being accessed.
* :param pkgconf_list_t* list: The fragment list.
* :param char* string: The string of text to add as a fragment to the fragment list.
* :param uint flags: Parsing-related flags for the package.
* :return: nothing
*/
void
pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string, unsigned int flags)
pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string)
{
pkgconf_fragment_t *frag;
if (*string == '\0')
return;
if (strlen(string) > 1 && !pkgconf_fragment_is_special(string))
if (!pkgconf_fragment_is_special(string))
{
frag = calloc(1, sizeof(pkgconf_fragment_t));
frag = calloc(sizeof(pkgconf_fragment_t), 1);
frag->type = *(string + 1);
frag->data = pkgconf_fragment_copy_munged(client, string + 2, flags);
frag->data = pkgconf_fragment_copy_munged(client, string + 2);
PKGCONF_TRACE(client, "added fragment {%c, '%s'} to list @%p", frag->type, frag->data, list);
}
@ -154,18 +150,17 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const
{
char mungebuf[PKGCONF_ITEM_SIZE];
if (list->tail != NULL && list->tail->data != NULL &&
!(client->flags & PKGCONF_PKG_PKGF_DONT_MERGE_SPECIAL_FRAGMENTS))
if (list->tail != NULL && list->tail->data != NULL)
{
pkgconf_fragment_t *parent = list->tail->data;
/* only attempt to merge 'special' fragments together */
if (!parent->type && parent->data != NULL && pkgconf_fragment_is_unmergeable(parent->data))
if (!parent->type && pkgconf_fragment_is_unmergeable(parent->data))
{
size_t len;
char *newdata;
pkgconf_fragment_munge(client, mungebuf, sizeof mungebuf, string, NULL, flags);
pkgconf_fragment_munge(client, mungebuf, sizeof mungebuf, string, NULL);
len = strlen(parent->data) + strlen(mungebuf) + 2;
newdata = malloc(len);
@ -192,7 +187,7 @@ pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const
}
}
frag = calloc(1, sizeof(pkgconf_fragment_t));
frag = calloc(sizeof(pkgconf_fragment_t), 1);
frag->type = 0;
frag->data = strdup(string);
@ -353,7 +348,7 @@ pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, cons
else if (!is_private && !pkgconf_fragment_can_merge_back(base, client->flags, is_private) && (pkgconf_fragment_lookup(list, base) != NULL))
return;
frag = calloc(1, sizeof(pkgconf_fragment_t));
frag = calloc(sizeof(pkgconf_fragment_t), 1);
frag->type = base->type;
frag->merged = base->merged;
@ -363,32 +358,6 @@ pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, cons
pkgconf_node_insert_tail(&frag->iter, frag, list);
}
/*
* !doc
*
* .. c:function:: void pkgconf_fragment_copy_list(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_list_t *base)
*
* Copies a `fragment list` to another `fragment list`, possibly removing a previous copy of the fragments
* in a process known as `mergeback`.
*
* :param pkgconf_client_t* client: The pkgconf client being accessed.
* :param pkgconf_list_t* list: The list the fragments are being added to.
* :param pkgconf_list_t* base: The list the fragments are being copied from.
* :return: nothing
*/
void
pkgconf_fragment_copy_list(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_list_t *base)
{
pkgconf_node_t *node;
PKGCONF_FOREACH_LIST_ENTRY(base->head, node)
{
pkgconf_fragment_t *frag = node->data;
pkgconf_fragment_copy(client, list, frag, true);
}
}
/*
* !doc
*
@ -427,7 +396,7 @@ fragment_quote(const pkgconf_fragment_t *frag)
if (frag->data == NULL)
return NULL;
out = dst = calloc(1, outlen);
out = dst = calloc(outlen, 1);
for (; *src; src++)
{
@ -437,11 +406,7 @@ fragment_quote(const pkgconf_fragment_t *frag)
(*src > ')' && *src < '+') ||
(*src > ':' && *src < '=') ||
(*src > '=' && *src < '@') ||
(*src > 'Z' && *src < '\\') ||
#ifndef _WIN32
(*src == '\\') ||
#endif
(*src > '\\' && *src < '^') ||
(*src > 'Z' && *src < '^') ||
(*src == '`') ||
(*src > 'z' && *src < '~') ||
(*src > '~')))
@ -451,10 +416,8 @@ fragment_quote(const pkgconf_fragment_t *frag)
if ((ptrdiff_t)(dst - out) + 2 > outlen)
{
ptrdiff_t offset = dst - out;
outlen *= 2;
out = realloc(out, outlen);
dst = out + offset;
}
}
@ -531,8 +494,7 @@ fragment_render_buf(const pkgconf_list_t *list, char *buf, size_t buflen, bool e
free(quoted);
}
if (node->next != NULL)
*bptr++ = ' ';
*bptr++ = ' ';
}
*bptr = '\0';
@ -668,16 +630,15 @@ pkgconf_fragment_free(pkgconf_list_t *list)
* :param pkgconf_client_t* client: The pkgconf client being accessed.
* :param pkgconf_list_t* list: The `fragment list` to add the fragment entries to.
* :param pkgconf_list_t* vars: A list of variables to use for variable substitution.
* :param uint flags: Any parsing flags to be aware of.
* :param char* value: The string to parse into fragments.
* :return: true on success, false on parse error
*/
bool
pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags)
pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value)
{
int i, ret, argc;
char **argv;
char *repstr = pkgconf_tuple_parse(client, vars, value, flags);
char *repstr = pkgconf_tuple_parse(client, vars, value);
PKGCONF_TRACE(client, "post-subst: [%s] -> [%s]", value, repstr);
@ -691,8 +652,6 @@ pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkg
for (i = 0; i < argc; i++)
{
PKGCONF_TRACE(client, "processing %s", argv[i]);
if (argv[i] == NULL)
{
PKGCONF_TRACE(client, "parsed fragment string is inconsistent: argc = %d while argv[%d] == NULL", argc, i);
@ -701,7 +660,7 @@ pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkg
return false;
}
pkgconf_fragment_add(client, list, argv[i], flags);
pkgconf_fragment_add(client, list, argv[i]);
}
pkgconf_argv_free(argv);

View File

@ -13,8 +13,8 @@
* from the use of this software.
*/
#ifndef LIBPKGCONF_ITER_H
#define LIBPKGCONF_ITER_H
#ifndef PKGCONF__ITER_H
#define PKGCONF__ITER_H
#ifdef __cplusplus
extern "C" {
@ -34,14 +34,6 @@ typedef struct {
#define PKGCONF_LIST_INITIALIZER { NULL, NULL, 0 }
static inline void
pkgconf_list_zero(pkgconf_list_t *list)
{
list->head = NULL;
list->tail = NULL;
list->length = 0;
}
static inline void
pkgconf_node_insert(pkgconf_node_t *node, void *data, pkgconf_list_t *list)
{

View File

@ -1,8 +1,9 @@
#ifndef LIBPKGCONF_LIBPKGCONF_API_H
#define LIBPKGCONF_LIBPKGCONF_API_H
#ifndef PKGCONFG_API
#define PKGCONFG_API
/* Makefile.am specifies visibility using the libtool option -export-symbols-regex '^pkgconf_'
* Unfortunately, that is not available when building with meson, so use attributes instead.
* Unfortunately, that is not available when building with cmake, so use attributes instead,
* in a way that doesn't depend on any cmake magic.
*/
#if defined(PKGCONFIG_IS_STATIC)
# define PKGCONF_API

View File

@ -16,15 +16,13 @@
#ifndef LIBPKGCONF__LIBPKGCONF_H
#define LIBPKGCONF__LIBPKGCONF_H
#include <inttypes.h>
#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdint.h>
#include <libpkgconf/libpkgconf-api.h>
#include <libpkgconf/iter.h>
#include <libpkgconf/bsdstubs.h>
#include <libpkgconf/libpkgconf-api.h>
#ifdef __cplusplus
extern "C" {
@ -43,10 +41,6 @@ extern "C" {
#define PKG_DIR_SEP_S '/'
#endif
#ifdef _WIN32
#define realpath(N,R) _fullpath((R),(N),_MAX_PATH)
#endif
#define PKGCONF_BUFSIZE (65535)
typedef enum {
@ -67,8 +61,6 @@ typedef struct pkgconf_tuple_ pkgconf_tuple_t;
typedef struct pkgconf_fragment_ pkgconf_fragment_t;
typedef struct pkgconf_path_ pkgconf_path_t;
typedef struct pkgconf_client_ pkgconf_client_t;
typedef struct pkgconf_cross_personality_ pkgconf_cross_personality_t;
typedef struct pkgconf_queue_ pkgconf_queue_t;
#define PKGCONF_ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
@ -81,14 +73,6 @@ typedef struct pkgconf_queue_ pkgconf_queue_t;
#define PKGCONF_FOREACH_LIST_ENTRY_REVERSE(tail, value) \
for ((value) = (tail); (value) != NULL; (value) = (value)->prev)
#define LIBPKGCONF_VERSION 20200
#define LIBPKGCONF_VERSION_STR "2.2.0"
struct pkgconf_queue_ {
pkgconf_node_t iter;
char *package;
};
struct pkgconf_fragment_ {
pkgconf_node_t iter;
@ -106,11 +90,6 @@ struct pkgconf_dependency_ {
char *version;
pkgconf_pkg_t *parent;
pkgconf_pkg_t *match;
unsigned int flags;
int refcount;
pkgconf_client_t *owner;
};
struct pkgconf_tuple_ {
@ -118,12 +97,8 @@ struct pkgconf_tuple_ {
char *key;
char *value;
unsigned int flags;
};
#define PKGCONF_PKG_TUPLEF_OVERRIDE 0x1
struct pkgconf_path_ {
pkgconf_node_t lnode;
@ -135,12 +110,13 @@ struct pkgconf_path_ {
#define PKGCONF_PKG_PROPF_NONE 0x00
#define PKGCONF_PKG_PROPF_STATIC 0x01
#define PKGCONF_PKG_PROPF_CACHED 0x02
#define PKGCONF_PKG_PROPF_SEEN 0x04
#define PKGCONF_PKG_PROPF_UNINSTALLED 0x08
#define PKGCONF_PKG_PROPF_VIRTUAL 0x10
#define PKGCONF_PKG_PROPF_ANCESTOR 0x20
#define PKGCONF_PKG_PROPF_VISITED_PRIVATE 0x40
struct pkgconf_pkg_ {
pkgconf_node_t cache_iter;
int refcount;
char *id;
char *filename;
@ -149,10 +125,6 @@ struct pkgconf_pkg_ {
char *description;
char *url;
char *pc_filedir;
char *license;
char *maintainer;
char *copyright;
char *why;
pkgconf_list_t libs;
pkgconf_list_t libs_private;
@ -169,24 +141,16 @@ struct pkgconf_pkg_ {
unsigned int flags;
pkgconf_client_t *owner;
/* these resources are owned by the package and do not need special management,
* under no circumstance attempt to allocate or free objects belonging to these pointers
*/
pkgconf_tuple_t *orig_prefix;
pkgconf_tuple_t *prefix;
uint64_t serial;
uint64_t identifier;
};
typedef bool (*pkgconf_pkg_iteration_func_t)(const pkgconf_pkg_t *pkg, void *data);
typedef void (*pkgconf_pkg_traverse_func_t)(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data);
typedef bool (*pkgconf_queue_apply_func_t)(pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth);
typedef bool (*pkgconf_error_handler_func_t)(const char *msg, const pkgconf_client_t *client, void *data);
typedef bool (*pkgconf_error_handler_func_t)(const char *msg, const pkgconf_client_t *client, const void *data);
struct pkgconf_client_ {
pkgconf_list_t dir_list;
pkgconf_list_t pkg_cache;
pkgconf_list_t filter_libdirs;
pkgconf_list_t filter_includedirs;
@ -211,31 +175,11 @@ struct pkgconf_client_ {
char *prefix_varname;
bool already_sent_notice;
uint64_t serial;
uint64_t identifier;
pkgconf_pkg_t **cache_table;
size_t cache_count;
};
struct pkgconf_cross_personality_ {
const char *name;
pkgconf_list_t dir_list;
pkgconf_list_t filter_libdirs;
pkgconf_list_t filter_includedirs;
char *sysroot_dir;
bool want_default_static;
bool want_default_pure;
};
/* client.c */
PKGCONF_API void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality);
PKGCONF_API pkgconf_client_t * pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data, const pkgconf_cross_personality_t *personality);
PKGCONF_API void pkgconf_client_init(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data);
PKGCONF_API pkgconf_client_t * pkgconf_client_new(pkgconf_error_handler_func_t error_handler, void *error_handler_data);
PKGCONF_API void pkgconf_client_deinit(pkgconf_client_t *client);
PKGCONF_API void pkgconf_client_free(pkgconf_client_t *client);
PKGCONF_API const char *pkgconf_client_get_sysroot_dir(const pkgconf_client_t *client);
@ -252,14 +196,8 @@ PKGCONF_API pkgconf_error_handler_func_t pkgconf_client_get_error_handler(const
PKGCONF_API void pkgconf_client_set_error_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t error_handler, void *error_handler_data);
PKGCONF_API pkgconf_error_handler_func_t pkgconf_client_get_trace_handler(const pkgconf_client_t *client);
PKGCONF_API void pkgconf_client_set_trace_handler(pkgconf_client_t *client, pkgconf_error_handler_func_t trace_handler, void *trace_handler_data);
PKGCONF_API void pkgconf_client_dir_list_build(pkgconf_client_t *client, const pkgconf_cross_personality_t *personality);
/* personality.c */
PKGCONF_API pkgconf_cross_personality_t *pkgconf_cross_personality_default(void);
PKGCONF_API pkgconf_cross_personality_t *pkgconf_cross_personality_find(const char *triplet);
PKGCONF_API void pkgconf_cross_personality_deinit(pkgconf_cross_personality_t *personality);
#define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((unsigned char)(c)))
#define PKGCONF_IS_MODULE_SEPARATOR(c) ((c) == ',' || isspace ((unsigned int)(c)))
#define PKGCONF_IS_OPERATOR_CHAR(c) ((c) == '<' || (c) == '>' || (c) == '!' || (c) == '=')
#define PKGCONF_PKG_PKGF_NONE 0x0000
@ -276,13 +214,6 @@ PKGCONF_API void pkgconf_cross_personality_deinit(pkgconf_cross_personality_t *p
#define PKGCONF_PKG_PKGF_REDEFINE_PREFIX 0x0400
#define PKGCONF_PKG_PKGF_DONT_RELOCATE_PATHS 0x0800
#define PKGCONF_PKG_PKGF_SIMPLIFY_ERRORS 0x1000
#define PKGCONF_PKG_PKGF_DONT_FILTER_INTERNAL_CFLAGS 0x2000
#define PKGCONF_PKG_PKGF_DONT_MERGE_SPECIAL_FRAGMENTS 0x4000
#define PKGCONF_PKG_PKGF_FDO_SYSROOT_RULES 0x8000
#define PKGCONF_PKG_PKGF_PKGCONF1_SYSROOT_RULES 0x10000
#define PKGCONF_PKG_DEPF_INTERNAL 0x1
#define PKGCONF_PKG_DEPF_PRIVATE 0x2
#define PKGCONF_PKG_ERRF_OK 0x0
#define PKGCONF_PKG_ERRF_PACKAGE_NOT_FOUND 0x1
@ -290,6 +221,7 @@ PKGCONF_API void pkgconf_cross_personality_deinit(pkgconf_cross_personality_t *p
#define PKGCONF_PKG_ERRF_PACKAGE_CONFLICT 0x4
#define PKGCONF_PKG_ERRF_DEPGRAPH_BREAK 0x8
/* pkg.c */
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
#define PRINTFLIKE(fmtarg, firstvararg) \
__attribute__((__format__ (__printf__, fmtarg, firstvararg)))
@ -300,37 +232,26 @@ PKGCONF_API void pkgconf_cross_personality_deinit(pkgconf_cross_personality_t *p
#define DEPRECATED
#endif /* defined(__INTEL_COMPILER) || defined(__GNUC__) */
/* parser.c */
typedef void (*pkgconf_parser_operand_func_t)(void *data, const size_t lineno, const char *key, const char *value);
typedef void (*pkgconf_parser_warn_func_t)(void *data, const char *fmt, ...);
PKGCONF_API void pkgconf_parser_parse(FILE *f, void *data, const pkgconf_parser_operand_func_t *ops, const pkgconf_parser_warn_func_t warnfunc, const char *filename);
/* pkg.c */
PKGCONF_API bool pkgconf_error(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
PKGCONF_API bool pkgconf_warn(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
PKGCONF_API bool pkgconf_trace(const pkgconf_client_t *client, const char *filename, size_t lineno, const char *funcname, const char *format, ...) PRINTFLIKE(5, 6);
PKGCONF_API bool pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, void *data);
PKGCONF_API bool pkgconf_default_error_handler(const char *msg, const pkgconf_client_t *client, const void *data);
#ifndef PKGCONF_LITE
#if defined(__GNUC__) || defined(__INTEL_COMPILER)
#define PKGCONF_TRACE(client, ...) do { \
pkgconf_trace(client, __FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__); \
} while (0)
} while (0);
#else
#define PKGCONF_TRACE(client, ...) do { \
pkgconf_trace(client, __FILE__, __LINE__, __func__, __VA_ARGS__); \
} while (0)
#endif
#else
#define PKGCONF_TRACE(client, ...)
} while (0);
#endif
PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_ref(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
PKGCONF_API void pkgconf_pkg_unref(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
PKGCONF_API void pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_find(pkgconf_client_t *client, const char *name);
PKGCONF_API unsigned int pkgconf_pkg_traverse(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth, unsigned int skip_flags);
PKGCONF_API unsigned int pkgconf_pkg_traverse(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth);
PKGCONF_API unsigned int pkgconf_pkg_verify_graph(pkgconf_client_t *client, pkgconf_pkg_t *root, int depth);
PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_verify_dependency(pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int *eflags);
PKGCONF_API const char *pkgconf_pkg_get_comparator(const pkgconf_dependency_t *pkgdep);
@ -341,18 +262,15 @@ PKGCONF_API pkgconf_pkg_t *pkgconf_builtin_pkg_get(const char *name);
PKGCONF_API int pkgconf_compare_version(const char *a, const char *b);
PKGCONF_API pkgconf_pkg_t *pkgconf_scan_all(pkgconf_client_t *client, void *ptr, pkgconf_pkg_iteration_func_t func);
PKGCONF_API void pkgconf_pkg_dir_list_build(pkgconf_client_t *client);
/* parse.c */
PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *path, FILE *f, unsigned int flags);
PKGCONF_API void pkgconf_dependency_parse_str(pkgconf_client_t *client, pkgconf_list_t *deplist_head, const char *depends, unsigned int flags);
PKGCONF_API void pkgconf_dependency_parse(pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends, unsigned int flags);
PKGCONF_API pkgconf_pkg_t *pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *path, FILE *f);
PKGCONF_API void pkgconf_dependency_parse_str(const pkgconf_client_t *client, pkgconf_list_t *deplist_head, const char *depends);
PKGCONF_API void pkgconf_dependency_parse(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, pkgconf_list_t *deplist_head, const char *depends);
PKGCONF_API void pkgconf_dependency_append(pkgconf_list_t *list, pkgconf_dependency_t *tail);
PKGCONF_API void pkgconf_dependency_free(pkgconf_list_t *list);
PKGCONF_API void pkgconf_dependency_free_one(pkgconf_dependency_t *dep);
PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_add(pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare, unsigned int flags);
PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_ref(pkgconf_client_t *client, pkgconf_dependency_t *dep);
PKGCONF_API void pkgconf_dependency_unref(pkgconf_client_t *client, pkgconf_dependency_t *dep);
PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_copy(pkgconf_client_t *client, const pkgconf_dependency_t *dep);
PKGCONF_API pkgconf_dependency_t *pkgconf_dependency_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *package, const char *version, pkgconf_pkg_comparator_t compare);
/* argvsplit.c */
PKGCONF_API int pkgconf_argv_split(const char *src, int *argc, char ***argv);
@ -365,10 +283,9 @@ typedef struct pkgconf_fragment_render_ops_ {
} pkgconf_fragment_render_ops_t;
typedef bool (*pkgconf_fragment_filter_func_t)(const pkgconf_client_t *client, const pkgconf_fragment_t *frag, void *data);
PKGCONF_API bool pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value, unsigned int flags);
PKGCONF_API void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string, unsigned int flags);
PKGCONF_API bool pkgconf_fragment_parse(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_list_t *vars, const char *value);
PKGCONF_API void pkgconf_fragment_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *string);
PKGCONF_API void pkgconf_fragment_copy(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_fragment_t *base, bool is_private);
PKGCONF_API void pkgconf_fragment_copy_list(const pkgconf_client_t *client, pkgconf_list_t *list, const pkgconf_list_t *base);
PKGCONF_API void pkgconf_fragment_delete(pkgconf_list_t *list, pkgconf_fragment_t *node);
PKGCONF_API void pkgconf_fragment_free(pkgconf_list_t *list);
PKGCONF_API void pkgconf_fragment_filter(const pkgconf_client_t *client, pkgconf_list_t *dest, pkgconf_list_t *src, pkgconf_fragment_filter_func_t filter_func, void *data);
@ -381,9 +298,9 @@ PKGCONF_API bool pkgconf_fragment_has_system_dir(const pkgconf_client_t *client,
PKGCONF_API char *pkgconf_fgetline(char *line, size_t size, FILE *stream);
/* tuple.c */
PKGCONF_API pkgconf_tuple_t *pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *parent, const char *key, const char *value, bool parse, unsigned int flags);
PKGCONF_API pkgconf_tuple_t *pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *parent, const char *key, const char *value, bool parse);
PKGCONF_API char *pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key);
PKGCONF_API char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *list, const char *value, unsigned int flags);
PKGCONF_API char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *list, const char *value);
PKGCONF_API void pkgconf_tuple_free(pkgconf_list_t *list);
PKGCONF_API void pkgconf_tuple_free_entry(pkgconf_tuple_t *tuple, pkgconf_list_t *list);
PKGCONF_API void pkgconf_tuple_add_global(pkgconf_client_t *client, const char *key, const char *value);
@ -394,11 +311,9 @@ PKGCONF_API void pkgconf_tuple_define_global(pkgconf_client_t *client, const cha
/* queue.c */
PKGCONF_API void pkgconf_queue_push(pkgconf_list_t *list, const char *package);
PKGCONF_API bool pkgconf_queue_compile(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list);
PKGCONF_API bool pkgconf_queue_solve(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_pkg_t *world, int maxdepth);
PKGCONF_API void pkgconf_queue_free(pkgconf_list_t *list);
PKGCONF_API bool pkgconf_queue_apply(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, void *data);
PKGCONF_API bool pkgconf_queue_validate(pkgconf_client_t *client, pkgconf_list_t *list, int maxdepth);
PKGCONF_API void pkgconf_solution_free(pkgconf_client_t *client, pkgconf_pkg_t *world);
/* cache.c */
PKGCONF_API pkgconf_pkg_t *pkgconf_cache_lookup(pkgconf_client_t *client, const char *id);
@ -413,13 +328,11 @@ PKGCONF_API void pkgconf_audit_log_dependency(pkgconf_client_t *client, const pk
/* path.c */
PKGCONF_API void pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter);
PKGCONF_API void pkgconf_path_prepend(const char *text, pkgconf_list_t *dirlist, bool filter);
PKGCONF_API size_t pkgconf_path_split(const char *text, pkgconf_list_t *dirlist, bool filter);
PKGCONF_API size_t pkgconf_path_build_from_environ(const char *envvarname, const char *fallback, pkgconf_list_t *dirlist, bool filter);
PKGCONF_API bool pkgconf_path_match_list(const char *path, const pkgconf_list_t *dirlist);
PKGCONF_API void pkgconf_path_free(pkgconf_list_t *dirlist);
PKGCONF_API bool pkgconf_path_relocate(char *buf, size_t buflen);
PKGCONF_API void pkgconf_path_copy_list(pkgconf_list_t *dst, const pkgconf_list_t *src);
#ifdef __cplusplus
}

View File

@ -8,5 +8,5 @@ install_headers('libpkgconf.h',
'iter.h',
'bsdstubs.h',
'libpkgconf-api.h',
subdir : 'pkgconf/libpkgconf')
subdir : 'libpkgconf')

View File

@ -1,106 +0,0 @@
/*
* parser.c
* rfc822 message parser
*
* Copyright (c) 2018 pkgconf authors (see AUTHORS).
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* This software is provided 'as is' and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising
* from the use of this software.
*/
#include <libpkgconf/config.h>
#include <libpkgconf/stdinc.h>
#include <libpkgconf/libpkgconf.h>
/*
* !doc
*
* .. c:function:: pkgconf_pkg_t *pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *filename, FILE *f)
*
* Parse a .pc file into a pkgconf_pkg_t object structure.
*
* :param pkgconf_client_t* client: The pkgconf client object to use for dependency resolution.
* :param char* filename: The filename of the package file (including full path).
* :param FILE* f: The file object to read from.
* :returns: A ``pkgconf_pkg_t`` object which contains the package data.
* :rtype: pkgconf_pkg_t *
*/
void
pkgconf_parser_parse(FILE *f, void *data, const pkgconf_parser_operand_func_t *ops, const pkgconf_parser_warn_func_t warnfunc, const char *filename)
{
char readbuf[PKGCONF_BUFSIZE];
size_t lineno = 0;
while (pkgconf_fgetline(readbuf, PKGCONF_BUFSIZE, f) != NULL)
{
char op, *p, *key, *value;
bool warned_key_whitespace = false, warned_value_whitespace = false;
lineno++;
p = readbuf;
while (*p && isspace((unsigned char)*p))
p++;
if (*p && p != readbuf)
{
warnfunc(data, "%s:" SIZE_FMT_SPECIFIER ": warning: whitespace encountered while parsing key section\n",
filename, lineno);
warned_key_whitespace = true;
}
key = p;
while (*p && (isalpha((unsigned char)*p) || isdigit((unsigned char)*p) || *p == '_' || *p == '.'))
p++;
if (!isalpha((unsigned char)*key) &&
!isdigit((unsigned char)*p))
continue;
while (*p && isspace((unsigned char)*p))
{
if (!warned_key_whitespace)
{
warnfunc(data, "%s:" SIZE_FMT_SPECIFIER ": warning: whitespace encountered while parsing key section\n",
filename, lineno);
warned_key_whitespace = true;
}
/* set to null to avoid trailing spaces in key */
*p = '\0';
p++;
}
op = *p;
if (*p != '\0')
{
*p = '\0';
p++;
}
while (*p && isspace((unsigned char)*p))
p++;
value = p;
p = value + (strlen(value) - 1);
while (*p && isspace((unsigned char) *p) && p > value)
{
if (!warned_value_whitespace && op == '=')
{
warnfunc(data, "%s:" SIZE_FMT_SPECIFIER ": warning: trailing whitespace encountered while parsing value section\n",
filename, lineno);
warned_value_whitespace = true;
}
*p = '\0';
p--;
}
if (ops[(unsigned char) op])
ops[(unsigned char) op](data, lineno, key, value);
}
fclose(f);
}

View File

@ -13,9 +13,13 @@
* from the use of this software.
*/
#include <libpkgconf/config.h>
#include <libpkgconf/stdinc.h>
#include <libpkgconf/libpkgconf.h>
#include <libpkgconf/config.h>
#if defined(HAVE_CYGWIN_CONV_PATH) && defined(__MSYS__)
# include <sys/cygwin.h>
#endif
#if defined(HAVE_SYS_STAT_H) && ! defined(_WIN32)
# include <sys/stat.h>
@ -58,51 +62,6 @@ path_list_contains_entry(const char *text, pkgconf_list_t *dirlist)
* variables.
*/
static pkgconf_path_t *
prepare_path_node(const char *text, pkgconf_list_t *dirlist, bool filter)
{
pkgconf_path_t *node;
char path[PKGCONF_ITEM_SIZE];
pkgconf_strlcpy(path, text, sizeof path);
pkgconf_path_relocate(path, sizeof path);
#ifdef PKGCONF_CACHE_INODES
struct stat st;
if (filter)
{
if (lstat(path, &st) == -1)
return NULL;
if (S_ISLNK(st.st_mode))
{
char pathbuf[PKGCONF_ITEM_SIZE * 4];
char *linkdest = realpath(path, pathbuf);
if (linkdest != NULL && stat(linkdest, &st) == -1)
return NULL;
}
if (path_list_contains_entry(path, dirlist, &st))
return NULL;
}
#else
if (filter && path_list_contains_entry(path, dirlist))
return NULL;
#endif
node = calloc(1, sizeof(pkgconf_path_t));
node->path = strdup(path);
#ifdef PKGCONF_CACHE_INODES
if (filter) {
node->handle_path = (void *)(intptr_t) st.st_ino;
node->handle_device = (void *)(intptr_t) st.st_dev;
}
#endif
return node;
}
/*
* !doc
*
@ -118,35 +77,52 @@ prepare_path_node(const char *text, pkgconf_list_t *dirlist, bool filter)
void
pkgconf_path_add(const char *text, pkgconf_list_t *dirlist, bool filter)
{
pkgconf_path_t *node = prepare_path_node(text, dirlist, filter);
if (node == NULL)
pkgconf_path_t *node;
char path[PKGCONF_ITEM_SIZE];
pkgconf_strlcpy(path, text, sizeof path);
pkgconf_path_relocate(path, sizeof path);
#ifdef PKGCONF_CACHE_INODES
struct stat st;
if (filter)
{
if (lstat(path, &st) == -1)
return;
if (S_ISLNK(st.st_mode))
{
char linkdest[PKGCONF_ITEM_SIZE];
ssize_t len;
memset(linkdest, '\0', sizeof linkdest);
len = readlink(path, linkdest, sizeof linkdest);
if (len != -1 && (size_t)len < sizeof(linkdest) &&
stat(linkdest, &st) == -1)
return;
}
if (path_list_contains_entry(path, dirlist, &st))
return;
}
#else
if (filter && path_list_contains_entry(path, dirlist))
return;
#endif
node = calloc(sizeof(pkgconf_path_t), 1);
node->path = strdup(path);
#ifdef PKGCONF_CACHE_INODES
if (filter) {
node->handle_path = (void *)(intptr_t) st.st_ino;
node->handle_device = (void *)(intptr_t) st.st_dev;
}
#endif
pkgconf_node_insert_tail(&node->lnode, node, dirlist);
}
/*
* !doc
*
* .. c:function:: void pkgconf_path_prepend(const char *text, pkgconf_list_t *dirlist)
*
* Prepends a path node to a path list. If the path is already in the list, do nothing.
*
* :param char* text: The path text to add as a path node.
* :param pkgconf_list_t* dirlist: The path list to add the path node to.
* :param bool filter: Whether to perform duplicate filtering.
* :return: nothing
*/
void
pkgconf_path_prepend(const char *text, pkgconf_list_t *dirlist, bool filter)
{
pkgconf_path_t *node = prepare_path_node(text, dirlist, filter);
if (node == NULL)
return;
pkgconf_node_insert(&node->lnode, node, dirlist);
}
/*
* !doc
*
@ -246,38 +222,6 @@ pkgconf_path_match_list(const char *path, const pkgconf_list_t *dirlist)
return false;
}
/*
* !doc
*
* .. c:function:: void pkgconf_path_copy_list(pkgconf_list_t *dst, const pkgconf_list_t *src)
*
* Copies a path list to another path list.
*
* :param pkgconf_list_t* dst: The path list to copy to.
* :param pkgconf_list_t* src: The path list to copy from.
* :return: nothing
*/
void
pkgconf_path_copy_list(pkgconf_list_t *dst, const pkgconf_list_t *src)
{
pkgconf_node_t *n;
PKGCONF_FOREACH_LIST_ENTRY(src->head, n)
{
pkgconf_path_t *srcpath = n->data, *path;
path = calloc(1, sizeof(pkgconf_path_t));
path->path = strdup(srcpath->path);
#ifdef PKGCONF_CACHE_INODES
path->handle_path = srcpath->handle_path;
path->handle_device = srcpath->handle_device;
#endif
pkgconf_node_insert_tail(&path->lnode, path, dst);
}
}
/*
* !doc
*
@ -300,8 +244,6 @@ pkgconf_path_free(pkgconf_list_t *dirlist)
free(pnode->path);
free(pnode);
}
pkgconf_list_zero(dirlist);
}
static char *
@ -336,7 +278,7 @@ normpath(const char *path)
*
* .. c:function:: bool pkgconf_path_relocate(char *buf, size_t buflen)
*
* Relocates a path, possibly calling normpath() on it.
* Relocates a path, possibly calling normpath() or cygwin_conv_path() on it.
*
* :param char* buf: The path to relocate.
* :param size_t buflen: The buffer length the path is contained in.
@ -346,10 +288,28 @@ normpath(const char *path)
bool
pkgconf_path_relocate(char *buf, size_t buflen)
{
#ifdef _WIN32
char *ti;
#endif
#if defined(HAVE_CYGWIN_CONV_PATH) && defined(__MSYS__)
ssize_t size;
char *tmpbuf, *ti;
size = cygwin_conv_path(CCP_POSIX_TO_WIN_A, buf, NULL, 0);
if (size < 0 || (size_t) size > buflen)
return false;
tmpbuf = malloc(size);
if (cygwin_conv_path(CCP_POSIX_TO_WIN_A, buf, tmpbuf, size))
return false;
pkgconf_strlcpy(buf, tmpbuf, buflen);
free(tmpbuf);
/* rewrite any backslash arguments for best compatibility */
for (ti = buf; *ti != '\0'; ti++)
{
if (*ti == '\\')
*ti = '/';
}
#else
char *tmpbuf;
if ((tmpbuf = normpath(buf)) != NULL)
@ -364,6 +324,7 @@ pkgconf_path_relocate(char *buf, size_t buflen)
pkgconf_strlcpy(buf, tmpbuf, buflen);
free(tmpbuf);
}
#endif
return true;
}

View File

@ -1,339 +0,0 @@
/*
* personality.c
* libpkgconf cross-compile personality database
*
* Copyright (c) 2018 pkgconf authors (see AUTHORS).
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* This software is provided 'as is' and without any warranty, express or
* implied. In no event shall the authors be liable for any damages arising
* from the use of this software.
*/
#include <libpkgconf/config.h>
#include <libpkgconf/stdinc.h>
#include <libpkgconf/libpkgconf.h>
/*
* !doc
*
* libpkgconf `personality` module
* =========================
*/
#ifdef _WIN32
# define strcasecmp _stricmp
#endif
/*
* Increment each time the default personality is inited, decrement each time
* it's deinited. Whenever it is 0, then the deinit frees the personality. In
* that case an additional call to init will create it anew.
*/
static unsigned default_personality_init = 0;
static pkgconf_cross_personality_t default_personality = {
.name = "default",
#ifdef _WIN32
.want_default_static = true,
.want_default_pure = true,
#endif
};
static inline void
build_default_search_path(pkgconf_list_t* dirlist)
{
#ifdef _WIN32
char namebuf[MAX_PATH];
char outbuf[MAX_PATH];
char *p;
int sizepath = GetModuleFileName(NULL, namebuf, sizeof namebuf);
char * winslash;
namebuf[sizepath] = '\0';
while ((winslash = strchr (namebuf, '\\')) != NULL)
{
*winslash = '/';
}
p = strrchr(namebuf, '/');
if (p == NULL)
pkgconf_path_split(PKG_DEFAULT_PATH, dirlist, true);
*p = '\0';
pkgconf_strlcpy(outbuf, namebuf, sizeof outbuf);
pkgconf_strlcat(outbuf, "/", sizeof outbuf);
pkgconf_strlcat(outbuf, "../lib/pkgconfig", sizeof outbuf);
pkgconf_path_add(outbuf, dirlist, true);
pkgconf_strlcpy(outbuf, namebuf, sizeof outbuf);
pkgconf_strlcat(outbuf, "/", sizeof outbuf);
pkgconf_strlcat(outbuf, "../share/pkgconfig", sizeof outbuf);
pkgconf_path_add(outbuf, dirlist, true);
#elif __HAIKU__
char **paths;
size_t count;
if (find_paths(B_FIND_PATH_DEVELOP_LIB_DIRECTORY, "pkgconfig", &paths, &count) == B_OK) {
for (size_t i = 0; i < count; i++)
pkgconf_path_add(paths[i], dirlist, true);
free(paths);
paths = NULL;
}
if (find_paths(B_FIND_PATH_DATA_DIRECTORY, "pkgconfig", &paths, &count) == B_OK) {
for (size_t i = 0; i < count; i++)
pkgconf_path_add(paths[i], dirlist, true);
free(paths);
paths = NULL;
}
#else
pkgconf_path_split(PKG_DEFAULT_PATH, dirlist, true);
#endif
}
/*
* !doc
*
* .. c:function:: const pkgconf_cross_personality_t *pkgconf_cross_personality_default(void)
*
* Returns the default cross-compile personality.
*
* Not thread safe.
*
* :rtype: pkgconf_cross_personality_t*
* :return: the default cross-compile personality
*/
pkgconf_cross_personality_t *
pkgconf_cross_personality_default(void)
{
if (default_personality_init) {
++default_personality_init;
return &default_personality;
}
build_default_search_path(&default_personality.dir_list);
pkgconf_path_split(SYSTEM_LIBDIR, &default_personality.filter_libdirs, false);
pkgconf_path_split(SYSTEM_INCLUDEDIR, &default_personality.filter_includedirs, false);
++default_personality_init;
return &default_personality;
}
/*
* !doc
*
* .. c:function:: void pkgconf_cross_personality_deinit(pkgconf_cross_personality_t *)
*
* Decrements the count of default cross personality instances.
*
* Not thread safe.
*
* :rtype: void
*/
void
pkgconf_cross_personality_deinit(pkgconf_cross_personality_t *personality)
{
if (--default_personality_init == 0) {
pkgconf_path_free(&personality->dir_list);
pkgconf_path_free(&personality->filter_libdirs);
pkgconf_path_free(&personality->filter_includedirs);
}
}
#ifndef PKGCONF_LITE
static bool
valid_triplet(const char *triplet)
{
const char *c = triplet;
for (; *c; c++)
if (!isalnum((unsigned char)*c) && *c != '-' && *c != '_')
return false;
return true;
}
typedef void (*personality_keyword_func_t)(pkgconf_cross_personality_t *p, const char *keyword, const size_t lineno, const ptrdiff_t offset, char *value);
typedef struct {
const char *keyword;
const personality_keyword_func_t func;
const ptrdiff_t offset;
} personality_keyword_pair_t;
static void
personality_bool_func(pkgconf_cross_personality_t *p, const char *keyword, const size_t lineno, const ptrdiff_t offset, char *value)
{
(void) keyword;
(void) lineno;
bool *dest = (bool *)((char *) p + offset);
*dest = strcasecmp(value, "true") || strcasecmp(value, "yes") || *value == '1';
}
static void
personality_copy_func(pkgconf_cross_personality_t *p, const char *keyword, const size_t lineno, const ptrdiff_t offset, char *value)
{
(void) keyword;
(void) lineno;
char **dest = (char **)((char *) p + offset);
*dest = strdup(value);
}
static void
personality_fragment_func(pkgconf_cross_personality_t *p, const char *keyword, const size_t lineno, const ptrdiff_t offset, char *value)
{
(void) keyword;
(void) lineno;
pkgconf_list_t *dest = (pkgconf_list_t *)((char *) p + offset);
pkgconf_path_split(value, dest, false);
}
/* keep in alphabetical order! */
static const personality_keyword_pair_t personality_keyword_pairs[] = {
{"DefaultSearchPaths", personality_fragment_func, offsetof(pkgconf_cross_personality_t, dir_list)},
{"SysrootDir", personality_copy_func, offsetof(pkgconf_cross_personality_t, sysroot_dir)},
{"SystemIncludePaths", personality_fragment_func, offsetof(pkgconf_cross_personality_t, filter_includedirs)},
{"SystemLibraryPaths", personality_fragment_func, offsetof(pkgconf_cross_personality_t, filter_libdirs)},
{"Triplet", personality_copy_func, offsetof(pkgconf_cross_personality_t, name)},
{"WantDefaultPure", personality_bool_func, offsetof(pkgconf_cross_personality_t, want_default_pure)},
{"WantDefaultStatic", personality_bool_func, offsetof(pkgconf_cross_personality_t, want_default_static)},
};
static int
personality_keyword_pair_cmp(const void *key, const void *ptr)
{
const personality_keyword_pair_t *pair = ptr;
return strcasecmp(key, pair->keyword);
}
static void
personality_keyword_set(pkgconf_cross_personality_t *p, const size_t lineno, const char *keyword, char *value)
{
const personality_keyword_pair_t *pair = bsearch(keyword,
personality_keyword_pairs, PKGCONF_ARRAY_SIZE(personality_keyword_pairs),
sizeof(personality_keyword_pair_t), personality_keyword_pair_cmp);
if (pair == NULL || pair->func == NULL)
return;
pair->func(p, keyword, lineno, pair->offset, value);
}
static const pkgconf_parser_operand_func_t personality_parser_ops[256] = {
[':'] = (pkgconf_parser_operand_func_t) personality_keyword_set
};
static void personality_warn_func(void *p, const char *fmt, ...) PRINTFLIKE(2, 3);
static void
personality_warn_func(void *p, const char *fmt, ...)
{
va_list va;
(void) p;
va_start(va, fmt);
vfprintf(stderr, fmt, va);
va_end(va);
}
static pkgconf_cross_personality_t *
load_personality_with_path(const char *path, const char *triplet, bool datadir)
{
char pathbuf[PKGCONF_ITEM_SIZE];
FILE *f;
pkgconf_cross_personality_t *p;
/* if triplet is null, assume that path is a direct path to the personality file */
if (triplet == NULL)
pkgconf_strlcpy(pathbuf, path, sizeof pathbuf);
else if (datadir)
snprintf(pathbuf, sizeof pathbuf, "%s/pkgconfig/personality.d/%s.personality", path, triplet);
else
snprintf(pathbuf, sizeof pathbuf, "%s/%s.personality", path, triplet);
f = fopen(pathbuf, "r");
if (f == NULL)
return NULL;
p = calloc(1, sizeof(pkgconf_cross_personality_t));
if (triplet != NULL)
p->name = strdup(triplet);
pkgconf_parser_parse(f, p, personality_parser_ops, personality_warn_func, pathbuf);
return p;
}
/*
* !doc
*
* .. c:function:: pkgconf_cross_personality_t *pkgconf_cross_personality_find(const char *triplet)
*
* Attempts to find a cross-compile personality given a triplet.
*
* :rtype: pkgconf_cross_personality_t*
* :return: the default cross-compile personality
*/
pkgconf_cross_personality_t *
pkgconf_cross_personality_find(const char *triplet)
{
pkgconf_list_t plist = PKGCONF_LIST_INITIALIZER;
pkgconf_node_t *n;
pkgconf_cross_personality_t *out = NULL;
#if ! defined(_WIN32) && ! defined(__HAIKU__)
char pathbuf[PKGCONF_ITEM_SIZE];
const char *envvar;
#endif
out = load_personality_with_path(triplet, NULL, false);
if (out != NULL)
return out;
if (!valid_triplet(triplet))
return NULL;
#if ! defined(_WIN32) && ! defined(__HAIKU__)
envvar = getenv("XDG_DATA_HOME");
if (envvar != NULL)
pkgconf_path_add(envvar, &plist, true);
else {
envvar = getenv("HOME");
if (envvar != NULL) {
pkgconf_strlcpy(pathbuf, envvar, sizeof pathbuf);
pkgconf_strlcat(pathbuf, "/.local/share", sizeof pathbuf);
pkgconf_path_add(pathbuf, &plist, true);
}
}
pkgconf_path_build_from_environ("XDG_DATA_DIRS", "/usr/local/share" PKG_CONFIG_PATH_SEP_S "/usr/share", &plist, true);
PKGCONF_FOREACH_LIST_ENTRY(plist.head, n)
{
pkgconf_path_t *pn = n->data;
out = load_personality_with_path(pn->path, triplet, true);
if (out != NULL)
goto finish;
}
pkgconf_path_free(&plist);
#endif
pkgconf_path_split(PERSONALITY_PATH, &plist, true);
PKGCONF_FOREACH_LIST_ENTRY(plist.head, n)
{
pkgconf_path_t *pn = n->data;
out = load_personality_with_path(pn->path, triplet, false);
if (out != NULL)
goto finish;
}
finish:
pkgconf_path_free(&plist);
return out != NULL ? out : pkgconf_cross_personality_default();
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -29,6 +29,11 @@
* Using the `queue` module functions is the recommended way of working with dependency graphs.
*/
typedef struct {
pkgconf_node_t iter;
char *package;
} pkgconf_queue_t;
/*
* !doc
*
@ -43,7 +48,7 @@
void
pkgconf_queue_push(pkgconf_list_t *list, const char *package)
{
pkgconf_queue_t *pkgq = calloc(1, sizeof(pkgconf_queue_t));
pkgconf_queue_t *pkgq = calloc(sizeof(pkgconf_queue_t), 1);
pkgq->package = strdup(package);
pkgconf_node_insert_tail(&pkgq->iter, pkgq, list);
@ -72,7 +77,7 @@ pkgconf_queue_compile(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_li
pkgconf_queue_t *pkgq;
pkgq = iter->data;
pkgconf_dependency_parse(client, world, &world->required, pkgq->package, 0);
pkgconf_dependency_parse(client, world, &world->required, pkgq->package);
}
return (world->required.head != NULL);
@ -102,225 +107,13 @@ pkgconf_queue_free(pkgconf_list_t *list)
}
}
static void
pkgconf_queue_mark_public(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data)
{
if (pkg->flags & PKGCONF_PKG_PROPF_VISITED_PRIVATE)
{
pkgconf_list_t *list = data;
pkgconf_node_t *node;
PKGCONF_FOREACH_LIST_ENTRY(list->head, node)
{
pkgconf_dependency_t *dep = node->data;
if (dep->match == pkg)
dep->flags &= ~PKGCONF_PKG_DEPF_PRIVATE;
}
pkg->flags &= ~PKGCONF_PKG_PROPF_VISITED_PRIVATE;
PKGCONF_TRACE(client, "%s: updated, public", pkg->id);
}
}
static unsigned int
pkgconf_queue_collect_dependencies_main(pkgconf_client_t *client,
pkgconf_pkg_t *root,
void *data,
int maxdepth);
static inline unsigned int
pkgconf_queue_collect_dependencies_walk(pkgconf_client_t *client,
pkgconf_list_t *deplist,
void *data,
int depth)
{
unsigned int eflags = PKGCONF_PKG_ERRF_OK;
pkgconf_node_t *node;
pkgconf_pkg_t *world = data;
PKGCONF_FOREACH_LIST_ENTRY_REVERSE(deplist->tail, node)
{
pkgconf_dependency_t *dep = node->data;
pkgconf_dependency_t *flattened_dep;
pkgconf_pkg_t *pkg = dep->match;
if (*dep->package == '\0')
continue;
if (pkg == NULL)
{
PKGCONF_TRACE(client, "WTF: unmatched dependency %p <%s>", dep, dep->package);
abort();
}
if (pkg->serial == client->serial)
continue;
if (client->flags & PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE)
pkg->flags |= PKGCONF_PKG_PROPF_VISITED_PRIVATE;
else
pkg->flags &= ~PKGCONF_PKG_PROPF_VISITED_PRIVATE;
eflags |= pkgconf_queue_collect_dependencies_main(client, pkg, data, depth - 1);
flattened_dep = pkgconf_dependency_copy(client, dep);
pkgconf_node_insert(&flattened_dep->iter, flattened_dep, &world->required);
}
return eflags;
}
static unsigned int
pkgconf_queue_collect_dependencies_main(pkgconf_client_t *client,
pkgconf_pkg_t *root,
void *data,
int maxdepth)
{
unsigned int eflags = PKGCONF_PKG_ERRF_OK;
if (maxdepth == 0)
return eflags;
/* Short-circuit if we have already visited this node.
*/
if (root->serial == client->serial)
return eflags;
root->serial = client->serial;
if (client->flags & PKGCONF_PKG_PKGF_SEARCH_PRIVATE)
{
PKGCONF_TRACE(client, "%s: collecting private dependencies, level %d", root->id, maxdepth);
/* XXX: ugly */
const unsigned int saved_flags = client->flags;
client->flags |= PKGCONF_PKG_PKGF_ITER_PKG_IS_PRIVATE;
eflags = pkgconf_queue_collect_dependencies_walk(client, &root->requires_private, data, maxdepth);
client->flags = saved_flags;
if (eflags != PKGCONF_PKG_ERRF_OK)
return eflags;
}
PKGCONF_TRACE(client, "%s: collecting public dependencies, level %d", root->id, maxdepth);
eflags = pkgconf_queue_collect_dependencies_walk(client, &root->required, data, maxdepth);
if (eflags != PKGCONF_PKG_ERRF_OK)
return eflags;
PKGCONF_TRACE(client, "%s: finished, %s", root->id, (root->flags & PKGCONF_PKG_PROPF_VISITED_PRIVATE) ? "private" : "public");
return eflags;
}
static inline unsigned int
pkgconf_queue_collect_dependencies(pkgconf_client_t *client,
pkgconf_pkg_t *root,
void *data,
int maxdepth)
{
++client->serial;
return pkgconf_queue_collect_dependencies_main(client, root, data, maxdepth);
}
static inline unsigned int
pkgconf_queue_verify(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list, int maxdepth)
{
unsigned int result;
const unsigned int saved_flags = client->flags;
pkgconf_pkg_t initial_world = {
.id = "user:request",
.realname = "virtual world package",
.flags = PKGCONF_PKG_PROPF_STATIC | PKGCONF_PKG_PROPF_VIRTUAL,
};
if (!pkgconf_queue_compile(client, &initial_world, list))
{
pkgconf_solution_free(client, &initial_world);
if (!pkgconf_queue_compile(client, world, list))
return PKGCONF_PKG_ERRF_DEPGRAPH_BREAK;
}
PKGCONF_TRACE(client, "solving");
result = pkgconf_pkg_traverse(client, &initial_world, NULL, NULL, maxdepth, 0);
if (result != PKGCONF_PKG_ERRF_OK)
{
pkgconf_solution_free(client, &initial_world);
return result;
}
PKGCONF_TRACE(client, "flattening");
result = pkgconf_queue_collect_dependencies(client, &initial_world, world, maxdepth);
if (result != PKGCONF_PKG_ERRF_OK)
{
pkgconf_solution_free(client, &initial_world);
return result;
}
if (client->flags & PKGCONF_PKG_PKGF_SEARCH_PRIVATE)
{
PKGCONF_TRACE(client, "marking public deps");
client->flags &= ~PKGCONF_PKG_PKGF_SEARCH_PRIVATE;
client->flags |= PKGCONF_PKG_PKGF_SKIP_CONFLICTS;
result = pkgconf_pkg_traverse(client, &initial_world, pkgconf_queue_mark_public, &world->required, maxdepth, 0);
client->flags = saved_flags;
if (result != PKGCONF_PKG_ERRF_OK)
{
pkgconf_solution_free(client, &initial_world);
return result;
}
}
/* free the initial solution */
pkgconf_solution_free(client, &initial_world);
return PKGCONF_PKG_ERRF_OK;
}
/*
* !doc
*
* .. c:function:: void pkgconf_solution_free(pkgconf_client_t *client, pkgconf_pkg_t *world, int maxdepth)
*
* Removes references to package nodes contained in a solution.
*
* :param pkgconf_client_t* client: The pkgconf client object to use for dependency resolution.
* :param pkgconf_pkg_t* world: The root for the generated dependency graph. Should have PKGCONF_PKG_PROPF_VIRTUAL flag.
* :returns: nothing
*/
void
pkgconf_solution_free(pkgconf_client_t *client, pkgconf_pkg_t *world)
{
(void) client;
if (world->flags & PKGCONF_PKG_PROPF_VIRTUAL)
{
pkgconf_dependency_free(&world->required);
pkgconf_dependency_free(&world->requires_private);
}
}
/*
* !doc
*
* .. c:function:: bool pkgconf_queue_solve(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_pkg_t *world, int maxdepth)
*
* Solves and flattens the dependency graph for the supplied dependency list.
*
* :param pkgconf_client_t* client: The pkgconf client object to use for dependency resolution.
* :param pkgconf_list_t* list: The list of dependency requests to consider.
* :param pkgconf_pkg_t* world: The root for the generated dependency graph, provided by the caller. Should have PKGCONF_PKG_PROPF_VIRTUAL flag.
* :param int maxdepth: The maximum allowed depth for the dependency resolver. A depth of -1 means unlimited.
* :returns: true if the dependency resolver found a solution, otherwise false.
* :rtype: bool
*/
bool
pkgconf_queue_solve(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_pkg_t *world, int maxdepth)
{
/* if maxdepth is one, then we will not traverse deeper than our virtual package. */
if (!maxdepth)
maxdepth = -1;
return pkgconf_queue_verify(client, world, list, maxdepth) == PKGCONF_PKG_ERRF_OK;
return pkgconf_pkg_verify_graph(client, world, maxdepth);
}
/*
@ -331,8 +124,6 @@ pkgconf_queue_solve(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_pkg_
* Attempt to compile a dependency resolution queue into a dependency resolution problem, then attempt to solve the problem and
* feed the solution to a callback function if a complete dependency graph is found.
*
* This function should not be used in new code. Use pkgconf_queue_solve instead.
*
* :param pkgconf_client_t* client: The pkgconf client object to use for dependency resolution.
* :param pkgconf_list_t* list: The list of dependency requests to consider.
* :param pkgconf_queue_apply_func_t func: The callback function to call if a solution is found by the dependency resolver.
@ -344,7 +135,6 @@ pkgconf_queue_solve(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_pkg_
bool
pkgconf_queue_apply(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, void *data)
{
bool ret = false;
pkgconf_pkg_t world = {
.id = "virtual:world",
.realname = "virtual world package",
@ -355,18 +145,18 @@ pkgconf_queue_apply(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queu
if (!maxdepth)
maxdepth = -1;
if (!pkgconf_queue_solve(client, list, &world, maxdepth))
goto cleanup;
if (pkgconf_queue_verify(client, &world, list, maxdepth) != PKGCONF_PKG_ERRF_OK)
return false;
/* the world dependency set is flattened after it is returned from pkgconf_queue_verify */
if (!func(client, &world, data, maxdepth))
goto cleanup;
{
pkgconf_pkg_free(client, &world);
return false;
}
ret = true;
cleanup:
pkgconf_pkg_free(client, &world);
return ret;
return true;
}
/*

View File

@ -13,8 +13,8 @@
* from the use of this software.
*/
#ifndef LIBPKGCONF_STDINC_H
#define LIBPKGCONF_STDINC_H
#ifndef __STDINC_H
#define __STDINC_H
#include <ctype.h>
#include <stdio.h>
@ -53,13 +53,9 @@
#else
# define PATH_DEV_NULL "/dev/null"
# define SIZE_FMT_SPECIFIER "%zu"
# ifdef __HAIKU__
# include <FindDirectory.h>
# endif
# include <dirent.h>
# include <unistd.h>
# include <limits.h>
# include <strings.h>
# ifdef PATH_MAX
# define PKGCONF_ITEM_SIZE (PATH_MAX + 1024)
# else

View File

@ -45,23 +45,7 @@
void
pkgconf_tuple_add_global(pkgconf_client_t *client, const char *key, const char *value)
{
pkgconf_tuple_add(client, &client->global_vars, key, value, false, 0);
}
static pkgconf_tuple_t *
lookup_global_tuple(const pkgconf_client_t *client, const char *key)
{
pkgconf_node_t *node;
PKGCONF_FOREACH_LIST_ENTRY(client->global_vars.head, node)
{
pkgconf_tuple_t *tuple = node->data;
if (!strcmp(tuple->key, key))
return tuple;
}
return NULL;
pkgconf_tuple_add(client, &client->global_vars, key, value, false);
}
/*
@ -79,13 +63,17 @@ lookup_global_tuple(const pkgconf_client_t *client, const char *key)
char *
pkgconf_tuple_find_global(const pkgconf_client_t *client, const char *key)
{
pkgconf_tuple_t *tuple;
pkgconf_node_t *node;
tuple = lookup_global_tuple(client, key);
if (tuple == NULL)
return NULL;
PKGCONF_FOREACH_LIST_ENTRY(client->global_vars.head, node)
{
pkgconf_tuple_t *tuple = node->data;
return tuple->value;
if (!strcmp(tuple->key, key))
return tuple->value;
}
return NULL;
}
/*
@ -120,18 +108,13 @@ pkgconf_tuple_define_global(pkgconf_client_t *client, const char *kv)
{
char *workbuf = strdup(kv);
char *value;
pkgconf_tuple_t *tuple;
value = strchr(workbuf, '=');
if (value == NULL)
goto out;
*value++ = '\0';
tuple = pkgconf_tuple_add(client, &client->global_vars, workbuf, value, false, 0);
if (tuple != NULL)
tuple->flags = PKGCONF_PKG_TUPLEF_OVERRIDE;
pkgconf_tuple_add_global(client, workbuf, value);
out:
free(workbuf);
}
@ -153,70 +136,6 @@ pkgconf_tuple_find_delete(pkgconf_list_t *list, const char *key)
}
}
static char *
dequote(const char *value)
{
char *buf = calloc(1, (strlen(value) + 1) * 2);
char *bptr = buf;
const char *i;
char quote = 0;
if (*value == '\'' || *value == '"')
quote = *value;
for (i = value; *i != '\0'; i++)
{
if (*i == '\\' && quote && *(i + 1) == quote)
{
i++;
*bptr++ = *i;
}
else if (*i != quote)
*bptr++ = *i;
}
return buf;
}
static const char *
find_sysroot(const pkgconf_client_t *client, pkgconf_list_t *vars)
{
const char *sysroot_dir;
sysroot_dir = pkgconf_tuple_find(client, vars, "pc_sysrootdir");
if (sysroot_dir == NULL)
sysroot_dir = client->sysroot_dir;
return sysroot_dir;
}
static bool
should_rewrite_sysroot(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *buf, unsigned int flags)
{
const char *sysroot_dir;
if (flags & PKGCONF_PKG_PROPF_UNINSTALLED && !(client->flags & PKGCONF_PKG_PKGF_FDO_SYSROOT_RULES))
return false;
sysroot_dir = find_sysroot(client, vars);
if (sysroot_dir == NULL)
return false;
if (*buf != '/')
return false;
if (!strcmp(sysroot_dir, "/"))
return false;
if (strlen(buf) <= strlen(sysroot_dir))
return false;
if (strstr(buf + strlen(sysroot_dir), sysroot_dir) == NULL)
return false;
return true;
}
/*
* !doc
*
@ -233,27 +152,22 @@ should_rewrite_sysroot(const pkgconf_client_t *client, pkgconf_list_t *vars, con
* :rtype: pkgconf_tuple_t *
*/
pkgconf_tuple_t *
pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key, const char *value, bool parse, unsigned int flags)
pkgconf_tuple_add(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key, const char *value, bool parse)
{
char *dequote_value;
pkgconf_tuple_t *tuple = calloc(1, sizeof(pkgconf_tuple_t));
pkgconf_tuple_t *tuple = calloc(sizeof(pkgconf_tuple_t), 1);
pkgconf_tuple_find_delete(list, key);
dequote_value = dequote(value);
PKGCONF_TRACE(client, "adding tuple to @%p: %s => %s (parsed? %d)", list, key, value, parse);
tuple->key = strdup(key);
if (parse)
tuple->value = pkgconf_tuple_parse(client, list, dequote_value, flags);
tuple->value = pkgconf_tuple_parse(client, list, value);
else
tuple->value = strdup(dequote_value);
PKGCONF_TRACE(client, "adding tuple to @%p: %s => %s (parsed? %d)", list, key, tuple->value, parse);
tuple->value = strdup(value);
pkgconf_node_insert(&tuple->iter, tuple, list);
free(dequote_value);
return tuple;
}
@ -274,11 +188,10 @@ char *
pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const char *key)
{
pkgconf_node_t *node;
pkgconf_tuple_t *global_tuple;
char *res;
global_tuple = lookup_global_tuple(client, key);
if (global_tuple != NULL && global_tuple->flags & PKGCONF_PKG_TUPLEF_OVERRIDE)
return global_tuple->value;
if ((res = pkgconf_tuple_find_global(client, key)) != NULL)
return res;
PKGCONF_FOREACH_LIST_ENTRY(list->head, node)
{
@ -288,39 +201,31 @@ pkgconf_tuple_find(const pkgconf_client_t *client, pkgconf_list_t *list, const c
return tuple->value;
}
if (global_tuple != NULL)
return global_tuple->value;
return NULL;
}
/*
* !doc
*
* .. c:function:: char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags)
* .. c:function:: char *pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value)
*
* Parse an expression for variable substitution.
*
* :param pkgconf_client_t* client: The pkgconf client object to access.
* :param pkgconf_list_t* list: The variable list to search for variables (along side the global variable list).
* :param char* value: The ``key=value`` string to parse.
* :param uint flags: Any flags to consider while parsing.
* :return: the variable data with any variables substituted
* :rtype: char *
*/
char *
pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value, unsigned int flags)
pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const char *value)
{
char buf[PKGCONF_BUFSIZE];
const char *ptr;
char *bptr = buf;
if (!(client->flags & PKGCONF_PKG_PKGF_FDO_SYSROOT_RULES) &&
(!(flags & PKGCONF_PKG_PROPF_UNINSTALLED) || (client->flags & PKGCONF_PKG_PKGF_PKGCONF1_SYSROOT_RULES)))
{
if (*value == '/' && client->sysroot_dir != NULL && strncmp(value, client->sysroot_dir, strlen(client->sysroot_dir)))
bptr += pkgconf_strlcpy(buf, client->sysroot_dir, sizeof buf);
}
if (*value == '/' && client->sysroot_dir != NULL && strncmp(value, client->sysroot_dir, strlen(client->sysroot_dir)))
bptr += pkgconf_strlcpy(buf, client->sysroot_dir, sizeof buf);
for (ptr = value; *ptr != '\0' && bptr - buf < PKGCONF_BUFSIZE; ptr++)
{
@ -329,7 +234,6 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const
else if (*(ptr + 1) == '{')
{
char varname[PKGCONF_ITEM_SIZE];
char *vend = varname + PKGCONF_ITEM_SIZE - 1;
char *vptr = varname;
const char *pptr;
char *kv, *parsekv;
@ -339,15 +243,7 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const
for (pptr = ptr + 2; *pptr != '\0'; pptr++)
{
if (*pptr != '}')
{
if (vptr < vend)
*vptr++ = *pptr;
else
{
*vptr = '\0';
break;
}
}
*vptr++ = *pptr;
else
{
*vptr = '\0';
@ -355,23 +251,12 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const
}
}
PKGCONF_TRACE(client, "lookup tuple %s", varname);
size_t remain = PKGCONF_BUFSIZE - (bptr - buf);
ptr += (pptr - ptr);
kv = pkgconf_tuple_find_global(client, varname);
if (kv != NULL)
{
size_t nlen = pkgconf_strlcpy(bptr, kv, remain);
if (nlen > remain)
{
pkgconf_warn(client, "warning: truncating very long variable to 64KB\n");
bptr = buf + (PKGCONF_BUFSIZE - 1);
break;
}
bptr += nlen;
strncpy(bptr, kv, PKGCONF_BUFSIZE - (bptr - buf));
bptr += strlen(kv);
}
else
{
@ -379,21 +264,12 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const
if (kv != NULL)
{
size_t nlen;
parsekv = pkgconf_tuple_parse(client, vars, kv);
strncpy(bptr, parsekv, PKGCONF_BUFSIZE - (bptr - buf));
bptr += strlen(parsekv);
parsekv = pkgconf_tuple_parse(client, vars, kv, flags);
nlen = pkgconf_strlcpy(bptr, parsekv, remain);
free(parsekv);
if (nlen > remain)
{
pkgconf_warn(client, "warning: truncating very long variable to 64KB\n");
bptr = buf + (PKGCONF_BUFSIZE - 1);
break;
}
bptr += nlen;
}
}
}
@ -415,15 +291,16 @@ pkgconf_tuple_parse(const pkgconf_client_t *client, pkgconf_list_t *vars, const
* safe to skip ahead in the string to scan for our sysroot dir.
*
* Finally, we call pkgconf_path_relocate() to clean the path of spurious elements.
*
* New in 1.9: Only attempt to rewrite the sysroot if we are not processing an uninstalled package.
*/
if (should_rewrite_sysroot(client, vars, buf, flags))
if (*buf == '/' &&
client->sysroot_dir != NULL &&
strcmp(client->sysroot_dir, "/") != 0 &&
strlen(buf) > strlen(client->sysroot_dir) &&
strstr(buf + strlen(client->sysroot_dir), client->sysroot_dir) != NULL)
{
char cleanpath[PKGCONF_ITEM_SIZE];
const char *sysroot_dir = find_sysroot(client, vars);
pkgconf_strlcpy(cleanpath, buf + strlen(sysroot_dir), sizeof cleanpath);
pkgconf_strlcpy(cleanpath, buf + strlen(client->sysroot_dir), sizeof cleanpath);
pkgconf_path_relocate(cleanpath, sizeof cleanpath);
return strdup(cleanpath);
@ -471,6 +348,4 @@ pkgconf_tuple_free(pkgconf_list_t *list)
PKGCONF_FOREACH_LIST_ENTRY_SAFE(list->head, next, node)
pkgconf_tuple_free_entry(node->data, list);
pkgconf_list_zero(list);
}

File diff suppressed because it is too large Load Diff

View File

@ -29,12 +29,33 @@
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <https://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
#serial 6
#serial 5
AC_DEFUN([AX_CHECK_COMPILE_FLAG],
[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF

File diff suppressed because it is too large Load Diff

View File

@ -14,9 +14,8 @@
.Nm file.pc
.Nd pkg-config file format
.Sh DESCRIPTION
pkg-config files provide a useful mechanism for storing various information
about libraries and packages on a given system.
Information stored by
pkg-config files provide a useful mechanism for storing various information
about libraries and packages on a given system. Information stored by
.Nm .pc
files include compiler and linker flags necessary to use a given library, as
well as any other relevant metadata.
@ -32,9 +31,8 @@ is an implementation.
.Ss FILE SYNTAX
The
.Nm .pc
file follows a format inspired by RFC822.
Comments are prefixed by a pound sign, hash sign or octothorpe (#), and variable
assignment is similar to POSIX shell.
file follows a format inspired by RFC822. Comments are prefixed by a pound sign,
hash sign or octothorpe (#), and variable assignment is similar to POSIX shell.
Properties are defined using RFC822-style stanzas.
.\"
.Ss VARIABLES
@ -42,18 +40,18 @@ Properties are defined using RFC822-style stanzas.
Variable definitions start with an alphanumeric string, followed by an equal sign,
and then the value the variable should contain.
.Pp
Variable references are always written as "${variable}".
It is possible to escape literal "${" as "$${".
Variable references are always written as "${variable}". It is possible to escape
literal "${" as "$${".
.\"
.Ss PROPERTIES
.\"
Properties are set using RFC822-style stanzas which consist of a keyword, followed
by a colon (:) and then the value the property should be set to.
Variable substitution is always performed regardless of property type.
by a colon (:) and then the value the property should be set to. Variable
substitution is always performed regardless of property type.
.Pp
There are three types of property:
.\"
.Bl -tag -width indent
.Bl -tag
.\"
.It Literal
The property will be set to the text of the value.
@ -77,75 +75,53 @@ shell without any shell expansions after variable substitution has been done.
.\"
.El
.Ss PROPERTY KEYWORDS
.Bl -tag -width indent
.Bl -tag
.\"
.It Name
The displayed name of the package.
(mandatory; literal)
The displayed name of the package. (mandatory; literal)
.It Version
The version of the package.
(mandatory; literal)
The version of the package. (mandatory; literal)
.It Description
A description of the package.
(mandatory; literal)
A description of the package. (mandatory; literal)
.It URL
A URL to a webpage for the package.
This is used to recommend where newer versions of the package can be acquired.
(mandatory; literal)
A URL to a webpage for the package. This is used to recommend where newer
versions of the package can be acquired. (mandatory; literal)
.It Cflags
Required compiler flags.
These flags are always used, regardless of whether static compilation is requested.
(optional; fragment list)
Required compiler flags. These flags are always used, regardless of whether
static compilation is requested. (optional; fragment list)
.It Cflags.private
Required compiler flags for static compilation.
(optional; fragment list; pkgconf extension)
.It Copyright
A copyright attestation statement.
(optional; literal; pkgconf extension)
.It Libs
Required linking flags for this package.
Libraries this package depends on for linking against it, which are not
described as dependencies should be specified here.
(optional; fragment list)
described as dependencies should be specified here. (optional; fragment list)
.It Libs.private
Required linking flags for this package that are only required when linking
statically.
Libraries this package depends on for linking against it statically, which are
not described as dependencies should be specified here.
(optional; fragment list)
.It License
The asserted SPDX license tag that should be applied to the given package.
(optional; literal; pkgconf extension)
.It Maintainer
The preferred contact for the maintainer. This should be in the format of a
name followed by an e-mail address or website.
(optional; literal; pkgconf extension)
not described as dependencies should be specified here. (optional; fragment list)
.It Requires
Required dependencies that must be met for the package to be usable.
All dependencies must be satisfied or the pkg-config implementation must not use
the package.
(optional; dependency list)
the package. (optional; dependency list)
.It Requires.private
Required dependencies that must be met for the package to be usable for header
inclusion and static linking.
Required dependencies that must be met for the package to be usable for static linking.
All dependencies must be satisfied or the pkg-config implementation must not use
the package for header inclusion and static linking.
(optional; dependency list)
the package for static linking. (optional; dependency list)
.It Conflicts
Dependencies that must not be met for the package to be usable.
If any package in the proposed dependency solution match any dependency in the
Conflicts list, the package being considered is not usable.
(optional; dependency list)
Dependencies that must not be met for the package to be usable. If any package in the
proposed dependency solution match any dependency in the Conflicts list, the package
being considered is not usable. (optional; dependency list)
.It Provides
Dependencies that may be provided by an alternate package.
If a package cannot be found, the entire package collection is scanned for
providers which can match the requested dependency.
(optional; dependency list; pkgconf extension)
Dependencies that may be provided by an alternate package. If a package cannot be
found, the entire package collection is scanned for providers which can match the
requested dependency. (optional; dependency list; pkgconf extension)
.El
.Ss EXTENSIONS
Features that have been marked as a pkgconf extension are only guaranteed to work
with the pkgconf implementation of pkg-config.
Other implementations may or may not support the extensions.
with the pkgconf implementation of pkg-config. Other implementations may or may
not support the extensions.
.Pp
Accordingly, it is suggested that
.Nm .pc
@ -162,9 +138,6 @@ includedir=${prefix}/include
Name: libfoo # human-readable name
Description: an example library called libfoo # human-readable description
Copyright: Copyright (c) 2022 pkgconf project authors
License: Apache-2.0
Maintainer: the pkgconf project <http://www.pkgconf.org>
Version: 1.0
URL: http://www.pkgconf.org
Requires: libbar > 2.0.0

View File

@ -27,21 +27,23 @@
.Sh DESCRIPTION
.Nm
is a collection of autoconf macros which help to configure compiler and linker
flags for development libraries.
This allows build systems to detect other dependencies and use them with the
system toolchain.
flags for development libraries. This allows build systems to detect other
dependencies and use them with the system toolchain.
.Sh "AUTOCONF MACROS"
.Pp
.Ss "PKG_PREREQ(MIN-VERSION)"
Checks that the version of the
.Nm
autoconf macros in use is at least MIN-VERSION.
This can be used to ensure a particular
autoconf macros in use is at
least MIN-VERSION. This can be used to ensure a particular
.Nm
macro will be available.
.Pp
.Ss "PKG_PROG_PKG_CONFIG([MIN-VERSION])"
Checks for an implementation of
.Nm pkg-config
which is at least MIN-VERSION or newer.
.Pp
.Ss "PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])"
.Ss "PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])"
Checks whether a given module set exists, and if so, defines
@ -87,7 +89,7 @@ be changed by passing the
.Nm DIRECTORY
parameter.
.Pp
This value can be overridden with the
This value can be overriden with the
.Fl -with-pkgconfigdir
configure parameter.
.Ss "PKG_NOARCH_INSTALLDIR(DIRECTORY)"
@ -99,7 +101,7 @@ be changed by passing the
.Nm DIRECTORY
parameter.
.Pp
This value can be overridden with the
This value can be overriden with the
.Fl -with-noarch-pkgconfigdir
configure parameter.
.Ss "PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])"
@ -129,7 +131,7 @@ in a single macro.
Convenience macro to trigger
.Nm AM_CONDITIONAL
after a
.Nm PKG_WITH_MODULES check.\&
.Nm PKG_WITH_MODULES check.
.Nm VARIABLE-PREFIX
is exported as a make variable.
.Ss "PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, [DESCRIPTION], [DEFAULT])"
@ -138,6 +140,6 @@ Convenience macro to trigger
and
.Nm AC_DEFINE
after a
.Nm PKG_WITH_MODULES check.\&
.Nm PKG_WITH_MODULES check.
.Nm VARIABLE-PREFIX
is exported as a make variable.

View File

@ -1,100 +0,0 @@
.\" Copyright (c) 2018 pkgconf authors (see AUTHORS).
.\"
.\" Permission to use, copy, modify, and/or distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" This software is provided 'as is' and without any warranty, express or
.\" implied. In no event shall the authors be liable for any damages arising
.\" from the use of this software.
.Dd July 19, 2018
.Dt PKGCONF-PERSONALITY 5
.Os
.Sh NAME
.Nm file.personality
.Nd pkgconf cross-compile personality file format
.Sh DESCRIPTION
pkgconf cross-compile personality files provide a useful mechanism for storing
various information about system toolchains.
Information stored by
.Nm .personality
files include information about paths used by a cross-compile toolchain, such as
the sysroot directory and default include and library paths. pkgconf uses this
information to determine what information is necessary to use libraries.
.\"
.Ss FILE SYNTAX
The
.Nm .personality
file follows a format inspired by RFC822.
Comments are prefixed by a pound sign, hash sign or octothorpe (#), and variable
assignment is similar to POSIX shell.
Properties are defined using RFC822-style stanzas.
.\"
.Ss PROPERTIES
.\"
Properties are set using RFC822-style stanzas which consist of a keyword, followed
by a colon (:) and then the value the property should be set to.
Variable substitution is always performed regardless of property type.
.Pp
There are three types of property:
.\"
.Bl -tag -width indent
.\"
.It Literal
The property will be set to the text of the value.
.\"
.It Fragment List
The property will be set to a list of fragments parsed from the text.
The input text must be in a format that is suitable for passing to a POSIX
shell without any shell expansions after variable substitution has been done.
Elements are delimited with a colon.
.\"
.It Boolean
The property will be set to true if the value is one of: true, yes or 1.
Otherwise it will be set to false.
.\"
.El
.Ss PROPERTY KEYWORDS
.Bl -tag -width indent
.\"
.It Triplet
The triplet used by the cross-compile toolchain.
(mandatory; literal)
.It SysrootDir
The directory used by the system root of the cross-compile toolchain.
(mandatory; literal)
.It DefaultSearchPaths
A list of directories to look for
.Xr pc 5
files in.
(mandatory; fragment list)
.It SystemIncludePaths
A list of directories that are included by default in the search path for
include files.
(mandatory; fragment list)
.It SystemLibraryPaths
A list of directories that are included by default in the search path for
libraries.
(mandatory; fragment list)
.It WantDefaultPure
If true, pkgconf will default to preferring a pure dependency graph.
(optional; boolean; default is false)
.It WantDefaultStatic
If true, pkgconf will default to operating in static linking mode.
(optional; boolean; default is false)
.\"
.El
.Sh EXAMPLES
An example .personality file:
.Bd -literal
# This is a comment
Triplet: x86_64-pc-linux-gnu
SysrootDir: /home/kaniini/sysroot/x86_64-pc-linux-gnu
DefaultSearchPaths: /home/kaniini/sysroot/x86_64-pc-linux-gnu/lib/pkgconfig:/home/kaniini/sysroot/x86_64-pc-linux-gnu/share/pkgconfig
SystemIncludePaths: /home/kaniini/sysroot/x86_64-pc-linux-gnu/include
SystemLibraryPaths: /home/kaniini/sysroot/x86_64-pc-linux-gnu/lib
.Ed
.Sh SEE ALSO
.Xr pkgconf 1 ,
.Xr pc 5 ,
.Xr pkg.m4 7

View File

@ -20,9 +20,8 @@
.Sh DESCRIPTION
.Nm
is a program which helps to configure compiler and linker flags for
development libraries.
This allows build systems to detect other dependencies and use them with the
system toolchain.
development libraries. This allows build systems to detect other dependencies
and use them with the system toolchain.
.Sh GENERAL OPTIONS
.Bl -tag -width indent
.It Fl -version
@ -40,33 +39,26 @@ environmental variable and display information on packages which have registered
information there.
.It Fl -simulate
Simulates resolving a dependency graph based on the requested modules on the
command line.
Dumps a series of trees denoting pkgconf's resolver state.
command line. Dumps a series of trees denoting pkgconf's resolver state.
.It Fl -no-cache
Skip caching packages when they are loaded into the internal resolver.
This may result in an alternate dependency graph being computed.
Skip caching packages when they are loaded into the internal resolver. This may
result in an alternate dependency graph being computed.
.It Fl -ignore-conflicts
Ignore
.Sq Conflicts
rules in modules.
.It Fl -env-only
Learn about pkgconf's configuration strictly from environmental variables.
.It Fl -validate Ar package ...
Validate specific
.Sq .pc
files for correctness.
.It Fl -maximum-traverse-depth Ns = Ns Ar DEPTH
Impose a limit on the allowed depth in the dependency graph.
For example, a depth of 2 will restrict the resolver from acting on child
dependencies of modules added to the resolver's solution.
Impose a limit on the allowed depth in the dependency graph. For example, a
depth of 2 will restrict the resolver from acting on child dependencies of
modules added to the resolver's solution.
.It Fl -static
Compute a deeper dependency graph and use compiler/linker flags intended for
static linking.
.It Fl -shared
Compute a simple dependency graph that is only suitable for shared linking.
.It Fl -pure
Treats the computed dependency graph as if it were pure.
This is mainly intended for use with the
Treats the computed dependency graph as if it were pure. This is mainly intended
for use with the
.Fl -static
flag.
.It Fl -no-provides
@ -74,8 +66,8 @@ Ignore
.Sq Provides
rules in modules when resolving dependencies.
.It Fl -with-path Ns = Ns Ar PATH
Adds a new module search path to pkgconf's dependency resolver.
Paths added in this way are given preference before other paths.
Adds a new module search path to pkgconf's dependency resolver. Paths added in
this way are given preference before other paths.
.It Fl -define-prefix
Attempts to determine the prefix variable to use for CFLAGS and LIBS entry relocations.
This is mainly useful for platforms where framework SDKs are relocatable, such as Windows.
@ -90,9 +82,8 @@ variable used by the
.Sq define-prefix
feature.
.It Fl -relocate Ns = Ns Ar PATH
Relocates a path using the pkgconf_path_relocate API.
This is mainly used by the testsuite to provide a guaranteed interface
to the system's path relocation backend.
Relocates a path using the pkgconf_path_relocate API. This is mainly used by the
testsuite to provide a guaranteed interface to the system's path relocation backend.
.It Fl -dont-relocate-paths
Disables the path relocation feature.
.El
@ -105,24 +96,24 @@ Exit with error if a module's version is not exactly the specified version.
.It Fl -max-version Ns = Ns Ar VERSION
Exit with error if a module's version is greater than the specified version.
.It Fl -exists
Exit with a non-zero result if the dependency resolver was unable to find all of
Exit with a non-zero result if the dependency resolver was able to find all of
the requested modules.
.It Fl -uninstalled
Exit with a non-zero result if the dependency resolver uses an
.Sq uninstalled
module as part of its solution.
module as part of it's solution.
.It Fl -no-uninstalled
Forbids the dependency resolver from considering 'uninstalled' modules as part
of a solution.
.El
.Sh QUERY-SPECIFIC OPTIONS
.Bl -tag -width indent
.It Fl -cflags , Fl -cflags-only-I , Fl -cflags-only-other
.It Fl -cflags Ns , Fl -cflags-only-I Ns , Fl -cflags-only-other
Display either all CFLAGS, only
.Fl I
CFLAGS or only CFLAGS that are not
.Fl I .
.It Fl -libs , Fl -libs-only-L , Fl -libs-only-l , Fl -libs-only-other
.It Fl -libs Ns , Fl -libs-only-L Ns , Fl -libs-only-l Ns , Fl -libs-only-other
Display either all linker flags, only
.Fl L
linker flags, only
@ -131,7 +122,7 @@ linker flags or only linker flags that are not
.Fl L
or
.Fl l .
.It Fl -keep-system-cflags , Fl -keep-system-libs
.It Fl -keep-system-cflags Ns , Fl -keep-system-libs
Keep CFLAGS or linker flag fragments that would be filtered due to being
included by default in the compiler.
.It Fl -define-variable Ns = Ns Ar VARNAME Ns = Ns Ar VALUE
@ -150,7 +141,7 @@ entries for a module to the output channel.
.It Fl -variable Ns = Ns Ar VARNAME
Print the value of
.Va VARNAME .
.It Fl -print-requires , Fl -print-requires-private
.It Fl -print-requires Ns , Fl -print-requires-private
Print the modules included in either the
.Va Requires
field or the
@ -159,8 +150,7 @@ field.
.It Fl -digraph
Dump the dependency resolver's solution as a graphviz
.Sq dot
file.
This can be used with graphviz to visualize module interdependencies.
file. This can be used with graphviz to visualize module interdependencies.
.It Fl -path
Display the filenames of the
.Sq .pc
@ -169,10 +159,6 @@ files used by the dependency resolver for a given dependency set.
Print the requested values as variable declarations in a similar format as the
.Xr env 1
command.
.It Fl -fragment-filter Ns = Ns Ar TYPES
Filter the fragment lists for the specified types.
.It Fl -modversion
Print the version of the queried module.
.El
.Sh ENVIRONMENT
.Bl -tag -width indent
@ -211,21 +197,15 @@ flag.
.Sq logfile
which is used for dumping audit information concerning installed module versions.
.It Va PKG_CONFIG_DEBUG_SPEW
If set, enables additional debug logging.
The format of the debug log messages is implementation-specific.
If set, enables additional debug logging. The format of the debug log messages is
implementation-specific.
.It Va PKG_CONFIG_DONT_RELOCATE_PATHS
If set, disables the path relocation feature.
.It Va PKG_CONFIG_MSVC_SYNTAX
If set, uses MSVC syntax for fragments.
.It Va PKG_CONFIG_FDO_SYSROOT_RULES
If set, follow the sysroot prefixing rules that freedesktop.org pkg-config uses.
.It Va DESTDIR
If set to PKG_CONFIG_SYSROOT_DIR, assume that PKG_CONFIG_FDO_SYSROOT_RULES is set.
.El
.Sh EXAMPLES
Displaying the CFLAGS of a package:
.Dl $ pkgconf --cflags foo
.Dl -fPIC -I/usr/include/foo
.Sh SEE ALSO
.Xr pc 5 ,
.Xr pkg.m4 7
.Xr pkg.m4 7 ,
.Xr pc 5

View File

@ -1,41 +1,42 @@
project('pkgconf', 'c',
version : '2.2.0',
version : '1.4.0',
license : 'ISC',
meson_version : '>=0.49',
default_options : ['c_std=c99'],
)
meson_version : '>=0.40')
cc = meson.get_compiler('c')
add_project_arguments(
'-D_BSD_SOURCE',
'-D_DEFAULT_SOURCE',
cc.get_supported_arguments(
'-Wimplicit-function-declaration',
'-Wmisleading-indentation',
),
language : 'c',
)
cdata = configuration_data()
check_headers = [
['HAVE_DLFCN_H', 'dlfcn.h'],
['HAVE_INTTYPES_H', 'inttypes.h'],
['HAVE_MEMORY_H', 'memory.h'],
['HAVE_STDINT_H', 'stdint.h'],
['HAVE_STDLIB_H', 'stdlib.h'],
['HAVE_STRINGS_H', 'strings.h'],
['HAVE_STRING_H', 'string.h'],
['HAVE_SYS_STAT_H', 'sys/stat.h'],
['HAVE_SYS_TYPES_H', 'sys/types.h'],
['HAVE_UNISTD_H', 'unistd.h'],
]
foreach h : check_headers
if cc.has_header(h.get(1))
cdata.set(h.get(0), 1)
endif
endforeach
check_functions = [
['strlcat', 'string.h'],
['strlcpy', 'string.h'],
['strndup', 'string.h'],
['strdup', 'string.h'],
['strncasecmp', 'strings.h'],
['strcasecmp', 'strings.h'],
['reallocarray', 'stdlib.h'],
['HAVE_CYGWIN_CONV_PATH', 'cygwin_conv_path', '#include<sys/cygwin.h>'],
['HAVE_STRLCAT', 'strlcat', '#include<string.h>'],
['HAVE_STRLCPY', 'strlcpy', '#include<string.h>'],
['HAVE_STRNDUP', 'strndup', '#include<string.h>'],
]
foreach f : check_functions
name = f[0].to_upper().underscorify()
if cc.has_function(f[0], prefix : '#define _BSD_SOURCE\n#include <@0@>'.format(f[1])) and cc.has_header_symbol(f[1], f[0], prefix : '#define _BSD_SOURCE')
cdata.set('HAVE_@0@'.format(name), 1)
cdata.set('HAVE_DECL_@0@'.format(name), 1)
else
cdata.set('HAVE_DECL_@0@'.format(name), 0)
if cc.has_function(f.get(1), prefix : f.get(2))
cdata.set(f.get(0), 1)
endif
endforeach
@ -44,42 +45,19 @@ foreach f : ['libdir', 'datadir']
default_path += [join_paths(get_option('prefix'), get_option(f), 'pkgconfig')]
endforeach
personality_path = []
foreach f : ['libdir', 'datadir']
personality_path += [join_paths(get_option('prefix'), get_option(f), 'pkgconfig', 'personality.d')]
endforeach
SYSTEM_LIBDIR = get_option('with-system-libdir')
if SYSTEM_LIBDIR != ''
cdata.set_quoted('SYSTEM_LIBDIR', SYSTEM_LIBDIR)
else
cdata.set_quoted('SYSTEM_LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
endif
SYSTEM_INCLUDEDIR = get_option('with-system-includedir')
if SYSTEM_INCLUDEDIR != ''
cdata.set_quoted('SYSTEM_INCLUDEDIR', SYSTEM_INCLUDEDIR)
else
cdata.set_quoted('SYSTEM_INCLUDEDIR', join_paths(get_option('prefix'), get_option('includedir')))
endif
cdata.set_quoted('SYSTEM_LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
cdata.set_quoted('SYSTEM_INCLUDEDIR', join_paths(get_option('prefix'), get_option('includedir')))
cdata.set_quoted('PKG_DEFAULT_PATH', ':'.join(default_path))
cdata.set_quoted('PERSONALITY_PATH', ':'.join(personality_path))
cdata.set_quoted('PACKAGE_NAME', meson.project_name())
cdata.set_quoted('PACKAGE_VERSION', meson.project_version())
cdata.set_quoted('PACKAGE_BUGREPORT', 'https://todo.sr.ht/~kaniini/pkgconf')
cdata.set('abs_top_srcdir', meson.current_source_dir())
cdata.set('abs_top_builddir', meson.current_build_dir())
cdata.set_quoted('PACKAGE_BUGREPORT', 'http://github.com/pkgconf/pkgconf/issues')
cdata.set('abs_top_srcdir', meson.source_root())
cdata.set('abs_top_builddir', meson.build_root())
subdir('libpkgconf')
libtype = get_option('default_library')
if libtype == 'static'
build_static = '-DPKGCONFIG_IS_STATIC'
else
build_static = '-DPKGCONFIG_IS_NOT_STATIC'
endif
libpkgconf = library('pkgconf',
libpkgconf = shared_library('pkgconf',
'libpkgconf/argvsplit.c',
'libpkgconf/audit.c',
'libpkgconf/bsdstubs.c',
@ -88,60 +66,33 @@ libpkgconf = library('pkgconf',
'libpkgconf/dependency.c',
'libpkgconf/fileio.c',
'libpkgconf/fragment.c',
'libpkgconf/parser.c',
'libpkgconf/path.c',
'libpkgconf/personality.c',
'libpkgconf/pkg.c',
'libpkgconf/queue.c',
'libpkgconf/tuple.c',
c_args: ['-DLIBPKGCONF_EXPORT', build_static],
install : true,
version : '5.0.0',
soversion : '5',
)
# For other projects using libpkgconfig as a subproject
dep_libpkgconf = declare_dependency(
link_with : libpkgconf,
include_directories : include_directories('.'),
)
# If we have a new enough meson override the dependency so that only
# `dependency('libpkgconf')` is required from the consumer
if meson.version().version_compare('>= 0.54.0')
meson.override_dependency('libpkgconf', dep_libpkgconf)
endif
pkg = import('pkgconfig')
pkg.generate(libpkgconf,
name : 'libpkgconf',
description : 'a library for accessing and manipulating development framework configuration',
url: 'http://github.com/pkgconf/pkgconf',
filebase : 'libpkgconf',
subdirs: ['pkgconf'],
extra_cflags : build_static
version : '3.0.0',
soversion : '3',
)
pkgconf_exe = executable('pkgconf',
'cli/main.c',
'cli/getopt_long.c',
'cli/renderer-msvc.c',
'main.c',
'getopt_long.c',
'renderer-msvc.c',
link_with : libpkgconf,
c_args: build_static,
install : true)
with_tests = get_option('tests')
kyua_exe = find_program('kyua', required : with_tests, disabler : true)
atf_sh_exe = find_program('atf-sh', required : with_tests, disabler : true)
kyuafile = configure_file(input : 'Kyuafile.in', output : 'Kyuafile', configuration : cdata)
test('kyua', kyua_exe, args : ['--config=none', 'test', '--kyuafile', kyuafile, '--build-root', meson.current_build_dir()])
kyua_exe = find_program('kyua')
atf_sh_exe = find_program('atf-sh')
test('kyua', kyua_exe, args : ['--config=none', 'test', '--kyuafile=' + join_paths(meson.build_root(), 'Kyuafile'), '--build-root=' + meson.build_root()])
configure_file(input : 'Kyuafile.in', output : 'Kyuafile', configuration : cdata)
subdir('tests')
install_man('man/pkgconf.1')
install_man('man/pkg.m4.7')
install_man('man/pc.5')
install_man('man/pkgconf-personality.5')
install_data('pkg.m4', install_dir: 'share/aclocal')
install_data('AUTHORS', install_dir: 'share/doc/pkgconf')
install_data('README.md', install_dir: 'share/doc/pkgconf')

View File

@ -1,19 +0,0 @@
option(
'tests',
type: 'feature',
description: 'Build tests which depends upon the kyua framework',
)
option(
'with-system-libdir',
type: 'string',
value: '',
description: 'Specify the system library directory (default {prefix}/{libdir})'
)
option(
'with-system-includedir',
type: 'string',
value: '',
description: 'Specify the system include directory (default {prefix}/{includedir})'
)

47
pkg.m4
View File

@ -1,5 +1,5 @@
# pkg.m4 - Macros to locate and use pkg-config. -*- Autoconf -*-
# serial 12 (pkg-config-0.29.2)
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 11 (pkg-config-0.29.1)
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
@ -41,13 +41,13 @@ dnl
dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require.
m4_defun([PKG_PREREQ],
[m4_define([PKG_MACROS_VERSION], [0.29.2])
[m4_define([PKG_MACROS_VERSION], [0.29.1])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION], [ACTION-IF-NOT-FOUND])
dnl ---------------------------------------------------------
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
dnl ----------------------------------
dnl Since: 0.16
dnl
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
@ -55,12 +55,6 @@ dnl first found in the path. Checks that the version of pkg-config found
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
dnl used since that's the first version where most current features of
dnl pkg-config existed.
dnl
dnl If pkg-config is not found or older than specified, it will result
dnl in an empty PKG_CONFIG variable. To avoid widespread issues with
dnl scripts not checking it, ACTION-IF-NOT-FOUND defaults to aborting.
dnl You can specify [PKG_CONFIG=false] as an action instead, which would
dnl result in pkg-config tests failing, but no bogus error messages.
AC_DEFUN([PKG_PROG_PKG_CONFIG],
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
@ -81,9 +75,6 @@ if test -n "$PKG_CONFIG"; then
AC_MSG_RESULT([no])
PKG_CONFIG=""
fi
fi
if test -z "$PKG_CONFIG"; then
m4_default([$2], [AC_MSG_ERROR([pkg-config not found])])
fi[]dnl
])dnl PKG_PROG_PKG_CONFIG
@ -95,7 +86,7 @@ dnl Check to see whether a particular set of modules exists. Similar to
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
dnl
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
dnl only at the first occurrence in configure.ac, so if the first place
dnl only at the first occurence in configure.ac, so if the first place
dnl it's called might be skipped (such as if it is within an "if", you
dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS],
@ -151,7 +142,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no
AC_MSG_CHECKING([for $2])
AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
@ -161,17 +152,17 @@ and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.])
if test $pkg_failed = yes; then
AC_MSG_RESULT([no])
AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
# Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR(
m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met:
$$1_PKG_ERRORS
@ -182,8 +173,8 @@ installed software in a non-standard prefix.
_PKG_TEXT])[]dnl
])
elif test $pkg_failed = untried; then
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
@ -193,10 +184,10 @@ _PKG_TEXT
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
])
else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes])
$3
$3
fi[]dnl
])dnl PKG_CHECK_MODULES

View File

@ -149,6 +149,7 @@ msvc_renderer_render_buf(const pkgconf_list_t *list, char *buf, size_t buflen, b
{
cnt = pkgconf_strlcpy(bptr, ".lib", buf_remaining);
bptr += cnt;
buf_remaining -= cnt;
}
if (escape)

92
scripts/install_deps.sh Executable file
View File

@ -0,0 +1,92 @@
#! /bin/sh
# Copyright (c) 2012 Bryan Drewery <bryan@shatow.net>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer
# in this position and unchanged.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Install build dependencies for pkg on Mac or Linux (Debiaun/Ubuntu) systems.
#
# This script is primarily intended for travis CI to be able to setup the
# build environment.
#
# To run on a clean Ubuntu system, try something like this:
# export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
# sudo apt install liblua5.2-dev libsqlite3-dev
# sh -ex scripts/install_deps.sh
install_from_github() {
local name="${1}"
local ver="${2}"
local distname="${name}-${ver}"
# https://github.com/jmmv/kyua/releases/download/kyua-0.12/kyua-0.12.tar.gz
local url="https://github.com/jmmv/${name}"
wget "${url}/releases/download/${distname}/${distname}.tar.gz"
tar -xzvf "${distname}.tar.gz"
cd "${distname}"
./configure \
--disable-developer \
--without-atf \
--without-doxygen \
CPPFLAGS="-I/usr/local/include" \
LDFLAGS="-L/usr/local/lib -Wl,-R/usr/local/lib" \
PKG_CONFIG_PATH="/usr/local/lib/pkgconfig"
make -j2
$SUDO make install
cd -
rm -rf "${distname}" "${distname}.tar.gz"
}
SUDO=sudo
CFLAGS="-g -O2"
case $(uname -s) in
Darwin)
brew update
brew install libarchive --with-xz
brew install openssl
brew install kyua
;;
Linux)
install_from_github atf 0.21
install_from_github lutok 0.4
install_from_github kyua 0.12
;;
CYGWIN*)
SUDO=""
apt-cyg update
apt-cyg install lua-devel libsqlite3-devel
install_from_github lutok 0.4
# Work around
# utils/process/system.cpp:59:68: error: invalid conversion from pid_t (*)(pid_t, __wait_status_ptr_t, int) {aka int (*)(int, void*, int)} to pid_t (*)(pid_t, int*, int) {aka int (*)(int, int*, int)} [-fpermissive]
# pid_t (*detail::syscall_waitpid)(const pid_t, int*, const int) = ::waitpid;
# ^
# make[1]: *** [Makefile:7014: utils/process/libutils_a-system.o] Error 1
export CXXFLAGS="-g -O2 -fpermissive"
install_from_github kyua 0.12
unset CXXFLAGS
install_from_github atf 0.21
;;
esac

View File

@ -29,10 +29,6 @@ tests_init \
libs_circular_directpc \
libs_static \
libs_static_ordering \
libs_metapackage \
license_isc \
license_noassertion \
modversion_noflatten \
pkg_config_path \
nolibs \
nocflags \
@ -51,7 +47,7 @@ libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lfoo\n" \
-o inline:"-L/test/lib -lfoo \n" \
pkgconf --libs foo
}
@ -59,7 +55,7 @@ libs_cflags_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo\n" \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
pkgconf --cflags --libs foo
}
@ -68,7 +64,7 @@ libs_cflags_version_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo\n" \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
pkgconf --cflags --libs 'foo > 1.2'
}
@ -76,7 +72,7 @@ libs_cflags_version_multiple_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lbar -lfoo\n" \
-o inline:"-I/test/include/foo -fPIC -L/test/lib -lbar -lfoo \n" \
pkgconf --cflags --libs 'foo > 1.2 bar >= 1.3'
}
@ -84,7 +80,7 @@ libs_cflags_version_multiple_coma_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lbar -lfoo\n" \
-o inline:"-I/test/include/foo -fPIC -L/test/lib -lbar -lfoo \n" \
pkgconf --cflags --libs 'foo > 1.2,bar >= 1.3'
}
@ -92,7 +88,7 @@ libs_cflags_version_alt_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo\n" \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
pkgconf --cflags --libs 'foo' '>' '1.2'
}
@ -100,7 +96,7 @@ libs_cflags_version_different_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo\n" \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lfoo \n" \
pkgconf --cflags --libs 'foo' '!=' '1.3.0'
}
@ -180,7 +176,7 @@ exists_version_bad3_body()
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s exit:1 \
pkgconf --exists 'tilde >= 1.0.0'
pkgconf --exists 'tilde <= 1.0.0'
}
exists_body()
@ -194,7 +190,7 @@ exists2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
pkgconf --exists 'tilde <= 1.0.0'
pkgconf --exists 'tilde >= 1.0.0'
}
exists3_body()
@ -208,30 +204,30 @@ libs_intermediary_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lintermediary-1 -lintermediary-2 -lfoo -lbar -lbaz\n" \
-o inline:"-lintermediary-1 -lintermediary-2 -lfoo -lbar -lbaz \n" \
pkgconf --libs intermediary-1 intermediary-2
}
libs_circular2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"circular-1: breaking circular reference (circular-1 -> circular-2 -> circular-1)\n" \
pkgconf circular-2 --validate
}
libs_circular1_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"circular-3: breaking circular reference (circular-3 -> circular-1 -> circular-3)\n" \
pkgconf circular-1 --validate
-o inline:"-lcircular-1 -lcircular-2 -lcircular-3 \n" \
pkgconf --libs circular-1
}
libs_circular2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lcircular-3 -lcircular-1 -lcircular-2 \n" \
pkgconf --libs circular-3
}
libs_circular_directpc_body()
{
atf_check \
-o inline:"-lcircular-3 -lcircular-1 -lcircular-2\n" \
-o inline:"-lcircular-1 -lcircular-2 -lcircular-3 \n" \
pkgconf --libs ${selfdir}/lib1/circular-3.pc
}
@ -239,7 +235,7 @@ libs_static_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"/libfoo.a -pthread\n" \
-o inline:"/libfoo.a -pthread \n" \
pkgconf --libs static-archive-libs
}
@ -247,36 +243,28 @@ libs_static_ordering_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lbar -lfoo\n" \
-o inline:"-L/test/lib -lbar -lfoo \n" \
pkgconf --libs foo bar
}
libs_metapackage_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lbar -lfoo\n" \
pkgconf --static --libs metapackage-3
}
pkg_config_path_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1${PATH_SEP}${selfdir}/lib2"
atf_check \
-o inline:"-L/test/lib -lfoo\n" \
-o inline:"-L/test/lib -lfoo \n" \
pkgconf --libs foo
atf_check \
-o inline:"-L/test/lib -lbar -lfoo\n" \
-o inline:"-L/test/lib -lbar -lfoo \n" \
pkgconf --libs bar
}
with_path_body()
{
atf_check \
-o inline:"-L/test/lib -lfoo\n" \
-o inline:"-L/test/lib -lfoo \n" \
pkgconf --with-path=${selfdir}/lib1 --with-path=${selfdir}/lib2 --libs foo
atf_check \
-o inline:"-L/test/lib -lbar -lfoo\n" \
-o inline:"-L/test/lib -lbar -lfoo \n" \
pkgconf --with-path=${selfdir}/lib1 --with-path=${selfdir}/lib2 --libs bar
}
@ -300,7 +288,7 @@ arbitary_path_body()
{
cp ${selfdir}/lib1/foo.pc .
atf_check \
-o inline:"-L/test/lib -lfoo\n" \
-o inline:"-L/test/lib -lfoo \n" \
pkgconf --libs foo.pc
}
@ -319,24 +307,3 @@ single_depth_selectors_body()
-o inline:"foo\n" \
pkgconf --with-path=${selfdir}/lib3 --print-requires bar
}
license_isc_body()
{
atf_check \
-o inline:"foo: ISC\n" \
pkgconf --with-path=${selfdir}/lib1 --license foo
}
license_noassertion_body()
{
atf_check \
-o inline:"bar: NOASSERTION\nfoo: ISC\n" \
pkgconf --with-path=${selfdir}/lib1 --license bar
}
modversion_noflatten_body()
{
atf_check \
-o inline:"1.3\n" \
pkgconf --with-path=${selfdir}/lib1 --modversion bar
}

View File

@ -10,7 +10,7 @@ libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lconflicts\n" \
-o inline:"-L/test/lib -lconflicts \n" \
pkgconf --libs conflicts
}
@ -18,6 +18,6 @@ ignore_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lconflicts\n" \
-o inline:"-L/test/lib -lconflicts \n" \
pkgconf --ignore-conflicts --libs conflicts
}

View File

@ -9,12 +9,12 @@ libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-F/test/lib -framework framework-1\n" \
-o inline:"-F/test/lib -framework framework-1 \n" \
pkgconf --libs framework-1
atf_check \
-o inline:"-F/test/lib -framework framework-2 -framework framework-1\n" \
-o inline:"-F/test/lib -framework framework-2 -framework framework-1 \n" \
pkgconf --libs framework-2
atf_check \
-o inline:"-F/test/lib -framework framework-2 -framework framework-1\n" \
-o inline:"-F/test/lib -framework framework-2 -framework framework-1 \n" \
pkgconf --libs framework-1 framework-2
}

View File

@ -1,13 +0,0 @@
v9=lol
v8=${v9}${v9}${v9}${v9}${v9}${v9}${v9}${v9}${v9}${v9}
v7=${v8}${v8}${v8}${v8}${v8}${v8}${v8}${v8}${v8}${v8}
v6=${v7}${v7}${v7}${v7}${v7}${v7}${v7}${v7}${v7}${v7}
v5=${v6}${v6}${v6}${v6}${v6}${v6}${v6}${v6}${v6}${v6}
v4=${v5}${v5}${v5}${v5}${v5}${v5}${v5}${v5}${v5}${v5}
v3=${v4}${v4}${v4}${v4}${v4}${v4}${v4}${v4}${v4}${v4}
v2=${v3}${v3}${v3}${v3}${v3}${v3}${v3}${v3}${v3}${v3}
v1=${v2}${v2}${v2}${v2}${v2}${v2}${v2}${v2}${v2}${v2}
v0=${v1}${v1}${v1}${v1}${v1}${v1}${v1}${v1}${v1}${v1}
Name: One Billion Laughs
Version: ${v0}
Description: Don't install this!

View File

@ -1,9 +0,0 @@
prefix=/test/local
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: cflags-internal
Description: A testing pkg-config file
Version: 1.2.3
Cflags: -I${includedir}/foo

View File

@ -1,6 +0,0 @@
xcflags=
Name: empty-tuple
Description: testing file
Version: 1
CFlags: ${xcflags}

View File

@ -9,4 +9,3 @@ Version: 1.2.3
Libs: -L${libdir} -lfoo
Cflags: -fPIC -I${includedir}/foo
Cflags.private: -DFOO_STATIC
License: ISC

View File

@ -1,12 +0,0 @@
prefix=/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: foobar
Description: A testing pkg-config file
Version: 3.2.1
Libs: -L${libdir} -lfoobar
Cflags: -fPIC -I${includedir}/foobar
Cflags.private: -DFOOBAR_STATIC
License: ISC

View File

@ -1,4 +0,0 @@
Name: fragment-comment
Description: Test case for issue #215
Version: 1.0
Cflags: kuku=\#ttt

View File

@ -1,5 +0,0 @@
Name: malformed-version
Version: 3.922 2018-03-17
Description: None.
Cflags: -Ifoo
Libs: -lbar

View File

@ -1,6 +0,0 @@
Name: metapackage-1
Version: 0.1
Description: metapackage for testing purposes
Requires.private: metapackage-2
Libs: -lmetapackage-1
Cflags: -I/metapackage-1

View File

@ -1,5 +0,0 @@
Name: metapackage-2
Version: 0.1
Description: metapackage for testing purposes
Libs: -lmetapackage-2
Cflags: -I/metapackage-2

View File

@ -1,4 +0,0 @@
Name: metapackage-3
Version: 0.1
Description: metapackage for testing purposes
Requires.private: bar

View File

@ -1,4 +0,0 @@
Name: metapackage
Version: 0.1
Description: metapackage for testing purposes
Requires: metapackage-1, metapackage-2

View File

@ -1,9 +0,0 @@
prefix=/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: multiline
Description: A multiline
description blah blah blah
Version: 1.2.3

View File

@ -1,10 +0,0 @@
prefix=${pc_sysrootdir}/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: omg-sysroot
Description: A testing pkg-config file
Version: 1.2.3
Libs: -L${libdir} -lomg
Cflags: -fPIC -I${includedir}/omg

View File

@ -1,8 +0,0 @@
Name: orphaned-requires-private
Version: 1
Description: A testing module for pkgconf
URL: http://www.pkgconf.org/
Requires: foo
Requires.private: orphaned-foo
Cflags: -DUNREACHABLE
Libs:

View File

@ -7,4 +7,4 @@ Name: quotes
Description: A testing pkg-config file
Version: 1.2.3
Libs: -L${libdir} -lfoo
Cflags: -DQUOTED=\"bla\" -DA=\"escaped\ string\'\ \literal\" -DB="\1\$" -DC='bla'
Cflags: -DQUOTED=\"bla\"

View File

@ -1,9 +0,0 @@
prefix=/test/local
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: requires-internal
Description: A testing pkg-config file
Version: 1.2.3
Requires.internal: cflags-internal

View File

@ -1,10 +0,0 @@
prefix=/test/local
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: requires-internal
Description: A testing pkg-config file
Version: 1.2.3
Requires.internal: cflags-internal
Requires.private: cflags-internal

View File

@ -1,10 +0,0 @@
prefix=/test/local
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: requires-internal
Description: A testing pkg-config file
Version: 1.2.3
Requires.internal: static-libs, missing
Requires.private: foo

View File

@ -1,10 +0,0 @@
prefix=/test/local
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: requires-internal
Description: A testing pkg-config file
Version: 1.2.3
Requires.internal: static-libs
Requires.private: foo

View File

@ -1,7 +0,0 @@
prefix=/test\ with\ spaces
includedir=${prefix}/include
Name: spaces-in-paths
Version: 1
Description: test package for properly expanding spaces in variables
Cflags: -I${includedir} -I${includedir}/subdir

View File

@ -1,7 +0,0 @@
prefix=${pc_sysrootdir}/usr
Name: sysroot-dir
Description: Package for testing whether sysroot dirs are repeated or not
Version: 1
CFlags: -I${prefix}/include
Libs: -L${prefix}/lib -lfoo

View File

@ -1,9 +0,0 @@
prefix=/sysroot/usr
includedir=${prefix}/include
libdir=${prefix}/lib
Name: sysroot-dir
Description: Package for testing whether sysroot dirs are repeated or not
Version: 1
CFlags: -I${includedir}
Libs: -L${libdir} -lfoo

View File

@ -1,9 +0,0 @@
prefix=${pc_sysrootdir}/usr
includedir=${prefix}/include
libdir=${prefix}/lib
Name: sysroot-dir
Description: Package for testing whether sysroot dirs are repeated or not
Version: 1
CFlags: -I${includedir}
Libs: -L${libdir} -lfoo

View File

@ -1,9 +0,0 @@
prefix=/sysroot/usr
includedir=${prefix}/include
libdir=${prefix}/lib
Name: sysroot-dir
Description: Package for testing whether sysroot dirs are repeated or not
Version: 1
CFlags: -I${includedir}
Libs: -L${libdir} -lfoo

View File

@ -1,7 +0,0 @@
prefix="/test"
libdir=${prefix}/lib
Name: tuple-quoting
Description: Another pkg-config test
Version: 1.3
Libs: -L${libdir} -lfoo

View File

@ -1,11 +0,0 @@
prefix=/test
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: unavailable_provider
Description: Provides an otherwise unavailable package
Version: 1.2.3
Provides: unavailable = 1.2.3
Libs: -lunavailable
Cflags:

View File

@ -1,10 +0,0 @@
prefix=/tëst
exec_prefix=${prefix}
libdir=${prefix}/lib
includedir=${prefix}/include
Name: utf8
Description: Library installed in a prefix with UTF-8
Version: 0
Libs: -L${libdir} -lutf8
Cflags: -I${includedir}

View File

@ -18,5 +18,6 @@ tests = [
# yuck
foreach test : tests
test_file = configure_file(input: test + '.sh', output: test, copy: true)
configure_file(input: test + '.sh', output: test, configuration: configuration_data())
run_command('chmod', '755', join_paths(meson.build_root(), 'tests', test))
endforeach

View File

@ -13,7 +13,6 @@ tests_init \
tilde_quoting \
paren_quoting \
multiline_field \
multiline_bogus_header \
escaped_backslash \
flag_order_1 \
flag_order_2 \
@ -29,19 +28,14 @@ tests_init \
fragment_quoting_3 \
fragment_quoting_5 \
fragment_quoting_7 \
fragment_comment \
msvc_fragment_quoting \
msvc_fragment_render_cflags \
tuple_dequote \
version_with_whitespace \
version_with_whitespace_2 \
version_with_whitespace_diagnostic
msvc_fragment_render_cflags
comments_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lfoo\n" \
-o inline:"-lfoo \n" \
pkgconf --libs comments
}
@ -49,7 +43,7 @@ comments_in_fields_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lfoo\n" \
-o inline:"-lfoo \n" \
pkgconf --libs comments-in-fields
}
@ -57,7 +51,7 @@ dos_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib/dos-lineendings -ldos-lineendings\n" \
-o inline:"-L/test/lib/dos-lineendings -ldos-lineendings \n" \
pkgconf --libs dos-lineendings
}
@ -65,7 +59,7 @@ no_trailing_newline_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/test/include/no-trailing-newline\n" \
-o inline:"-I/test/include/no-trailing-newline \n" \
pkgconf --cflags no-trailing-newline
}
@ -73,7 +67,7 @@ argv_parse_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-llib-3 -llib-1 -llib-2 -lpthread\n" \
-o inline:"-llib-3 -llib-1 -llib-2 -lpthread \n" \
pkgconf --libs argv-parse
}
@ -90,7 +84,7 @@ argv_parse_3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-llib-1 -pthread /test/lib/lib2.so\n" \
-o inline:"-llib-1 -pthread /test/lib/lib2.so \n" \
pkgconf --libs argv-parse-3
}
@ -98,10 +92,10 @@ tilde_quoting_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L~ -ltilde\n" \
-o inline:"-L~ -ltilde \n" \
pkgconf --libs tilde-quoting
atf_check \
-o inline:"-I~\n" \
-o inline:"-I~ \n" \
pkgconf --cflags tilde-quoting
}
@ -109,7 +103,7 @@ paren_quoting_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L\$(libdir) -ltilde\n" \
-o inline:"-L\$(libdir) -ltilde \n" \
pkgconf --libs paren-quoting
}
@ -122,19 +116,11 @@ multiline_field_body()
pkgconf --list-all
}
multiline_bogus_header_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-s eq:0 \
pkgconf --exists multiline-bogus
}
escaped_backslash_body()
{
atf_check \
-e ignore \
-o inline:"-IC:\\\\\\\\A\n" \
-o inline:"-IC:\\\\\\\\A \n" \
pkgconf --with-path=${selfdir}/lib1 --cflags escaped-backslash
}
@ -142,7 +128,7 @@ quoted_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-DQUOTED=\\\"bla\\\" -DA=\\\"escaped\\ string\\\'\\ literal\\\" -DB=\\\\\\1\$ -DC=bla\n" \
-o inline:"-DQUOTED=\\\"bla\\\" \n" \
pkgconf --cflags quotes
}
@ -150,7 +136,7 @@ flag_order_1_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -Bdynamic -lfoo -Bstatic -lbar\n" \
-o inline:"-L/test/lib -Bdynamic -lfoo -Bstatic -lbar \n" \
pkgconf --libs flag-order-1
}
@ -158,7 +144,7 @@ flag_order_2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -Bdynamic -lfoo -Bstatic -lbar -lfoo\n" \
-o inline:"-L/test/lib -Bdynamic -lfoo -Bstatic -lbar -lfoo \n" \
pkgconf --libs flag-order-1 foo
}
@ -166,7 +152,7 @@ flag_order_3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -Wl,--start-group -lfoo -lbar -Wl,--end-group\n" \
-o inline:"-L/test/lib -Wl,--start-group -lfoo -lbar -Wl,--end-group \n" \
pkgconf --libs flag-order-3
}
@ -174,7 +160,7 @@ flag_order_4_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -Wl,--start-group -lfoo -lbar -Wl,--end-group -lfoo\n" \
-o inline:"-L/test/lib -Wl,--start-group -lfoo -lbar -Wl,--end-group -lfoo \n" \
pkgconf --libs flag-order-3 foo
}
@ -182,7 +168,7 @@ variable_whitespace_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/test/include\n" \
-o inline:"-I/test/include \n" \
pkgconf --cflags variable-whitespace
}
@ -190,7 +176,7 @@ fragment_quoting_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=\\\"/test/share/doc\\\"\n" \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=\\\"/test/share/doc\\\" \n" \
pkgconf --cflags fragment-quoting
}
@ -198,7 +184,7 @@ fragment_quoting_2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=/test/share/doc\n" \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=/test/share/doc \n" \
pkgconf --cflags fragment-quoting-2
}
@ -206,7 +192,7 @@ fragment_quoting_3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=\\\"/test/share/doc\\\"\n" \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=\\\"/test/share/doc\\\" \n" \
pkgconf --cflags fragment-quoting-3
}
@ -214,7 +200,7 @@ fragment_quoting_5_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=/test/share/doc\n" \
-o inline:"-fPIC -I/test/include/foo -DQUOTED=/test/share/doc \n" \
pkgconf --cflags fragment-quoting-5
}
@ -222,28 +208,28 @@ fragment_quoting_7_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\\ world\n" \
-o inline:"-Dhello=10 -Dworld=+32 -DDEFINED_FROM_PKG_CONFIG=hello\\ world \n" \
pkgconf --cflags fragment-quoting-7
}
fragment_escaping_1_body()
{
atf_check \
-o inline:"-IC:\\\\\\\\D\\ E\n" \
-o inline:"-IC:\\\\\\\\D\\ E \n" \
pkgconf --with-path="${selfdir}/lib1" --cflags fragment-escaping-1
}
fragment_escaping_2_body()
{
atf_check \
-o inline:"-IC:\\\\\\\\D\\ E\n" \
-o inline:"-IC:\\\\\\\\D\\ E \n" \
pkgconf --with-path="${selfdir}/lib1" --cflags fragment-escaping-2
}
fragment_escaping_3_body()
{
atf_check \
-o inline:"-IC:\\\\\\\\D\\ E\n" \
-o inline:"-IC:\\\\\\\\D\\ E \n" \
pkgconf --with-path="${selfdir}/lib1" --cflags fragment-escaping-3
}
@ -265,14 +251,6 @@ fragment_quoting_7a_body()
set +x
}
fragment_comment_body()
{
atf_check \
-o inline:'kuku=\#ttt\n' \
pkgconf --with-path="${selfdir}/lib1" --cflags fragment-comment
}
msvc_fragment_quoting_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
@ -288,31 +266,3 @@ msvc_fragment_render_cflags_body()
-o inline:'/I/test/include/foo /DFOO_STATIC \n' \
pkgconf --cflags --static --msvc-syntax foo
}
tuple_dequote_body()
{
atf_check \
-o inline:'-L/test/lib -lfoo\n' \
pkgconf --with-path="${selfdir}/lib1" --libs tuple-quoting
}
version_with_whitespace_body()
{
atf_check \
-o inline:'3.922\n' \
pkgconf --with-path="${selfdir}/lib1" --modversion malformed-version
}
version_with_whitespace_2_body()
{
atf_check \
-o inline:'malformed-version = 3.922\n' \
pkgconf --with-path="${selfdir}/lib1" --print-provides malformed-version
}
version_with_whitespace_diagnostic_body()
{
atf_check \
-o match:warning \
pkgconf --with-path="${selfdir}/lib1" --validate malformed-version
}

View File

@ -9,8 +9,7 @@ tests_init \
baz \
quux \
moo \
meow \
indirect_dependency_node
meow
simple_body()
{
@ -27,7 +26,7 @@ provides = 1.2.3
-o inline:"${OUTPUT}" \
pkgconf --print-provides provides
atf_check \
-o inline:"-lfoo\n" \
-o inline:"-lfoo \n" \
pkgconf --libs provides-request-simple
atf_check \
-e ignore \
@ -297,14 +296,3 @@ meow_body()
-o ignore \
pkgconf --libs 'provides-test-meow < 1.2.9'
}
indirect_dependency_node_body()
{
atf_check \
-o inline:'1.2.3\n' \
pkgconf --with-path="${selfdir}/lib1" --modversion 'provides-test-meow'
atf_check \
-s exit:1 \
-e ignore \
pkgconf --with-path="${selfdir}/lib1" --modversion 'provides-test-meow = 1.3.0'
}

View File

@ -8,7 +8,6 @@ tests_init \
depgraph_break_2 \
depgraph_break_3 \
define_variable \
define_variable_override \
variable \
keep_system_libs \
libs \
@ -23,24 +22,13 @@ tests_init \
idirafter_munge_order \
idirafter_munge_sysroot \
idirafter_ordering \
modversion_common_prefix \
modversion_fullpath \
modversion_provides \
modversion_uninstalled \
modversion_one_word_expression \
modversion_two_word_expression \
modversion_three_word_expression \
pcpath \
sysroot_munge \
virtual_variable \
fragment_collision \
malformed_1 \
malformed_quoting \
explicit_sysroot \
empty_tuple \
solver_requires_private_debounce \
billion_laughs
# sysroot_munge \
explicit_sysroot
case_sensitivity_body()
{
@ -81,13 +69,6 @@ define_variable_body()
pkgconf --variable=typelibdir --define-variable='libdir=\${libdir}' typelibdir
}
define_variable_override_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check -o inline:"/test\n" \
pkgconf --variable=prefix --define-variable='prefix=/test' typelibdir
}
variable_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
@ -98,14 +79,13 @@ variable_body()
keep_system_libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
eval export "$LIBRARY_PATH_ENV"="/test/local/lib"
export PKG_CONFIG_PATH="${selfdir}/lib1" LIBRARY_PATH="/test/local/lib"
atf_check \
-o inline:"\n" \
pkgconf --libs-only-L cflags-libs-only
atf_check \
-o inline:"-L/test/local/lib\n" \
-o inline:"-L/test/local/lib \n" \
pkgconf --libs-only-L --keep-system-libs cflags-libs-only
}
@ -113,7 +93,7 @@ libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/local/lib -lfoo\n" \
-o inline:"-L/test/local/lib -lfoo \n" \
pkgconf --libs cflags-libs-only
}
@ -121,7 +101,7 @@ libs_only_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/local/lib -lfoo\n" \
-o inline:"-L/test/local/lib -lfoo \n" \
pkgconf --libs-only-L --libs-only-l cflags-libs-only
}
@ -129,10 +109,10 @@ libs_never_mergeback_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/bar/lib -lfoo1\n" \
pkgconf --libs prefix-foo1
-o inline:"-L/test/bar/lib -lfoo1 \n" \
pkgconf --libs prefix-foo1
atf_check \
-o inline:"-L/test/bar/lib -lfoo1 -lfoo2\n" \
-o inline:"-L/test/bar/lib -lfoo1 -lfoo2 \n" \
pkgconf --libs prefix-foo1 prefix-foo2
}
@ -140,7 +120,7 @@ cflags_only_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/test/local/include/foo\n" \
-o inline:"-I/test/local/include/foo \n" \
pkgconf --cflags-only-I --cflags-only-other cflags-libs-only
}
@ -148,7 +128,7 @@ cflags_never_mergeback_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/test/bar/include/foo -DBAR -fPIC -DFOO\n" \
-o inline:"-I/test/bar/include/foo -DBAR -fPIC -DFOO \n" \
pkgconf --cflags prefix-foo1 prefix-foo2
}
@ -172,15 +152,15 @@ isystem_munge_order_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-isystem /opt/bad/include -isystem /opt/bad2/include\n" \
-o inline:"-isystem /opt/bad/include -isystem /opt/bad2/include \n" \
pkgconf --cflags isystem
}
isystem_munge_sysroot_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1" PKG_CONFIG_SYSROOT_DIR="${selfdir}"
export PKG_CONFIG_PATH="${selfdir}/lib1" PKG_CONFIG_SYSROOT_DIR='/test'
atf_check \
-o match:"-isystem ${selfdir}/opt/bad/include" \
-o match:"-isystem /test/opt/bad/include" \
pkgconf --cflags isystem
}
@ -188,15 +168,15 @@ idirafter_munge_order_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-idirafter /opt/bad/include -idirafter /opt/bad2/include\n" \
-o inline:"-idirafter /opt/bad/include -idirafter /opt/bad2/include \n" \
pkgconf --cflags idirafter
}
idirafter_munge_sysroot_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1" PKG_CONFIG_SYSROOT_DIR="${selfdir}"
export PKG_CONFIG_PATH="${selfdir}/lib1" PKG_CONFIG_SYSROOT_DIR='/test'
atf_check \
-o match:"-idirafter ${selfdir}/opt/bad/include" \
-o match:"-idirafter /test/opt/bad/include" \
pkgconf --cflags idirafter
}
@ -204,7 +184,7 @@ idirafter_ordering_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-I/opt/bad/include1 -idirafter -I/opt/bad/include2 -I/opt/bad/include3\n" \
-o inline:"-I/opt/bad/include1 -idirafter -I/opt/bad/include2 -I/opt/bad/include3 \n" \
pkgconf --cflags idirafter-ordering
}
@ -212,17 +192,21 @@ pcpath_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib2"
atf_check \
-o inline:"-fPIC -I/test/include/foo\n" \
pkgconf --cflags ${selfdir}/lib3/bar.pc
-o inline:"-fPIC -I/test/include/foo \n" \
pkgconf --cflags ${selfdir}/lib3/bar.pc
}
sysroot_munge_body()
{
sed "s|/sysroot/|${selfdir}/|g" ${selfdir}/lib1/sysroot-dir.pc > ${selfdir}/lib1/sysroot-dir-selfdir.pc
export PKG_CONFIG_PATH="${selfdir}/lib1" PKG_CONFIG_SYSROOT_DIR="${selfdir}"
export PKG_CONFIG_PATH="${selfdir}/lib1" PKG_CONFIG_SYSROOT_DIR="/sysroot"
atf_check \
-o inline:"-L${selfdir}/lib -lfoo\n" \
pkgconf --libs sysroot-dir-selfdir
-o inline:"-L/sysroot/lib -lfoo \n" \
pkgconf --libs sysroot-dir
export PKG_CONFIG_SYSROOT_DIR="/sysroot2"
atf_check \
-o inline:"-L/sysroot2/sysroot/lib -lfoo \n" \
pkgconf --libs sysroot-dir
}
virtual_variable_body()
@ -240,7 +224,7 @@ virtual_variable_body()
fragment_collision_body()
{
atf_check -o inline:"-D_BAZ -D_BAR -D_FOO -D_THREAD_SAFE -pthread\n" \
atf_check -o inline:"-D_BAZ -D_BAR -D_FOO -D_THREAD_SAFE -pthread \n" \
pkgconf --with-path="${selfdir}/lib1" --cflags fragment-collision
}
@ -258,67 +242,7 @@ malformed_quoting_body()
explicit_sysroot_body()
{
export PKG_CONFIG_SYSROOT_DIR=${selfdir}
atf_check -o inline:"${selfdir}/usr/share/test\n" \
export PKG_CONFIG_SYSROOT_DIR=/sysroot
atf_check -o inline:"/sysroot/usr/share/test\n" \
pkgconf --with-path="${selfdir}/lib1" --variable=pkgdatadir explicit-sysroot
}
empty_tuple_body()
{
atf_check -o inline:"\n" \
pkgconf --with-path="${selfdir}/lib1" --cflags empty-tuple
}
solver_requires_private_debounce_body()
{
atf_check -o inline:"-I/metapackage-1 -I/metapackage-2 -lmetapackage-1 -lmetapackage-2\n" \
pkgconf --with-path="${selfdir}/lib1" --cflags --libs metapackage
}
billion_laughs_body()
{
atf_check -o inline:"warning: truncating very long variable to 64KB\nwarning: truncating very long variable to 64KB\nwarning: truncating very long variable to 64KB\nwarning: truncating very long variable to 64KB\nwarning: truncating very long variable to 64KB\n" \
pkgconf --with-path="${selfdir}/lib1" --validate billion-laughs
}
modversion_common_prefix_body()
{
atf_check -o inline:"foo: 1.2.3\nfoobar: 3.2.1\n" \
pkgconf --with-path="${selfdir}/lib1" --modversion --verbose foo foobar
}
modversion_fullpath_body()
{
atf_check -o inline:"1.2.3\n" \
pkgconf --modversion "${selfdir}/lib1/foo.pc"
}
modversion_provides_body()
{
atf_check -o inline:"1.2.3\n" \
pkgconf --with-path="${selfdir}/lib1" --modversion unavailable
}
modversion_uninstalled_body()
{
atf_check -o inline:"1.2.3\n" \
pkgconf --with-path="${selfdir}/lib1" --modversion omg
}
modversion_one_word_expression_body()
{
atf_check -o inline:"1.2.3\n" \
pkgconf --with-path="${selfdir}/lib1" --modversion "foo > 1.0"
}
modversion_two_word_expression_body()
{
atf_check -o inline:"1.2.3\n" \
pkgconf --with-path="${selfdir}/lib1" --modversion foo "> 1.0"
}
modversion_three_word_expression_body()
{
atf_check -o inline:"1.2.3\n" \
pkgconf --with-path="${selfdir}/lib1" --modversion foo ">" 1.0
}

View File

@ -10,22 +10,14 @@ tests_init \
argv_parse2 \
static_cflags \
private_duplication \
private_duplication_digraph \
foo_bar \
bar_foo \
foo_metapackage_3 \
libs_static2 \
missing \
requires_internal \
requires_internal_missing \
requires_internal_collision \
orphaned_requires_private
missing
libs_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lbar -lfoo\n" \
-o inline:"-L/test/lib -lbar -lfoo \n" \
pkgconf --libs bar
}
@ -33,7 +25,7 @@ libs_cflags_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lbaz\n" \
-o inline:"-fPIC -I/test/include/foo -L/test/lib -lbaz \n" \
pkgconf --libs --cflags baz
}
@ -41,7 +33,7 @@ libs_static_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lbaz -L/test/lib -lzee -lfoo\n" \
-o inline:"-L/test/lib -lbaz -L/test/lib -lzee -L/test/lib -lfoo \n" \
pkgconf --static --libs baz
}
@ -49,7 +41,7 @@ libs_static_pure_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-L/test/lib -lbaz -lfoo\n" \
-o inline:"-L/test/lib -lbaz -L/test/lib -lfoo \n" \
pkgconf --static --pure --libs baz
}
@ -57,7 +49,7 @@ argv_parse2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-llib-1 -pthread /test/lib/lib2.so\n" \
-o inline:"-llib-1 -pthread /test/lib/lib2.so \n" \
pkgconf --static --libs argv-parse-2
}
@ -65,7 +57,7 @@ static_cflags_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-fPIC -I/test/include/foo -DFOO_STATIC\n" \
-o inline:"-fPIC -I/test/include/foo -DFOO_STATIC \n" \
pkgconf --static --cflags baz
}
@ -73,51 +65,15 @@ private_duplication_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lprivate -lbaz -lzee -lbar -lfoo\n" \
-o inline:"-lprivate -lfoo -lbaz -lzee -lbar -lfoo \n" \
pkgconf --static --libs-only-l private-libs-duplication
}
private_duplication_digraph_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o 'match:"user:request" -> "private-libs-duplication"' \
-o 'match:"private-libs-duplication" -> "bar"' \
-o 'match:"private-libs-duplication" -> "baz"' \
-o 'match:"bar" -> "foo"' \
-o 'match:"baz" -> "foo"' \
pkgconf --static --libs-only-l private-libs-duplication --digraph
}
bar_foo_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lbar -lfoo\n" \
pkgconf --static --libs-only-l bar foo
}
foo_bar_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lbar -lfoo\n" \
pkgconf --static --libs-only-l foo bar
}
foo_metapackage_3_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lbar -lfoo\n" \
pkgconf --static --libs-only-l foo metapackage-3
}
libs_static2_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
atf_check \
-o inline:"-lbar -lbar-private -L/test/lib -lfoo\n" \
-o inline:"-lbar -lbar-private -L/test/lib -lfoo \n" \
pkgconf --static --libs static-libs
}
@ -127,38 +83,6 @@ missing_body()
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
-o inline:"\n" \
pkgconf --cflags missing-require
}
requires_internal_body()
{
atf_check \
-o inline:"-lbar -lbar-private -L/test/lib -lfoo\n" \
pkgconf --with-path="${selfdir}/lib1" --static --libs requires-internal
}
requires_internal_missing_body()
{
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --with-path="${selfdir}/lib1" --static --libs requires-internal-missing
}
requires_internal_collision_body()
{
atf_check \
-o inline:"-I/test/local/include/foo\n" \
pkgconf --with-path="${selfdir}/lib1" --cflags requires-internal-collision
}
orphaned_requires_private_body()
{
atf_check \
-s exit:1 \
-e ignore \
-o ignore \
pkgconf --with-path="${selfdir}/lib1" --cflags --libs orphaned-requires-private
}

View File

@ -6,18 +6,13 @@ tests_init \
cflags \
variable \
do_not_eat_slash \
do_not_duplicate_sysroot_dir \
uninstalled \
uninstalled_pkgconf1 \
uninstalled_fdo \
uninstalled_fdo_pc_sysrootdir
do_not_eat_slash_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
export PKG_CONFIG_SYSROOT_DIR="/"
atf_check \
-o inline:"-fPIC -I/test/include/foo\n" \
-o inline:"-fPIC -I/test/include/foo \n" \
pkgconf --cflags baz
}
@ -26,7 +21,7 @@ cflags_body()
export PKG_CONFIG_PATH="${selfdir}/lib1"
export PKG_CONFIG_SYSROOT_DIR="${SYSROOT_DIR}"
atf_check \
-o inline:"-fPIC -I${SYSROOT_DIR}/test/include/foo\n" \
-o inline:"-fPIC -I${SYSROOT_DIR}/test/include/foo \n" \
pkgconf --cflags baz
}
@ -41,70 +36,3 @@ variable_body()
-o inline:"${SYSROOT_DIR}/test/include\n" \
pkgconf --variable=includedir foo
}
do_not_duplicate_sysroot_dir_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
export PKG_CONFIG_SYSROOT_DIR="/sysroot"
atf_check \
-o inline:"-I/sysroot/usr/include\n" \
pkgconf --cflags sysroot-dir-2
atf_check \
-o inline:"-I/sysroot/usr/include\n" \
pkgconf --cflags sysroot-dir-3
atf_check \
-o inline:"-I/sysroot/usr/include\n" \
pkgconf --cflags sysroot-dir-5
export PKG_CONFIG_SYSROOT_DIR="${SYSROOT_DIR}"
atf_check \
-o inline:"-I${SYSROOT_DIR}/usr/include\n" \
pkgconf --cflags sysroot-dir-4
}
uninstalled_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
export PKG_CONFIG_SYSROOT_DIR="/sysroot"
atf_check \
-o inline:"-L/test/lib -lomg\n" \
pkgconf --libs omg
}
uninstalled_pkgconf1_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
export PKG_CONFIG_SYSROOT_DIR="/sysroot"
export PKG_CONFIG_PKGCONF1_SYSROOT_RULES="1"
atf_check \
-o inline:"-L/sysroot/test/lib -lomg\n" \
pkgconf --libs omg
}
uninstalled_fdo_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
export PKG_CONFIG_SYSROOT_DIR="/sysroot"
export PKG_CONFIG_FDO_SYSROOT_RULES="1"
atf_check \
-o inline:"-L/test/lib -lomg\n" \
pkgconf --libs omg
}
uninstalled_fdo_pc_sysrootdir_body()
{
export PKG_CONFIG_PATH="${selfdir}/lib1"
export PKG_CONFIG_SYSROOT_DIR="/sysroot"
export PKG_CONFIG_FDO_SYSROOT_RULES="1"
atf_check \
-o inline:"-L/sysroot/test/lib -lomg\n" \
pkgconf --libs omg-sysroot
}

View File

@ -22,11 +22,10 @@ done
#--- end kludge ---
selfdir="@abs_top_srcdir@/tests"
LIBRARY_PATH_ENV="LIBRARY_PATH"
PATH_SEP=":"
SYSROOT_DIR="${selfdir}"
SYSROOT_DIR="${selfdir}/test"
case "$(uname -s)" in
Haiku) LIBRARY_PATH_ENV="BELIBRARIES";;
Msys|CYGWIN*) PATH_SEP=";";;
esac
prefix="@prefix@"