Skip to content

Add pkg-config files for ports #24426

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ See docs/process.md for more on how version tagging works.

4.0.10 (in development)
----------------------
- Emscripten ports now install pkg-config `.pc` files so they will show up, for
example, when you run `pkg-config --list-all` or `pkg-config --cflags
<portname>`. Bare in mind that the correct PKG_CONFIG_PATH needs to be set for
this to work. One way to do this is to run `emmake pkg-config`. (#24426)
- libcxx, libcxxabi, and compiler-rt were updated to LLVM 20.1.4. (#24346 and
#24357)
- Emscripten will not longer generate trampoline functions for Wasm exports
Expand Down
3 changes: 2 additions & 1 deletion system/lib/pkgconfig/sdl.pc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Name: sdl
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
Version: 1.2.15
Cflags: -D_GNU_SOURCE=1 -D_REENTRANT
Libs: -sUSE_SDL
Cflags: -sUSE_SDL
13 changes: 11 additions & 2 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,8 +1088,17 @@ def test_pkg_config_packages(self):
('sdl', '1.2.15'),
]
for package, version in packages:
out = self.run_process([emmake, 'pkg-config', '--modversion', package], stdout=PIPE).stdout
self.assertContained(version, out)
out = self.run_process([emmake, 'pkg-config', '--modversion', package], stdout=PIPE).stdout
self.assertContained(version, out)

@requires_pkg_config
@crossplatform
def test_pkg_config_ports(self):
self.run_process([EMBUILDER, 'build', 'bullet'])
out = self.run_process([emmake, 'pkg-config', '--list-all'], stdout=PIPE).stdout
self.assertContained('bullet', out)
out = self.run_process([emmake, 'pkg-config', '--cflags', 'bullet'], stdout=PIPE).stdout
self.assertContained('-sUSE_BULLET', out)

@parameterized({
'': [None],
Expand Down
12 changes: 12 additions & 0 deletions tools/ports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,18 @@ def write_file(filename, contents):
return
utils.write_file(filename, contents)

@staticmethod
def make_pkg_config(name, version, flags):
pkgconfig_dir = cache.get_sysroot_dir('lib/pkgconfig')
filename = os.path.join(pkgconfig_dir, name + '.pc')
Ports.write_file(filename, f'''
Name: {name}
Description: {name} port from emscripten
Version: {version}
Libs: {flags}
Cflags: {flags}
''')


class OrderedSet:
"""Partial implementation of OrderedSet. Just enough for what we need here."""
Expand Down
4 changes: 2 additions & 2 deletions tools/ports/bullet.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def create(final):
'-Wno-int-to-void-pointer-cast',
'-std=gnu++14',
]

ports.make_pkg_config('bullet', TAG, '-sUSE_BULLET')
ports.build_port(src_path, final, 'bullet', includes=includes, flags=flags, exclude_dirs=['MiniCL'])

return [shared.cache.get_lib('libbullet.a', create)]
Expand All @@ -57,4 +57,4 @@ def process_args(ports):


def show():
return 'bullet (-sUSE_BULLET=1 or --use-port=bullet; zlib license)'
return 'bullet (-sUSE_BULLET or --use-port=bullet; zlib license)'
3 changes: 2 additions & 1 deletion tools/ports/bzip2.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def get(ports, settings, shared):
def create(final):
source_path = ports.get_dir('bzip2', 'bzip2-' + VERSION)
ports.install_headers(source_path)
ports.make_pkg_config('bzip2', VERSION, '-sUSE_BZIP2')

# build
srcs = [
Expand All @@ -33,4 +34,4 @@ def clear(ports, settings, shared):


def show():
return 'bzip2 (-sUSE_BZIP2=1 or --use-port=bzip2; BSD license)'
return 'bzip2 (-sUSE_BZIP2 or --use-port=bzip2; BSD license)'
3 changes: 2 additions & 1 deletion tools/ports/freetype.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def create(final):
if settings.SUPPORT_LONGJMP == 'wasm':
flags.append('-sSUPPORT_LONGJMP=wasm')

ports.make_pkg_config('freetype', TAG, '-sUSE_FREETYPE')
ports.build_port(source_path, final, 'freetype', flags=flags, srcs=srcs)

return [shared.cache.get_lib(get_lib_name(settings), create, what='port')]
Expand All @@ -110,4 +111,4 @@ def process_args(ports):


def show():
return 'freetype (-sUSE_FREETYPE=1 or --use-port=freetype; freetype license)'
return 'freetype (-sUSE_FREETYPE or --use-port=freetype; freetype license)'
3 changes: 2 additions & 1 deletion tools/ports/giflib.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def get(ports, settings, shared):
def create(final):
source_path = ports.get_dir('giflib', f'giflib-{VERSION}')
ports.install_headers(source_path)
ports.make_pkg_config('giffix', VERSION, '-sUSE_GIFLIB')
exclude_files = [
'giffix.c', 'gifecho.c', 'giffilter.c', 'gifcolor.c', 'gifecho.c', 'gifinto.c',
'gifsponge.c', 'gif2rgb.c', 'gifbg.c', 'gifbuild.c', 'gifclrmp.c', 'gifhisto.c',
Expand All @@ -32,4 +33,4 @@ def clear(ports, settings, shared):


def show():
return 'giflib (-sUSE_GIFLIB=1 or --use-port=giflib; MIT license)'
return 'giflib (-sUSE_GIFLIB or --use-port=giflib; MIT license)'
2 changes: 1 addition & 1 deletion tools/ports/icu.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ def clear(ports, settings, shared):


def show():
return 'icu (-sUSE_ICU=1 or --use-port=icu; Unicode License)'
return 'icu (-sUSE_ICU or --use-port=icu; Unicode License)'
3 changes: 2 additions & 1 deletion tools/ports/libjpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def create(final):
shutil.copyfile(jconfig_h, os.path.join(source_path, 'jconfig.h'))

ports.install_headers(source_path)
ports.make_pkg_config('libjpeg', VERSION, '-sUSE_LIBJPEG')
excludes = [
'ansi2knr.c', 'cjpeg.c', 'cjpegalt.c', 'ckconfig.c', 'djpeg.c', 'djpegalt.c', 'example.c',
'jmemansi.c', 'jmemdos.c', 'jmemmac.c', 'jmemname.c',
Expand All @@ -41,4 +42,4 @@ def clear(ports, settings, shared):


def show():
return 'libjpeg (-sUSE_LIBJPEG=1 or --use-port=libjpeg; BSD license)'
return 'libjpeg (-sUSE_LIBJPEG or --use-port=libjpeg; BSD license)'
3 changes: 2 additions & 1 deletion tools/ports/libmodplug.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def create(final):

ports.install_headers(libmodplug_path, pattern="*.h", target='libmodplug')
ports.install_headers(src_dir, pattern="modplug.h", target='libmodplug')
ports.make_pkg_config('libmodplug', TAG, '-sUSE_MODPLUG')

return [shared.cache.get_lib('libmodplug.a', create, what='port')]

Expand All @@ -89,4 +90,4 @@ def clear(ports, settings, shared):


def show():
return 'libmodplug (-sUSE_MODPLUG=1 or --use-port=libmodplug; public domain)'
return 'libmodplug (-sUSE_MODPLUG or --use-port=libmodplug; public domain)'
3 changes: 2 additions & 1 deletion tools/ports/mpg123.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def create(final):

# copy header to a location so it can be used as 'MPG123/'
ports.install_headers(libmpg123_path, pattern="*123.h", target='')
ports.make_pkg_config('mpg123', TAG, '-sUSE_MPG123')

flags = [
'-DOPT_GENERIC',
Expand Down Expand Up @@ -83,4 +84,4 @@ def clear(ports, settings, shared):


def show():
return 'mpg123 (-sUSE_MPG123=1 or --use-port=mpg123; zlib license)'
return 'mpg123 (-sUSE_MPG123 or --use-port=mpg123; zlib license)'
3 changes: 2 additions & 1 deletion tools/ports/ogg.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def create(final):
config_types_h = os.path.join(os.path.dirname(__file__), 'ogg/config_types.h')
shutil.copyfile(config_types_h, os.path.join(source_path, 'include/ogg/config_types.h'))
ports.install_headers(os.path.join(source_path, 'include', 'ogg'), target='ogg')
ports.make_pkg_config('ogg', TAG, '-sUSE_OGG')
ports.build_port(os.path.join(source_path, 'src'), final, 'ogg')

return [shared.cache.get_lib('libogg.a', create)]
Expand All @@ -32,4 +33,4 @@ def clear(ports, settings, shared):


def show():
return 'ogg (-sUSE_OGG=1 or --use-port=ogg; zlib license)'
return 'ogg (-sUSE_OGG or --use-port=ogg; zlib license)'
2 changes: 2 additions & 0 deletions tools/ports/sdl2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import os

VERSION = '2.32.0'
TAG = 'release-2.32.0'
HASH = 'd3e4ce9784152aa1194c4f2d2399829f3b01a652915afc6ddaec334068bf95d850edcb43b1a951e0202fc2ecaafc1f58e538ca39b9b16d3fdfe412af0b6aebb0'
SUBDIR = 'SDL-' + TAG
Expand Down Expand Up @@ -35,6 +36,7 @@ def create(final):
src_dir = ports.get_dir('sdl2', SUBDIR)
source_include_path = os.path.join(src_dir, 'include')
ports.install_headers(source_include_path, target='SDL2')
ports.make_pkg_config('sdl2', VERSION, '-sUSE_SDL=2')

# copy sdl2-config.cmake
cmake_file = os.path.join(os.path.dirname(__file__), 'sdl2/sdl2-config.cmake')
Expand Down
2 changes: 2 additions & 0 deletions tools/ports/sdl3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from tools import diagnostics

VERSION = '3.2.4'
TAG = 'release-3.2.4'
HASH = 'c26a8afeec481e3ae3b435eec405d9f99d78752ebf5118963cd56728ceff23772769f5291df581329488da7489034e835301b08d61a42c811764e24b3542a4c2'
SUBDIR = 'SDL-' + TAG
Expand Down Expand Up @@ -45,6 +46,7 @@ def create(final):
# copy includes to a location so they can be used as 'SDL3/'
source_include_path = os.path.join(root_dir, 'include', 'SDL3')
ports.install_headers(source_include_path, target='SDL3')
ports.make_pkg_config('sdl3', VERSION, '-sUSE_SDL=3')

# copy sdl3-config.cmake
cmake_file = os.path.join(os.path.dirname(__file__), 'sdl3/sdl3-config.cmake')
Expand Down
1 change: 1 addition & 0 deletions tools/ports/sqlite3.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def create(final):
source_path = ports.get_dir('sqlite3', release)

ports.install_headers(source_path)
ports.make_pkg_config('sqlite', ','.join(str(v) for v in VERSION), '-sUSE_SQLITE3')

# flags are based on sqlite-autoconf output.
# SQLITE_HAVE_ZLIB is only used by shell.c
Expand Down
1 change: 1 addition & 0 deletions tools/ports/vorbis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def get(ports, settings, shared):
def create(final):
source_path = ports.get_dir('vorbis', 'Vorbis-' + TAG)
ports.install_headers(os.path.join(source_path, 'include', 'vorbis'), target='vorbis')
ports.make_pkg_config('vorbis', TAG, '-sUSE_VORBIS')
ports.build_port(os.path.join(source_path, 'lib'), final, 'vorbis',
flags=['-sUSE_OGG'],
exclude_files=['psytune', 'barkmel', 'tone', 'misc'])
Expand Down
3 changes: 2 additions & 1 deletion tools/ports/zlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def create(final):
zconf_h = os.path.join(os.path.dirname(__file__), 'zlib/zconf.h')
shutil.copyfile(zconf_h, os.path.join(source_path, 'zconf.h'))
ports.install_headers(source_path)
ports.make_pkg_config('zlib', VERSION, '-sUSE_ZIB')

# build
srcs = 'adler32.c compress.c crc32.c deflate.c gzclose.c gzlib.c gzread.c gzwrite.c infback.c inffast.c inflate.c inftrees.c trees.c uncompr.c zutil.c'.split()
Expand All @@ -37,5 +38,5 @@ def clear(ports, settings, shared):


def show():
return 'zlib (-sUSE_ZLIB=1 or --use-port=zlib; zlib license)'
return 'zlib (-sUSE_ZLIB or --use-port=zlib; zlib license)'