Skip to content

build: add a Swift Package Manager manifest - #40

Open
zunda-pixel wants to merge 1 commit into
xiph:masterfrom
zunda-pixel:swiftpm
Open

build: add a Swift Package Manager manifest#40
zunda-pixel wants to merge 1 commit into
xiph:masterfrom
zunda-pixel:swiftpm

Conversation

@zunda-pixel

@zunda-pixel zunda-pixel commented Sep 3, 2026

Copy link
Copy Markdown

Adds a Package.swift so a project on Apple platforms can depend on libspeex directly. That is the only way to reach the codec from Swift: no Apple framework decodes Speex, so an application that has to read it has to build this.

Two files, both new — Package.swift and a .gitignore for /.build/, /.swiftpm/, /DerivedData/. Nothing under libspeex/ changes, and the manifest adds no file that configure also generates, so the same checkout still builds with autotools or meson afterwards. I have been building it both ways in one tree.

What replaces config.h

Passed as -D rather than written to a file:

why
FLOATING_POINT, USE_SMALLFT the pair a bare ./configure settles on (configure.ac:215-250)
VAR_ARRAYS clang has variable-length arrays, so neither alloca nor a preallocated scratch area is needed
EXPORT= no dllexport decoration

speex_config_types.h is not needed at all: on Apple platforms speex_types.h defines the four sized types itself, in its __APPLE__ && __MACH__ branch.

Three things that are less obvious than they look

The sources are listed rather than walked, and the list is exactly what a bare ./configure builds — libspeex_la_SOURCES plus the smallft.c that FFTSRC resolves to, 31 files. Writing it out keeps the manager away from the rest of the repository: the other build systems, the ports, the documentation.

Directories are excluded even so. The manager walks the target's directory looking for resources whatever sources says, and stops on the localized ones under macosx/ to ask for a default localization. Only directories are named, because the list is short and stable, whereas the loose files at the root come and go.

The target is called libspeex, not speex. Given the latter, the manager takes include/speex/speex.h for an umbrella header and then rejects the module for leaving the neighbouring headers out. Under any other name it treats include/ as an umbrella directory, which is what those headers are.

Scope

  • Apple platforms only. The __APPLE__ && __MACH__ branch above is what makes the generated header unnecessary; elsewhere speex_types.h reaches for speex_config_types.h, so building on Linux would need either that file or a source change. I left both out to keep this to a manifest.
  • libspeex only. speexdsp is its own repository and would need the same there.
  • I did not add fftwrap.c or vorbis_psy.c. Neither is in libspeex_la_SOURCES or libspeex/meson.build's default, and vorbis_psy.c is empty without VORBIS_PSYCHO.

How it has been used

A Pebble companion app for iOS and macOS decodes the watch's Speex voice frames with this, built for both platforms. Its decoder tests — a recording from the watch round-tripped to samples, frame sizing, and the two refusal paths — pass against this manifest.

Lets a project on Apple platforms depend on the codec directly, which is the
only way to reach it from Swift: no Apple framework decodes Speex, so an
application that has to read it has to build this.

Nothing under libspeex/ changes, and the manifest adds no file that configure
also generates, so the same checkout still builds with autotools or meson
afterwards.

- What config.h would have carried is passed as -D instead: floating point
  with smallft, the pair a bare ./configure settles on (configure.ac:215-250),
  and VAR_ARRAYS, since clang has variable-length arrays and the codec then
  needs neither alloca nor a preallocated scratch area.
- speex_config_types.h is not needed either. On Apple platforms
  speex_types.h defines the four sized types itself, in its __APPLE__ &&
  __MACH__ branch. That branch is also why the manifest claims no other
  platform: elsewhere the same header reaches for the generated one.

Three things in it are less obvious than they look.

- The sources are listed rather than walked, and the list is what a bare
  ./configure builds: libspeex_la_SOURCES plus the smallft.c that FFTSRC
  resolves to. Writing it out keeps the manager away from the rest of the
  repository — the other build systems, the ports, the documentation.
- Directories are excluded even so, because the manager walks the target's
  directory for resources whatever `sources` says, and stops on the localized
  ones under macosx/ to ask for a default localization.
- The target is called libspeex rather than speex. Given the latter, the
  manager takes include/speex/speex.h for an umbrella header and then rejects
  the module for leaving the neighbouring headers out; under any other name it
  treats include/ as an umbrella directory, which is what those headers are.

Only libspeex is offered. speexdsp is its own repository and would need the
same there.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant