Skip to content

Commit 381b931

Browse files
committed
Updated libfwk to 2025.01.13
1 parent 893f28e commit 381b931

File tree

4 files changed

+16
-64
lines changed

4 files changed

+16
-64
lines changed

.github/workflows/test.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ jobs:
2323
env:
2424
cache-name: cache-deps
2525
with:
26-
path: C:/libraries
27-
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('libfwk/tools/install_deps.py') }}-v1
26+
path: libfwk/windows/libraries
27+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('libfwk/tools/install_deps.py', 'libfwk/dependencies.json') }}-v1
2828

2929
- if: ${{ steps.cache-deps.outputs.cache-hit != 'true' }}
3030
name: Install dependencies
3131
shell: cmd
3232
run: |
3333
pip install conan
34-
python libfwk/tools/install_deps.py C:/libraries
34+
cd libfwk
35+
python tools/install_deps.py
3536
3637
- name: Build libfwk release
3738
shell: cmd
@@ -49,7 +50,7 @@ jobs:
4950
mkdir lucid-raster
5051
copy build\lucid-x64-Release\lucid.exe lucid-raster\
5152
xcopy data\shaders\ lucid-raster\data\shaders\ /E
52-
copy C:\libraries\x86_64\bin\shaderc_shared.dll lucid-raster\
53+
copy libfwk\windows\libraries\bin\shaderc_shared.dll lucid-raster\
5354
5455
- name: Archive build
5556
uses: actions/upload-artifact@v4

src/wavefront_obj.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Ex<void> WavefrontMaterial::load(ZStr file_path, vector<WavefrontMaterial> &out)
1313
int count = 0;
1414
WavefrontMaterial *new_mat = nullptr;
1515

16-
for(auto line : tokenize(file_text, '\n')) {
16+
for(string line : tokenize(file_text, '\n')) {
1717
if(line[0] == '#')
1818
continue;
1919

@@ -112,7 +112,7 @@ Ex<WavefrontObject> WavefrontObject::load(ZStr path, i64 file_size_limit) {
112112
vector<UseMtl> use_mtls;
113113
vector<WavefrontMaterial> materials;
114114

115-
for(auto line : tokenize(file_text, '\n')) {
115+
for(string line : tokenize(file_text, '\n')) {
116116
if(line[0] == '#')
117117
continue;
118118
TextParser parser(line);

tools/format.py

+8-57
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,17 @@
11
#!/usr/bin/env python
22

3-
import argparse, os, re, subprocess, shutil
3+
# Copyright (C) Krzysztof Jakubowski <nadult@fastmail.fm>
4+
# This file is part of LucidRaster. See license.txt for details.
45

6+
import argparse, sys, os, re
57

6-
# TODO: import this form libfwk/tools/format.py
7-
class CodeFormatter:
8-
def __init__(self, expected_version=17):
9-
self.expected_version = expected_version
10-
self.clang_format_cmd = self._find_clang_format_cmd()
11-
self._verify_clang_format()
128

13-
def _find_clang_format_cmd(self):
14-
names = [f"clang-format-{self.expected_version}", "clang-format"]
15-
for name in names:
16-
if shutil.which(name) is not None:
17-
return name
18-
raise Exception(f"{names[0]} is missing")
9+
def lucid_dir():
10+
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
1911

20-
def _verify_clang_format(self):
21-
result = subprocess.run([self.clang_format_cmd, "--version"], stdout=subprocess.PIPE)
22-
tokens = result.stdout.decode("utf-8").split()
23-
while len(tokens) > 0 and tokens[0] != "clang-format":
24-
tokens.pop(0)
25-
if (
26-
result.returncode != 0
27-
or len(tokens) < 3
28-
or tokens[0] != "clang-format"
29-
or tokens[1] != "version"
30-
):
31-
raise Exception(f"error while checking clang-format version (version string: {tokens})")
32-
version = tokens[2].split(".", 2)
33-
print(f"clang-format version: {version[0]}.{version[1]}.{version[2]}")
34-
35-
if int(version[0]) < self.expected_version:
36-
raise Exception(
37-
"clang-format is too old; At least version {self.expected_version} is required"
38-
)
39-
40-
def format_cpp(self, files, check: bool):
41-
print("Checking code formatting..." if check else "Formatting code...")
42-
full_command = [self.clang_format_cmd, "-i"]
43-
if check:
44-
full_command += ["--dry-run", "-Werror"]
45-
full_command += files
46-
result = subprocess.run(full_command)
47-
48-
if check:
49-
if result.returncode != 0:
50-
exit(1)
51-
print("All OK")
52-
53-
54-
def find_files(root_dirs, regex):
55-
out = []
56-
for root_dir in root_dirs:
57-
for root, dirs, files in os.walk(root_dir):
58-
for file in files:
59-
if regex.match(file):
60-
out.append(os.path.join(root, file))
61-
return out
6212

13+
sys.path.insert(0, os.path.join(lucid_dir(), "libfwk", "tools"))
14+
from format import CodeFormatter, find_files
6315

6416
if __name__ == "__main__":
6517
parser = argparse.ArgumentParser(
@@ -70,7 +22,6 @@ def find_files(root_dirs, regex):
7022
args = parser.parse_args()
7123

7224
formatter = CodeFormatter()
73-
lucid_path = os.path.abspath(os.path.join(__file__, "../.."))
74-
os.chdir(lucid_path)
25+
os.chdir(lucid_dir())
7526
files = find_files(["src", os.path.join("data", "shaders")], re.compile(".*[.](h|cpp|glsl)$"))
7627
formatter.format_cpp(files, args.check)

0 commit comments

Comments
 (0)