Skip to content

Commit e7b105e

Browse files
authored
Merge pull request #75 from SYMSCAE/cmake-build
refactor: modernize build & test system
2 parents 427b5c6 + d87cb5d commit e7b105e

90 files changed

Lines changed: 5829 additions & 5793 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.codecov.yml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,3 @@ comment:
1212
require_base: false # [true :: must have a base report to post]
1313
require_head: false # [true :: must have a head report to post]
1414
hide_project_coverage: false # [true :: only show coverage on the git diff aka patch coverage]
15-
16-
# SCons compiles copies of the sources in build/coverage-<arch>/, map them back to src/
17-
fixes:
18-
- "build/coverage-x86_64/::src/"

‎.github/ISSUE_TEMPLATE/release_checklist.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ assignees: ""
1414
- [ ] Locally rendered documentation contains all appropriate pages and other human-written text is up-to-date with any changes in the code.
1515
- [ ] Installation instructions in the README, documentation, and the website are updated.
1616
- [ ] Grammar and writing quality are checked (no typos).
17-
- [ ] Review `FALLBACK_VERSION` in `site_scons/fallback_version.py` for builds without a resolvable release tag.
18-
- [ ] `scons test` passes locally with the latest conda-forge compilers and dependencies.
17+
- [ ] Review `LIBDIFFPY_FALLBACK_VERSION` in `cmake/FallbackVersion.cmake` for builds without a resolvable release tag.
18+
- [ ] The unit tests pass locally (`cmake --preset debug`, `cmake --build --preset debug`, `ctest --preset debug`) with the latest conda-forge compilers and dependencies.
1919
- [ ] Dispatch matrix testing to test the release on all systems. If you do not have permission to run this workflow, tag the maintainer and say `@maintainer, please dispatch matrix testing workflow`. Matrix testing also runs automatically after a GitHub release is published, but it does not block the release, so check that it passes.
2020

2121
Please tag the maintainer (e.g., @username) in the comment here when you are ready for the GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here:

‎.github/actions/setup-tests/action.yml‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ runs:
77
shell: bash
88
run: git fetch --tags https://github.com/diffpy/libdiffpy.git
99

10-
- name: Check out CxxTest 4.4
11-
uses: actions/checkout@v6
12-
with:
13-
repository: CxxTest/cxxtest
14-
ref: 191adddb3876ab389c0c856e1c03874bf70f8ee4
15-
path: build/cxxtest
16-
1710
- name: Prepare C++ test configuration
1811
shell: python {0}
1912
run: |

‎.github/scripts/configure-tests.py‎

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Configure SCons, CxxTest and the conda environment for CI tests."""
1+
"""Write the conda environment file for the CI tests."""
22

33
import json
44
from pathlib import Path
@@ -7,7 +7,7 @@
77
for filename in ("build.txt", "conda.txt", "tests.txt"):
88
for line in (Path("requirements") / filename).read_text().splitlines():
99
spec = line.split("#", 1)[0].strip()
10-
if spec and spec != "cxxtest":
10+
if spec:
1111
requirements.append(spec)
1212

1313
Path("build").mkdir(exist_ok=True)
@@ -22,34 +22,3 @@
2222
)
2323
+ "\n"
2424
)
25-
26-
Path("sconscript.local").write_text("""\
27-
Import('env')
28-
import os
29-
import sys
30-
31-
prefix = os.environ['CONDA_PREFIX']
32-
cxxtest = Dir('#/build/cxxtest').abspath
33-
env.Replace(CXXTEST=os.path.join(cxxtest, 'bin', 'cxxtestgen'),
34-
CXXTEST_INSTALL_DIR=cxxtest, CXXTEST_PYTHON=sys.executable)
35-
36-
if env['PLATFORM'] == 'win32':
37-
from SCons.Platform.win32 import exec_spawn
38-
39-
# The outer CI shell already activates conda and SCons configures MSVC.
40-
# /D stops each compiler/test-generator child from repeating cmd AutoRun.
41-
def spawn_without_autorun(sh, escape, cmd, args, child_env):
42-
return exec_spawn([sh, '/D', '/C', escape(' '.join(args))], child_env)
43-
44-
env['SPAWN'] = spawn_without_autorun
45-
else:
46-
env.Replace(CXX=os.environ.get('CXX', os.path.join(prefix, 'bin', 'c++')))
47-
env.Prepend(CCFLAGS=['-isystem' + os.path.join(prefix, 'include')])
48-
env.Append(LIBPATH=os.path.join(prefix, 'lib'))
49-
env.Append(LINKFLAGS='-Wl,-rpath,' + os.path.join(prefix, 'lib'))
50-
if env['PLATFORM'] == 'darwin':
51-
sdk = os.environ.get('CONDA_BUILD_SYSROOT')
52-
if sdk:
53-
env.Append(CXXFLAGS=['-isysroot', sdk])
54-
env.Append(LINKFLAGS=['-isysroot', sdk])
55-
""")

‎.github/workflows/matrix-and-codecov.yml‎

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,21 @@ jobs:
2727
include:
2828
- os: ubuntu-latest
2929
shell: bash -l {0}
30-
build: coverage
30+
build-type: Debug
31+
coverage: "ON"
3132
jobs: 4
3233
- os: windows-latest
3334
shell: cmd /C CALL {0}
34-
build: fast
3535
jobs: 4
3636
- os: macos-latest
3737
shell: bash -l {0}
38-
build: fast
38+
build-type: Release
39+
coverage: "OFF"
3940
jobs: 2
4041
- os: macos-15-intel
4142
shell: bash -l {0}
42-
build: fast
43+
build-type: Release
44+
coverage: "OFF"
4345
jobs: 4
4446
defaults:
4547
run:
@@ -55,13 +57,29 @@ jobs:
5557
uses: ./.github/actions/setup-tests
5658

5759
- name: Build and run C++ tests
58-
run: scons -j${{ matrix.jobs }} build=${{ matrix.build }} test
60+
if: runner.os != 'Windows'
61+
run: |
62+
cmake -S . -B build/ci -G Ninja $CMAKE_ARGS \
63+
-DCMAKE_BUILD_TYPE=${{ matrix.build-type }} \
64+
-DLIBDIFFPY_COVERAGE=${{ matrix.coverage }} \
65+
-DLIBDIFFPY_BUILD_TESTS=ON
66+
cmake --build build/ci --parallel ${{ matrix.jobs }}
67+
ctest --test-dir build/ci --output-on-failure
68+
69+
# The conda cxx-compiler activation configures MSVC for Ninja in cmd.
70+
- name: Build and run C++ tests (Windows)
71+
if: runner.os == 'Windows'
72+
run: |
73+
where cl.exe || exit /b 1
74+
cmake --preset release -DLIBDIFFPY_BUILD_TESTS=ON || exit /b 1
75+
cmake --build --preset release --parallel ${{ matrix.jobs }} || exit /b 1
76+
ctest --test-dir build\release --output-on-failure --no-tests=error
5977
6078
- name: Generate coverage report
6179
if: runner.os == 'Linux'
6280
run: >-
6381
gcovr --gcov-executable "$CONDA_PREFIX/bin/gcov"
64-
--root . --filter 'build/coverage-.*/diffpy/'
82+
--root . --filter 'src/diffpy/'
6583
--xml coverage.xml
6684
6785
- name: Save coverage report

‎.github/workflows/tests-on-pr.yml‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ jobs:
2727
- name: Build and run C++ tests with coverage
2828
run: |
2929
"$CONDA_PREFIX/bin/c++" --version
30-
scons -j4 build=coverage test
30+
cmake --preset coverage $CMAKE_ARGS \
31+
-DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu
32+
cmake --build --preset coverage --parallel 4
33+
ctest --preset coverage
3134
3235
- name: Generate coverage report
3336
run: >-
3437
gcovr --gcov-executable "$CONDA_PREFIX/bin/gcov"
35-
--root . --filter 'build/coverage-.*/diffpy/'
38+
--root . --filter 'src/diffpy/'
3639
--xml coverage.xml
3740
3841
- name: Upload coverage to Codecov

‎.gitignore‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,8 @@ __pycache__/
1919
*.la
2020
*.a
2121

22-
# SCons build files
23-
.sconf_temp/
24-
.sconsign.dblite
25-
/sconscript.local
26-
/sconsvars.py
22+
# CMake user settings
23+
/CMakeUserPresets.json
2724
.gdb_history
2825
tags
2926

‎.pre-commit-config.yaml‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ ci:
99
autoupdate_schedule: monthly
1010
skip: [no-commit-to-branch]
1111
submodules: false
12-
# Leave the vendored CxxTest SCons tool and the data tables untouched.
12+
# Leave the data tables untouched.
1313
exclude: |
1414
(?x)^(
15-
site_scons/site_tools/cxxtest\.py|
1615
.*\.(cif|dat)
1716
)$
1817
repos:

‎.readthedocs.yaml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ build:
44
os: "ubuntu-22.04"
55
tools:
66
python: "latest"
7+
# cmake resolves the documentation version from git tags.
8+
apt_packages:
9+
- cmake
710

811
python:
912
install:

0 commit comments

Comments
 (0)