Skip to content

Commit

Permalink
-updated seal_lake to v0.2.0;
Browse files Browse the repository at this point in the history
-updated figcone_tree to v2.1.0;
-added CMakePresets.json;
-set version to v1.1.0;
  • Loading branch information
kamchatka-volcano committed Jun 11, 2024
1 parent aeab733 commit ae03059
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 42 deletions.
25 changes: 15 additions & 10 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: build & test (clang, gcc, MSVC)

on:
workflow_dispatch:
push:
branches: [ "master", "dev" ]
paths-ignore:
Expand All @@ -25,27 +26,31 @@ jobs:
- {
name: "Ubuntu Latest gcc",
os: ubuntu-latest,
cc: "gcc",
cxx: "g++",
flags: "-Wall -Werror -Wextra -Wpedantic -Wcast-align -Wnon-virtual-dtor -Woverloaded-virtual -Wunused"
cmake-preset: gcc-release
}
- {
name: "Ubuntu Latest clang",
os: ubuntu-latest,
cc: "clang",
cxx: "clang++",
flags: "-Wall -Werror -Wextra -Wpedantic -Wcast-align -Wnon-virtual-dtor -Woverloaded-virtual -Wunused"
cmake-preset: clang-release
}
- {
name: "Windows Latest MSVC",
os: windows-latest,
cc: "cl",
cxx: "cl",
flags: "/EHsc /W4 /WX"
cmake-preset: msvc-release
}

steps:
- uses: actions/checkout@v3
- name: Install ninja (Windows)
if: matrix.config.os == 'windows-latest'
run: choco install ninja
- name: Install ninja (Linux)
if: matrix.config.os == 'ubuntu-latest'
run: sudo apt install ninja-build
- uses: actions/checkout@v4

- uses: rui314/setup-mold@v1
- uses: hendrikmuhs/ccache-action@v1.2
- uses: ilammy/msvc-dev-cmd@v1

- name: Configure CMake
run: cmake -B ${{github.workspace}}/build -DENABLE_TESTS=ON -DCMAKE_CXX_FLAGS="${{ matrix.config.flags }}"
Expand Down
15 changes: 7 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
cmake_minimum_required(VERSION 3.18)

project(figcone_shoal VERSION 1.0.0 DESCRIPTION "shoal parser for figcone library")
include(GNUInstallDirs)
project(figcone_shoal VERSION 1.1.0 DESCRIPTION "shoal parser for figcone library")
include(external/seal_lake)

set(INSTALL_FIGCONE_TREE ON)
SealLake_IsInstallEnabled(INSTALL_FIGCONE_TREE ON)
SealLake_Import(
figcone_tree 2.0.0
figcone_tree 2.1.0
GIT_REPOSITORY https://github.com/kamchatka-volcano/figcone_tree.git
GIT_TAG v2.0.0
GIT_TAG v2.1.0
)

SealLake_Bundle(
NAME figcone_shoal_sfun
GIT_REPOSITORY https://github.com/kamchatka-volcano/sfun.git
GIT_TAG v5.0.0
GIT_TAG v5.1.0
TEXT_REPLACEMENTS
"namespace sfun" "namespace figcone::shoal::sfun"
SFUN_ FIGCONE_SHOAL_SFUN
Expand Down Expand Up @@ -44,7 +43,7 @@ SealLake_ObjectLibrary(
LIBRARIES Microsoft.figcone_shoal_gsl::figcone_shoal_gsl figcone_shoal_sfun::figcone_shoal_sfun
INTERFACE_LIBRARIES figcone::figcone_tree
DEPENDENCIES
figcone_tree 2.0.0
figcone_tree 2.1.0
)

SealLake_OptionalBuildSteps(tests)
SealLake_OptionalSubProjects(tests)
123 changes: 123 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
{
"version": 6,
"configurePresets": [
{
"name": "base-linux",
"hidden": true,
"displayName": "linux base preset",
"generator": "Ninja",
"binaryDir": "build-${presetName}",
"cacheVariables": {
"CMAKE_EXE_LINKER_FLAGS": "-fuse-ld=mold",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache",
"CPM_SOURCE_CACHE": "cpm_cache"
}
},
{
"name": "clang-base",
"hidden": true,
"displayName": "clang base preset",
"inherits": "base-linux",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "clang++",
"CMAKE_C_COMPILER": "clang",
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Werror -Wcast-align -Wnon-virtual-dtor -Woverloaded-virtual -Wunused"
}
},
{
"name": "clang-debug",
"displayName": "clang (Debug)",
"inherits": "clang-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "clang-release",
"displayName": "clang (Release)",
"inherits": "clang-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "gcc-base",
"hidden": true,
"displayName": "gcc base preset",
"inherits": "base-linux",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "g++",
"CMAKE_C_COMPILER": "gcc",
"CMAKE_CXX_FLAGS": "-Wall -Wextra -Wpedantic -Werror -Wcast-align -Wnon-virtual-dtor -Woverloaded-virtual -Wunused"
}
},
{
"name": "gcc-debug",
"displayName": "gcc (Debug)",
"inherits": "gcc-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "gcc-release",
"displayName": "gcc (Release)",
"inherits": "gcc-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "base-windows",
"displayName": "windows base preset",
"hidden": true,
"generator": "Ninja",
"binaryDir": "build-${presetName}",
"architecture": {
"value": "x64",
"strategy": "external"
},
"cacheVariables": {
"CPM_SOURCE_CACHE": "cpm_cache",
"CMAKE_CXX_COMPILER_LAUNCHER": "ccache"
},
"vendor": {
"microsoft.com/VisualStudioSettings/CMake/1.0": {
"hostOS": [
"Windows"
]
},
"jetbrains.com/clion": {
"toolchain": "Visual Studio"
}
}
},
{
"name": "msvc-base",
"hidden": true,
"displayName": "msvc base preset",
"inherits": "base-windows",
"cacheVariables": {
"CMAKE_CXX_COMPILER": "cl.exe",
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_FLAGS": "/EHsc /W4 /WX"
}
},
{
"name": "msvc-debug",
"displayName": "msvc (Debug)",
"inherits": "msvc-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "msvc-release",
"displayName": "msvc (Release)",
"inherits": "msvc-base",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release"
}
}
]
}
12 changes: 7 additions & 5 deletions external/seal_lake
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
include(FetchContent)
Set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(seal_lake
set(SEAL_LAKE_VERSION v0.2.0)
set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare(seal_lake_${SEAL_LAKE_VERSION}
SOURCE_DIR seal_lake_${SEAL_LAKE_VERSION}
GIT_REPOSITORY "https://github.com/kamchatka-volcano/seal_lake.git"
GIT_TAG "origin/master"
GIT_TAG ${SEAL_LAKE_VERSION}
)
FetchContent_MakeAvailable(seal_lake)
include(${seal_lake_SOURCE_DIR}/seal_lake.cmake)
FetchContent_MakeAvailable(seal_lake_${SEAL_LAKE_VERSION})
include(${seal_lake_${SEAL_LAKE_VERSION}_SOURCE_DIR}/seal_lake.cmake)
20 changes: 10 additions & 10 deletions src/nodeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace figcone::shoal::detail {

std::string readNodeName(Stream& stream)
{
auto firstChar = stream.read();
const auto firstChar = stream.read();
Expects(firstChar == "#");

auto nodeName = std::string{};
Expand All @@ -20,7 +20,7 @@ std::string readNodeName(Stream& stream)

if (stream.peek() == ":") {
stream.skip(1);
auto pos = stream.position();
const auto pos = stream.position();
if (!isBlank(readUntil(stream, "\n")))
throw ConfigError{
"Wrong config node '" + nodeName +
Expand Down Expand Up @@ -48,12 +48,12 @@ ConfigReadResult readEndToken(Stream& stream)
return {ConfigReadResult::NextAction::ReturnToRootNode, {}, {}};
}

auto pos = stream.position();
auto nextChar = stream.read();
const auto pos = stream.position();
const auto nextChar = stream.read();
if (nextChar != "-")
throw ConfigError{"Invalid closing token '-" + nextChar + "'", pos};

auto parentConfigNode = readWord(stream);
const auto parentConfigNode = readWord(stream);
return {ConfigReadResult::NextAction::ReturnToNodeByName, parentConfigNode, pos};
}

Expand Down Expand Up @@ -133,8 +133,8 @@ std::optional<ConfigReadResult> parseListElementNodeSection(

std::optional<ConfigReadResult> parseNodeSection(Stream& stream, figcone::TreeNode& parent)
{
auto pos = stream.position();
auto newNodeName = readNodeName(stream);
const auto pos = stream.position();
const auto newNodeName = readNodeName(stream);
if (isBlank(newNodeName))
throw ConfigError{"Config node name can't be blank", pos};
skipWhitespace(stream);
Expand All @@ -149,7 +149,7 @@ std::optional<ConfigReadResult> parseNodeSection(Stream& stream, figcone::TreeNo
return parent.asItem().addNode(newNodeName, pos);
}();

auto readResult = parseNode(stream, newNode, newNodeName);
const auto readResult = parseNode(stream, newNode, newNodeName);
auto result = checkReadResult(readResult, newNodeName, parent);
if (result.nextAction != ConfigReadResult::NextAction::ContinueReading) {
if (result.nextAction == ConfigReadResult::NextAction::ReturnToParentNode)
Expand All @@ -162,7 +162,7 @@ std::optional<ConfigReadResult> parseNodeSection(Stream& stream, figcone::TreeNo
ConfigReadResult parseNode(Stream& stream, figcone::TreeNode& node, const std::string& nodeName)
{
while (!stream.atEnd()) {
auto nextChar = stream.peek().front();
const auto nextChar = stream.peek().front();
if (std::isspace(nextChar))
stream.skip(1);
else if (stream.peek(3) == "###") {
Expand All @@ -176,7 +176,7 @@ ConfigReadResult parseNode(Stream& stream, figcone::TreeNode& node, const std::s
else if (nextChar == '-')
return readEndToken(stream);
else {
auto [paramName, param] = parseParam(stream);
const auto [paramName, param] = parseParam(stream);
if (param.isItem())
node.asItem().addParam(paramName, param.value());
else
Expand Down
7 changes: 3 additions & 4 deletions src/paramparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ std::optional<std::string> readSingleParam(
stream.skipComments(true);
});

auto quotedParam = readQuotedString(stream);
if (quotedParam)
if (const auto quotedParam = readQuotedString(stream))
return *quotedParam;
else {
auto result = sfun::trim(readUntil(stream, wordSeparator + "\n"));
Expand Down Expand Up @@ -118,14 +117,14 @@ figcone::TreeParam readParamValue(Stream& stream, const std::string& paramName,
std::pair<std::string, figcone::TreeParam> parseParam(Stream& stream)
{
skipWhitespace(stream);
auto paramPos = stream.position();
const auto paramPos = stream.position();
auto paramName = readWord(stream, "=");
if (paramName.empty())
throw ConfigError{"Parameter's name can't be empty", paramPos};

skipParamWhitespace(stream, paramName);

auto pos = stream.position();
const auto pos = stream.position();
if (stream.read() != "=")
throw ConfigError{"Wrong param '" + paramName + "' format: missing '='", pos};

Expand Down
2 changes: 1 addition & 1 deletion src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Tree Parser::parse(std::istream& stream)
auto inputStream = detail::Stream{stream};
auto rootNode = makeTreeRoot();
detail::parseNode(inputStream, *rootNode, "");
return rootNode;
return Tree{std::move(rootNode)};
}

} //namespace figcone::shoal
8 changes: 4 additions & 4 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void skipLine(Stream& stream)
void skipWhitespace(Stream& stream, bool withNewLine)
{
while (!stream.atEnd()) {
auto nextChar = stream.peek().front();
const auto nextChar = stream.peek().front();
if (!withNewLine && nextChar == '\n')
return;

Expand Down Expand Up @@ -69,7 +69,7 @@ std::optional<std::string> readQuotedString(Stream& stream)
if (stream.atEnd())
return {};

auto quotationMark = stream.peek().front();
const auto quotationMark = stream.peek().front();
if (quotationMark != '\'' && quotationMark != '"' && quotationMark != '`')
return {};

Expand All @@ -79,15 +79,15 @@ std::optional<std::string> readQuotedString(Stream& stream)
{
stream.skipComments(true);
});
auto pos = stream.position();
const auto pos = stream.position();
stream.skip(1);

if (stream.peek() == "\n")
stream.skipLineSeparator();

auto result = std::string{};
while (!stream.atEnd()) {
auto ch = stream.read().front();
const auto ch = stream.read().front();
if (ch == quotationMark)
return result;
result += ch;
Expand Down

0 comments on commit ae03059

Please sign in to comment.