Skip to content

Commit

Permalink
build: separate builds of libnvme and nvme-cli
Browse files Browse the repository at this point in the history
Build and install libnvme separately from libnvme. This should catch any
attempts to include private headers from the library.

Also this is what distro usually do, so we should test this as well.

Signed-off-by: Daniel Wagner <[email protected]>
  • Loading branch information
igaw committed Jun 13, 2024
1 parent a300938 commit 67abaaa
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ jobs:
- name: build
run: |
scripts/build.sh -m muon
build-make-static:
name: make static
runs-on: ubuntu-latest
Expand All @@ -99,3 +100,14 @@ jobs:
- name: build
run: |
make static
build-distro:
name: build libnvme and nvme-cli separately
runs-on: ubuntu-latest
container:
image: ghcr.io/igaw/linux-nvme/debian:latest
steps:
- uses: actions/checkout@v4
- name: build
run: |
scripts/build.sh distro
46 changes: 46 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ usage() {
echo " cross use cross toolchain to build"
echo " coverage build coverage report"
echo " appimage build AppImage target"
echo " distro build libnvme and nvme-cli separately"
echo ""
echo "configs with muon:"
echo " [default] minimal static build"
Expand Down Expand Up @@ -205,6 +206,51 @@ test_muon() {
ldd "${BUILDDIR}/nvme" 2>&1 | grep 'not a dynamic executable' || exit 1
}

_install_libnvme() {
local libnvme_ref=$(sed -n "s/revision = \([0-9a-z]\+\)/\1/p" subprojects/libnvme.wrap)
local LBUILDDIR="${BUILDDIR}/.build-libnvme"

mkdir -p "${BUILDDIR}/libnvme"

pushd "${BUILDDIR}/libnvme"
git init
git remote add origin https://github.com/linux-nvme/libnvme.git
git fetch origin ${libnvme_ref}
git reset --hard FETCH_HEAD

CC="${CC}" "${MESON}" setup \
--prefix="${BUILDDIR}/usr" \
--buildtype="${BUILDTYPE}" \
"${LBUILDDIR}"

"${MESON}" compile \
-C "${LBUILDDIR}"

"${MESON}" install \
-C "${LBUILDDIR}"

popd || exit 1
}

config_meson_distro() {
_install_libnvme

PKG_CONFIG_PATH="${BUILDDIR}/usr/lib64/pkgconfig" \
CC="${CC}" ${MESON} setup \
--prefix="${BUILDDIR}/usr" \
--werror \
--buildtype="${BUILDTYPE}" \
"${BUILDDIR}"
}

build_meson_distro() {
build_meson
}

test_meson_distro() {
test_meson
}

if [[ "${BUILDTOOL}" == "muon" ]]; then
SAMU="$(which samu 2> /dev/null)" || true
if [[ -z "${SAMU}" ]]; then
Expand Down

0 comments on commit 67abaaa

Please sign in to comment.