Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit bfecf3d

Browse files
authored
Merge pull request #48 from sbromberger/sbromberger/devenv
Sbromberger/devenv
2 parents f140d97 + a8dbbc0 commit bfecf3d

28 files changed

+430
-5934
lines changed

.devcontainer/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-24.04
2+
FROM mcr.microsoft.com/devcontainers/cpp:dev-ubuntu-24.04
3+
4+
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="none"
5+
6+
# Optionally install the cmake for vcpkg
7+
COPY ./reinstall-cmake.sh /tmp/
8+
9+
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
10+
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
11+
fi \
12+
&& rm -f /tmp/reinstall-cmake.sh
13+
14+
# [Optional] Uncomment this section to install additional vcpkg ports.
15+
# RUN su vscode -c "${VCPKG_ROOT}/vcpkg install clangd"
16+
17+
# [Optional] Uncomment this section to install additional packages.
18+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
19+
# && apt-get -y install --no-install-recommends <your-package-list-here>
20+
RUN apt update && export DEBIAN_FRONTEND=noninteractive && apt -y install clangd-19 clang-tidy-19 python3-pip
21+
RUN update-alternatives --install /usr/bin/clangd clangd /usr/bin/clangd-19 100
22+
RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-19 100

.devcontainer/devcontainer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
3+
{
4+
"name": "C++",
5+
"build": {
6+
"dockerfile": "Dockerfile"
7+
},
8+
"containerEnv": {
9+
"CLIPPY_BACKEND_PATH": "${containerWorkspaceFolder}/build/test"
10+
},
11+
"customizations": {
12+
"vscode": {
13+
"extensions": [
14+
"llvm-vs-code-extensions.vscode-clangd",
15+
"ms-python.python"
16+
// add other extensions as needed
17+
]
18+
}
19+
},
20+
"postCreateCommand": "pip install --break-system-packages -r ${containerWorkspaceFolder}/test/requirements.txt"
21+
}

.devcontainer/reinstall-cmake.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
#-------------------------------------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
5+
#-------------------------------------------------------------------------------------------------------------
6+
#
7+
set -e
8+
9+
CMAKE_VERSION=${1:-"none"}
10+
11+
if [ "${CMAKE_VERSION}" = "none" ]; then
12+
echo "No CMake version specified, skipping CMake reinstallation"
13+
exit 0
14+
fi
15+
16+
# Cleanup temporary directory and associated files when exiting the script.
17+
cleanup() {
18+
EXIT_CODE=$?
19+
set +e
20+
if [[ -n "${TMP_DIR}" ]]; then
21+
echo "Executing cleanup of tmp files"
22+
rm -Rf "${TMP_DIR}"
23+
fi
24+
exit $EXIT_CODE
25+
}
26+
trap cleanup EXIT
27+
28+
29+
echo "Installing CMake..."
30+
apt-get -y purge --auto-remove cmake
31+
mkdir -p /opt/cmake
32+
33+
architecture=$(dpkg --print-architecture)
34+
case "${architecture}" in
35+
arm64)
36+
ARCH=aarch64 ;;
37+
amd64)
38+
ARCH=x86_64 ;;
39+
*)
40+
echo "Unsupported architecture ${architecture}."
41+
exit 1
42+
;;
43+
esac
44+
45+
CMAKE_BINARY_NAME="cmake-${CMAKE_VERSION}-linux-${ARCH}.sh"
46+
CMAKE_CHECKSUM_NAME="cmake-${CMAKE_VERSION}-SHA-256.txt"
47+
TMP_DIR=$(mktemp -d -t cmake-XXXXXXXXXX)
48+
49+
echo "${TMP_DIR}"
50+
cd "${TMP_DIR}"
51+
52+
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_BINARY_NAME}" -O
53+
curl -sSL "https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/${CMAKE_CHECKSUM_NAME}" -O
54+
55+
sha256sum -c --ignore-missing "${CMAKE_CHECKSUM_NAME}"
56+
sh "${TMP_DIR}/${CMAKE_BINARY_NAME}" --prefix=/opt/cmake --skip-license
57+
58+
ln -s /opt/cmake/bin/cmake /usr/local/bin/cmake
59+
ln -s /opt/cmake/bin/ctest /usr/local/bin/ctest

.github/workflows/pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: actions/checkout@v4
1212
- uses: actions/setup-python@v5
1313
with:
14-
python-version: '3.9'
14+
python-version: '3.10'
1515

1616
- name: Install dependencies
1717
run: |
@@ -20,13 +20,13 @@ jobs:
2020
2121
2222
- name: Install Boost
23-
uses: MarkusJx/install-boost@v2.4.5
23+
uses: MarkusJx/install-boost@v2
2424
id: install-boost
2525
with:
2626
# REQUIRED: Specify the required boost version
2727
# A list of supported versions can be found here:
2828
# https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
29-
boost_version: 1.83.0
29+
boost_version: 1.87.0
3030
# OPTIONAL: Specify a platform version
3131
# platform_version: 18.04
3232
# OPTIONAL: Specify a custom install location

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.DS_Store
12
/.cache
23
/**/build
34
/.idea/
@@ -6,11 +7,10 @@ CMakeDoxygenDefaults.cmake
67
DartConfiguration.tcl
78
__pycache__
89
/.vscode
9-
/.devcontainer
1010
*.dSYM
1111
testbracket
1212
testmvmap
1313
testdf
1414
test/TestGraph/testgraph
1515
test/include/wheredev
16-
a.out
16+
a.out

CMakeLists.txt

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
#
44
# SPDX-License-Identifier: MIT
55

6-
# Works with 3.11 and tested through 3.15 (not tested yet)
7-
cmake_minimum_required(VERSION 3.14)
6+
7+
cmake_minimum_required(VERSION 3.26)
88
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
99
set(ALLOW_DUPLICATE_CUSTOM_TARGETS TRUE)
1010

11+
# Avoid warning about DOWNLOAD_EXTRACT_TIMESTAMP in CMake 3.24:
12+
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
13+
cmake_policy(SET CMP0135 NEW)
14+
endif()
15+
1116
project(CLIPPy
1217
VERSION 0.2
1318
DESCRIPTION "Command Line Interface Plus Python"
@@ -32,7 +37,7 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
3237
# Note this needs to be done in the main CMakeLists
3338
# since it calls enable_testing, which must be in the
3439
# main CMakeLists.
35-
include(CTest)
40+
# include(CTest)
3641

3742
# Docs only available if this is the main app
3843
find_package(Doxygen)
@@ -72,26 +77,41 @@ endif()
7277

7378
#
7479
# Boost
75-
set(BOOST_URL
76-
"https://github.com/boostorg/boost/releases/download/boost-1.87.0/boost-1.87.0-cmake.tar.gz"
80+
# Download and build Boost::json
81+
set(BOOST_URL
82+
"https://github.com/boostorg/boost/releases/download/boost-1.87.0/boost-1.87.0-cmake.tar.gz"
7783
CACHE STRING "URL to fetch Boost tarball")
7884

79-
#
80-
# Boost
85+
86+
set(BOOST_INCLUDE_LIBRARIES json lexical_cast range)
87+
set(BUILD_SHARED_LIBS ON)
8188
FetchContent_Declare(
82-
Boost
83-
URL ${BOOST_URL}
84-
)
85-
set(BOOST_INCLUDE_LIBRARIES json)
89+
Boost
90+
URL ${BOOST_URL})
8691
FetchContent_MakeAvailable(Boost)
8792

93+
8894
#
8995
# JSONLogic
90-
FetchContent_Declare(jsonlogic
91-
GIT_REPOSITORY https://github.com/LLNL/jsonlogic.git
92-
GIT_TAG master
93-
)
94-
FetchContent_MakeAvailable(jsonlogic)
96+
# find_package(jsonlogic QUIET)
97+
# if (NOT jsonlogic_FOUND)
98+
# message(STATUS "jsonlogic not found, doing stuff")
99+
set(Boost_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/boost-install) # needed for jsonlogic
100+
101+
FetchContent_Declare(jsonlogic
102+
GIT_REPOSITORY https://github.com/LLNL/jsonlogic.git
103+
GIT_TAG master
104+
SOURCE_SUBDIR cpp
105+
)
106+
# set(jsonlogic_INCLUDE_DIR ${jsonlogic_SOURCE_DIR}/cpp/include/jsonlogic)
107+
FetchContent_MakeAvailable(jsonlogic)
108+
message(STATUS "jsonlogic source dir: ${jsonlogic_SOURCE_DIR}")
109+
110+
111+
# else()
112+
# message(STATUS "jsonlogic found, weird")
113+
114+
# endif()
95115

96116
### Require out-of-source builds
97117
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
@@ -106,9 +126,12 @@ option(TEST_WITH_SLURM "Run tests with Slurm" OFF)
106126
# Header-only library, so likely not have src dir
107127
# add_subdirectory(src)
108128

129+
message(STATUS "CMAKE_PROJECT_NAME: ${CMAKE_PROJECT_NAME}")
130+
message(STATUS "PROJECT_NAME: ${PROJECT_NAME}")
109131
# Testing & examples are only available if this is the main app
110132
# Emergency override MODERN_CMAKE_BUILD_TESTING provided as well
111133
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR MODERN_CMAKE_BUILD_TESTING) AND BUILD_TESTING)
134+
message(STATUS "adding test subdir")
112135
add_subdirectory(test)
113136
# Example codes are here.
114137
#add_subdirectory(examples)

CMakePresets.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": 2,
3+
"configurePresets": [
4+
{
5+
"name": "default",
6+
"cacheVariables": {
7+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
8+
"BUILD_TESTING": "ON"
9+
},
10+
"generator": "Unix Makefiles",
11+
"binaryDir": "${sourceDir}/build"
12+
}
13+
]
14+
}

0 commit comments

Comments
 (0)