Skip to content
This repository was archived by the owner on Sep 20, 2026. It is now read-only.

feat(kcp): add LLAR formula for skywind3000/kcp - #420

Open
MeteorsLiu wants to merge 2 commits into
xgo-dev:mainfrom
MeteorsLiu:issue/224-kcp
Open

MeteorsLiu wants to merge 2 commits into
xgo-dev:mainfrom
MeteorsLiu:issue/224-kcp

Conversation

@MeteorsLiu

Copy link
Copy Markdown
Collaborator

Translate Conan Center kcp into an idiomatic LLAR Formula.

Closes #224

Formula

  • Module: skywind3000/kcp
  • fromVer: 1.4 (first upstream tag with CMake install; 1.0–1.3 are source-only)
  • Selected Conan version: 1.5 (https://github.com/skywind3000/kcp/archive/1.5.tar.gz)
  • Options: shared (default OFF), fPIC (default ON, static only)

Build

  • Drive upstream CMakeLists.txt through the cmake helper.
  • Relax add_library(kcp STATIC …) and add LIBRARY/RUNTIME install rules so shared builds work on 1.4–1.7 (Conan did the same).
  • Lower 1.7.1+ cmake_minimum_required(VERSION 4.0) to 3.5 so Ubuntu CI CMake can configure.
  • Publish relocatable lib/pkgconfig/kcp.pc via pkgconfig.new (Version is the fromVer floor).

Tests

Local llar test -v on darwin/arm64:

  • ./skywind3000/kcp@1.5 (Conan tag)
  • ./skywind3000/kcp@1.4 (fromVer)
  • ./skywind3000/kcp@1.7, @1.7.1, @2.1.1
  • default selection (@2.1.1)
  • --option shared=ON
  • --option fPIC=OFF
  • cache-hit retest of @1.5, @1.5 shared=ON, and default
  • @1.3 rejected (no formula found)

Conan package_info() audit vs published .pc:

  • cpp_info.libs = ["kcp"] → Libs: -L${libdir} -lkcp (match)
  • no system_libs / defines / extra includedirs / components (none extra)

Translate Conan Center kcp 1.5 into skywind3000/kcp from 1.4, the first
CMake-installing tag. Drive upstream CMake, publish relocatable kcp.pc,
and cover the installed C API with a pkg-config consumer.

Closes xgo-dev#224

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formula is structurally consistent with the repository and the Linux/macOS paths are covered by the included consumer test. The Windows shared-library contract is incomplete, however: the Conan recipe explicitly enabled Windows symbol exports and adjusted DLL runtime lookup, while this formula does neither.

binary := filepath.join(testDir, "consumer")
cc! consumer, "-o", binary, "@"+flagsFile

if target.options["shared"][0] == "ON" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Add the Windows DLL directory to PATH

For a Windows shared build, CMake installs the DLL under ${CMAKE_INSTALL_BINDIR} (normally bin), but the test only sets LD_LIBRARY_PATH and DYLD_LIBRARY_PATH, neither of which Windows uses. The compiled consumer therefore fails at startup with a missing kcp.dll even after linking succeeds. In the shared=ON test path, prepend filepath.join(installDir, "bin") to PATH when target.require["os"] is Windows, matching the runtime setup required by the installed layout.

c.define "CMAKE_POLICY_VERSION_MINIMUM", "3.5"
c.define "CMAKE_INSTALL_LIBDIR", "lib"
c.defineBool "BUILD_TESTING", false
c.defineBool "BUILD_SHARED_LIBS", shared

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Enable Windows exports for shared builds

When shared=ON on Windows, the 1.4–1.7 sources are changed to add_library(kcp ikcp.c) but no symbols are exported from the resulting DLL. The Conan recipe sets CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS for this exact case, and the older upstream tags do not provide the explicit .def file added in 1.7.1. Consequently the installed import library has no usable KCP API symbols and a Windows consumer cannot link. Pass CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON (or otherwise provide the required exports) for the supported Windows shared configuration.

This branch has not been deployed

No deployments
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Translate Conan Center kcp recipe to LLAR

1 participant