Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
178e4ef
Update yscope-dev-utils to the newest version and fix any task errors
Bill-hbrhbr Feb 11, 2025
1cb2278
Add Catch2 dep
Bill-hbrhbr Feb 11, 2025
2780b90
Add Catch2 to ystdlib-cpp and use Catch2 as main
Bill-hbrhbr Feb 11, 2025
531cb78
lint fix
Bill-hbrhbr Feb 11, 2025
0bb5783
Fix task order depedencies
Bill-hbrhbr Feb 12, 2025
1bc8ba4
temp disable macos in workflow
Bill-hbrhbr Feb 12, 2025
a308c94
make G_DEPS_DIR global
Bill-hbrhbr Feb 12, 2025
8dc65c8
Run macOS again
Bill-hbrhbr Feb 12, 2025
72545e1
Revert dev utils
Bill-hbrhbr Feb 12, 2025
fc8f364
change to new branch
Bill-hbrhbr Feb 12, 2025
3511a96
Fix another --parent
Bill-hbrhbr Feb 12, 2025
e26e8d3
fix rm
Bill-hbrhbr Feb 12, 2025
7fd895d
Test macos-compliant utils-remote
Bill-hbrhbr Feb 12, 2025
5b87eae
Var fix
Bill-hbrhbr Feb 12, 2025
9063174
syntax fix
Bill-hbrhbr Feb 12, 2025
38917dd
syntax fix
Bill-hbrhbr Feb 12, 2025
e49bfb3
newline fix
Bill-hbrhbr Feb 12, 2025
15794f1
update to newest tool
Bill-hbrhbr Feb 13, 2025
dde7b8b
Refactor based on the new dev utils
Bill-hbrhbr Feb 13, 2025
54b4320
Remove lint task issues
Bill-hbrhbr Feb 13, 2025
7dc60b2
rename task to remove the concept of testing
Bill-hbrhbr Feb 13, 2025
c9fd401
nit fixes
Bill-hbrhbr Feb 13, 2025
c774459
Enchance project root specification for CMake
Bill-hbrhbr Feb 14, 2025
8611aad
Group dependency files into individual folders by module name
Bill-hbrhbr Feb 14, 2025
57ac41b
Try the newest curl remote task
Bill-hbrhbr Feb 14, 2025
55c438f
Remove submodules from possible exclusion folders
Bill-hbrhbr Feb 14, 2025
335b3cb
lint fix
Bill-hbrhbr Feb 14, 2025
2c0c2f9
Remove unnecessary Catch2 main macro
Bill-hbrhbr Feb 14, 2025
6d73f81
Grammar fix for submodule
Bill-hbrhbr Feb 14, 2025
1d347a6
Update CMakeLists.txt
Bill-hbrhbr Feb 14, 2025
019f783
Add header reorder format rules
Bill-hbrhbr Feb 19, 2025
3910e31
Address review concerns
Bill-hbrhbr Feb 19, 2025
6bb2234
Apply suggestions from code review
Bill-hbrhbr Feb 20, 2025
0292b29
Rename local cmake-generate to init to avoid confusion with utils tasks
Bill-hbrhbr Feb 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,4 @@ jobs:

# TODO: Change the task to run all unittests once any unittest is added. Until then we check
# that building the project succeeds.
- run: "task build:target"
- run: "task build:all"
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,25 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS
FORCE
)

find_package(Catch2 3.8.0 REQUIRED)
if(Catch2_FOUND)
message(STATUS "Found Catch2 ${Catch2_VERSION}.")
else()
message(FATAL_ERROR "Could not find libraries for Catch2.")
endif()

# Import CMake helper functions
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake)
include(ystdlib-cpp-helpers)

add_subdirectory(src/ystdlib)

# Test dummy project
add_executable(dummy)
target_sources(dummy PRIVATE src/main.cpp)
target_link_libraries(dummy PRIVATE ystdlib::testlib)
target_compile_features(dummy PRIVATE cxx_std_20)
add_executable(unitTest)
target_sources(unitTest PRIVATE src/main.cpp)
target_link_libraries(
unitTest
PRIVATE
ystdlib::testlib
Catch2::Catch2WithMain
)
target_compile_features(unitTest PRIVATE cxx_std_20)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ git submodule update --init --recursive
## Building
To build all targets in `ystdlib-cpp`:
```shell
task build:target
task build:all
```

## Linting
Expand Down
19 changes: 19 additions & 0 deletions src/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
BasedOnStyle: "InheritParentConfig"

IncludeCategories:
# NOTE: A header is grouped by first matching regex library headers. Update when adding new
# libraries.
# NOTE: clang-format retains leading white-space on a line in violation of the YAML spec.
- Regex: "<(ystdlib)"
Priority: 3
- Regex: "<(catch2)"
Priority: 4
# C system headers
- Regex: "^<.+\\.h>"
Priority: 1
# C++ standard libraries
- Regex: "^<.+>"
Priority: 2
# Project headers
- Regex: "^\".+\""
Priority: 5
10 changes: 6 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#include <concepts>
#include <iostream>

#include <ystdlib/testlib/hello.hpp>

#include <catch2/catch_test_macros.hpp>

namespace {
template <typename T>
requires std::integral<T>

[[nodiscard]] auto square(T x) -> T {
return x * x;
}
}; // namespace

[[nodiscard]] auto main() -> int {
std::cout << square(ystdlib::testlib::hello().size()) << '\n';
return 0;
TEST_CASE("dummy") {
REQUIRE((169 == square(ystdlib::testlib::hello().size())));
}
17 changes: 3 additions & 14 deletions taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,21 @@ version: "3"

includes:
build: "./taskfiles/build.yaml"
deps: "./taskfiles/deps.yaml"
lint: "./taskfiles/lint.yaml"
utils: "tools/yscope-dev-utils/taskfiles/utils.yml"
utils: "tools/yscope-dev-utils/taskfiles/utils.yaml"

vars:
G_BUILD_DIR: "{{.ROOT_DIR}}/build"
G_CMAKE_CACHE: "{{.G_BUILD_DIR}}/CMakeCache.txt"
G_COMPILE_COMMANDS_DB: "{{.G_BUILD_DIR}}/compile_commands.json"
G_CPP_SRC_DIR: "{{.ROOT_DIR}}/src"
G_DEPS_DIR: "{{.G_BUILD_DIR}}/deps"

tasks:
clean:
desc: "Removes the project build directory."
cmds:
- "rm -rf '{{.G_BUILD_DIR}}'"

config-cmake-project:
internal: true
sources:
- "CMakeLists.txt"
- "{{.TASKFILE}}"
generates:
- "{{.G_CMAKE_CACHE}}"
- "{{.G_COMPILE_COMMANDS_DB}}"
cmds:
- "cmake -S '{{.ROOT_DIR}}' -B '{{.G_BUILD_DIR}}'"

init:
internal: true
silent: true
Expand Down
42 changes: 26 additions & 16 deletions taskfiles/build.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
version: "3"

vars:
G_CMAKE_CACHE: "{{.G_BUILD_DIR}}/CMakeCache.txt"
G_CMAKE_CONF_ARGS:
- "-DCatch2_ROOT={{.G_DEPS_DIR}}/Catch2/Catch2-install"
G_COMPILE_COMMANDS_DB: "{{.G_BUILD_DIR}}/compile_commands.json"

tasks:
target:
all:
desc: "Builds ystdlib-cpp."
vars:
TARGETS:
ref: "default (list \"all\") .TARGETS"
deps:
- ":config-cmake-project"
- "init"
cmds:
- >-
cmake
--build "{{.G_BUILD_DIR}}"
--parallel {{numCPU}}
--target {{range .TARGETS}}{{.}} {{end}}
- task: ":utils:cmake-build"
vars:
BUILD_DIR: "{{.G_BUILD_DIR}}"

clean:
desc: "Removes all built artifacts."
deps:
- ":config-cmake-project"
- task: ":utils:cmake-clean"
vars:
BUILD_DIR: "{{.G_BUILD_DIR}}"

init:
internal: true
deps:
- ":deps:install-all"
run: "once"
cmds:
- >-
cmake
--build "{{.G_BUILD_DIR}}"
--parallel {{numCPU}}
--target clean
- task: ":utils:cmake-generate"
vars:
BUILD_DIR: "{{.G_BUILD_DIR}}"
EXTRA_ARGS:
ref: ".G_CMAKE_CONF_ARGS"
SOURCE_DIR: "{{.ROOT_DIR}}"
21 changes: 21 additions & 0 deletions taskfiles/deps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: "3"

tasks:
install-all:
desc: "Install all dependencies required by ystdlib-cpp."
deps:
- "install-Catch2"

install-Catch2:
internal: true
vars:
NAME: "Catch2"
WORK_DIR: "{{.G_DEPS_DIR}}/{{.NAME}}"
run: "once"
cmds:
- task: ":utils:cmake-install-remote-tar"
vars:
NAME: "{{.NAME}}"
WORK_DIR: "{{.WORK_DIR}}"
FILE_SHA256: "1ab2de20460d4641553addfdfe6acd4109d871d5531f8f519a52ea4926303087"
URL: "https://github.com/catchorg/Catch2/archive/refs/tags/v3.8.0.tar.gz"
2 changes: 1 addition & 1 deletion taskfiles/lint-cpp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ tasks:
- "{{.ROOT_DIR}}/.clang-tidy"
- "{{.TASKFILE}}"
deps:
- ":config-cmake-project"
- ":build:init"
- "cpp-configs"
- "venv"
cmds:
Expand Down
6 changes: 3 additions & 3 deletions taskfiles/lint-venv.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tasks:
- task: ":utils:validate-checksum"
vars:
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
DATA_DIR: "{{.OUTPUT_DIR}}"
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]
cmds:
- task: ":utils:create-venv"
vars:
Expand All @@ -28,5 +28,5 @@ tasks:
# This command must be last
- task: ":utils:compute-checksum"
vars:
DATA_DIR: "{{.OUTPUT_DIR}}"
OUTPUT_FILE: "{{.CHECKSUM_FILE}}"
CHECKSUM_FILE: "{{.CHECKSUM_FILE}}"
INCLUDE_PATTERNS: ["{{.OUTPUT_DIR}}"]
3 changes: 1 addition & 2 deletions taskfiles/lint-yaml.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ tasks:
- "{{.ROOT_DIR}}/**/*.yml"
- "{{.TASKFILE}}"
- exclude: "{{.ROOT_DIR}}/**/build/*"
- exclude: "{{.ROOT_DIR}}/**/submodules/*"
- exclude: "{{.ROOT_DIR}}/**/tools/*"
dir: "{{.ROOT_DIR}}"
deps:
Expand All @@ -21,7 +20,7 @@ tasks:
- |-
. "{{.G_LINT_VENV_DIR}}/bin/activate"
find . \
\( -path '**/build' -o -path '**/submodules' -o -path '**/tools' \) -prune -o \
\( -path '**/build' -o -path '**/tools' \) -prune -o \
\( -iname "*.yaml" -o -iname "*.yml" \) \
-print0 | \
xargs -0 yamllint \
Expand Down
Loading