Skip to content

Commit 51a15a1

Browse files
committed
Add pkg-config files for ports
Fixes: #24361
1 parent f531731 commit 51a15a1

18 files changed

+54
-14
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ See docs/process.md for more on how version tagging works.
2020

2121
4.0.10 (in development)
2222
----------------------
23+
- Emscripten ports now install pkg-config `.pc` files so they will show up, for
24+
example, when you run `pkg-config --list-all` or `pkg-config --cflags
25+
<portname>`. Bare in mind that the correct PKG_CONFIG_PATH needs to be set for
26+
this to work. One way to do this is to run `emmake pkg-config`. (#24426)
2327
- libcxx, libcxxabi, and compiler-rt were updated to LLVM 20.1.4. (#24346 and
2428
#24357)
2529
- Emscripten will not longer generate trampoline functions for Wasm exports

system/lib/pkgconfig/sdl.pc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Name: sdl
22
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.
33
Version: 1.2.15
4-
Cflags: -D_GNU_SOURCE=1 -D_REENTRANT
4+
Libs: -sUSE_SDL
5+
Cflags: -sUSE_SDL

test/test_other.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,8 +1088,17 @@ def test_pkg_config_packages(self):
10881088
('sdl', '1.2.15'),
10891089
]
10901090
for package, version in packages:
1091-
out = self.run_process([emmake, 'pkg-config', '--modversion', package], stdout=PIPE).stdout
1092-
self.assertContained(version, out)
1091+
out = self.run_process([emmake, 'pkg-config', '--modversion', package], stdout=PIPE).stdout
1092+
self.assertContained(version, out)
1093+
1094+
@requires_pkg_config
1095+
@crossplatform
1096+
def test_pkg_config_ports(self):
1097+
self.run_process([EMBUILDER, 'build', 'bullet'])
1098+
out = self.run_process([emmake, 'pkg-config', '--list-all'], stdout=PIPE).stdout
1099+
self.assertContained('libjpeg', out)
1100+
out = self.run_process([emmake, 'pkg-config', '--cflags', 'bullet'], stdout=PIPE).stdout
1101+
self.assertContained('-sUSE_BULLET', out)
10931102

10941103
@parameterized({
10951104
'': [None],

tools/ports/__init__.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,18 @@ def write_file(filename, contents):
428428
return
429429
utils.write_file(filename, contents)
430430

431+
@staticmethod
432+
def make_pkg_config(name, version, flags):
433+
pkgconfig_dir = cache.get_sysroot_dir('lib/pkgconfig')
434+
filename = os.path.join(pkgconfig_dir, name + '.pc')
435+
Ports.write_file(filename, f'''
436+
Name: {name}
437+
Description: {name} port from emscripten
438+
Version: {version}
439+
Libs: {flags}
440+
Cflags: {flags}
441+
''')
442+
431443

432444
class OrderedSet:
433445
"""Partial implementation of OrderedSet. Just enough for what we need here."""

tools/ports/bullet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def create(final):
4242
'-Wno-int-to-void-pointer-cast',
4343
'-std=gnu++14',
4444
]
45-
45+
ports.make_pkg_config('bullet', TAG, '-sUSE_BULLET')
4646
ports.build_port(src_path, final, 'bullet', includes=includes, flags=flags, exclude_dirs=['MiniCL'])
4747

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

5858

5959
def show():
60-
return 'bullet (-sUSE_BULLET=1 or --use-port=bullet; zlib license)'
60+
return 'bullet (-sUSE_BULLET or --use-port=bullet; zlib license)'

tools/ports/bzip2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def get(ports, settings, shared):
1717
def create(final):
1818
source_path = ports.get_dir('bzip2', 'bzip2-' + VERSION)
1919
ports.install_headers(source_path)
20+
ports.make_pkg_config('bzip2', VERSION, '-sUSE_BZIP2')
2021

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

3435

3536
def show():
36-
return 'bzip2 (-sUSE_BZIP2=1 or --use-port=bzip2; BSD license)'
37+
return 'bzip2 (-sUSE_BZIP2 or --use-port=bzip2; BSD license)'

tools/ports/freetype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def create(final):
9696
if settings.SUPPORT_LONGJMP == 'wasm':
9797
flags.append('-sSUPPORT_LONGJMP=wasm')
9898

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

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

111112

112113
def show():
113-
return 'freetype (-sUSE_FREETYPE=1 or --use-port=freetype; freetype license)'
114+
return 'freetype (-sUSE_FREETYPE or --use-port=freetype; freetype license)'

tools/ports/giflib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def get(ports, settings, shared):
1717
def create(final):
1818
source_path = ports.get_dir('giflib', f'giflib-{VERSION}')
1919
ports.install_headers(source_path)
20+
ports.make_pkg_config('giffix', VERSION, '-sUSE_GIFLIB')
2021
exclude_files = [
2122
'giffix.c', 'gifecho.c', 'giffilter.c', 'gifcolor.c', 'gifecho.c', 'gifinto.c',
2223
'gifsponge.c', 'gif2rgb.c', 'gifbg.c', 'gifbuild.c', 'gifclrmp.c', 'gifhisto.c',
@@ -32,4 +33,4 @@ def clear(ports, settings, shared):
3233

3334

3435
def show():
35-
return 'giflib (-sUSE_GIFLIB=1 or --use-port=giflib; MIT license)'
36+
return 'giflib (-sUSE_GIFLIB or --use-port=giflib; MIT license)'

tools/ports/icu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ def clear(ports, settings, shared):
103103

104104

105105
def show():
106-
return 'icu (-sUSE_ICU=1 or --use-port=icu; Unicode License)'
106+
return 'icu (-sUSE_ICU or --use-port=icu; Unicode License)'

tools/ports/libjpeg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ def create(final):
2626
shutil.copyfile(jconfig_h, os.path.join(source_path, 'jconfig.h'))
2727

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

4243

4344
def show():
44-
return 'libjpeg (-sUSE_LIBJPEG=1 or --use-port=libjpeg; BSD license)'
45+
return 'libjpeg (-sUSE_LIBJPEG or --use-port=libjpeg; BSD license)'

tools/ports/libmodplug.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ def create(final):
8080

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

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

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

9091

9192
def show():
92-
return 'libmodplug (-sUSE_MODPLUG=1 or --use-port=libmodplug; public domain)'
93+
return 'libmodplug (-sUSE_MODPLUG or --use-port=libmodplug; public domain)'

tools/ports/mpg123.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def create(final):
3131

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

3536
flags = [
3637
'-DOPT_GENERIC',
@@ -83,4 +84,4 @@ def clear(ports, settings, shared):
8384

8485

8586
def show():
86-
return 'mpg123 (-sUSE_MPG123=1 or --use-port=mpg123; zlib license)'
87+
return 'mpg123 (-sUSE_MPG123 or --use-port=mpg123; zlib license)'

tools/ports/ogg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def create(final):
2222
config_types_h = os.path.join(os.path.dirname(__file__), 'ogg/config_types.h')
2323
shutil.copyfile(config_types_h, os.path.join(source_path, 'include/ogg/config_types.h'))
2424
ports.install_headers(os.path.join(source_path, 'include', 'ogg'), target='ogg')
25+
ports.make_pkg_config('ogg', TAG, '-sUSE_OGG')
2526
ports.build_port(os.path.join(source_path, 'src'), final, 'ogg')
2627

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

3334

3435
def show():
35-
return 'ogg (-sUSE_OGG=1 or --use-port=ogg; zlib license)'
36+
return 'ogg (-sUSE_OGG or --use-port=ogg; zlib license)'

tools/ports/sdl2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import os
77

8+
VERSION = '2.32.0'
89
TAG = 'release-2.32.0'
910
HASH = 'd3e4ce9784152aa1194c4f2d2399829f3b01a652915afc6ddaec334068bf95d850edcb43b1a951e0202fc2ecaafc1f58e538ca39b9b16d3fdfe412af0b6aebb0'
1011
SUBDIR = 'SDL-' + TAG
@@ -35,6 +36,7 @@ def create(final):
3536
src_dir = ports.get_dir('sdl2', SUBDIR)
3637
source_include_path = os.path.join(src_dir, 'include')
3738
ports.install_headers(source_include_path, target='SDL2')
39+
ports.make_pkg_config('sdl2', VERSION, '-sUSE_SDL=2')
3840

3941
# copy sdl2-config.cmake
4042
cmake_file = os.path.join(os.path.dirname(__file__), 'sdl2/sdl2-config.cmake')

tools/ports/sdl3.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
from tools import diagnostics
1111

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

4951
# copy sdl3-config.cmake
5052
cmake_file = os.path.join(os.path.dirname(__file__), 'sdl3/sdl3-config.cmake')

tools/ports/sqlite3.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def create(final):
2929
source_path = ports.get_dir('sqlite3', release)
3030

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

3334
# flags are based on sqlite-autoconf output.
3435
# SQLITE_HAVE_ZLIB is only used by shell.c

tools/ports/vorbis.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def get(ports, settings, shared):
2121
def create(final):
2222
source_path = ports.get_dir('vorbis', 'Vorbis-' + TAG)
2323
ports.install_headers(os.path.join(source_path, 'include', 'vorbis'), target='vorbis')
24+
ports.make_pkg_config('vorbis', TAG, '-sUSE_VORBIS')
2425
ports.build_port(os.path.join(source_path, 'lib'), final, 'vorbis',
2526
flags=['-sUSE_OGG'],
2627
exclude_files=['psytune', 'barkmel', 'tone', 'misc'])

tools/ports/zlib.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ def create(final):
2323
zconf_h = os.path.join(os.path.dirname(__file__), 'zlib/zconf.h')
2424
shutil.copyfile(zconf_h, os.path.join(source_path, 'zconf.h'))
2525
ports.install_headers(source_path)
26+
ports.make_pkg_config('zlib', VERSION, '-sUSE_ZIB')
2627

2728
# build
2829
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()
@@ -37,5 +38,5 @@ def clear(ports, settings, shared):
3738

3839

3940
def show():
40-
return 'zlib (-sUSE_ZLIB=1 or --use-port=zlib; zlib license)'
41+
return 'zlib (-sUSE_ZLIB or --use-port=zlib; zlib license)'
4142

0 commit comments

Comments
 (0)