Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated libfwk to 2025.01.13 #12

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 5 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@ jobs:
env:
cache-name: cache-deps
with:
path: C:/libraries
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('libfwk/tools/install_deps.py') }}-v1
path: libfwk/windows/libraries
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('libfwk/tools/install_deps.py', 'libfwk/dependencies.json') }}-v1

- if: ${{ steps.cache-deps.outputs.cache-hit != 'true' }}
name: Install dependencies
shell: cmd
run: |
pip install conan
python libfwk/tools/install_deps.py C:/libraries
cd libfwk
python tools/install_deps.py

- name: Build libfwk release
shell: cmd
Expand All @@ -49,7 +50,7 @@ jobs:
mkdir lucid-raster
copy build\lucid-x64-Release\lucid.exe lucid-raster\
xcopy data\shaders\ lucid-raster\data\shaders\ /E
copy C:\libraries\x86_64\bin\shaderc_shared.dll lucid-raster\
copy libfwk\windows\libraries\bin\shaderc_shared.dll lucid-raster\

- name: Archive build
uses: actions/upload-artifact@v4
Expand Down
4 changes: 2 additions & 2 deletions src/wavefront_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Ex<void> WavefrontMaterial::load(ZStr file_path, vector<WavefrontMaterial> &out)
int count = 0;
WavefrontMaterial *new_mat = nullptr;

for(auto line : tokenize(file_text, '\n')) {
for(string line : tokenize(file_text, '\n')) {
if(line[0] == '#')
continue;

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

for(auto line : tokenize(file_text, '\n')) {
for(string line : tokenize(file_text, '\n')) {
if(line[0] == '#')
continue;
TextParser parser(line);
Expand Down
65 changes: 8 additions & 57 deletions tools/format.py
Original file line number Diff line number Diff line change
@@ -1,65 +1,17 @@
#!/usr/bin/env python

import argparse, os, re, subprocess, shutil
# Copyright (C) Krzysztof Jakubowski <[email protected]>
# This file is part of LucidRaster. See license.txt for details.

import argparse, sys, os, re

# TODO: import this form libfwk/tools/format.py
class CodeFormatter:
def __init__(self, expected_version=17):
self.expected_version = expected_version
self.clang_format_cmd = self._find_clang_format_cmd()
self._verify_clang_format()

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

def _verify_clang_format(self):
result = subprocess.run([self.clang_format_cmd, "--version"], stdout=subprocess.PIPE)
tokens = result.stdout.decode("utf-8").split()
while len(tokens) > 0 and tokens[0] != "clang-format":
tokens.pop(0)
if (
result.returncode != 0
or len(tokens) < 3
or tokens[0] != "clang-format"
or tokens[1] != "version"
):
raise Exception(f"error while checking clang-format version (version string: {tokens})")
version = tokens[2].split(".", 2)
print(f"clang-format version: {version[0]}.{version[1]}.{version[2]}")

if int(version[0]) < self.expected_version:
raise Exception(
"clang-format is too old; At least version {self.expected_version} is required"
)

def format_cpp(self, files, check: bool):
print("Checking code formatting..." if check else "Formatting code...")
full_command = [self.clang_format_cmd, "-i"]
if check:
full_command += ["--dry-run", "-Werror"]
full_command += files
result = subprocess.run(full_command)

if check:
if result.returncode != 0:
exit(1)
print("All OK")


def find_files(root_dirs, regex):
out = []
for root_dir in root_dirs:
for root, dirs, files in os.walk(root_dir):
for file in files:
if regex.match(file):
out.append(os.path.join(root, file))
return out

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

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

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