Skip to content

Commit 49e061f

Browse files
committed
Make code build with gcc 9
1 parent 1d7eb47 commit 49e061f

File tree

6 files changed

+69
-28
lines changed

6 files changed

+69
-28
lines changed

.github/workflows/multiplatform_build.yaml

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ jobs:
3333
- name: Checkout code
3434
uses: actions/[email protected]
3535

36-
- name: Install LLVM and Clang
36+
- if: startsWith(matrix.os, 'windows')
37+
name: Install LLVM and Clang
3738
uses: KyleMayes/[email protected]
3839
with:
3940
version: "18"
@@ -52,24 +53,6 @@ jobs:
5253
libncurses5-dev libncursesw5-dev xz-utils tk-dev \
5354
libffi-dev liblzma-dev python3-openssl git
5455
55-
- if: endsWith(matrix.os, '20.04')
56-
name: Install ubuntu-20.04 specific dependencies
57-
run: |
58-
sudo apt-get install -y software-properties-common
59-
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
60-
sudo apt-get update
61-
sudo apt-get install -y libtinfo5
62-
sudo apt install gcc-13 g++-13
63-
64-
- if: endsWith(matrix.os, '22.04')
65-
name: Install ubuntu-22.04 specific dependencies
66-
run: |
67-
sudo apt-get install -y software-properties-common
68-
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
69-
sudo apt-get update
70-
sudo apt-get install -y libtinfo5
71-
sudo apt install gcc-13 g++-13
72-
7356
- if: endsWith(matrix.os, '24.04')
7457
name: Install ubuntu-24.04 specific dependencies
7558
run: |

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**/*.min.js
2+
**/*min.css
3+
/.tox
4+
/.git
5+
/.env
6+
/.venv
7+
/coverage
8+
/dist
9+
/.venv
10+
**/data/*

.prettierrc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"semi": true,
3+
"useTabs": false,
4+
"endOfLine": "lf",
5+
"printWidth": 88,
6+
"overrides": [
7+
{
8+
"files": ["*.html", "*.js", "*.json", "*.prettierrc", "*.overrides"],
9+
"options": {
10+
"tabWidth": 4
11+
}
12+
},
13+
{
14+
"files": ["*.md"],
15+
"options": {
16+
"proseWrap": "always"
17+
}
18+
},
19+
{
20+
"files": ["*.css"],
21+
"options": {
22+
"tabWidth": 4
23+
}
24+
}
25+
]
26+
}

CMakeLists.txt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,27 @@ set(CMAKE_CXX_STANDARD 20)
55
set(CMAKE_CXX_STANDARD_REQUIRED ON)
66
set(CMAKE_CXX_EXTENSIONS OFF)
77

8+
include(cmake/CPM.cmake)
9+
10+
CPMAddPackage(
11+
NAME fmt
12+
VERSION 8.0.1
13+
URL https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.zip
14+
)
15+
16+
817
add_library(GerberParserCppModule STATIC)
918
target_sources(
1019
GerberParserCppModule PUBLIC
1120
FILE_SET cxx_modules TYPE CXX_MODULES FILES
1221
cpp/src/GerberParserCppModule.cxx
1322
)
23+
target_link_libraries(
24+
GerberParserCppModule
25+
PRIVATE fmt::fmt
26+
)
1427
target_compile_features(GerberParserCppModule PUBLIC cxx_std_20)
1528

16-
include(cmake/CPM.cmake)
17-
1829
# Download and load pybind11 with CMake Package Manager
1930
# See https://github.com/cpm-cmake/CPM.cmake/blob/master/README.md
2031
CPMAddPackage(
@@ -24,7 +35,11 @@ CPMAddPackage(
2435
)
2536

2637
pybind11_add_module(PyGerberGerberParserCpp cpp/src/PythonModule.cpp)
27-
target_link_libraries(PyGerberGerberParserCpp PRIVATE GerberParserCppModule)
38+
target_link_libraries(
39+
PyGerberGerberParserCpp
40+
PRIVATE fmt::fmt
41+
PRIVATE GerberParserCppModule
42+
)
2843
target_compile_features(PyGerberGerberParserCpp PRIVATE cxx_std_20)
2944

3045
add_custom_command(
@@ -46,5 +61,10 @@ file(GLOB_RECURSE test_source_files ${PROJECT_SOURCE_DIR}/cpp/test/ *.test.cpp)
4661
add_executable(tests)
4762
target_sources(tests PUBLIC ${test_source_files})
4863

49-
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain GerberParserCppModule)
64+
target_link_libraries(
65+
tests
66+
PRIVATE fmt::fmt
67+
PRIVATE Catch2::Catch2WithMain
68+
PRIVATE GerberParserCppModule
69+
)
5070
target_compile_features(tests PRIVATE cxx_std_20)

cpp/src/GerberParserCppModule.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module;
22

3+
#include "fmt/format.h"
34
#include <algorithm>
45
#include <cstdint>
5-
#include <format>
66
#include <memory>
77
#include <regex>
88
#include <stdexcept>
@@ -11,6 +11,7 @@ module;
1111
#include <tuple>
1212
#include <vector>
1313

14+
1415
export module GerberParserCppModule;
1516

1617
export namespace gerber {
@@ -403,7 +404,7 @@ export namespace gerber {
403404
(next_endl_or_end_index - global_index) > 20 ? global_index + 20 : next_endl_index;
404405
const auto source_view = full_source.substr(global_index, end_index);
405406

406-
auto message = std::format(
407+
auto message = fmt::format(
407408
"Syntax error at index {} (line: {} column: {}): '{}'",
408409
global_index,
409410
line,

cpp/test/main.test.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import GerberParserCppModule;
22

3+
#include "fmt/format.h"
34
#include <catch2/catch_template_test_macros.hpp>
45
#include <catch2/catch_test_macros.hpp>
56

@@ -42,14 +43,14 @@ TEMPLATE_TEST_CASE_SIG(
4243
(gerber::G91, 91)
4344
) {
4445
gerber::Parser parser;
45-
auto gerber_source = std::format("G{}*G0{}*G00{}*G000{}*", code, code, code, code);
46+
auto gerber_source = fmt::format("G{}*G0{}*G00{}*G000{}*", code, code, code, code);
4647
auto result = parser.parse(gerber_source);
4748
const auto& nodes = result.getNodes();
4849

4950
REQUIRE(nodes.size() == 4);
5051

5152
for (const auto& node : nodes) {
52-
REQUIRE(node->getNodeName() == std::format("G{:0>2}", code));
53+
REQUIRE(node->getNodeName() == fmt::format("G{:0>2}", code));
5354
}
5455
}
5556

@@ -93,7 +94,7 @@ TEMPLATE_TEST_CASE_SIG(
9394
) {
9495
std::string unitModeString = gerber::UnitMode(enumValue).toString();
9596
gerber::Parser parser;
96-
auto gerber_source = std::format("%MO{}*%", unitModeString);
97+
auto gerber_source = fmt::format("%MO{}*%", unitModeString);
9798
auto result = parser.parse(gerber_source);
9899
const auto& nodes = result.getNodes();
99100

0 commit comments

Comments
 (0)