Skip to content

Support LIBNEO_BRANCH override for the libneo dependency#19

Merged
krystophny merged 6 commits into
mainfrom
feat/dep-branch-override
Jun 15, 2026
Merged

Support LIBNEO_BRANCH override for the libneo dependency#19
krystophny merged 6 commits into
mainfrom
feat/dep-branch-override

Conversation

@krystophny

@krystophny krystophny commented May 28, 2026

Copy link
Copy Markdown
Member

Wires MEPHIT into libneo's per-PR reverse-dependency gate (full=yes downstream) and makes the build hermetic with respect to $CODE.

Dispatch contract

Implements the gate's dispatch contract for MEPHIT's main.yml:

  • main.yml workflow_dispatch inputs: libneo_ref (the libneo ref to build against) and full (accepted for uniform dispatch). LIBNEO_BRANCH is set from inputs.libneo_ref.
  • cmake/Util.cmake: find_or_fetch honors a <DEP>_BRANCH env override. For libneo that is LIBNEO_BRANCH, so a gate dispatch with -f libneo_ref=<sha> builds MEPHIT against that candidate libneo via FetchContent (GIT_TAG ${REMOTE_BRANCH}). Unset keeps the current branch/main resolution. Additive.

MEPHIT CI is build-only (no ctest/pytest tests are registered with the build), so building against the candidate libneo is itself the gate; full=true changes nothing and is accepted only so the gate can dispatch every full=yes downstream uniformly.

Normal push/PR builds are unchanged.

Hermetic build (no $ENV{CODE})

Remove every $ENV{CODE} path from the CMake build so a clean checkout configures without an ambient $CODE tree. libneo is now built from source by default.

  • cmake/Util.cmake find_or_fetch: dropped the $ENV{CODE}/<dep> source bypass. Dependencies default to FetchContent; -D<DEP>_PATH (e.g. -DLIBNEO_PATH=<dir>) remains the explicit local-source fast override. The function now also exports <DEP>_DIR as the dependency build dir.
  • cmake/SetupCODE.cmake: dropped the if(DEFINED ENV{CODE}) block that pre-seeded LIBNEO_DIR, FGSL_DIR, TRIANGLE_DIR, MFEM_DIR from $CODE. LIBNEO_DIR was unused by the build (build links the LIBNEO:: FetchContent targets). FGSL_DIR is unused (build uses find_package(GSL) + GSL::gsl). Triangle and MFEM keep their -DTRIANGLE_DIR= / -DMFEM_DIR= cache options and the FetchContent/ExternalProject fallback in SetupTriangle.cmake / SetupMFEM.cmake.
  • Runtime binary: libneo's FetchContent subbuild builds vacfield.x (via libneo CMakeSources.in) into the dependency build dir. find_or_fetch exports that as LIBNEO_DIR, so vacfield.x is at $MEPHIT_DIR/libneo/vacfield.x instead of $CODE/libneo/build/vacfield.x. README updated accordingly.

Consequence: MEPHIT builds libneo from source by default (hermetic, slower). -DLIBNEO_PATH=<dir> is the local-dev fast path.

Verification

rg -i '\$ENV\{CODE\}' over cmake/, CMakeLists.txt, Makefile returns nothing.

Configure with CODE set in env still fetches libneo from git, not from $CODE:

$ CODE=/home/ert/code cmake -S . -B /tmp/mephit-cfg -G Ninja
...
-- Using libneo ref main from https://github.com/itpplasma/libneo.git
...
-- Configuring done
-- Generating done

LIBNEO_DIR cache resolves to the fetched build dir (<build>/libneo), and vacfield.x is a build target (ninja -t targets | grep vacfield -> vacfield.x).

Tracking itpplasma/code#55, gated by itpplasma/libneo#278.

@krystophny krystophny force-pushed the feat/dep-branch-override branch from 6be309e to 902c4a3 Compare June 8, 2026 12:00
@krystophny krystophny changed the title Support LIBNEO_BRANCH override for the libneo dependency Resolve libneo via LIBNEO_REF override, default to release branch Jun 8, 2026
@krystophny krystophny force-pushed the feat/dep-branch-override branch from 902c4a3 to bb6de68 Compare June 8, 2026 12:12
@krystophny

Copy link
Copy Markdown
Member Author

@phizenz heads-up: this PR is part of a cross-repo change unifying how the codes resolve libneo (a validated LIBNEO_REF override and tracking the release/26.2 branch by default), plus an external CI trigger so the libneo release gate can build this code against a candidate ref. It needed a few more changes than expected, so your feedback would be valuable before it lands. We plan to merge the whole set on Monday, 2026-06-15. Companion CI PR: #23.

@krystophny krystophny force-pushed the feat/dep-branch-override branch from bb6de68 to 98a5768 Compare June 8, 2026 16:38
@krystophny krystophny changed the title Resolve libneo via LIBNEO_REF override, default to release branch Support LIBNEO_BRANCH override for the libneo dependency Jun 8, 2026
Additive: unset keeps current ref resolution. main.yml takes a libneo_ref
dispatch input and exports it as LIBNEO_BRANCH so libneo's release gate can
build MEPHIT against a candidate ref. Tracking itpplasma/code#55.
@krystophny krystophny force-pushed the feat/dep-branch-override branch from 98a5768 to b658305 Compare June 8, 2026 16:42
MEPHIT CI is build-only, so a libneo-gate dispatch already runs the fast path
(the build against the candidate libneo). The inert full input lets the nightly
dispatch every downstream the same way.
LIBNEO_BRANCH read from $ENV{} is replaced by the -DLIBNEO_REF=<ref>
cache variable. LIBNEO_PATH replaces the implicit $ENV{CODE}/libneo
local-source path. Both default to auto-detection when unset; no
behavior change for unmodified builds.

Makefile unexports LIBNEO_REF, LIBNEO_PATH, LIBNEO_BRANCH, and LIBNEO_DIR
so ambient shell values cannot reach cmake. Only an explicit command-line
value (make LIBNEO_REF=<ref>) is forwarded as -DLIBNEO_REF.

The dispatch workflow drops the env: LIBNEO_BRANCH block and passes the
ref directly via make LIBNEO_REF=${{ inputs.libneo_ref }}, so the
libneo-gate contract is preserved without the environment footgun.

SetupCODE.cmake declares LIBNEO_REF and LIBNEO_PATH as typed cache
variables so they appear in cmake-gui and ccmake. README documents
both overrides.
Remove every $ENV{CODE} path from the CMake build so a clean checkout
configures without an ambient $CODE tree.

- find_or_fetch (Util.cmake): drop the $ENV{CODE}/<dep> source bypass.
  Dependencies default to FetchContent; -D<DEP>_PATH stays as the
  explicit local-source override.
- SetupCODE.cmake: drop the $ENV{CODE} block that pre-seeded
  LIBNEO_DIR, FGSL_DIR, TRIANGLE_DIR, MFEM_DIR. LIBNEO_DIR was unused
  by the build; FGSL_DIR is unused (build uses find_package(GSL));
  Triangle and MFEM keep their -DTRIANGLE_DIR / -DMFEM_DIR cache
  options plus FetchContent fallback in SetupTriangle / SetupMFEM.
- find_or_fetch now exports <DEP>_DIR as the dependency build dir.
  libneo builds vacfield.x into that dir, so LIBNEO_DIR points at the
  fetched build output instead of $CODE/libneo/build.
- README: vacfield.x now lives at $MEPHIT_DIR/libneo/vacfield.x.

libneo is now built from source by default (hermetic, slower);
-DLIBNEO_PATH=<dir> is the fast local-dev override.
MEPHIT calls fftw_* directly from src/fftw3.f90 and src/mephit_util.f90.
The MEPHIT_LIBS list already referenced ${FFTW_LIBRARIES}, but
find_package(FFTW) was never called, so the variable was empty and the
link line carried no -lfftw3. FFTW was previously pulled in transitively
through the prebuilt libneo shared object; building libneo from source as
a static library removed that transitive linkage and exposed the missing
explicit dependency.

Call find_package(FFTW REQUIRED COMPONENTS DOUBLE_LIB) alongside the other
system deps and add FFTW_INCLUDE_DIRS to the mephit include path.
@krystophny krystophny merged commit 01ddfbf into main Jun 15, 2026
1 check passed
@krystophny krystophny deleted the feat/dep-branch-override branch June 15, 2026 21:49
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