Skip to content

fix: Conan 2 compliance for CI, packaging, and publishing workflow#18

Merged
jbltx merged 2 commits into
developfrom
copilot/ensure-ci-publishing-compliance
Apr 13, 2026
Merged

fix: Conan 2 compliance for CI, packaging, and publishing workflow#18
jbltx merged 2 commits into
developfrom
copilot/ensure-ci-publishing-compliance

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 13, 2026

Conan 2 rejects exports_sources patterns starting with .., breaking conan export/conan create for this monorepo where thirdparty submodules live at ../../thirdparty relative to packages/tml-cpp/. Additionally, the package lacked a test_package/, the generated tml_export.h was never installed, and the CI had no Conan validation step.

conanfile.py

  • Remove ../../thirdparty/rapidjson/* and ../../thirdparty/oniguruma/* from exports_sources (Conan 2 hard-rejects .. patterns via copy())
  • Add export_sources() method to copy vendored submodules into the Conan cache using explicit absolute src paths — this is the correct Conan 2 escape hatch for monorepos
  • Add smart THIRDPARTY_DIR resolution in generate(): use source_folder/thirdparty when present (cache build from conan create), fall back to ../../thirdparty (local conan install flow)
  • Add package_type = "library"

CMakeLists.txt

  • Introduce THIRDPARTY_DIR CMake variable (defaults to ../../thirdparty for bare CMake builds; Conan overrides via CMakeToolchain)
  • Replace all hardcoded ../../thirdparty occurrences with ${THIRDPARTY_DIR}
  • Install generated tml_export.h to include/tml/ — previously missing, breaking consumers who include c_api.h (which does #include "tml_export.h")

test_package/ (new)

Conan 2's conan create expects a test_package/ to verify the installed package end-to-end:

test_package/
  conanfile.py       # uses tested_reference_str + can_run() guard
  CMakeLists.txt     # find_package(TextMateLib) + links TextMateLib::tml
  src/example.cpp    # creates/disposes OnigLib and Registry via public C API

CI workflows

  • build-and-test.yml: add conan-test job — installs Conan 2, detects profile, runs conan create packages/tml-cpp --build=missing from repo root (exercises export_sources() + test_package/)
  • release.yml publish-conan: run conan create from repo root instead of packages/tml-cpp/; use Python to extract version from conanfile.py reliably; fix malformed regex character class in prior version-extraction script

@jbltx
Copy link
Copy Markdown
Owner

jbltx commented Apr 13, 2026

@copilot

home/runner/.conan2/p/b/textm15294e5504b89/p/lib/libtml.a(onigLib.cpp.o): in function `tml::DefaultOnigLib::~DefaultOnigLib()':
onigLib.cpp:(.text+0x17): undefined reference to `onig_end'
/usr/bin/ld: /home/runner/.conan2/p/b/textm15294e5504b89/p/lib/libtml.a(onigLib.cpp.o): in function `tml::OnigScanner::compilePatterns()':
onigLib.cpp:(.text+0x1bc): undefined reference to `OnigDefaultSyntax'
/usr/bin/ld: onigLib.cpp:(.text+0x1d3): undefined reference to `OnigEncodingUTF8'
/usr/bin/ld: onigLib.cpp:(.text+0x245): undefined reference to `onig_new'
/usr/bin/ld: onigLib.cpp:(.text+0x25c): undefined reference to `onig_error_code_to_str'
/usr/bin/ld: onigLib.cpp:(.text+0x303): undefined reference to `onig_regset_new'
/usr/bin/ld: /home/runner/.conan2/p/b/textm15294e5504b89/p/lib/libtml.a(onigLib.cpp.o): in function `tml::OnigScanner::dispose()':
onigLib.cpp:(.text+0x391): undefined reference to `onig_regset_free'
/usr/bin/ld: onigLib.cpp:(.text+0x3ea): undefined reference to `onig_free'
/usr/bin/ld: /home/runner/.conan2/p/b/textm15294e5504b89/p/lib/libtml.a(onigLib.cpp.o): in function `tml::OnigScanner::findNextMatchSync(tml::OnigString*, int, int)':
onigLib.cpp:(.text+0x7f5): undefined reference to `onig_regset_search'
/usr/bin/ld: onigLib.cpp:(.text+0x81b): undefined reference to `onig_region_new'
/usr/bin/ld: onigLib.cpp:(.text+0x83c): undefined reference to `onig_search'
/usr/bin/ld: onigLib.cpp:(.text+0x922): undefined reference to `onig_region_free'
/usr/bin/ld: onigLib.cpp:(.text+0x979): undefined reference to `onig_region_free'
/usr/bin/ld: /home/runner/.conan2/p/b/textm15294e5504b89/p/lib/libtml.a(onigLib.cpp.o): in function `tml::DefaultOnigLib::DefaultOnigLib()':
onigLib.cpp:(.text+0x4e3): undefined reference to `onig_init'
collect2: error: ld returned 1 exit status
gmake[2]: *** [CMakeFiles/example.dir/build.make:102: example] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/example.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2
ERROR: textmatelib/0.1.0 (test package): Error in build() method, line 20
	cmake.build()
	ConanException: Error 2 while executing

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 13, 2026

@copilot

...

The linker failure was caused by two gaps in the Conan packaging:

  1. cmake --install only installs libtml.a — Oniguruma is built via ExternalProject_Add and never ends up in the package.
  2. package_info() only declared libs = ["tml"], so Conan's CMakeDeps generator didn't expose libonig.a to consumers at all.

Fixed in 66abc32:

  • package() now copies libonig.a (and .lib on Windows) from build_folder/oniguruma/lib/ plus the Oniguruma headers (needed for installed onigLib.h which #include "oniguruma.h") into the Conan package.
  • package_info() now declares cpp_info.libs = ["tml", "onig"] — order is intentional (tml references onig symbols, so tml must come first for static linkers).

Copilot AI requested a review from jbltx April 13, 2026 17:37
@jbltx jbltx marked this pull request as ready for review April 13, 2026 18:03
@jbltx jbltx merged commit 7558272 into develop Apr 13, 2026
11 checks passed
@jbltx jbltx deleted the copilot/ensure-ci-publishing-compliance branch April 13, 2026 18:04
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.

2 participants