From c4f560809bc83298ed07ed76fdce7f542d437d6d Mon Sep 17 00:00:00 2001 From: Jacob Heider Date: Tue, 19 Dec 2023 17:36:02 -0500 Subject: [PATCH 1/2] fix-up.ts not catching our new directory names this creates broken .pc and .cmake output. see: https://github.com/pkgxdev/pantry/actions/runs/7267412014/job/19801705304 --- lib/porcelain/fix-up.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/porcelain/fix-up.ts b/lib/porcelain/fix-up.ts index a2eeec34..0cff4ffc 100644 --- a/lib/porcelain/fix-up.ts +++ b/lib/porcelain/fix-up.ts @@ -63,7 +63,11 @@ async function fix_pc_files(pkg_prefix: Path) { if (isFile && path.extname() == ".pc") { const orig = await path.read() const relative_path = pkg_prefix.relative({ to: path.parent() }) - const text = orig.replaceAll(pkg_prefix.string, `\${pcfiledir}/${relative_path}`) + // newer versions of brewkit append +brewing to the path; this will get both + // variants + const text = orig + .replaceAll(pkg_prefix.join("+brewing").string, `\${pcfiledir}/${relative_path}`) + .replaceAll(pkg_prefix.string, `\${pcfiledir}/${relative_path}`) if (orig !== text) { console.log({ fixing: path }) path.write({text, force: true}) @@ -83,7 +87,11 @@ async function fix_cmake_files(pkg_prefix: Path) { if (isFile && path.extname() == ".cmake") { const orig = await path.read() const relative_path = pkg_prefix.relative({ to: path.parent() }) - const text = orig.replaceAll(pkg_prefix.string, `\${CMAKE_CURRENT_LIST_DIR}/${relative_path}`) + // newer versions of brewkit append +brewing to the path; this will get both + // variants + const text = orig + .replaceAll(pkg_prefix.join("+brewing").string, `\${CMAKE_CURRENT_LIST_DIR}/${relative_path}`) + .replaceAll(pkg_prefix.string, `\${CMAKE_CURRENT_LIST_DIR}/${relative_path}`) if (orig !== text) { console.log({ fixing: path }) path.write({text, force: true}) From 1a56cf18b75e39e6ebbae48d9ef279ceebeaaddf Mon Sep 17 00:00:00 2001 From: Jacob Heider Date: Wed, 20 Dec 2023 10:04:20 -0500 Subject: [PATCH 2/2] use `config.path.build_install` --- .github/workflows/ci.cli.yml | 10 ++++++++++ lib/porcelain/fix-up.ts | 12 ++++++------ projects/pc-cmake.com/package.yml | 12 ++++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) create mode 100644 projects/pc-cmake.com/package.yml diff --git a/.github/workflows/ci.cli.yml b/.github/workflows/ci.cli.yml index 2413cac3..f059f3e2 100644 --- a/.github/workflows/ci.cli.yml +++ b/.github/workflows/ci.cli.yml @@ -78,3 +78,13 @@ jobs: set +e bin/bk build unavailable.com test $? -eq 2 + + fix-up: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pkgxdev/setup@v2 + - run: pkgx --sync + - run: bin/bk build pc-cmake.com + - run: bin/bk test pc-cmake.com + - run: bin/bk audit pc-cmake.com \ No newline at end of file diff --git a/lib/porcelain/fix-up.ts b/lib/porcelain/fix-up.ts index 0cff4ffc..26e4d238 100644 --- a/lib/porcelain/fix-up.ts +++ b/lib/porcelain/fix-up.ts @@ -6,8 +6,8 @@ const { host } = utils export default async function finish(config: Config) { const prefix = config.path.install await fix_rpaths(prefix, config.pkg, config.path.cache, config.deps.gas) - await fix_pc_files(prefix) - await fix_cmake_files(prefix) + await fix_pc_files(prefix, config.path.build_install) + await fix_cmake_files(prefix, config.path.build_install) } ////////////////////////////////////////////////////////////////////////////////////// @@ -52,7 +52,7 @@ async function fix_rpaths(pkg_prefix: Path, pkg: Package, cache: Path, deps: Ins }} } -async function fix_pc_files(pkg_prefix: Path) { +async function fix_pc_files(pkg_prefix: Path, build_prefix: Path) { //NOTE currently we only support pc files in lib/pkgconfig // we aim to standardize on this but will relent if a package is found // that uses share and other tools that build against it only accept that @@ -66,7 +66,7 @@ async function fix_pc_files(pkg_prefix: Path) { // newer versions of brewkit append +brewing to the path; this will get both // variants const text = orig - .replaceAll(pkg_prefix.join("+brewing").string, `\${pcfiledir}/${relative_path}`) + .replaceAll(build_prefix.string, `\${pcfiledir}/${relative_path}`) .replaceAll(pkg_prefix.string, `\${pcfiledir}/${relative_path}`) if (orig !== text) { console.log({ fixing: path }) @@ -77,7 +77,7 @@ async function fix_pc_files(pkg_prefix: Path) { } } -async function fix_cmake_files(pkg_prefix: Path) { +async function fix_cmake_files(pkg_prefix: Path, build_prefix: Path) { // Facebook and others who use CMake sometimes rely on a libary's .cmake files // being shipped with it. This would be fine, except they have hardcoded paths. // But a simple solution has been found. @@ -90,7 +90,7 @@ async function fix_cmake_files(pkg_prefix: Path) { // newer versions of brewkit append +brewing to the path; this will get both // variants const text = orig - .replaceAll(pkg_prefix.join("+brewing").string, `\${CMAKE_CURRENT_LIST_DIR}/${relative_path}`) + .replaceAll(build_prefix.string, `\${CMAKE_CURRENT_LIST_DIR}/${relative_path}`) .replaceAll(pkg_prefix.string, `\${CMAKE_CURRENT_LIST_DIR}/${relative_path}`) if (orig !== text) { console.log({ fixing: path }) diff --git a/projects/pc-cmake.com/package.yml b/projects/pc-cmake.com/package.yml new file mode 100644 index 00000000..0b426217 --- /dev/null +++ b/projects/pc-cmake.com/package.yml @@ -0,0 +1,12 @@ +versions: + - 1.0.0 + +build: + - run: echo "{{prefix}}" >pc-cmake.pc + working-directory: '{{prefix}}/lib/pkgconfig' + - run: echo "{{prefix}}" >pc-cmake-targets.cmake + working-directory: '{{prefix}}/lib/cmake/pc-cmake' + +test: + - test "$(cat {{prefix}}/lib/pkgconfig/pc-cmake.pc)" = '${pcfiledir}/../..' + - test "$(cat {{prefix}}/lib/cmake/pc-cmake/pc-cmake-targets.cmake)" = '${CMAKE_CURRENT_LIST_DIR}/../../..'