Skip to content

Commit 16677cc

Browse files
-updated seal_lake to v0.2.0
-updated figcone_tree to v2.1.0 -added CMakePresets.json -set version to v1.1.0
1 parent 28a67e5 commit 16677cc

File tree

5 files changed

+167
-39
lines changed

5 files changed

+167
-39
lines changed

.github/workflows/build_and_test.yml

+16-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: build & test (clang, gcc, MSVC)
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches: [ "master", "dev" ]
67
paths-ignore:
@@ -25,30 +26,34 @@ jobs:
2526
- {
2627
name: "Ubuntu Latest gcc",
2728
os: ubuntu-latest,
28-
cc: "gcc",
29-
cxx: "g++",
30-
flags: "-Wall -Werror -Wextra -Wpedantic -Wcast-align -Wnon-virtual-dtor -Woverloaded-virtual -Wunused"
29+
cmake-preset: "gcc-release"
3130
}
3231
- {
3332
name: "Ubuntu Latest clang",
3433
os: ubuntu-latest,
35-
cc: "clang",
36-
cxx: "clang++",
37-
flags: "-Wall -Werror -Wextra -Wpedantic -Wcast-align -Wnon-virtual-dtor -Woverloaded-virtual -Wunused"
34+
cmake-preset: "clang-release"
3835
}
3936
- {
4037
name: "Windows Latest MSVC",
4138
os: windows-latest,
42-
cc: "cl",
43-
cxx: "cl",
44-
flags: "/EHsc /W4 /WX"
39+
cmake-preset: "msvc-release"
4540
}
4641

4742
steps:
48-
- uses: actions/checkout@v3
43+
- name: Install ninja (Windows)
44+
if: matrix.config.os == 'windows-latest'
45+
run: choco install ninja
46+
- name: Install ninja (Linux)
47+
if: matrix.config.os == 'ubuntu-latest'
48+
run: sudo apt install ninja-build
49+
- uses: actions/checkout@v4
50+
51+
- uses: rui314/setup-mold@v1
52+
- uses: hendrikmuhs/[email protected]
53+
- uses: ilammy/msvc-dev-cmd@v1
4954

5055
- name: Configure CMake
51-
run: cmake -B ${{github.workspace}}/build -DENABLE_TESTS=ON -DCMAKE_CXX_FLAGS="${{ matrix.config.flags }}"
56+
run: cmake -B ${{github.workspace}}/build -DENABLE_TESTS=ON --preset="${{ matrix.config.cmake-preset }}"
5257

5358
- name: Build
5459
run: cmake --build ${{github.workspace}}/build

CMakeLists.txt

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
cmake_minimum_required(VERSION 3.18)
22

3-
project(figcone_ini VERSION 1.0.0 DESCRIPTION "inifile-cpp parser adapter for figcone library")
4-
include(GNUInstallDirs)
3+
project(figcone_ini VERSION 1.1.0 DESCRIPTION "inifile-cpp parser adapter for figcone library")
54
include(external/seal_lake)
65

76
SealLake_Bundle(
87
NAME figcone_inicpp
9-
GIT_REPOSITORY https://github.com/Rookfighter/inifile-cpp.git
10-
GIT_TAG master
8+
GIT_REPOSITORY https://github.com/kamchatka-volcano/inifile-cpp.git
9+
GIT_TAG v0.1.0
1110
SKIP_LOAD
1211
TEXT_REPLACEMENTS
1312
"namespace ini" "namespace figcone::ini"
@@ -16,16 +15,16 @@ SealLake_Bundle(
1615
SealLake_Bundle(
1716
NAME figcone_ini_sfun
1817
GIT_REPOSITORY https://github.com/kamchatka-volcano/sfun.git
19-
GIT_TAG v5.0.0
18+
GIT_TAG v5.1.0
2019
TEXT_REPLACEMENTS
2120
"namespace sfun" "namespace figcone::ini::sfun"
2221
)
2322

24-
set(INSTALL_FIGCONE_TREE ON)
23+
SealLake_IsInstallEnabled(INSTALL_FIGCONE_TREE)
2524
SealLake_Import(
26-
figcone_tree 2.0.0
25+
figcone_tree 2.1.0
2726
GIT_REPOSITORY https://github.com/kamchatka-volcano/figcone_tree.git
28-
GIT_TAG v2.0.0
27+
GIT_TAG v2.1.0
2928
)
3029

3130
SealLake_ObjectLibrary(
@@ -43,7 +42,7 @@ SealLake_ObjectLibrary(
4342
LIBRARIES
4443
figcone_ini_sfun::figcone_ini_sfun
4544
DEPENDENCIES
46-
figcone_tree 2.0.0
45+
figcone_tree 2.1.0
4746
)
4847

49-
SealLake_OptionalBuildSteps(tests)
48+
SealLake_OptionalSubProjects(tests)

CMakePresets.json

+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
{
2+
"version": 6,
3+
"configurePresets": [
4+
{
5+
"name": "base-linux",
6+
"hidden": true,
7+
"displayName": "linux base preset",
8+
"generator": "Ninja",
9+
"binaryDir": "build-${presetName}",
10+
"cacheVariables": {
11+
"CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=mold",
12+
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
13+
"CPM_SOURCE_CACHE": "cpm_cache"
14+
}
15+
},
16+
{
17+
"name": "clang-base",
18+
"hidden": true,
19+
"displayName": "clang base preset",
20+
"inherits": "base-linux",
21+
"cacheVariables": {
22+
"CMAKE_CXX_COMPILER": "clang++",
23+
"CMAKE_C_COMPILER": "clang",
24+
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Werror -Wcast-align -Wnon-virtual-dtor -Woverloaded-virtual -Wunused"
25+
}
26+
},
27+
{
28+
"name": "clang-debug",
29+
"displayName": "clang (Debug)",
30+
"inherits": "clang-base",
31+
"cacheVariables": {
32+
"CMAKE_BUILD_TYPE": "Debug"
33+
}
34+
},
35+
{
36+
"name": "clang-release",
37+
"displayName": "clang (Release)",
38+
"inherits": "clang-base",
39+
"cacheVariables": {
40+
"CMAKE_BUILD_TYPE": "Release"
41+
}
42+
},
43+
{
44+
"name": "gcc-base",
45+
"hidden": true,
46+
"displayName": "gcc base preset",
47+
"inherits": "base-linux",
48+
"cacheVariables": {
49+
"CMAKE_CXX_COMPILER": "g++",
50+
"CMAKE_C_COMPILER": "gcc",
51+
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Werror -Wcast-align -Wnon-virtual-dtor -Woverloaded-virtual -Wunused"
52+
}
53+
},
54+
{
55+
"name": "gcc-debug",
56+
"displayName": "gcc (Debug)",
57+
"inherits": "gcc-base",
58+
"cacheVariables": {
59+
"CMAKE_BUILD_TYPE": "Debug"
60+
}
61+
},
62+
{
63+
"name": "gcc-release",
64+
"displayName": "gcc (Release)",
65+
"inherits": "gcc-base",
66+
"cacheVariables": {
67+
"CMAKE_BUILD_TYPE": "Release"
68+
}
69+
},
70+
{
71+
"name": "base-windows",
72+
"displayName": "windows base preset",
73+
"hidden": true,
74+
"generator": "Ninja",
75+
"binaryDir": "build-${presetName}",
76+
"architecture": {
77+
"value": "x64",
78+
"strategy": "external"
79+
},
80+
"cacheVariables": {
81+
"CPM_SOURCE_CACHE": "cpm_cache",
82+
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache"
83+
},
84+
"vendor": {
85+
"microsoft.com/VisualStudioSettings/CMake/1.0": {
86+
"hostOS": [
87+
"Windows"
88+
]
89+
},
90+
"jetbrains.com/clion": {
91+
"toolchain": "Visual Studio"
92+
}
93+
}
94+
},
95+
{
96+
"name": "msvc-base",
97+
"hidden": true,
98+
"displayName": "msvc base preset",
99+
"inherits": "base-windows",
100+
"cacheVariables": {
101+
"CMAKE_CXX_COMPILER": "cl.exe",
102+
"CMAKE_C_COMPILER": "cl.exe",
103+
"CMAKE_CXX_FLAGS": "/EHsc /W4 /WX"
104+
}
105+
},
106+
{
107+
"name": "msvc-debug",
108+
"displayName": "msvc (Debug)",
109+
"inherits": "msvc-base",
110+
"cacheVariables": {
111+
"CMAKE_BUILD_TYPE": "Debug"
112+
}
113+
},
114+
{
115+
"name": "msvc-release",
116+
"displayName": "msvc (Release)",
117+
"inherits": "msvc-base",
118+
"cacheVariables": {
119+
"CMAKE_BUILD_TYPE": "Release"
120+
}
121+
}
122+
]
123+
}

external/seal_lake

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
include(FetchContent)
2-
Set(FETCHCONTENT_QUIET FALSE)
3-
FetchContent_Declare(seal_lake
2+
set(SEAL_LAKE_VERSION v0.2.0)
3+
set(FETCHCONTENT_QUIET FALSE)
4+
FetchContent_Declare(seal_lake_${SEAL_LAKE_VERSION}
5+
SOURCE_DIR seal_lake_${SEAL_LAKE_VERSION}
46
GIT_REPOSITORY "https://github.com/kamchatka-volcano/seal_lake.git"
5-
GIT_TAG "origin/master"
7+
GIT_TAG ${SEAL_LAKE_VERSION}
68
)
7-
FetchContent_MakeAvailable(seal_lake)
8-
include(${seal_lake_SOURCE_DIR}/seal_lake.cmake)
9+
FetchContent_MakeAvailable(seal_lake_${SEAL_LAKE_VERSION})
10+
include(${seal_lake_${SEAL_LAKE_VERSION}_SOURCE_DIR}/seal_lake.cmake)

src/parser.cpp

+12-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ bool isUnsignedInt(const std::string& str)
2323

2424
bool hasRootSection(std::istream& stream)
2525
{
26-
auto pos = stream.tellg();
26+
const auto pos = stream.tellg();
2727
auto firstWord = std::string{};
2828
stream >> firstWord;
2929
stream.seekg(pos);
@@ -39,8 +39,7 @@ std::string getStreamContent(std::istream& stream)
3939
void parseSection(const figcone::ini::IniSection& section, figcone::TreeNode& node)
4040
{
4141
for (const auto& [key, value] : section) {
42-
auto paramList = detail::readParamList(key, value.as<std::string>());
43-
if (paramList)
42+
if (const auto paramList = detail::readParamList(key, value.as<std::string>()))
4443
node.asItem().addParamList(key, *paramList);
4544
else
4645
node.asItem().addParam(key, detail::readParam(value.as<std::string>()));
@@ -49,16 +48,16 @@ void parseSection(const figcone::ini::IniSection& section, figcone::TreeNode& no
4948

5049
std::string beforeLast(const std::string& str, const std::string& delim)
5150
{
52-
auto pos = str.rfind(delim);
51+
const auto pos = str.rfind(delim);
5352
if (pos == std::string::npos)
5453
return str;
5554
return str.substr(0, pos);
5655
}
5756

5857
figcone::ConfigError makeConfigError(const std::exception& e, bool hasFakeRootSection)
5958
{
60-
auto message = std::string{e.what()};
61-
auto regex = std::regex{R"(l\.(\d+): (.*))"};
59+
const auto message = std::string{e.what()};
60+
static const auto regex = std::regex{R"(l\.(\d+): (.*))"};
6261
auto match = std::smatch{};
6362
if (std::regex_search(message, match, regex)) {
6463
auto line = std::stoi(match[1]);
@@ -106,7 +105,7 @@ Tree Parser::parse(std::istream& stream)
106105
return *fixedInputStream;
107106
}();
108107

109-
auto ini = [&]
108+
const auto ini = [&]
110109
{
111110
try {
112111
return IniFile{input};
@@ -116,10 +115,10 @@ Tree Parser::parse(std::istream& stream)
116115
}
117116
}();
118117

119-
auto tree = figcone::makeTreeRoot();
120-
impl_->createSectionNodes(ini, *tree);
121-
impl_->parseSections(ini, *tree);
122-
return tree;
118+
auto treeRoot = figcone::makeTreeRoot();
119+
impl_->createSectionNodes(ini, *treeRoot);
120+
impl_->parseSections(ini, *treeRoot);
121+
return Tree{std::move(treeRoot)};
123122
}
124123

125124
void Parser::Impl::parseSections(const IniFile& ini, figcone::TreeNode& node)
@@ -157,8 +156,8 @@ void Parser::Impl::createSectionNodes(const IniFile& ini, figcone::TreeNode& nod
157156
newSectionName,
158157
[&](auto& parentNode)
159158
{
160-
auto listSectionName = beforeLast(newSectionName, ".");
161-
auto sectionArrayIndex = std::stoi(sectionPart);
159+
const auto listSectionName = beforeLast(newSectionName, ".");
160+
const auto sectionArrayIndex = std::stoi(sectionPart);
162161
if (sectionArrayIndex != sectionArrays_[listSectionName]) {
163162
if (sectionArrayIndex != ++sectionArrays_[listSectionName])
164163
throw figcone::ConfigError{"Section array index mismatch"};

0 commit comments

Comments
 (0)