Skip to content

Commit

Permalink
Add GitHub Action for CI (#1)
Browse files Browse the repository at this point in the history
* Fix paths on Windows
  • Loading branch information
LDAP authored Aug 6, 2024
1 parent 9c5f4bb commit 170ea53
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build Merian

on: [push, pull_request, workflow_dispatch]

jobs:
build:
name: Build ${{ matrix.buildtype }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
buildtype: [debugoptimized, release]
meson_version: ["1.5.1"]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install Vulkan SDK
uses: humbletim/[email protected]
with:
vulkan-query-version: 1.3.290.0
vulkan-components: Vulkan-Headers, Vulkan-Loader
vulkan-use-cache: true
- name: Install dependencies
run: python -m pip install meson==${{ matrix.meson_version }} ninja
- name: Prepare MSVC
uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-latest'
- name: Install dependencies for Linux
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get -y install \
libxkbcommon-dev \
xorg-dev
- name: Setup Project
run: meson setup build --buildtype=${{ matrix.buildtype }}
- name: Compile Project
run: meson compile -C build
# - name: Run Tests
# run: meson test -C build -v
# - name: Upload Test Log
# uses: actions/upload-artifact@v4
# if: failure()
# with:
# name: ${{ matrix.os }}_Meson_Testlog
# path: build/meson-logs/testlog.txt
2 changes: 1 addition & 1 deletion scripts/compile_shader.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def main():
print(f"fixup depfile {depfile_path}")
with open(depfile_path, "r") as f:
depfile = f.read()
depfile = re.sub("^(.*):", args.implementation_path.name + ":", depfile)
depfile = re.sub("^(.*):(?![\\\\/])", args.implementation_path.name + ":", depfile)
with open(depfile_path, "w") as f:
f.write(depfile)

Expand Down
9 changes: 7 additions & 2 deletions src/merian/vk/shader/shader_hotreloader.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "merian/vk/shader/shader_hotreloader.hpp"

#include <chrono>

namespace merian {

ShaderModuleHandle
Expand All @@ -16,8 +18,11 @@ HotReloader::get_shader(const std::filesystem::path& path,
std::filesystem::last_write_time(*canonical);

if (!shaders.contains(*canonical) ||
(clock_cast<std::chrono::file_clock>(std::chrono::system_clock::now() - 200ms) >
last_write_time &&
// workaround for this not working in older Ubuntu versions
// (std::chrono::system_clock::now().time_since_epoch() - 200ms >
// last_write_time.time_since_epoch()
((std::chrono::system_clock::now().time_since_epoch() - 200ms) >
last_write_time.time_since_epoch() &&
last_write_time > shaders[*canonical].last_write_time)) {
// wait additional 200ms, else the write to the file might still be in process.

Expand Down

0 comments on commit 170ea53

Please sign in to comment.