Skip to content

Add simplified build system with meta-modules and wrapper scripts#4512

Open
tclune wants to merge 4 commits intodevelopfrom
feature/simplified-build-system
Open

Add simplified build system with meta-modules and wrapper scripts#4512
tclune wants to merge 4 commits intodevelopfrom
feature/simplified-build-system

Conversation

@tclune
Copy link
Collaborator

@tclune tclune commented Mar 11, 2026

Summary

This PR introduces a simplified build system for MAPL that reduces cognitive load for both developers and AI agents by providing meta-modules and wrapper scripts.

Changes

Wrapper Scripts

  • build.sh - Simple build wrapper: ./build.sh [compiler] [build_type]
  • test.sh - Simple test wrapper: ./test.sh [compiler] [test_pattern]
  • BUILD.md - Comprehensive documentation

Meta-Modules (Created in ~/modulefiles/core/)

  • nag-stack - Loads NAG + OpenMPI + baselibs
  • gfortran-stack - Loads GFortran + OpenMPI + baselibs

Benefits

Before:

module purge
module load nag/7.2.41
module load openmpi/5.0.5
module load baselibs/9.7.0
mkdir -p build-nag
cd build-nag
cmake .. -DCMAKE_BUILD_TYPE=Debug
cmake --build . -j8
# For tests: remember to set DYLD_LIBRARY_PATH...

After:

./build.sh nag
./test.sh nag

Key Features

  • Automatic module loading (no need to remember sequences)
  • Automatic DYLD_LIBRARY_PATH handling via ctest
  • Consistent build directory naming
  • Support for test filtering
  • Clear error messages

Related Issues

Testing

Meta-modules tested and confirmed working:

module load nag-stack      # ✓ Loads all dependencies
module load gfortran-stack # ✓ Loads all dependencies

Scripts tested for proper module loading and error handling.

- Add build.sh wrapper script for simplified building
- Add test.sh wrapper script for simplified testing
- Add BUILD.md documentation
- Created meta-modules (nag-stack, gfortran-stack) in ~/modulefiles/core/
- Simplifies workflow for AI agents and developers
- Automatically handles module loading and DYLD_LIBRARY_PATH

Resolves #4511 (partially - meta-modules and scripts, documentation update tracked separately)
@tclune tclune requested a review from a team as a code owner March 11, 2026 18:57
@tclune tclune requested a review from mathomp4 March 11, 2026 19:01
@tclune tclune added 🎁 New Feature This is a new feature 0 Diff The changes in this pull request have verified to be zero-diff with the target branch. labels Mar 11, 2026
@mathomp4
Copy link
Member

@tclune This might only work for you...or only on bucy? For example, I don't have things like gfortran-stack on my macOS machines.

But if it helps you, that is good. I might suggest more modern CMake though a la:

BUILD_DIR="build-${COMPILER}"
INSTALL_DIR="install-${COMPILER}"

and then replace:

# Create build directory
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"

# Configure with CMake
echo ""
echo "Configuring with CMake..."
cmake .. \
    -DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
    -DCMAKE_INSTALL_PREFIX=../install

with:

cmake -B ${BUILD_DIR} -S . --install-prefix=$(pwd)/${INSTALL_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}

You also don't ever do install with this:

cmake --build . -j8

(and you should point to ${BUILD_DIR}).

If you want that then you'd need to add a:

cmake --build ${BUILD_DIR} --parallel 8 --target install

Similarly for ctest you can do:

ctest --test-dir ${BUILD_DIR} ...

For real safety, maybe BUILD_DIR and INSTALL_DIR should be full paths and even where the source is? Then you can do:

cmake -B ${BUILD_DIR} -S ${SOURCE_DIR} --install-prefix=${INSTALL_DIR} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}

@tclune
Copy link
Collaborator Author

tclune commented Mar 11, 2026

Yes - this was just the initial response (recommendation) from claude after a lengthy set of questions. Not at all sure I like it and very much think of this as just the start of a discussion.

@tclune
Copy link
Collaborator Author

tclune commented Mar 11, 2026

Please make inline suggestions. I also now see that claude failed to bring the updated "skill" over from the other branch. (It did not follow my instructions and initially committed in on the wrong branch.)

Address code review feedback from @mathomp4:
- Use modern CMake syntax: -B, -S, --install-prefix, --test-dir
- Use compiler-specific build and install directories
- Use full paths (SOURCE_DIR, BUILD_DIR, INSTALL_DIR) for safety
- Point cmake --build to BUILD_DIR explicitly
- Add optional install prefix parameter to build.sh
- Remove need to cd into build directory

Changes:
- build.sh: Use cmake -B/-S syntax, add full paths, show install command
- test.sh: Use ctest --test-dir syntax, add full paths
- CHANGELOG.md: Document new build system features
Co-authored-by: Matt Thompson <matthew.thompson@nasa.gov>
@tclune
Copy link
Collaborator Author

tclune commented Mar 12, 2026

I wonder where Claude found that CMake version. The environment it was running in has v3.31.1.


# Use full paths for safety
SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="${SOURCE_DIR}/build-${COMPILER}"
Copy link
Contributor

Choose a reason for hiding this comment

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

I use something like
BUILD_DIR="${SOURCE_DIR}/build/${COMPILER}/${BUILD_TYPE}”
Might be cleaner - you will need to gitignore only the build directory.

Copy link
Member

Choose a reason for hiding this comment

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

Well, at the moment we ignore:

/build*
/install*

so if it's a directory called that, we ignore it. Plus our CMake adds a .gitignore file to all build and install directories regardless of names.

SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="${SOURCE_DIR}/build-${COMPILER}"
if [[ -z "$INSTALL_PREFIX" ]]; then
INSTALL_DIR="${SOURCE_DIR}/install-${COMPILER}"
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to BUILD_DIR

### Running Tests

```bash
./test.sh [compiler] [test_pattern]
Copy link
Contributor

Choose a reason for hiding this comment

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

We’ll need build type, unless we assume that we are testing only the Debug build for that compiler

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0 Diff The changes in this pull request have verified to be zero-diff with the target branch. 🎁 New Feature This is a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants