Skip to content

build: add swift package for local builds#172

Merged
webern merged 2 commits into
musicxml-4.0from
swift-build
Jun 14, 2026
Merged

build: add swift package for local builds#172
webern merged 2 commits into
musicxml-4.0from
swift-build

Conversation

@webern

@webern webern commented Jun 14, 2026

Copy link
Copy Markdown
Owner

Summary

Compile mx as a Swift package so a sibling consumer can depend on it via
.package(path:) for local-checkout development.

  • Package.swift vends the Mx library.
  • MX_LOCAL_CHECKOUT selects the mode:
    • When set, mx is a local sibling checkout and being compiled from local source.
    • Unset is reserved for a future binary release mechanism.
  • swift-local ci job builds the package in local mode

Also fixes the AppleClang charconv error on from_chars / to_chars

Base: musicxml-4.0 (feeds #169).

Add Package.swift vending the `Mx` library. With MX_LOCAL_CHECKOUT
set, `Mx` is a source target compiled from this checkout -- the path
a sibling consumer (komp) takes via `.package(path:)`. SPM globs the
C++ sources under src/private (minus the Catch2 runner, the test
suites, and the examples) with the mx::api headers in src/include as
the public surface. Without the variable the manifest fails loudly;
the binary xcframework release is follow-up work.

Add a macOS swift-local CI job that builds the package in
local-checkout mode on every pull request, covering the SPM /
AppleClang source build alongside the CMake gates.
@github-actions

Copy link
Copy Markdown

gen-quality gen/

gen-quality: 84.5 / 100   (floor 84.5, +0.0)

  structure     86.5  x0.50   [fn 90.5 / file 82.6]
  cyclomatic    88.4  x0.25
  cognitive     76.6  x0.25

  409 functions across 31 files, 7702 lines (largest file 1044)
  max cc 56  max cognitive 44  max fn loc 152

Worst offenders (top 5 per axis; full lists in score.json):
  cyclomatic gen/xsd/analyze.py:311     report                             56
  cyclomatic gen/plates/build.py:956    _validate_config_against_ir        35
  cyclomatic gen/press/context.py:145   plate_context                      34
  cyclomatic gen/__main__.py:46         _ir                                23
  cyclomatic gen/tests/test_ir.py:102   _check_references                  20
  cognitive  gen/xsd/analyze.py:311     report                             44
  cognitive  gen/ir/resolve.py:119      flat_elements                      40
  cognitive  gen/tests/test_ir.py:102   _check_references                  38
  cognitive  gen/press/context.py:145   plate_context                      37
  cognitive  gen/xsd/analyze.py:207     _sccs                              37
  size       gen/xsd/analyze.py:311     report                             152
  size       gen/press/context.py:145   plate_context                      96
  size       gen/plates/build.py:533    _value_plate                       89
  size       gen/plates/build.py:956    _validate_config_against_ir        89
  size       gen/ir/resolve.py:119      flat_elements                      78

Commit bf0ccebc2a17c9c5cc5c326d845c5827af60e1d5.

@github-actions

Copy link
Copy Markdown

Coverage report

Core-dev coverage src/private/mx/core/

Metric Coverage Covered / Total
Lines 77.9% 28505 / 36590
Functions 74.4% 6354 / 8542
Branches 50.7% 22645 / 44673

API coverage src/private/mx/{api,impl,utility}/

Metric Coverage Covered / Total
Lines 68.7% 4734 / 6895
Functions 53.5% 1507 / 2816
Branches 40.3% 3851 / 9562

Core HTML report | API HTML report

Commit bf0ccebc2a17c9c5cc5c326d845c5827af60e1d5.

mx::api modeled xs:decimal/float/double values as long double, but the
impl only widens core doubles into them, so they never hold extra
precision -- and writing them back via brace-init (core::Decimal{ v })
is a long double -> double narrowing that Clang rejects as ill-formed
while GCC merely warns. That split broke every AppleClang build (the
macOS CMake job and the new Swift package).

Make api::Double a double and sweep the stray literal long double
declarations and their L-suffixed literals to match. xs:* values are
<= 64-bit and long double == double on Apple silicon, so this loses
nothing and removes the narrowing at the root.
@github-actions

Copy link
Copy Markdown

gen-quality gen/

gen-quality: 84.5 / 100   (floor 84.5, +0.0)

  structure     86.5  x0.50   [fn 90.5 / file 82.6]
  cyclomatic    88.4  x0.25
  cognitive     76.6  x0.25

  409 functions across 31 files, 7702 lines (largest file 1044)
  max cc 56  max cognitive 44  max fn loc 152

Worst offenders (top 5 per axis; full lists in score.json):
  cyclomatic gen/xsd/analyze.py:311     report                             56
  cyclomatic gen/plates/build.py:956    _validate_config_against_ir        35
  cyclomatic gen/press/context.py:145   plate_context                      34
  cyclomatic gen/__main__.py:46         _ir                                23
  cyclomatic gen/tests/test_ir.py:102   _check_references                  20
  cognitive  gen/xsd/analyze.py:311     report                             44
  cognitive  gen/ir/resolve.py:119      flat_elements                      40
  cognitive  gen/tests/test_ir.py:102   _check_references                  38
  cognitive  gen/press/context.py:145   plate_context                      37
  cognitive  gen/xsd/analyze.py:207     _sccs                              37
  size       gen/xsd/analyze.py:311     report                             152
  size       gen/press/context.py:145   plate_context                      96
  size       gen/plates/build.py:533    _value_plate                       89
  size       gen/plates/build.py:956    _validate_config_against_ir        89
  size       gen/ir/resolve.py:119      flat_elements                      78

Commit b5cdacd695d6e20386f38953d0e11b0d1cec6e0b.

@webern webern changed the title Swift package: local-checkout build mode build: add swift package for local builds Jun 14, 2026
@github-actions

Copy link
Copy Markdown

Coverage report

Core-dev coverage src/private/mx/core/

Metric Coverage Covered / Total
Lines 77.9% 28505 / 36590
Functions 74.4% 6354 / 8542
Branches 50.7% 22645 / 44673

API coverage src/private/mx/{api,impl,utility}/

Metric Coverage Covered / Total
Lines 68.7% 4734 / 6895
Functions 54.8% 1475 / 2692
Branches 40.3% 3848 / 9556

Core HTML report | API HTML report

Commit b5cdacd695d6e20386f38953d0e11b0d1cec6e0b.

@webern webern merged commit 024406a into musicxml-4.0 Jun 14, 2026
7 checks passed
@webern webern deleted the swift-build branch June 14, 2026 18:35
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