From ff677a0c3a4c63d2c5cd9ce401d9e42dc6d1d25e Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Sun, 23 Jul 2023 00:43:40 -0700 Subject: [PATCH 1/8] ensure superceded PR workflows are cancelled Add a concurrency specifier so that github actions cancels matching PR pushes and similar, saves a lot of compute when iterating on commit style and similar with force pushes. --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a83848610..870a91057 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,5 +1,8 @@ on: [ pull_request, push, workflow_dispatch ] name: ci +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true jobs: check-pr: name: validate commits From d71f9613b4d0176c881b2c1a083db504be07126c Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Mon, 24 Jul 2023 23:58:15 -0700 Subject: [PATCH 2/8] remove extra quote in codecov.yml It's unclear if this was causing problems, but it made the yaml fail validation so it seems prudent to clean it up. --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 33f27dcf1..71317c661 100644 --- a/codecov.yml +++ b/codecov.yml @@ -7,7 +7,7 @@ coverage: - "**/tests/*.c" - "src/common/libtap/.*" - "src/common/libutil/json.hpp" - - "src/common/yggdrasil/.*"" + - "src/common/yggdrasil/.*" # Allow coverage to drop up to 0.1% status: From 7077ec0847d3e52e3be1f9ac3edb72f5713c2c99 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Tue, 22 Aug 2023 09:54:40 -0700 Subject: [PATCH 3/8] docker: update docker/checks from core, add cmake problem: sched's containers, matrix and check scripts were out of date compared to core solution: Pull in the new bookworm and fedora38 containers and multiarch build setup from core, along with updated check files and fixes. We now get arm64 containers out the other end. I tried getting 32-bit also, but it is very, very broken, and also complicated by a bug in qemu-user and/or the linux kernel depending on who you ask. Would be really nice to have that extra check, but it's got to be a different PR at this point. Add cmake and ninja to all containers for the new build setup. While not strictly required, ninja is tiny and makes the builds and rebuilds faster when used. --- .github/workflows/main.yml | 36 ++++++++++++++-- src/test/docker/bionic/Dockerfile | 28 ------------- src/test/docker/bookworm/Dockerfile | 5 ++- src/test/docker/docker-run-checks.sh | 21 +++++++++- src/test/docker/el7/Dockerfile | 27 ------------ src/test/docker/el8/Dockerfile | 8 +++- src/test/docker/fedora34/Dockerfile | 1 + .../docker/{fedora33 => fedora38}/Dockerfile | 9 ++-- src/test/docker/focal/Dockerfile | 8 +++- src/test/docker/jammy/Dockerfile | 3 +- src/test/generate-matrix.py | 42 ++++++++++++++++++- 11 files changed, 118 insertions(+), 70 deletions(-) delete mode 100644 src/test/docker/bionic/Dockerfile delete mode 100644 src/test/docker/el7/Dockerfile rename src/test/docker/{fedora33 => fedora38}/Dockerfile (78%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 870a91057..169cd67c6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -on: [ pull_request, push, workflow_dispatch ] +on: [ pull_request, push, workflow_dispatch, merge_group] name: ci concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'pull_request' steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 @@ -89,7 +89,7 @@ jobs: fail-fast: false name: ${{matrix.name}} steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: ref: ${{ github.event.pull_request.head.sha }} fetch-depth: 0 @@ -100,10 +100,11 @@ jobs: github.ref != 'refs/heads/master' run: | # Ensure git-describe works on a tag. - # (checkout@v2 action may have left current tag as + # (checkout@v3 action may have left current tag as # lightweight instead of annotated. See # https://github.com/actions/checkout/issues/290) # + echo github.ref == ${{ github.ref }} ; git fetch -f origin ${{ github.ref }}:${{ github.ref }} ; echo git describe now reports $(git describe --always) @@ -117,6 +118,15 @@ jobs: pip3 install --upgrade pip ; pip3 install --upgrade --force-reinstall coverage ; + + - name: docker buildx + uses: docker/setup-buildx-action@v2 + if: matrix.needs_buildx + + - uses: dbhi/qus/action@main + with: + targets: aarch64 + - name: docker-run-checks env: ${{matrix.env}} run: ${{matrix.command}} @@ -153,6 +163,24 @@ jobs: prerelease: true body: | View [Release Notes](https://github.com/${{ github.repository }}/blob/${{ matrix.tag }}/NEWS.md) for flux-sched ${{ matrix.tag }} + generate-manifest: + name: Generate docker manifest + runs-on: ubuntu-latest + needs: [ci-checks] + env: + DOCKER_REPO: fluxrm/flux-core + DOCKER_USERNAME: travisflux + DOCKER_PASSWORD: ${{ secrets.DOCKER_HUB_TRAVISFLUX_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - name: make and push manifest as fluxrm/flux-core + if: > + (startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master') + run: | + echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin + # maybe bring back later: fluxrm/flux-core:bookworm-386 + docker manifest create fluxrm/flux-core:bookworm fluxrm/flux-core:bookworm-amd64 fluxrm/flux-core:bookworm-arm64 + docker manifest push fluxrm/flux-core:bookworm - name: upload tarball id: upload-tarball diff --git a/src/test/docker/bionic/Dockerfile b/src/test/docker/bionic/Dockerfile deleted file mode 100644 index a3a38e7bc..000000000 --- a/src/test/docker/bionic/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM fluxrm/flux-core:bionic - -ARG USER=flux -ARG UID=1000 - -# Install extra buildrequires for flux-sched: -RUN sudo apt-get update -RUN sudo apt-get -qq install -y --no-install-recommends \ - libboost-graph-dev \ - libboost-system-dev \ - libboost-filesystem-dev \ - libboost-regex-dev \ - python-yaml \ - libyaml-cpp-dev \ - libedit-dev - -# Add configured user to image with sudo access: -# -RUN \ - if test "$USER" != "flux"; then \ - sudo groupadd -g $UID $USER \ - && sudo useradd -g $USER -u $UID -d /home/$USER -m $USER \ - && sudo sh -c "printf \"$USER ALL= NOPASSWD: ALL\\n\" >> /etc/sudoers" \ - && sudo adduser $USER sudo ; \ - fi - -USER $USER -WORKDIR /home/$USER diff --git a/src/test/docker/bookworm/Dockerfile b/src/test/docker/bookworm/Dockerfile index 3f8fefe98..4dff140a3 100644 --- a/src/test/docker/bookworm/Dockerfile +++ b/src/test/docker/bookworm/Dockerfile @@ -10,9 +10,10 @@ RUN sudo apt-get -qq install -y --no-install-recommends \ libboost-system-dev \ libboost-filesystem-dev \ libboost-regex-dev \ - python3-yaml \ libyaml-cpp-dev \ - libedit-dev + libedit-dev \ + ninja-build \ + python3-yaml # Add configured user to image with sudo access: # diff --git a/src/test/docker/docker-run-checks.sh b/src/test/docker/docker-run-checks.sh index 4f83a353c..fc9587917 100755 --- a/src/test/docker/docker-run-checks.sh +++ b/src/test/docker/docker-run-checks.sh @@ -11,7 +11,7 @@ PROJECT=flux-sched BASE_DOCKER_REPO=fluxrm/flux-core WORKDIR=/usr/src -IMAGE=jammy +IMAGE=bookworm JOBS=2 MOUNT_HOME_ARGS="--volume=$HOME:/home/$USER -e HOME" @@ -118,6 +118,17 @@ if test "$DISTCHECK" = "t"; then done fi +if test "$SYSTEM" = "t"; then + if test "$IMAGE" != "el8"; then + echo >&2 "Setting image to el8 for system checks build" + fi + IMAGE=el8 + TAG="checks-builder:el8" + INSTALL_ONLY=t + NO_CACHE="--no-cache" + POISON=0 +fi + CONFIGURE_ARGS="$@" . ${TOP}/src/test/checks-lib.sh @@ -252,3 +263,11 @@ if test -n "$TAG"; then docker rm tmp.$$ echo "Tagged image $TAG" fi + +if test -n "$SYSTEM"; then + ${TOP}/src/test/docker/docker-run-systest.sh \ + --image=${TAG} \ + --jobs=${JOBS} \ + -- src/test/checks_run.sh ${CONFIGURE_ARGS} \ + || die "docker-run-systest.sh failed" +fi diff --git a/src/test/docker/el7/Dockerfile b/src/test/docker/el7/Dockerfile deleted file mode 100644 index 93ac6a519..000000000 --- a/src/test/docker/el7/Dockerfile +++ /dev/null @@ -1,27 +0,0 @@ -FROM fluxrm/flux-core:el7 - -ARG USER=flux -ARG UID=1000 - -# Install extra buildrequires for flux-sched: -RUN sudo yum -y install \ - libboost-graph-devel \ - libboost-system-devel \ - libboost-filesystem-devel \ - libboost-regex-devel \ - python-yaml \ - yaml-cpp-devel \ - libedit-devel - -# Add configured user to image with sudo access: -# -RUN \ - if test "$USER" != "flux"; then \ - sudo groupadd -g $UID $USER \ - && sudo useradd -g $USER -u $UID -d /home/$USER -m $USER \ - && sudo sh -c "printf \"$USER ALL= NOPASSWD: ALL\\n\" >> /etc/sudoers" \ - && sudo usermod -G wheel $USER; \ - fi - -USER $USER -WORKDIR /home/$USER diff --git a/src/test/docker/el8/Dockerfile b/src/test/docker/el8/Dockerfile index febc2293b..deaa2a60e 100644 --- a/src/test/docker/el8/Dockerfile +++ b/src/test/docker/el8/Dockerfile @@ -13,7 +13,13 @@ RUN sudo yum -y install \ readline-devel \ python3-pyyaml \ yaml-cpp-devel \ - libedit-devel + libedit-devel \ + ninja-build \ + curl + +RUN curl -s -L https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-$(uname -m).sh > cmake.sh ;\ + sudo bash cmake.sh --prefix=/usr/local --skip-license ;\ + rm cmake.sh # Add configured user to image with sudo access: # diff --git a/src/test/docker/fedora34/Dockerfile b/src/test/docker/fedora34/Dockerfile index 7745cd4c1..649b44b44 100644 --- a/src/test/docker/fedora34/Dockerfile +++ b/src/test/docker/fedora34/Dockerfile @@ -17,6 +17,7 @@ RUN sudo yum -y update \ python3-pyyaml \ yaml-cpp-devel \ libedit-devel \ + ninja-build \ && sudo yum clean all # Add configured user to image with sudo access: diff --git a/src/test/docker/fedora33/Dockerfile b/src/test/docker/fedora38/Dockerfile similarity index 78% rename from src/test/docker/fedora33/Dockerfile rename to src/test/docker/fedora38/Dockerfile index 5709d6eb2..d0c013299 100644 --- a/src/test/docker/fedora33/Dockerfile +++ b/src/test/docker/fedora38/Dockerfile @@ -1,11 +1,11 @@ -FROM fluxrm/flux-core:fedora33 +FROM fluxrm/flux-core:fedora38 -LABEL maintainer="Stephen Herbein " +LABEL maintainer="Mark A. Grondona " ARG USER=flux ARG UID=1000 -# Enable PowerTools for development packages +# Install flux-sched dependencies RUN sudo yum -y update \ && sudo yum -y install \ boost-devel \ @@ -17,6 +17,9 @@ RUN sudo yum -y update \ python3-pyyaml \ yaml-cpp-devel \ libedit-devel \ + ninja-build \ + cmake \ + clang \ && sudo yum clean all # Add configured user to image with sudo access: diff --git a/src/test/docker/focal/Dockerfile b/src/test/docker/focal/Dockerfile index 63e39bc41..0fbf1eddd 100644 --- a/src/test/docker/focal/Dockerfile +++ b/src/test/docker/focal/Dockerfile @@ -12,7 +12,13 @@ RUN sudo apt-get -qq install -y --no-install-recommends \ libboost-regex-dev \ python-yaml \ libyaml-cpp-dev \ - libedit-dev + libedit-dev \ + ninja-build \ + curl + +RUN curl -s -L https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-linux-$(uname -m).sh > cmake.sh ;\ + sudo bash cmake.sh --prefix=/usr/local --skip-license ;\ + rm cmake.sh # Add configured user to image with sudo access: # diff --git a/src/test/docker/jammy/Dockerfile b/src/test/docker/jammy/Dockerfile index 97d18e60b..b8c3e18c2 100644 --- a/src/test/docker/jammy/Dockerfile +++ b/src/test/docker/jammy/Dockerfile @@ -12,7 +12,8 @@ RUN sudo apt-get -qq install -y --no-install-recommends \ libboost-regex-dev \ python3-yaml \ libyaml-cpp-dev \ - libedit-dev + libedit-dev \ + ninja-build # Add configured user to image with sudo access: # diff --git a/src/test/generate-matrix.py b/src/test/generate-matrix.py index 512ab406f..dcfa98372 100755 --- a/src/test/generate-matrix.py +++ b/src/test/generate-matrix.py @@ -30,12 +30,14 @@ def __init__(self): if match: self.tag = match.group(1) - def create_docker_tag(self, image, env, command): + def create_docker_tag(self, image, env, command, platform): """Create docker tag string if this is master branch or a tag""" if self.branch == "master" or self.tag: tag = f"{DOCKER_REPO}:{image}" if self.tag: tag += f"-{self.tag}" + if platform is not None: + tag += "-" + platform.split("/")[1] env["DOCKER_TAG"] = tag command += f" --tag={tag}" return True, command @@ -52,6 +54,7 @@ def add_build( docker_tag=False, coverage=False, recheck=True, + platform=None, command_args="", ): """Add a build to the matrix.include array""" @@ -59,6 +62,11 @@ def add_build( # Extra environment to add to this command: env = env or {} + needs_buildx = False + if platform: + command_args += f"--platform={platform}" + needs_buildx = True + # The command to run: command = f"{docker_run_checks} -j{jobs} --image={image} {command_args}" @@ -68,7 +76,7 @@ def add_build( if docker_tag: # Only export docker_tag if this is main branch or a tag: - docker_tag, command = self.create_docker_tag(image, env, command) + docker_tag, command = self.create_docker_tag(image, env, command, platform) if coverage: env["COVERAGE"] = "t" @@ -94,6 +102,7 @@ def add_build( "branch": self.branch, "coverage": coverage, "docker_tag": docker_tag, + "needs_buildx": needs_buildx, "create_release": create_release, } ) @@ -107,6 +116,27 @@ def __str__(self): matrix = BuildMatrix() +# Debian: no args +matrix.add_build(name="bookworm") + +# # Debian: 32b -- NOTE: VERY broken right now +# matrix.add_build( +# name="bookworm - 32 bit", +# image="bookworm", +# platform="linux/386", +# docker_tag=True, +# ) + +# Debian: arm64, expensive, only on master and tags, only install +if matrix.branch == "master" or matrix.tag: + matrix.add_build( + name="bookworm - arm64", + image="bookworm", + platform="linux/arm64", + docker_tag=True, + command_args="--install-only ", + ) + # Debian: gcc-12, distcheck matrix.add_build( name="bookworm - gcc-12,distcheck", @@ -138,6 +168,7 @@ def __str__(self): matrix.add_build( name="bookworm - test-install", env=dict(TEST_INSTALL="t"), + platform="linux/amd64", docker_tag=True, ) @@ -170,4 +201,11 @@ def __str__(self): docker_tag=True, ) +# Fedora38 +matrix.add_build( + name="fedora38", + image="fedora38", + docker_tag=True, +) + print(matrix) From 4b0c1ab48651ca14d6e2e7bd8c6a5766ff4ae1f3 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Wed, 6 Sep 2023 16:38:40 -0700 Subject: [PATCH 4/8] gitignore: ignore cmake, ninja, direnv, macos and vim artifacts lots of noise gets generated by cmake and ctest without some ignores --- .gitignore | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.gitignore b/.gitignore index a2eb95e39..4f66700fa 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,33 @@ libtool .libs/ libltdl/ +# cmake and ninja +*.counts +.ninja_deps +.ninja_log +.cmake/ +/*build* +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing +Makefile +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps + +# directory management +.direnv + +# MacOS +.DS_Store + +# vim local +.vim + # generated library version header /src/common/libflux/version.h From 8b503eb5d809182a48d9f100cfd5846b800c14c7 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Wed, 6 Sep 2023 16:39:57 -0700 Subject: [PATCH 5/8] add cmake build system alongside autotools This is a big one, that was originally developed as a series of commits, major decisions are summarized below, but the short version is we have a cmake-based build system that can be configured and built as though it still had autotools. To use the autotools build system, manually run autoreconf to replace the configure script, and then build as usual. We're adding a fake configure script here so that it has approximately the same ergonomics as the autotools build system. The only thing that causes some breakage is that the autogen.sh script is a no-op, so autoreconf needs to be run manually to do the autotools side of the build system. To mimic the autotools build system: 1. respect PYTHON env var This is a QOL improvement to allow specifying the python version the autotools way rather than with the cmake defines. 2. find flux-core by finding flux, match prefix if none specified @grondo pointed me to a feature I didn't know we had, where if flux-core is in path it's automatically found. This does that in the cmake build system both for the way autotools does it, by checking the install prefix, and by checking path as well. Note on yaml-cpp, while they provide an upstream cmake config that I would prefer to use, not all of our docker containers actually offer that support, so we're still using pkg-config for now. --- .configure-custom.sh | 4 + .github/workflows/main.yml | 10 +- CMakeLists.txt | 213 ++++++++++++++ autogen.sh | 5 - cmake/CodeCoverage.cmake | 122 ++++++++ cmake/FindFluxCore.cmake | 42 +++ cmake/config_testing.cmake | 46 +++ configure | 319 +++++++++++++++++++++ configure-cmake | 319 +++++++++++++++++++++ configure.ac | 2 +- etc/CMakeLists.txt | 4 + flux-plugin.map | 9 + qmanager/CMakeLists.txt | 2 + qmanager/modules/CMakeLists.txt | 13 + resource/CMakeLists.txt | 100 +++++++ resource/evaluators/CMakeLists.txt | 2 + resource/evaluators/test/CMakeLists.txt | 9 + resource/libjobspec/CMakeLists.txt | 25 ++ resource/modules/CMakeLists.txt | 10 + resource/planner/CMakeLists.txt | 3 + resource/planner/c++/CMakeLists.txt | 12 + resource/planner/c/CMakeLists.txt | 9 + resource/planner/test/CMakeLists.txt | 9 + resource/policies/CMakeLists.txt | 2 + resource/policies/base/CMakeLists.txt | 2 + resource/policies/base/test/CMakeLists.txt | 7 + resource/reapi/CMakeLists.txt | 2 + resource/reapi/bindings/CMakeLists.txt | 20 ++ resource/schema/CMakeLists.txt | 1 + resource/schema/test/CMakeLists.txt | 7 + resource/utilities/CMakeLists.txt | 30 ++ resource/utilities/test/CMakeLists.txt | 2 + src/CMakeLists.txt | 5 + src/cmd/CMakeLists.txt | 3 + src/common/CMakeLists.txt | 4 + src/common/c++wrappers/CMakeLists.txt | 2 + src/common/c++wrappers/test/CMakeLists.txt | 3 + src/common/libtap/CMakeLists.txt | 7 + src/common/yggdrasil/CMakeLists.txt | 15 + src/python/CMakeLists.txt | 14 + src/shell/CMakeLists.txt | 5 + src/test/checks_run.sh | 9 +- src/test/docker/fedora38/Dockerfile | 1 + t/CMakeLists.txt | 93 ++++++ t/scripts/maybe-installtest | 7 + t/sharness.d/sched-sharness.sh | 4 +- t/t7000-shell-datastaging.t | 6 +- 47 files changed, 1526 insertions(+), 14 deletions(-) create mode 100755 .configure-custom.sh create mode 100644 CMakeLists.txt create mode 100644 cmake/CodeCoverage.cmake create mode 100644 cmake/FindFluxCore.cmake create mode 100644 cmake/config_testing.cmake create mode 100755 configure create mode 100755 configure-cmake create mode 100644 etc/CMakeLists.txt create mode 100644 flux-plugin.map create mode 100644 qmanager/CMakeLists.txt create mode 100644 qmanager/modules/CMakeLists.txt create mode 100644 resource/CMakeLists.txt create mode 100644 resource/evaluators/CMakeLists.txt create mode 100644 resource/evaluators/test/CMakeLists.txt create mode 100644 resource/libjobspec/CMakeLists.txt create mode 100644 resource/modules/CMakeLists.txt create mode 100644 resource/planner/CMakeLists.txt create mode 100644 resource/planner/c++/CMakeLists.txt create mode 100644 resource/planner/c/CMakeLists.txt create mode 100644 resource/planner/test/CMakeLists.txt create mode 100644 resource/policies/CMakeLists.txt create mode 100644 resource/policies/base/CMakeLists.txt create mode 100644 resource/policies/base/test/CMakeLists.txt create mode 100644 resource/reapi/CMakeLists.txt create mode 100644 resource/reapi/bindings/CMakeLists.txt create mode 100644 resource/schema/CMakeLists.txt create mode 100644 resource/schema/test/CMakeLists.txt create mode 100644 resource/utilities/CMakeLists.txt create mode 100644 resource/utilities/test/CMakeLists.txt create mode 100644 src/CMakeLists.txt create mode 100644 src/cmd/CMakeLists.txt create mode 100644 src/common/CMakeLists.txt create mode 100644 src/common/c++wrappers/CMakeLists.txt create mode 100644 src/common/c++wrappers/test/CMakeLists.txt create mode 100644 src/common/libtap/CMakeLists.txt create mode 100644 src/common/yggdrasil/CMakeLists.txt create mode 100644 src/python/CMakeLists.txt create mode 100644 src/shell/CMakeLists.txt create mode 100644 t/CMakeLists.txt create mode 100755 t/scripts/maybe-installtest diff --git a/.configure-custom.sh b/.configure-custom.sh new file mode 100755 index 000000000..a4aea3889 --- /dev/null +++ b/.configure-custom.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +ENABLE_VARS="code-coverage|yes|ENABLE_COVERAGE" +ENABLE_ENABLE_COVERAGE_DOC="enable coverage analysis" diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 169cd67c6..b5f1172c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -131,10 +131,12 @@ jobs: env: ${{matrix.env}} run: ${{matrix.command}} - - name: annotate errors - if: failure() || cancelled() - env: ${{matrix.env}} - run: src/test/checks-annotate.sh + - name: Upload test results + if: always() + uses: actions/upload-artifact@v3 + with: + name: ${{matrix.name}}-results.xml + path: test-results.xml - name: coverage report if: success() && matrix.coverage diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..e1defe4e2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,213 @@ +cmake_minimum_required(VERSION 3.14) +set(VER_FILE ${CMAKE_BINARY_DIR}/flux-sched.ver) +if(EXISTS ${VER_FILE}) + file(READ ${VER_FILE} FLUX_SCHED_VER) + string(STRIP ${FLUX_SCHED_VER} FLUX_SCHED_VER) +else() + execute_process(COMMAND sh -c [=[git describe --always | awk '/.*/ {sub(/^v/, ""); printf "%s",$1; exit}']=] OUTPUT_VARIABLE FLUX_SCHED_VER) +endif() +message(STATUS "VER ${FLUX_SCHED_VER}") +string(REGEX REPLACE "-.*$" "" FLUX_SCHED_VER_NOGIT ${FLUX_SCHED_VER}) +project(flux-sched VERSION ${FLUX_SCHED_VER_NOGIT} LANGUAGES CXX C) +message(STATUS "Building flux-sched version ${FLUX_SCHED_VER}") + +if(POLICY CMP0140) + cmake_policy(SET CMP0140 NEW) +endif() +# Option to Enable SPHINX +option( SPHINX "Enable SPHINX" OFF ) + +# Option to AS_HELP_STRING([--disable-docs +option( DOCS "Enable docs generation" OFF ) + +set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ standard to use") +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +# The lines below will generate the config.h based on the options above +# The file will be in the ${CMAKE_BINARY_DIR} location +set(CONFIG_H ${CMAKE_BINARY_DIR}/config.h) +string(TIMESTAMP CURRENT_TIMESTAMP) +file(WRITE ${CONFIG_H} "/* WARNING: This file is auto-generated by CMake on ${CURRENT_TIMESTAMP}. DO NOT EDIT!!! */\n\n") + +## !!! WARNING These are the defines that were defined regardless of an option. +## !!! Or the script couldn't match them. Match them accordingly, delete them or keep them +file(APPEND ${CONFIG_H} "/* Define _GNU_SOURCE so that we get all necessary prototypes */\n") +file(APPEND ${CONFIG_H} "#define _GNU_SOURCE 1 \n\n ") +include( GNUInstallDirs ) # convenience names for gnu-style directories +# RPATH setup +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH ON) +set( CMAKE_BUILD_RPATH + ${CMAKE_BINARY_DIR}/resource:${CMAKE_BINARY_DIR}/src/common/libtap ) +# the RPATH to be used when installing, but only if it's not a system directory +list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir) +if("${isSystemDir}" STREQUAL "-1") + set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") +endif("${isSystemDir}" STREQUAL "-1") + + +# Setting the include directory for the application to find config.h +include_directories( ${CMAKE_BINARY_DIR} ) +# Since we have created a config.h add a global define for it +add_definitions( "-DHAVE_CONFIG_H" ) +add_definitions( "-DPACKAGE_VERSION=\"${FLUX_SCHED_VER}\"" ) + +# We build a lot of shared libs, build them all with PIC +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + +# variable to store paths to add to module path for tests + +list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake) +list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}) + +# external dependencies +find_package(PkgConfig REQUIRED) +set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") +find_package(FluxCore REQUIRED) +if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) + message(STATUS "flux core found and no specific prefix specified, using ${FLUX_CORE_PREFIX}") + set(CMAKE_INSTALL_PREFIX ${FLUX_CORE_PREFIX} CACHE PATH "..." FORCE) +endif() +if(DEFINED ENV{PYTHON}) + set(Python_EXECUTABLE $ENV{PYTHON} CACHE FILEPATH "") +endif() +find_package(Python 3.6...<4.0 COMPONENTS Interpreter Development REQUIRED) # 3.6 or higher +execute_process( + COMMAND "${Python_EXECUTABLE}" -c "import sysconfig as sc; print(sc.get_path('purelib', vars={'base':'${CMAKE_INSTALL_PREFIX}'}))" + OUTPUT_VARIABLE PYTHON_INSTALL_SITELIB + OUTPUT_STRIP_TRAILING_WHITESPACE) +execute_process( + COMMAND "${Python_EXECUTABLE}" -c "import sysconfig as sc; print(sc.get_path('platlib', vars={'platbase':'${CMAKE_INSTALL_PREFIX}'}))" + OUTPUT_VARIABLE PYTHON_INSTALL_SITEARCH + OUTPUT_STRIP_TRAILING_WHITESPACE) +pkg_check_modules(yaml-cpp REQUIRED IMPORTED_TARGET yaml-cpp) +pkg_check_modules(LIBEDIT REQUIRED IMPORTED_TARGET libedit) +pkg_check_modules(CZMQ REQUIRED IMPORTED_TARGET libczmq>=3.0.0) +pkg_check_modules(HWLOC REQUIRED IMPORTED_TARGET hwloc>=1.11.1) +pkg_check_modules(JANSSON REQUIRED IMPORTED_TARGET jansson>=2.10) +pkg_check_modules(UUID REQUIRED IMPORTED_TARGET uuid) + +set(Boost_USE_STATIC_LIBS OFF) +set(Boost_USE_MULTITHREADED ON) +set(Boost_USE_STATIC_RUNTIME OFF) +find_package(Boost 1.50 REQUIRED COMPONENTS + system + filesystem + graph + regex) +message(STATUS "Boost version: ${Boost_VERSION}") + +# Install paths +set(FLUX_CMD_DIR "${CMAKE_INSTALL_PREFIX}/libexec/cmd") +set(FLUX_LIB_DIR "${CMAKE_INSTALL_LIBDIR}/flux") +set(FLUX_MOD_DIR "${FLUX_LIB_DIR}/modules") +set(FLUX_SHELL_PLUGIN_DIR "${FLUX_LIB_DIR}/shell/plugins") +set(FLUX_RC1_DIR "${CMAKE_INSTALL_SYSCONFDIR}/flux/rc1.d") +set(FLUX_RC3_DIR "${CMAKE_INSTALL_SYSCONFDIR}/flux/rc3.d") + +include(config_testing) +### HELPERS +function(flux_find_python_module Name Version) + execute_process( + COMMAND ${Python_EXECUTABLE} -c "import ${Name}; print(${Name}.__version__)" + RESULT_VARIABLE EXIT_CODE + OUTPUT_VARIABLE MOD_VER + OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_QUIET + # COMMAND_ECHO STDOUT + ) + if(MOD_VER VERSION_GREATER_EQUAL Version) + set(${Name}_MOD $MOD_VER PARENT_SCOPE) + else() + set(${Name}_MOD NOTFOUND PARENT_SCOPE) + message(FATAL_ERROR "Python module ${Name} not found or version too low, need ${Version} got ${MOD_VER}") + endif() +endfunction() +function(flux_add_plugin TargetName PluginType) + # This odd construction is as close as we can get to + # generic argument forwarding + set(options "NOINSTALL") + set(oneValueArgs "") + set(multiValueArgs "") + + if(PluginType STREQUAL "MODULE") + set(LinkerOpts "LINKER:--no-undefined") + set(InstallDest ${FLUX_MOD_DIR}) + elseif(PluginType STREQUAL "SHELL") + set(InstallDest ${FLUX_SHELL_PLUGIN_DIR}) + endif() + + cmake_parse_arguments(PARSE_ARGV 2 ARG + "${options}" "${oneValueArgs}" "${multiValueArgs}") + + set(__argsQuoted) + foreach(__item IN LISTS ARG_UNPARSED_ARGUMENTS) + string(APPEND __argsQuoted " [==[${__item}]==]") + endforeach() + cmake_language(EVAL CODE " + add_library( + ${TargetName} + ${LibFlags} + MODULE + # List these last so they can override things we set above + ${__argsQuoted} + )" + ) + target_link_options(${TargetName} PRIVATE + "LINKER:--version-script=${CMAKE_SOURCE_DIR}/flux-plugin.map" ${LinkerOpts}) + target_link_libraries(${TargetName} PRIVATE flux::core) + if (NOT ARG_NOINSTALL) + install(TARGETS ${TargetName} + LIBRARY DESTINATION ${InstallDest}) + endif() + set_property(TARGET ${TargetName} PROPERTY PREFIX "") +endfunction() +### END HELPERS +flux_find_python_module(yaml 3.10) +flux_find_python_module(jsonschema 2.3.0) + +if(ENABLE_COVERAGE) + include(CodeCoverage) + + SET(COVERAGE_FLAGS "--coverage -g -fprofile-arcs -ftest-coverage") + SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_FLAGS}" ) + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS}" ) + SET( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${COVERAGE_FLAGS}" ) +endif() + +include_directories(.) +add_subdirectory( etc ) +add_subdirectory( src ) +add_subdirectory( resource ) +add_subdirectory( qmanager ) +# add_subdirectory( doc ) +add_subdirectory( t ) + +if(ENABLE_COVERAGE) + blt_add_code_coverage_target(NAME flux-sched-coverage + DEPENDS check + RUNNER ${CMAKE_CTEST_COMMAND} + REMOVE "*/include/boost/*" "/nix/store/*" "*/include/boost/*" "*/src/common/libutil/*" "*/src/common/libtap/*" "*/src/common/yggdrasil/*") + add_custom_target(check-code-coverage + DEPENDS flux-sched-coverage) +endif() +set(CTEST_COMMON_FLAGS --output-on-failure --output-junit + ${CMAKE_CURRENT_BINARY_DIR}/test-results.xml) +add_custom_target(check + DEPENDS ${check_targets} + COMMAND ${CMAKE_CTEST_COMMAND} ${CTEST_COMMON_FLAGS} + ) +add_custom_target(installcheck + COMMAND env FLUX_SCHED_TEST_INSTALLED=1 ${CMAKE_CTEST_COMMAND} ${CTEST_COMMON_FLAGS}) +# run installcheck, if it passes then write out version information and pack up +# a tarball with the result +add_custom_target(distcheck + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target all + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target check + COMMAND git archive --format=tar.gz + --add-virtual-file=flux-sched.ver:${FLUX_SCHED_VER} + --prefix=flux-sched-${FLUX_SCHED_VER}/ + --output=${CMAKE_BINARY_DIR}/flux-sched-${FLUX_SCHED_VER}.tar.gz + HEAD . + ) diff --git a/autogen.sh b/autogen.sh index 15729ebd1..0fd9d9dcf 100755 --- a/autogen.sh +++ b/autogen.sh @@ -4,8 +4,3 @@ # libtool macros can be found if libtool is in PATH, but its # macros are not in default aclocal search path. # -echo "Running libtoolize --automake --copy ... " -libtoolize --automake --copy || exit -echo "Running autoreconf --verbose --install" -autoreconf --verbose --install || exit -echo "Now run ./configure." diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake new file mode 100644 index 000000000..b0dc4657b --- /dev/null +++ b/cmake/CodeCoverage.cmake @@ -0,0 +1,122 @@ +# Copyright (c) 2012 - 2015, Lars Bilke. See the top-level LICENSE file for details +# +# SPDX-License-Identifier: (BSD-3-Clause) + + +# 2012-01-31, Lars Bilke +# - Enable Code Coverage +# +# 2013-09-17, Joakim Soderberg +# - Added support for Clang. +# - Some additional usage instructions. +# +# (Original LCOV + GENHTML CMake Macro) from Lars Bilke + Joakim Soderberg +# +# 2015-07-06, Aaron Black +# - Modified for use by BLT. +# +# 2016-04-04, Kenny Weiss +# - Removed support for clang; simplified flags +# +# 2017-07-25, Cyrus Harrison +# - Refactored to only include report gen logic, not coverage flags +# +# 2020-11-18, Josh Essman +# - Continue generation after failing tests, allow user to specify src dir + +set(BLT_CODE_COVERAGE_REPORTS ON) + +FIND_PROGRAM( GCOV_EXECUTABLE gcov ) +FIND_PROGRAM( LCOV_EXECUTABLE lcov ) +FIND_PROGRAM( GENHTML_EXECUTABLE genhtml ) +FIND_PROGRAM( GCOVR_EXECUTABLE gcovr PATHS ${CMAKE_SOURCE_DIR}/tests) + +# Check for lcov +if(NOT EXISTS ${LCOV_EXECUTABLE}) + message(STATUS "Code coverage: Unable to find lcov, disabling code coverage reports.") + set(BLT_CODE_COVERAGE_REPORTS OFF) +endif() + +# Check for genthml +if(NOT EXISTS ${GENHTML_EXECUTABLE}) + message(STATUS "Code coverage: Unable to find genhtml, disabling code coverage reports.") + set(BLT_CODE_COVERAGE_REPORTS OFF) +endif() + +# Check for gcov +if(NOT EXISTS ${GCOV_EXECUTABLE}) + message(STATUS "Code coverage: GCOV_EXECUTABLE is not set, disabling code coverage reports") + set(BLT_CODE_COVERAGE_REPORTS OFF) +endif() + +mark_as_advanced(BLT_CODE_COVERAGE_REPORTS) + + +##------------------------------------------------------------------------------ +## blt_add_code_coverage_target( NAME +## RUNNER +## SOURCE_DIRECTORIES [dir1 [dir2 ...]]) +## REMOVE [pat1 [pat2 ...]]) +## +## Creates a new target with the given NAME that generates a code coverage report. +##------------------------------------------------------------------------------ +function(blt_add_code_coverage_target) + + set(options) + set(singleValueArgs NAME) + set(multiValueArgs RUNNER SOURCE_DIRECTORIES REMOVE) + + # parse the arguments + cmake_parse_arguments(arg + "${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN} ) + + # Check/Set required parameters + if(NOT DEFINED arg_NAME) + message(FATAL_ERROR "blt_add_code_coverage_target requires a NAME parameter") + endif() + + if(NOT DEFINED arg_RUNNER) + message(FATAL_ERROR "blt_add_code_coverage_target requires a RUNNER parameter") + endif() + + set(_coverage_directories "--directory=${CMAKE_BINARY_DIR}") + if(DEFINED arg_SOURCE_DIRECTORIES) + foreach(_src_dir ${arg_SOURCE_DIRECTORIES}) + list(APPEND _coverage_directories "--directory=${_src_dir}") + endforeach() + else() + # Default to everything + list(APPEND _coverage_directories "--directory=${CMAKE_CURRENT_SOURCE_DIR}") + endif() + + # Setup target + add_custom_target(${arg_NAME} + + # Cleanup lcov + ${LCOV_EXECUTABLE} --no-external --gcov-tool ${GCOV_EXECUTABLE} ${_coverage_directories} --zerocounters + + # Run tests - allow for failing tests + COMMAND ${arg_RUNNER} || (exit 0) + + # Capture lcov counters and generating report + COMMAND ${LCOV_EXECUTABLE} --no-external --gcov-tool ${GCOV_EXECUTABLE} ${_coverage_directories} --capture --output-file ${arg_NAME}.info + COMMAND ${LCOV_EXECUTABLE} --no-external --gcov-tool ${GCOV_EXECUTABLE} ${_coverage_directories} --remove ${arg_NAME}.info ${arg_REMOVE} '/usr/include/*' --output-file ${arg_NAME}.info.cleaned + COMMAND ${GENHTML_EXECUTABLE} -o ${arg_NAME} ${arg_NAME}.info.cleaned + BYPRODUCTS ${arg_NAME}.info ${arg_NAME}.info.cleaned + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMENT "Resetting code coverage counters to zero.\nProcessing code coverage counters and generating report." + ) + + # Show info where to find the report + add_custom_command(TARGET ${arg_NAME} POST_BUILD + COMMAND ; + COMMENT "Open ./${arg_NAME}/index.html in your browser to view the coverage report." + ) +endfunction() + + +if(BLT_CODE_COVERAGE_REPORTS) + # Add code coverage target + blt_add_code_coverage_target(NAME coverage RUNNER make test) + message(STATUS "Code coverage: reports enabled via lcov, genthml, and gcov.") +endif() diff --git a/cmake/FindFluxCore.cmake b/cmake/FindFluxCore.cmake new file mode 100644 index 000000000..c00aa79b8 --- /dev/null +++ b/cmake/FindFluxCore.cmake @@ -0,0 +1,42 @@ +if(DEFINED FLUX_CORE_PREFIX) + set(ENV{PKG_CONFIG_PATH} "${FLUX_CORE_PREFIX}/lib/pkgconfig:$ENV{PKG_CONFIG_PATH}") +else() + find_program(FLUX flux ENV PATH) + if(FLUX) + get_filename_component(EXTRA_FLUX_CORE_PREFIX_BIN ${FLUX} DIRECTORY) + get_filename_component(EXTRA_FLUX_CORE_PREFIX ${EXTRA_FLUX_CORE_PREFIX_BIN} DIRECTORY) + set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:${EXTRA_FLUX_CORE_PREFIX}/lib/pkgconfig") + message(STATUS "flux found in PATH and no specific FLUX_CORE_PREFIX specified, using ${EXTRA_FLUX_CORE_PREFIX}") + endif() +endif() + +pkg_check_modules(FLUX_CORE REQUIRED IMPORTED_TARGET flux-core) +set(FLUX_PREFIX ${FLUX_CORE_PREFIX}) +set(LIBFLUX_VERSION ${FLUX_CORE_VERSION}) + +find_program(FLUX flux + PATHS ${FLUX_PREFIX}/bin ENV PATH) + +execute_process(COMMAND $FLUX python -c "import sys; print(\".\".join(map(str, sys.version_info[[:2]])))" + OUTPUT_VARIABLE FLUX_PYTHON_VERSION) + +pkg_check_modules(FLUX_HOSTLIST REQUIRED IMPORTED_TARGET flux-hostlist ) +pkg_check_modules(FLUX_IDSET REQUIRED IMPORTED_TARGET flux-idset ) +pkg_check_modules(FLUX_OPTPARSE REQUIRED IMPORTED_TARGET flux-optparse ) +pkg_check_modules(FLUX_PMI REQUIRED IMPORTED_TARGET flux-pmi) +pkg_check_modules(FLUX_SCHEDUTIL REQUIRED IMPORTED_TARGET flux-schedutil ) +pkg_check_modules(FLUX_TASKMAP REQUIRED IMPORTED_TARGET flux-taskmap ) + +add_library(flux::core ALIAS PkgConfig::FLUX_CORE) +add_library(flux::hostlist ALIAS PkgConfig::FLUX_HOSTLIST) +add_library(flux::idset ALIAS PkgConfig::FLUX_IDSET) +add_library(flux::pmi ALIAS PkgConfig::FLUX_PMI) +add_library(flux::optparse ALIAS PkgConfig::FLUX_OPTPARSE) +add_library(flux::schedutil ALIAS PkgConfig::FLUX_SCHEDUTIL) +add_library(flux::taskmap ALIAS PkgConfig::FLUX_TASKMAP) + +# all but PMI +add_library(flux-all INTERFACE) +target_link_libraries(flux-all INTERFACE flux::core flux::hostlist flux::idset flux::optparse flux::schedutil flux::taskmap) +add_library(flux::all ALIAS flux-all) + diff --git a/cmake/config_testing.cmake b/cmake/config_testing.cmake new file mode 100644 index 000000000..d74958df0 --- /dev/null +++ b/cmake/config_testing.cmake @@ -0,0 +1,46 @@ +if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) + include(CTest) +endif() + +set(TEST_ENV) +set(FLUX_CO_INST "") +if(FLUX_PREFIX EQUAL CMAKE_INSTALL_PREFIX) + set(FLUX_CO_INST "co") +endif() +list(APPEND TEST_ENV "FLUX_SCHED_CO_INST=${FLUX_CO_INST}") +list(APPEND TEST_ENV "PATH=${FLUX_PREFIX}/bin:$ENV{PATH}") +list(APPEND TEST_ENV "SHARNESS_TEST_DIRECTORY=${CMAKE_BINARY_DIR}/t") +list(APPEND TEST_ENV "SHARNESS_TEST_SRCDIR=${CMAKE_SOURCE_DIR}/t") +list(APPEND TEST_ENV "SHARNESS_BUILD_DIRECTORY=${CMAKE_BINARY_DIR}") +list(APPEND TEST_ENV "FLUX_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}") +list(APPEND TEST_ENV "FLUX_SCHED_MOD_DIR=${FLUX_MOD_DIR}") +list(APPEND TEST_ENV "FLUX_SCHED_EXEC_DIR=${FLUX_CMD_DIR}") +list(APPEND TEST_ENV "FLUX_SCHED_PYTHON_SITELIB=${PYTHON_INSTALL_SITELIB}") + +# add maybe-installtest to the start +function(flux_add_test) + # This odd construction is as close as we can get to + # generic argument forwarding + set(options "") + set(oneValueArgs NAME COMMAND) + set(multiValueArgs "") + + cmake_parse_arguments(PARSE_ARGV 0 ARG + "${options}" "${oneValueArgs}" "${multiValueArgs}") + + set(__argsQuoted) + foreach(__item IN LISTS ARG_UNPARSED_ARGUMENTS) + string(APPEND __argsQuoted " [==[${__item}]==]") + endforeach() + if(TARGET ${ARG_COMMAND}) + # if it's a target, pull the path from the target + set(ARG_COMMAND "$") + endif() + cmake_language(EVAL CODE " + add_test( + NAME ${ARG_NAME} + COMMAND ${CMAKE_SOURCE_DIR}/t/scripts/maybe-installtest ${ARG_COMMAND} + ${__argsQuoted} + ) ") + set_property(TEST ${ARG_NAME} PROPERTY ENVIRONMENT "${TEST_ENV}") +endfunction() diff --git a/configure b/configure new file mode 100755 index 000000000..1bcdc6f1d --- /dev/null +++ b/configure @@ -0,0 +1,319 @@ +#!/bin/sh +# Autotools-style (./configure) wrapper for CMake +# +# +# *** IMPORTANT *** +# +# You must include the GNUInstallDirs module (which comes with +# CMake) in your project. Just put "include (GNUInstallDirs)" in +# you CMakeLists.txt and you should be good. +# +# This script was originally written for Squash +# by Evan Nemerson +# , but has been spun off into a separate +# repository. Please feel free to copy it into your own repository, +# though I would appreciate it if you would post improvements, bugs, +# feature requests, etc. to the issue tracker at +# . +# +# To the extent possible under law, the author(s) hereby waive all +# copyright and related or neighboring rights to this work. For +# details, see + +TOP_SRCDIR="$(dirname $0)" + +if [ "${CMAKE_CMD}" = "" ]; then + CMAKE_CMD="cmake" +fi + +BUILD_TYPE="RelWithDebInfo" +# PREFIX=/usr/local +LIBDIR= +CMAKE_ARGS= + +if [ -e "${TOP_SRCDIR}/.configure-custom.sh" ]; then + . "${TOP_SRCDIR}/.configure-custom.sh" +fi + +quote() { + echo "$1" | sed -e "s|'|'\\\\''|g; 1s/^/'/; \$s/\$/'/" +} + +extract_var_string() { + VAR_NAME=$1 + VAR_NAME=$(echo $1 | sed -e 's/[ \t]*$//') + if [ "x$2" != "x" ]; then + VAR_VALUE=$2 + else + VAR_VALUE=yes + fi + + if [ "x$3" != "x" ]; then + VAR_UC_NAME=$3 + else + VAR_UC_NAME=$(echo "$1" | tr '[:lower:]' '[:upper:]' | tr -c '[:alnum:]' '_' | sed 's/_$//g') + fi +} + +set_config_var() { + is_with=n + case "$1" in + "--enable-"*) + name="${1#--enable-}" + cfg="${ENABLE_VARS}" + ;; + "--disable-"*) + name="${1#--disable-}"; + cfg="${DISABLE_VARS}"; + ;; + "--with-"*) + # IFS="=" read -ra WITHARGS <<< "${1}" + name="${1#--with-}" + cfg="${WITH_VARS}" + is_with=y + ;; + esac + + found=n + for varstring in $cfg; do + extract_var_string $(echo "${varstring}" | tr '|' ' ') + if [ "x$VAR_NAME" = "x$name" ]; then + found=y + break; + fi + done + + if [ "$found" = "y" ]; then + if [ "x$is_with" = "xy" ]; then + CMAKE_ARGS="$CMAKE_ARGS -D${VAR_UC_NAME}=$(quote "$2")" + else + CMAKE_ARGS="$CMAKE_ARGS -D${VAR_UC_NAME}=$(quote "${VAR_VALUE}")" + fi + else + echo "Unknown parameter: ${1}" + exit 1 + fi +} + +prefix_to_offset() { + expr $(echo "${1}" | awk '{ print length }') + 1 +} + +print_help() { + cat <&2 + -h, --help display this help and exit + --build-type=BUILD_TYPE explicitly set build type [$BUILD_TYPE] + Options: Debug, Release, RelWithDebInfo, MinSizeRel + --compiler-launcher=L Set the compiler launcher, for example ccache, distcc + --pass-thru, or -- pass remaining arguments through to CMake + + --prefix=PREFIX install architecture-independent files in PREFIX + [$PREFIX] + --bindir=DIR user executables [PREFIX/bin] + --sbindir=DIR system admin executables [PREFIX/sbin] + --libexecdir=DIR program executables [PREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [PREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PROJECT_NAME] +EOF + + first=y + for varstring in ${ENABLE_VARS}; do + if [ $first = 'y' ]; then + echo "" + first=n + fi + extract_var_string $(echo "${varstring}" | tr '|' ' ') + var_doc_name="ENABLE_${VAR_UC_NAME}_DOC" + eval "docstring=\$$var_doc_name" + if [ "x${docstring}" = "x" ]; then + printf " --enable-%-14s enable %s support\n" "${VAR_NAME}" "$(echo -n "${VAR_NAME}" | tr '-' ' ')" + else + printf " --enable-%-14s %s\n" "${VAR_NAME}" "$docstring" + fi + done + + first=y + for varstring in ${DISABLE_VARS}; do + if [ $first = 'y' ]; then + echo "" + first=n + fi + extract_var_string $(echo "${varstring}" | tr '|' ' ') + var_doc_name="DISABLE_${VAR_UC_NAME}_DOC" + eval "docstring=\$$var_doc_name" + if [ "x${docstring}" = "x" ]; then + printf " --disable-%-13s disable %s support\n" "${VAR_NAME}" "$(echo -n "${VAR_NAME}" | tr '-' ' ')" + else + printf " --disable-%-13s %s\n" "${VAR_NAME}" "$docstring" + fi + done + + first=y + for varstring in ${WITH_VARS}; do + if [ $first = 'y' ]; then + echo "" + first=n + fi + extract_var_string $(echo "${varstring}" | tr '|' ' ') + var_doc_name="WITH_${VAR_UC_NAME}_DOC" + eval "docstring=\$$var_doc_name" + paraminfo="${VAR_NAME}=${VAR_VALUE}" + if [ "x${docstring}" = "x" ]; then + printf " --with-%-16s enable %s support\n" "$paraminfo" "$(echo -n "${VAR_NAME}" | tr '-' ' ')" + else + printf " --with-%-16s %s\n" "$paraminfo" "$docstring" + fi + done + + exit 0 +} + +while [ $# != 0 ]; do + case "$1" in + "--prefix="*) + PREFIX="${1#*=}";; + "--prefix") + PREFIX="${2}"; shift;; + "--bindir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_BINDIR=$(quote "${1#*=}")";; + "--bindir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_BINDIR=$(quote "$2")"; shift;; + "--sbindir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SBINDIR=$(quote "${1#*=}")";; + "--sbindir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SBINDIR=$(quote "$2")"; shift;; + "--libexecdir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LIBEXECDIR=$(quote "${1#*=}")";; + "--libexecdir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LIBEXECDIR=$(quote "$2")"; shift;; + "--sysconfdir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SYSCONFDIR=$(quote "${1#*=}")";; + "--sysconfdir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SYSCONFDIR=$(quote "$2")"; shift;; + "--sharedstatedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SHAREDSTATEDIR=$(quote "${1#*=}")";; + "--sharedstatedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SHAREDSTATEDIR=$(quote "$2")"; shift;; + "--localstatedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALSTATEDIR=$(quote "${1#*=}")";; + "--localstatedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALSTATEDIR=$(quote "$2")"; shift;; + "--libdir="*) + LIBDIR="${1#*=}";; + "--libdir") + LIBDIR="${2}"; shift;; + "--includedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INCLUDEDIR=$(quote "${1#*=}")";; + "--includedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INCLUDEDIR=$(quote "$2")"; shift;; + "--oldincludedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_OLDINCLUDEDIR=$(quote "${1#*=}")";; + "--oldincludedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_OLDINCLUDEDIR=$(quote "$2")"; shift;; + "--datarootdir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATAROOTDIR=$(quote "${1#*=}")";; + "--datarootdir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATAROOTDIR=$(quote "$2")"; shift;; + "--datadir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATADIR=$(quote "${1#*=}")";; + "--datadir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATADIR=$(quote "$2")"; shift;; + "--infodir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INFODIR=$(quote "${1#*=}")";; + "--infodir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INFODIR=$(quote "$2")"; shift;; + "--localedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALEDIR=$(quote "${1#*=}")";; + "--localedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALEDIR=$(quote "$2")"; shift;; + "--mandir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_MANDIR=$(quote "${1#*=}")";; + "--mandir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_MANDIR=$(quote "$2")"; shift;; + "--docdir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "${1#*=}")";; + "--docdir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "$2")"; shift;; + + "CC="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER=$(quote "${1#*=}")";; + "CXX="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_COMPILER=$(quote "${1#*=}")";; + "CFLAGS="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_FLAGS=$(quote "${1#*=}")";; + "CXXFLAGS="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_FLAGS=$(quote "${1#*=}")";; + "LDFLAGS="*) + LDFLAGS="$LDFLAGS ${1#*=}";; + + "--help") + print_help;; + "-h") + print_help;; + + "--compiler-launcher="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_COMPILER_LAUNCHER=$(quote "${1#*=}")" + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER_LAUNCHER=$(quote "${1#*=}")";; + + "--build-type="*) + BUILD_TYPE="${1#*=}";; + + "--enable-"*) + set_config_var "$1" + ;; + + "--disable-"*) + set_config_var "$1" + ;; + + "--with-"*) + name=$(echo "${1#--with-}" | awk '{split($1,v,"="); print v[1]}') + case "${1}" in + "--with-${name}="*) + set_config_var "--with-${name}" "${1#--with-${name}=}";; + "--with-${name}") + set_config_var "$1" "$2"; + shift;; + esac + ;; + + "--pass-thru"|--) + while [ $# != 1 ]; do + shift; + CMAKE_ARGS="$CMAKE_ARGS $(quote "${1}")"; + done;; + + *) + echo "$0: error: unrecognized option: \`$1'" >&2 + echo "Try \`$0 --help' for more information" >&2 + exit -1 + esac; + shift +done + +if [ -n "${LIBDIR}" ]; then + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=\"${LIBDIR}\"" +fi +if [ -n "${PREFIX}" ]; then + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=\"${PREFIX}\"" +fi + +# Unlike CFLAGS/CXXFLAGS/CC/CXX, LDFLAGS isn't handled by CMake, so we +# need to parse it here. +if [ "x${LDFLAGS}" != "x" ]; then + for varname in EXE MODULE SHARED STATIC; do + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_${varname}_LINKER_FLAGS=$(quote "$LDFLAGS")" + done +fi + +eval "${CMAKE_CMD}" "${TOP_SRCDIR}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" ${CMAKE_ARGS} diff --git a/configure-cmake b/configure-cmake new file mode 100755 index 000000000..1bcdc6f1d --- /dev/null +++ b/configure-cmake @@ -0,0 +1,319 @@ +#!/bin/sh +# Autotools-style (./configure) wrapper for CMake +# +# +# *** IMPORTANT *** +# +# You must include the GNUInstallDirs module (which comes with +# CMake) in your project. Just put "include (GNUInstallDirs)" in +# you CMakeLists.txt and you should be good. +# +# This script was originally written for Squash +# by Evan Nemerson +# , but has been spun off into a separate +# repository. Please feel free to copy it into your own repository, +# though I would appreciate it if you would post improvements, bugs, +# feature requests, etc. to the issue tracker at +# . +# +# To the extent possible under law, the author(s) hereby waive all +# copyright and related or neighboring rights to this work. For +# details, see + +TOP_SRCDIR="$(dirname $0)" + +if [ "${CMAKE_CMD}" = "" ]; then + CMAKE_CMD="cmake" +fi + +BUILD_TYPE="RelWithDebInfo" +# PREFIX=/usr/local +LIBDIR= +CMAKE_ARGS= + +if [ -e "${TOP_SRCDIR}/.configure-custom.sh" ]; then + . "${TOP_SRCDIR}/.configure-custom.sh" +fi + +quote() { + echo "$1" | sed -e "s|'|'\\\\''|g; 1s/^/'/; \$s/\$/'/" +} + +extract_var_string() { + VAR_NAME=$1 + VAR_NAME=$(echo $1 | sed -e 's/[ \t]*$//') + if [ "x$2" != "x" ]; then + VAR_VALUE=$2 + else + VAR_VALUE=yes + fi + + if [ "x$3" != "x" ]; then + VAR_UC_NAME=$3 + else + VAR_UC_NAME=$(echo "$1" | tr '[:lower:]' '[:upper:]' | tr -c '[:alnum:]' '_' | sed 's/_$//g') + fi +} + +set_config_var() { + is_with=n + case "$1" in + "--enable-"*) + name="${1#--enable-}" + cfg="${ENABLE_VARS}" + ;; + "--disable-"*) + name="${1#--disable-}"; + cfg="${DISABLE_VARS}"; + ;; + "--with-"*) + # IFS="=" read -ra WITHARGS <<< "${1}" + name="${1#--with-}" + cfg="${WITH_VARS}" + is_with=y + ;; + esac + + found=n + for varstring in $cfg; do + extract_var_string $(echo "${varstring}" | tr '|' ' ') + if [ "x$VAR_NAME" = "x$name" ]; then + found=y + break; + fi + done + + if [ "$found" = "y" ]; then + if [ "x$is_with" = "xy" ]; then + CMAKE_ARGS="$CMAKE_ARGS -D${VAR_UC_NAME}=$(quote "$2")" + else + CMAKE_ARGS="$CMAKE_ARGS -D${VAR_UC_NAME}=$(quote "${VAR_VALUE}")" + fi + else + echo "Unknown parameter: ${1}" + exit 1 + fi +} + +prefix_to_offset() { + expr $(echo "${1}" | awk '{ print length }') + 1 +} + +print_help() { + cat <&2 + -h, --help display this help and exit + --build-type=BUILD_TYPE explicitly set build type [$BUILD_TYPE] + Options: Debug, Release, RelWithDebInfo, MinSizeRel + --compiler-launcher=L Set the compiler launcher, for example ccache, distcc + --pass-thru, or -- pass remaining arguments through to CMake + + --prefix=PREFIX install architecture-independent files in PREFIX + [$PREFIX] + --bindir=DIR user executables [PREFIX/bin] + --sbindir=DIR system admin executables [PREFIX/sbin] + --libexecdir=DIR program executables [PREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [PREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PROJECT_NAME] +EOF + + first=y + for varstring in ${ENABLE_VARS}; do + if [ $first = 'y' ]; then + echo "" + first=n + fi + extract_var_string $(echo "${varstring}" | tr '|' ' ') + var_doc_name="ENABLE_${VAR_UC_NAME}_DOC" + eval "docstring=\$$var_doc_name" + if [ "x${docstring}" = "x" ]; then + printf " --enable-%-14s enable %s support\n" "${VAR_NAME}" "$(echo -n "${VAR_NAME}" | tr '-' ' ')" + else + printf " --enable-%-14s %s\n" "${VAR_NAME}" "$docstring" + fi + done + + first=y + for varstring in ${DISABLE_VARS}; do + if [ $first = 'y' ]; then + echo "" + first=n + fi + extract_var_string $(echo "${varstring}" | tr '|' ' ') + var_doc_name="DISABLE_${VAR_UC_NAME}_DOC" + eval "docstring=\$$var_doc_name" + if [ "x${docstring}" = "x" ]; then + printf " --disable-%-13s disable %s support\n" "${VAR_NAME}" "$(echo -n "${VAR_NAME}" | tr '-' ' ')" + else + printf " --disable-%-13s %s\n" "${VAR_NAME}" "$docstring" + fi + done + + first=y + for varstring in ${WITH_VARS}; do + if [ $first = 'y' ]; then + echo "" + first=n + fi + extract_var_string $(echo "${varstring}" | tr '|' ' ') + var_doc_name="WITH_${VAR_UC_NAME}_DOC" + eval "docstring=\$$var_doc_name" + paraminfo="${VAR_NAME}=${VAR_VALUE}" + if [ "x${docstring}" = "x" ]; then + printf " --with-%-16s enable %s support\n" "$paraminfo" "$(echo -n "${VAR_NAME}" | tr '-' ' ')" + else + printf " --with-%-16s %s\n" "$paraminfo" "$docstring" + fi + done + + exit 0 +} + +while [ $# != 0 ]; do + case "$1" in + "--prefix="*) + PREFIX="${1#*=}";; + "--prefix") + PREFIX="${2}"; shift;; + "--bindir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_BINDIR=$(quote "${1#*=}")";; + "--bindir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_BINDIR=$(quote "$2")"; shift;; + "--sbindir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SBINDIR=$(quote "${1#*=}")";; + "--sbindir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SBINDIR=$(quote "$2")"; shift;; + "--libexecdir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LIBEXECDIR=$(quote "${1#*=}")";; + "--libexecdir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LIBEXECDIR=$(quote "$2")"; shift;; + "--sysconfdir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SYSCONFDIR=$(quote "${1#*=}")";; + "--sysconfdir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SYSCONFDIR=$(quote "$2")"; shift;; + "--sharedstatedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SHAREDSTATEDIR=$(quote "${1#*=}")";; + "--sharedstatedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_SHAREDSTATEDIR=$(quote "$2")"; shift;; + "--localstatedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALSTATEDIR=$(quote "${1#*=}")";; + "--localstatedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALSTATEDIR=$(quote "$2")"; shift;; + "--libdir="*) + LIBDIR="${1#*=}";; + "--libdir") + LIBDIR="${2}"; shift;; + "--includedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INCLUDEDIR=$(quote "${1#*=}")";; + "--includedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INCLUDEDIR=$(quote "$2")"; shift;; + "--oldincludedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_OLDINCLUDEDIR=$(quote "${1#*=}")";; + "--oldincludedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_OLDINCLUDEDIR=$(quote "$2")"; shift;; + "--datarootdir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATAROOTDIR=$(quote "${1#*=}")";; + "--datarootdir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATAROOTDIR=$(quote "$2")"; shift;; + "--datadir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATADIR=$(quote "${1#*=}")";; + "--datadir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DATADIR=$(quote "$2")"; shift;; + "--infodir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INFODIR=$(quote "${1#*=}")";; + "--infodir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_INFODIR=$(quote "$2")"; shift;; + "--localedir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALEDIR=$(quote "${1#*=}")";; + "--localedir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LOCALEDIR=$(quote "$2")"; shift;; + "--mandir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_MANDIR=$(quote "${1#*=}")";; + "--mandir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_MANDIR=$(quote "$2")"; shift;; + "--docdir="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "${1#*=}")";; + "--docdir") + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_DOCDIR=$(quote "$2")"; shift;; + + "CC="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER=$(quote "${1#*=}")";; + "CXX="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_COMPILER=$(quote "${1#*=}")";; + "CFLAGS="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_FLAGS=$(quote "${1#*=}")";; + "CXXFLAGS="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_FLAGS=$(quote "${1#*=}")";; + "LDFLAGS="*) + LDFLAGS="$LDFLAGS ${1#*=}";; + + "--help") + print_help;; + "-h") + print_help;; + + "--compiler-launcher="*) + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_CXX_COMPILER_LAUNCHER=$(quote "${1#*=}")" + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_C_COMPILER_LAUNCHER=$(quote "${1#*=}")";; + + "--build-type="*) + BUILD_TYPE="${1#*=}";; + + "--enable-"*) + set_config_var "$1" + ;; + + "--disable-"*) + set_config_var "$1" + ;; + + "--with-"*) + name=$(echo "${1#--with-}" | awk '{split($1,v,"="); print v[1]}') + case "${1}" in + "--with-${name}="*) + set_config_var "--with-${name}" "${1#--with-${name}=}";; + "--with-${name}") + set_config_var "$1" "$2"; + shift;; + esac + ;; + + "--pass-thru"|--) + while [ $# != 1 ]; do + shift; + CMAKE_ARGS="$CMAKE_ARGS $(quote "${1}")"; + done;; + + *) + echo "$0: error: unrecognized option: \`$1'" >&2 + echo "Try \`$0 --help' for more information" >&2 + exit -1 + esac; + shift +done + +if [ -n "${LIBDIR}" ]; then + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR=\"${LIBDIR}\"" +fi +if [ -n "${PREFIX}" ]; then + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=\"${PREFIX}\"" +fi + +# Unlike CFLAGS/CXXFLAGS/CC/CXX, LDFLAGS isn't handled by CMake, so we +# need to parse it here. +if [ "x${LDFLAGS}" != "x" ]; then + for varname in EXE MODULE SHARED STATIC; do + CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_${varname}_LINKER_FLAGS=$(quote "$LDFLAGS")" + done +fi + +eval "${CMAKE_CMD}" "${TOP_SRCDIR}" -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" ${CMAKE_ARGS} diff --git a/configure.ac b/configure.ac index d2dbd5b3d..b2b83a970 100644 --- a/configure.ac +++ b/configure.ac @@ -127,7 +127,7 @@ AC_TYPE_UINT32_T AC_TYPE_UINT64_T # Checks for library functions. -AC_FUNC_MALLOC +# AC_FUNC_MALLOC AC_CHECK_FUNCS([gettimeofday localtime_r memset strchr strdup strerror strstr strtol strtoul]) ## diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt new file mode 100644 index 000000000..1d0a2127c --- /dev/null +++ b/etc/CMakeLists.txt @@ -0,0 +1,4 @@ +install(PROGRAMS ./rc1.d/01-sched-fluxion + DESTINATION ${FLUX_RC1_DIR}) +install(PROGRAMS ./rc3.d/01-sched-fluxion + DESTINATION ${FLUX_RC3_DIR}) diff --git a/flux-plugin.map b/flux-plugin.map new file mode 100644 index 000000000..bd157f9d9 --- /dev/null +++ b/flux-plugin.map @@ -0,0 +1,9 @@ +{ +global: + flux_plugin_init; + mod_main; + mod_name; + mod_service; +local: + *; +}; diff --git a/qmanager/CMakeLists.txt b/qmanager/CMakeLists.txt new file mode 100644 index 000000000..3cd72442c --- /dev/null +++ b/qmanager/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory( modules ) \ No newline at end of file diff --git a/qmanager/modules/CMakeLists.txt b/qmanager/modules/CMakeLists.txt new file mode 100644 index 000000000..5b224e5a3 --- /dev/null +++ b/qmanager/modules/CMakeLists.txt @@ -0,0 +1,13 @@ +flux_add_plugin ( sched-fluxion-qmanager MODULE + qmanager.cpp + qmanager_callbacks.cpp + qmanager_callbacks.hpp + qmanager_opts.cpp + qmanager_opts.hpp + ) +target_link_libraries(sched-fluxion-qmanager PRIVATE + jobspec_conv + flux::core + flux::schedutil + PkgConfig::JANSSON + ) diff --git a/resource/CMakeLists.txt b/resource/CMakeLists.txt new file mode 100644 index 000000000..64a7dd408 --- /dev/null +++ b/resource/CMakeLists.txt @@ -0,0 +1,100 @@ +add_subdirectory(libjobspec) +add_subdirectory(planner) +set(RESOURCE_HEADERS + utilities/command.hpp + policies/dfu_match_high_id_first.hpp + policies/dfu_match_low_id_first.hpp + policies/dfu_match_multilevel_id.hpp + policies/dfu_match_multilevel_id_impl.hpp + policies/dfu_match_locality.hpp + policies/dfu_match_var_aware.hpp + policies/dfu_match_policy_factory.hpp + jobinfo/jobinfo.hpp + schema/resource_graph.hpp + schema/data_std.hpp + schema/infra_data.hpp + schema/sched_data.hpp + schema/resource_base.hpp + schema/resource_data.hpp + schema/color.hpp + schema/ephemeral.hpp + traversers/dfu.hpp + traversers/dfu_impl.hpp + policies/base/dfu_match_cb.hpp + policies/base/matcher.hpp + readers/resource_namespace_remapper.hpp + readers/resource_reader_base.hpp + readers/resource_spec_grug.hpp + readers/resource_reader_grug.hpp + readers/resource_reader_hwloc.hpp + readers/resource_reader_jgf.hpp + readers/resource_reader_rv1exec.hpp + readers/resource_reader_factory.hpp + evaluators/scoring_api.hpp + evaluators/edge_eval_api.hpp + evaluators/fold.hpp + evaluators/expr_eval_api.hpp + evaluators/expr_eval_target.hpp + evaluators/expr_eval_vtx_target.hpp + config/system_defaults.hpp + store/resource_graph_store.hpp + ) + +add_library(resource SHARED + policies/dfu_match_locality.cpp + policies/dfu_match_var_aware.cpp + policies/dfu_match_policy_factory.cpp + jobinfo/jobinfo.cpp + schema/resource_data.cpp + schema/infra_data.cpp + schema/sched_data.cpp + schema/color.cpp + schema/ephemeral.cpp + traversers/dfu.cpp + traversers/dfu_impl.cpp + traversers/dfu_impl_update.cpp + policies/base/dfu_match_cb.cpp + policies/base/matcher.cpp + readers/resource_namespace_remapper.cpp + readers/resource_reader_base.cpp + readers/resource_spec_grug.cpp + readers/resource_reader_grug.cpp + readers/resource_reader_hwloc.cpp + readers/resource_reader_jgf.cpp + readers/resource_reader_rv1exec.cpp + readers/resource_reader_factory.cpp + writers/match_writers.cpp + evaluators/scoring_api.cpp + evaluators/edge_eval_api.cpp + evaluators/expr_eval_api.cpp + evaluators/expr_eval_vtx_target.cpp + store/resource_graph_store.cpp + ${RESOURCE_HEADERS} + ) +target_include_directories(resource PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(resource PRIVATE + planner + ) +target_link_libraries(resource PUBLIC + flux::hostlist + flux::idset + PkgConfig::JANSSON + PkgConfig::HWLOC + PkgConfig::UUID + Boost::system + Boost::graph + Boost::regex + jobspec_conv + Boost::filesystem + ) +install(TARGETS resource + LIBRARY) + +add_subdirectory(modules) +add_subdirectory(reapi) +add_subdirectory(evaluators) +add_subdirectory(policies) +add_subdirectory(schema) + +# programs that depend on libresource +add_subdirectory(utilities) diff --git a/resource/evaluators/CMakeLists.txt b/resource/evaluators/CMakeLists.txt new file mode 100644 index 000000000..1b37931ab --- /dev/null +++ b/resource/evaluators/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory( test ) \ No newline at end of file diff --git a/resource/evaluators/test/CMakeLists.txt b/resource/evaluators/test/CMakeLists.txt new file mode 100644 index 000000000..b1cbabfdd --- /dev/null +++ b/resource/evaluators/test/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(expr_eval_test + ${CMAKE_CURRENT_SOURCE_DIR}/expr_eval_test01.cpp + ) +target_link_libraries(expr_eval_test PRIVATE + libtap + resource + ) + +flux_add_test(NAME expr_eval_test COMMAND expr_eval_test) diff --git a/resource/libjobspec/CMakeLists.txt b/resource/libjobspec/CMakeLists.txt new file mode 100644 index 000000000..57e0fd75c --- /dev/null +++ b/resource/libjobspec/CMakeLists.txt @@ -0,0 +1,25 @@ +add_library ( jobspec_conv STATIC + ${CMAKE_CURRENT_SOURCE_DIR}/constraint.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/constraint.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/hostlist_constraint.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/hostlist_constraint.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/jobspec.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/jobspec.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/parse_error.hpp + ${CMAKE_CURRENT_SOURCE_DIR}/rank_constraint.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/rank_constraint.hpp + ) +target_link_libraries(jobspec_conv PUBLIC flux::hostlist flux::idset + flux::core yaml-cpp PkgConfig::JANSSON + PkgConfig::UUID + ) + +add_executable(flux-jobspec-validate + ${CMAKE_CURRENT_SOURCE_DIR}/flux-jobspec-validate.cpp + ) + +target_link_libraries(flux-jobspec-validate PRIVATE jobspec_conv) + +add_executable(test_constraint.t test/constraint.cpp) +target_link_libraries(test_constraint.t jobspec_conv libtap) +flux_add_test(NAME test_constraint COMMAND test_constraint.t) diff --git a/resource/modules/CMakeLists.txt b/resource/modules/CMakeLists.txt new file mode 100644 index 000000000..b8f9b2958 --- /dev/null +++ b/resource/modules/CMakeLists.txt @@ -0,0 +1,10 @@ +flux_add_plugin ( sched-fluxion-resource MODULE + ${CMAKE_CURRENT_SOURCE_DIR}/resource_match.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/resource_match_opts.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/resource_match_opts.hpp + ) +target_link_libraries (sched-fluxion-resource PRIVATE + resource + PkgConfig::JANSSON + PkgConfig::UUID + ) diff --git a/resource/planner/CMakeLists.txt b/resource/planner/CMakeLists.txt new file mode 100644 index 000000000..4f2dbaee5 --- /dev/null +++ b/resource/planner/CMakeLists.txt @@ -0,0 +1,3 @@ +add_subdirectory(c++) +add_subdirectory(c) +add_subdirectory(test) diff --git a/resource/planner/c++/CMakeLists.txt b/resource/planner/c++/CMakeLists.txt new file mode 100644 index 000000000..1858ae272 --- /dev/null +++ b/resource/planner/c++/CMakeLists.txt @@ -0,0 +1,12 @@ +add_library(planner_cxx STATIC + ./planner.cpp + ./scheduled_point_tree.cpp + ./mintime_resource_tree.cpp + ./planner_multi.cpp + ./mintime_resource_tree.hpp + ./planner_internal_tree.hpp + ./scheduled_point_tree.hpp + ) +target_link_libraries(planner_cxx yggdrasil) + + diff --git a/resource/planner/c/CMakeLists.txt b/resource/planner/c/CMakeLists.txt new file mode 100644 index 000000000..d9df7600d --- /dev/null +++ b/resource/planner/c/CMakeLists.txt @@ -0,0 +1,9 @@ +add_library(planner STATIC + ./planner_c_interface.cpp + ./planner_multi_c_interface.cpp + ./planner.h + ./planner_multi.h +) +target_include_directories(planner PUBLIC ./) +target_link_libraries(planner PUBLIC planner_cxx) + diff --git a/resource/planner/test/CMakeLists.txt b/resource/planner/test/CMakeLists.txt new file mode 100644 index 000000000..58169e9c2 --- /dev/null +++ b/resource/planner/test/CMakeLists.txt @@ -0,0 +1,9 @@ +add_executable(planner_test1 planner_test01.cpp) +target_link_libraries(planner_test1 planner libtap) +flux_add_test(NAME planner_test1 COMMAND planner_test1) +set_property(TEST planner_test1 PROPERTY ENVIRONMENT "TESTRESRC_INPUT_FILE=$(CMAKE_SOURCE_DIR)/conf/hype.lua") + +add_executable(planner_test2 planner_test02.cpp) +target_link_libraries(planner_test2 planner libtap) +flux_add_test(NAME planner_test2 COMMAND planner_test1) +set_property(TEST planner_test2 PROPERTY ENVIRONMENT "TESTRESRC_INPUT_FILE=$(CMAKE_SOURCE_DIR)/conf/hype.lua") diff --git a/resource/policies/CMakeLists.txt b/resource/policies/CMakeLists.txt new file mode 100644 index 000000000..113a26f33 --- /dev/null +++ b/resource/policies/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory( base ) \ No newline at end of file diff --git a/resource/policies/base/CMakeLists.txt b/resource/policies/base/CMakeLists.txt new file mode 100644 index 000000000..1b37931ab --- /dev/null +++ b/resource/policies/base/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory( test ) \ No newline at end of file diff --git a/resource/policies/base/test/CMakeLists.txt b/resource/policies/base/test/CMakeLists.txt new file mode 100644 index 000000000..53b51f677 --- /dev/null +++ b/resource/policies/base/test/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(matcher_util_api_test + ${CMAKE_CURRENT_SOURCE_DIR}/matcher_util_api_test01.cpp + ) +target_link_libraries(matcher_util_api_test PRIVATE libtap resource + PkgConfig::JANSSON + ) +flux_add_test(NAME matcher_util_api_test COMMAND matcher_util_api_test) diff --git a/resource/reapi/CMakeLists.txt b/resource/reapi/CMakeLists.txt new file mode 100644 index 000000000..118ab605b --- /dev/null +++ b/resource/reapi/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory( bindings ) \ No newline at end of file diff --git a/resource/reapi/bindings/CMakeLists.txt b/resource/reapi/bindings/CMakeLists.txt new file mode 100644 index 000000000..c478213aa --- /dev/null +++ b/resource/reapi/bindings/CMakeLists.txt @@ -0,0 +1,20 @@ +add_library ( reapi_cli STATIC + c++/reapi.hpp + c++/reapi_cli.hpp + c++/reapi_cli_impl.hpp + c/reapi_cli.cpp + c/reapi_cli.h + ) +target_link_libraries(reapi_cli PRIVATE + flux::core + ) +add_library ( reapi_module STATIC + c++/reapi.hpp + c++/reapi_module.hpp + c++/reapi_module_impl.hpp + c/reapi_module.cpp + c/reapi_module.h + ) +target_link_libraries(reapi_module PRIVATE + flux::core + ) diff --git a/resource/schema/CMakeLists.txt b/resource/schema/CMakeLists.txt new file mode 100644 index 000000000..552439ebc --- /dev/null +++ b/resource/schema/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(test) diff --git a/resource/schema/test/CMakeLists.txt b/resource/schema/test/CMakeLists.txt new file mode 100644 index 000000000..c18839128 --- /dev/null +++ b/resource/schema/test/CMakeLists.txt @@ -0,0 +1,7 @@ +add_executable(schema_test01 ./schema_test01.cpp) +target_link_libraries(schema_test01 resource libtap) +target_include_directories(schema_test01 PUBLIC ../) + +add_executable(schema_test02 ./schema_test02.cpp) +target_link_libraries(schema_test02 resource libtap) +target_include_directories(schema_test02 PUBLIC ../) diff --git a/resource/utilities/CMakeLists.txt b/resource/utilities/CMakeLists.txt new file mode 100644 index 000000000..d58e2c08e --- /dev/null +++ b/resource/utilities/CMakeLists.txt @@ -0,0 +1,30 @@ +add_executable(grug2dot + grug2dot.cpp + ) +target_link_libraries(grug2dot + resource + Boost::headers + Boost::filesystem + ) +add_executable(resource-query + resource-query.cpp + command.cpp + command.hpp + ) +target_link_libraries(resource-query + resource + PkgConfig::LIBEDIT + PkgConfig::JANSSON + PkgConfig::UUID + Boost::filesystem + Boost::headers + ) + +install( + TARGETS + grug2dot + resource-query + ) + +add_subdirectory(test) + diff --git a/resource/utilities/test/CMakeLists.txt b/resource/utilities/test/CMakeLists.txt new file mode 100644 index 000000000..d3f7758b6 --- /dev/null +++ b/resource/utilities/test/CMakeLists.txt @@ -0,0 +1,2 @@ +flux_add_test(NAME run_sanity_check COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/run_sanity_check.sh) +set_property(TEST run_sanity_check PROPERTY ENVIRONMENT "srcdir=${CMAKE_CURRENT_SOURCE_DIR}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 000000000..e93c86a2d --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,5 @@ + +add_subdirectory( common ) +add_subdirectory( cmd ) +add_subdirectory( shell ) +add_subdirectory( python ) diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt new file mode 100644 index 000000000..4c04ee9f4 --- /dev/null +++ b/src/cmd/CMakeLists.txt @@ -0,0 +1,3 @@ +# TODO: install flux-ion-R command +install(PROGRAMS flux-ion-R.py + DESTINATION ${FLUX_CMD_DIR}) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt new file mode 100644 index 000000000..709b91091 --- /dev/null +++ b/src/common/CMakeLists.txt @@ -0,0 +1,4 @@ + +add_subdirectory( libtap ) +add_subdirectory( c++wrappers ) +add_subdirectory( yggdrasil ) diff --git a/src/common/c++wrappers/CMakeLists.txt b/src/common/c++wrappers/CMakeLists.txt new file mode 100644 index 000000000..2e0aec239 --- /dev/null +++ b/src/common/c++wrappers/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(cppwrappers INTERFACE eh_wrapper.hpp) +add_subdirectory( test ) diff --git a/src/common/c++wrappers/test/CMakeLists.txt b/src/common/c++wrappers/test/CMakeLists.txt new file mode 100644 index 000000000..82350df27 --- /dev/null +++ b/src/common/c++wrappers/test/CMakeLists.txt @@ -0,0 +1,3 @@ +# Generating the library TESTS +add_executable(exception_safe_wrapper_test01 exception_safe_wrapper_test01.cpp) +target_link_libraries(exception_safe_wrapper_test01 PRIVATE cppwrappers libtap) diff --git a/src/common/libtap/CMakeLists.txt b/src/common/libtap/CMakeLists.txt new file mode 100644 index 000000000..414552e6a --- /dev/null +++ b/src/common/libtap/CMakeLists.txt @@ -0,0 +1,7 @@ +# Generating the library libtap.la +list(APPEND tap_SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/tap.c + ${CMAKE_CURRENT_SOURCE_DIR}/tap.h +) +add_library (libtap SHARED ${tap_SOURCES} ) +target_include_directories(libtap PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) diff --git a/src/common/yggdrasil/CMakeLists.txt b/src/common/yggdrasil/CMakeLists.txt new file mode 100644 index 000000000..17efca8a2 --- /dev/null +++ b/src/common/yggdrasil/CMakeLists.txt @@ -0,0 +1,15 @@ +# NOTE: despite the .cpp files this is a header-only library +add_library( + yggdrasil + INTERFACE + util.hpp + tree_iterator.hpp + tree_iterator.cpp + size_holder.hpp + rbtree.hpp + rbtree.cpp + options.hpp + debug.hpp + bst.hpp + bst.cpp + ) diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt new file mode 100644 index 000000000..b4228f694 --- /dev/null +++ b/src/python/CMakeLists.txt @@ -0,0 +1,14 @@ + +set(FLUXION_PY_FILES + fluxion/resourcegraph/V1.py + fluxion/resourcegraph/__init__.py + fluxion/jsongraph/objects/edge.py + fluxion/jsongraph/objects/graph.py + fluxion/jsongraph/objects/__init__.py + fluxion/jsongraph/objects/multigraph.py + fluxion/jsongraph/objects/node.py + ) +install(DIRECTORY fluxion + DESTINATION "${PYTHON_INSTALL_SITELIB}" + FILES_MATCHING PATTERN "*.py") + diff --git a/src/shell/CMakeLists.txt b/src/shell/CMakeLists.txt new file mode 100644 index 000000000..de213515d --- /dev/null +++ b/src/shell/CMakeLists.txt @@ -0,0 +1,5 @@ +flux_add_plugin ( datastaging SHELL data-staging.cpp) +target_link_libraries ( datastaging PRIVATE + Boost::filesystem + ) + diff --git a/src/test/checks_run.sh b/src/test/checks_run.sh index 65acf4772..1bfd604b1 100755 --- a/src/test/checks_run.sh +++ b/src/test/checks_run.sh @@ -44,6 +44,10 @@ fi ARGS="$@" JOBS=${JOBS:-2} +export CMAKE_BUILD_PARALLEL_LEVEL=$JOBS +export CTEST_PARALLEL_LEVEL=$JOBS +export CTEST_OUTPUT_ON_FAILURE=1 +export VERBOSE=1 MAKECMDS="${MAKE} -j ${JOBS}" CHECKCMDS="${MAKE} -j ${JOBS} ${DISTCHECK:+dist}check" @@ -194,9 +198,10 @@ RC=$? if test "$RECHECK" = "t" -a $RC -ne 0; then # # `make recheck` is not recursive, only perform it if at least some tests - # under ./t were run (and presumably failed) + # under ./t were run (and presumably failed), in ctest it is recursive, so + # just run it # - if test -s t/t0000-sharness.trs; then + if test -s t/t0000-sharness.trs -o -e ./CTestTestfile.cmake; then cd t printf "::warning::make check failed, trying recheck in ./t\n" checks_group "make recheck" ${MAKE} -j ${JOBS} recheck diff --git a/src/test/docker/fedora38/Dockerfile b/src/test/docker/fedora38/Dockerfile index d0c013299..99dcd8b7e 100644 --- a/src/test/docker/fedora38/Dockerfile +++ b/src/test/docker/fedora38/Dockerfile @@ -20,6 +20,7 @@ RUN sudo yum -y update \ ninja-build \ cmake \ clang \ + lcov \ && sudo yum clean all # Add configured user to image with sudo access: diff --git a/t/CMakeLists.txt b/t/CMakeLists.txt new file mode 100644 index 000000000..dbb8559f2 --- /dev/null +++ b/t/CMakeLists.txt @@ -0,0 +1,93 @@ +# NOTE: skipping tree tests, since they're long broken +# t2000-tree-basic.t +# t2001-tree-real.t +set(ALL_TESTS + t0000-sharness.t + t1001-qmanager-basic.t + t1002-qmanager-reload.t + t1003-qmanager-policy.t + t1004-qmanager-optimize.t + t1005-qmanager-conf.t + t1006-qmanager-multiqueue.t + t1007-recovery-full.t + t1009-recovery-multiqueue.t + t1010-sync-modules.t + t1011-dynstate-change.t + t1012-find-status.t + t1013-qmanager-priority.t + t1014-annotation.t + t1015-find-format.t + t1016-nest-namespace.t + t1017-rv1-bootstrap.t + t1018-rv1-bootstrap2.t + t1019-qmanager-async.t + t1020-qmanager-feasibility.t + t1021-qmanager-nodex.t + t1022-property-constraints.t + t1023-multiqueue-constraints.t + t1024-alloc-check.t + t3000-jobspec.t + t3001-resource-basic.t + t3002-resource-prefix.t + t3003-resource-global.t + t3004-resource-excl.t + t3005-resource-rsv.t + t3006-resource-advanced.t + t3007-resource-iobw.t + t3008-resource-cancel.t + t3009-resource-minmax.t + t3010-resource-power.t + t3011-resource-filt.t + t3012-resource-properties.t + t3013-resource-unsat.t + t3014-resource-var-aware.t + t3015-resource-basic-jgf.t + t3016-resource-power-jgf.t + t3017-resource-granule.t + t3018-resource-mtl0.t + t3019-resource-mtl1.t + t3020-resource-mtl2.t + t3021-resource-mtl3.t + t3022-resource-update.t + t3023-resource-update2.t + t3024-resource-status.t + t3025-resource-find.t + t3026-resource-node-local-storage.t + t3026-resource-sibling.t + t3027-resource-RV.t + t3028-resource-grow.t + t3029-resource-prune.t + t3030-resource-multi.t + t3031-resource-minmax2.t + t3033-resource-nodex.t + t3034-resource-pconstraints.t + t3300-system-dontblock.t + t3301-system-latestart.t + t4000-match-params.t + t4001-match-allocate.t + t4002-match-reserve.t + t4003-cancel-info.t + t4004-match-hwloc.t + t4005-match-unsat.t + t4006-properties.t + t4007-match-var-aware.t + t4008-match-jgf.t + t4009-match-update.t + t4010-match-conf.t + t4011-match-duration.t + t5000-valgrind.t + t6000-graph-size.t + t6001-match-formats.t + t6002-graph-hwloc.t + t7000-shell-datastaging.t + t8001-util-ion-R.t + ) +foreach(test ${ALL_TESTS}) + flux_add_test(NAME ${test} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${test} -v + ) +endforeach() + +add_custom_target(recheck + WORKING_DIRECTORY ${CMAKE_BINARY_DIR} + COMMAND ${CMAKE_CTEST_COMMAND} --rerun-failed --output-on-failure) \ No newline at end of file diff --git a/t/scripts/maybe-installtest b/t/scripts/maybe-installtest new file mode 100755 index 000000000..48a8f1c68 --- /dev/null +++ b/t/scripts/maybe-installtest @@ -0,0 +1,7 @@ +#!/bin/sh +if test -n "$FLUX_SCHED_TEST_INSTALLED" -o -n "$FLUX_TEST_INSTALLED_PATH"; then + export FLUX_EXEC_PATH_PREPEND="${FLUX_SCHED_EXEC_DIR}" + export FLUX_MODULE_PATH_PREPEND="${FLUX_SCHED_MOD_DIR}" + export PYTHONPATH="${FLUX_SCHED_PYTHON_SITELIB}${PYTHONPATH:+:${PYTHONPATH}}" +fi +exec $@ diff --git a/t/sharness.d/sched-sharness.sh b/t/sharness.d/sched-sharness.sh index 89f619bd6..23e27a968 100644 --- a/t/sharness.d/sched-sharness.sh +++ b/t/sharness.d/sched-sharness.sh @@ -14,7 +14,9 @@ if test -n "$FLUX_SCHED_TEST_INSTALLED"; then else # Set up environment so that we find flux-sched modules, # and commands from the build directories: - FLUX_MODULE_PATH_PREPEND="${SHARNESS_BUILD_DIRECTORY}/resource/modules/.libs" + FLUX_MODULE_PATH_PREPEND="${SHARNESS_BUILD_DIRECTORY}/resource/modules/" + FLUX_MODULE_PATH_PREPEND="${SHARNESS_BUILD_DIRECTORY}/resource/modules/.libs":${FLUX_MODULE_PATH_PREPEND} + FLUX_MODULE_PATH_PREPEND="${SHARNESS_BUILD_DIRECTORY}/qmanager/modules/":${FLUX_MODULE_PATH_PREPEND} FLUX_MODULE_PATH_PREPEND="${SHARNESS_BUILD_DIRECTORY}/qmanager/modules/.libs":${FLUX_MODULE_PATH_PREPEND} FLUX_EXEC_PATH_PREPEND="${SHARNESS_TEST_SRCDIR}/scripts":"${SHARNESS_TEST_SRCDIR}/../src/cmd" export PYTHONPATH="${SHARNESS_TEST_SRCDIR}/../src/python${PYTHONPATH:+:${PYTHONPATH}}" diff --git a/t/t7000-shell-datastaging.t b/t/t7000-shell-datastaging.t index a0ee94f25..b7f527151 100755 --- a/t/t7000-shell-datastaging.t +++ b/t/t7000-shell-datastaging.t @@ -5,7 +5,11 @@ test_description='Test data-staging job shell plugin' . `dirname $0`/sharness.sh shell_basepath=`readlink -e ${SHARNESS_TEST_SRCDIR}/data/shell` -shell_plugin_path="$(readlink -e ${SHARNESS_BUILD_DIRECTORY}/src/shell/.libs)" +if [ -d "${SHARNESS_BUILD_DIRECTORY}/src/shell/.libs" ] ; then + shell_plugin_path="$(readlink -e ${SHARNESS_BUILD_DIRECTORY}/src/shell/.libs)" +else + shell_plugin_path="$(readlink -e ${SHARNESS_BUILD_DIRECTORY}/src/shell)" +fi jobspec_basepath=`readlink -e ${SHARNESS_TEST_SRCDIR}/data/resource/jobspecs/` From 9dde768a0534fdddb9a5225d79ab1deb71bd7548 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Tue, 25 Jul 2023 03:37:46 -0700 Subject: [PATCH 6/8] add support for building manpages This is custom, but replicates exactly what we do in autotools to generate both manpages and html. --- .configure-custom.sh | 5 ++++- CMakeLists.txt | 7 +----- doc/CMakeLists.txt | 52 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 doc/CMakeLists.txt diff --git a/.configure-custom.sh b/.configure-custom.sh index a4aea3889..58b47c8fb 100755 --- a/.configure-custom.sh +++ b/.configure-custom.sh @@ -1,4 +1,7 @@ #!/bin/sh -ENABLE_VARS="code-coverage|yes|ENABLE_COVERAGE" +ENABLE_VARS="code-coverage|On|ENABLE_COVERAGE docs|On|ENABLE_DOCS" +DISABLE_VARS="docs|Off|ENABLE_DOCS" ENABLE_ENABLE_COVERAGE_DOC="enable coverage analysis" +ENABLE_ENABLE_DOCS_DOC="enable building manpages" +ENABLE_DISABLE_DOCS_DOC="disable building manpages" diff --git a/CMakeLists.txt b/CMakeLists.txt index e1defe4e2..9a64f9507 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,11 +14,6 @@ message(STATUS "Building flux-sched version ${FLUX_SCHED_VER}") if(POLICY CMP0140) cmake_policy(SET CMP0140 NEW) endif() -# Option to Enable SPHINX -option( SPHINX "Enable SPHINX" OFF ) - -# Option to AS_HELP_STRING([--disable-docs -option( DOCS "Enable docs generation" OFF ) set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ standard to use") set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -180,7 +175,7 @@ add_subdirectory( etc ) add_subdirectory( src ) add_subdirectory( resource ) add_subdirectory( qmanager ) -# add_subdirectory( doc ) +add_subdirectory( doc ) add_subdirectory( t ) if(ENABLE_COVERAGE) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 000000000..01f85553b --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,52 @@ +set(3VALUE_OPTS On Off Try) +set(ENABLE_DOCS "Try" CACHE STRING "Enables documentation") + +if(ENABLE_DOCS) # only matches On + set(REQ_DOCS REQUIRED) +endif() +find_program(SPHINX NAMES sphinx-build sphinx-build2 ${REQ_DOCS}) + +if(SPHINX AND ENABLE_DOCS) + + set(man5_inputs + man5/flux-config-sched-fluxion-qmanager.rst + man5/flux-config-sched-fluxion-resource.rst + ) + foreach(file ${man5_inputs}) + string(REPLACE ".rst" ".5" out ${file}) + list(APPEND man5_outputs ${CMAKE_CURRENT_BINARY_DIR}/${out}) + string(REPLACE ".rst" ".html" out ${file}) + list(APPEND man5_html_outputs ${CMAKE_CURRENT_BINARY_DIR}/html/${out}) + endforeach() + + add_custom_target(manpages + ALL + DEPENDS + man5/index.rst + ${man5_inputs} + COMMAND + PYTHONPATH=$ENV{PYTHONPATH}:${CMAKE_CURRENT_SOURCE_DIR} + SPHINX_BUILDDIR=${CMAKE_CURRENT_BINARY_DIR} + ${Python_EXECUTABLE} -m sphinx -b man ${CMAKE_CURRENT_SOURCE_DIR} ./man5 + BYPRODUCTS + ${man5_outputs} + ) + install( + DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/man5 + TYPE MAN + FILES_MATCHING PATTERN "*.5" PATTERN ".doctrees" EXCLUDE + ) + add_custom_target(html + DEPENDS + man5/index.rst + ${man5_inputs} + COMMAND + PYTHONPATH=$ENV{PYTHONPATH}:${CMAKE_CURRENT_SOURCE_DIR} + SPHINX_BUILDDIR=${CMAKE_CURRENT_BINARY_DIR} + ${Python_EXECUTABLE} -m sphinx -b html ${CMAKE_CURRENT_SOURCE_DIR} ./html + BYPRODUCTS + ${man5_html_outputs} + ) + add_custom_target(docs + DEPENDS html manpages) +endif() From 356dad11b00cf2ac006b5b636c431bcddd0f0a04 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Wed, 6 Sep 2023 17:38:03 -0700 Subject: [PATCH 7/8] allow overriding version detection with env var Problem: If no tag is available, the git describe could fail Solution: Users can now specify either the cmake define FLUX_SCHED_VER or the environment variable FLUX_SCHED_VERSION to override the version detection and set it to whatever --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a64f9507..07b32932b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.14) set(VER_FILE ${CMAKE_BINARY_DIR}/flux-sched.ver) -if(EXISTS ${VER_FILE}) +if(DEFINED FLUX_SCHED_VER) + # do nothing, user said so +elseif(DEFINED ENV{FLUX_SCHED_VERSION}) + set(FLUX_SCHED_VER "$ENV{FLUX_SCHED_VERSION}") +elseif(EXISTS ${VER_FILE}) file(READ ${VER_FILE} FLUX_SCHED_VER) string(STRIP ${FLUX_SCHED_VER} FLUX_SCHED_VER) else() From 5ecbd64a3aa33830a2ea889b48f37c0b7b6682b6 Mon Sep 17 00:00:00 2001 From: Tom Scogland Date: Wed, 6 Sep 2023 19:16:33 -0700 Subject: [PATCH 8/8] cmake: fix regex command string expansion problem: when none of the explicit version strings are set and no tags are available, the regex command used to strip the sha from the end of the version to make it pass as cmake's native version caused expansion errors solution (courtesy of @milroy): quote the last argument to `REGEX REPLACE` --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07b32932b..6c299b010 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ else() execute_process(COMMAND sh -c [=[git describe --always | awk '/.*/ {sub(/^v/, ""); printf "%s",$1; exit}']=] OUTPUT_VARIABLE FLUX_SCHED_VER) endif() message(STATUS "VER ${FLUX_SCHED_VER}") -string(REGEX REPLACE "-.*$" "" FLUX_SCHED_VER_NOGIT ${FLUX_SCHED_VER}) +string(REGEX REPLACE "-.*$" "" FLUX_SCHED_VER_NOGIT "${FLUX_SCHED_VER}") project(flux-sched VERSION ${FLUX_SCHED_VER_NOGIT} LANGUAGES CXX C) message(STATUS "Building flux-sched version ${FLUX_SCHED_VER}")