feat: modify flakenix to include cargo utils
This commit is contained in:
parent
16a4aee633
commit
1f90088350
15 changed files with 966 additions and 838 deletions
|
@ -1,11 +0,0 @@
|
|||
# To get started with Dependabot version updates, you'll need to specify which
|
||||
# package ecosystems to update and where the package manifests are located.
|
||||
# Please see the documentation for all configuration options:
|
||||
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
||||
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: "cargo" # See documentation for possible values
|
||||
directory: "/" # Location of package manifests
|
||||
schedule:
|
||||
interval: "weekly"
|
|
@ -1,101 +1,101 @@
|
|||
name: Build Zenyx ⚡
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ matrix.target }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
docker:
|
||||
image: docker:dind
|
||||
options: >-
|
||||
--privileged
|
||||
--env DOCKER_TLS_CERTDIR=""
|
||||
ports:
|
||||
- 2375:2375
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- x86_64-unknown-linux-gnu
|
||||
- aarch64-unknown-linux-gnu
|
||||
- powerpc64le-unknown-linux-gnu
|
||||
- s390x-unknown-linux-gnu
|
||||
- riscv64gc-unknown-linux-gnu
|
||||
- x86_64-pc-windows-gnu
|
||||
- x86_64-pc-windows-msvc
|
||||
include:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
binary_name: zenyx-x86_64-linux
|
||||
ext: ""
|
||||
- target: aarch64-unknown-linux-gnu
|
||||
binary_name: zenyx-aarch64-linux
|
||||
ext: ""
|
||||
- target: powerpc64le-unknown-linux-gnu
|
||||
binary_name: zenyx-powerpc64le-linux
|
||||
ext: ""
|
||||
- target: s390x-unknown-linux-gnu
|
||||
binary_name: zenyx-s390x-linux
|
||||
ext: ""
|
||||
- target: riscv64gc-unknown-linux-gnu
|
||||
binary_name: zenyx-riscv64-linux
|
||||
ext: ""
|
||||
- target: x86_64-pc-windows-gnu
|
||||
binary_name: zenyx-x86_64-windows-gnu.exe
|
||||
ext: ".exe"
|
||||
- target: x86_64-pc-windows-msvc
|
||||
binary_name: zenyx-x86_64-windows-msvc.exe
|
||||
ext: ".exe"
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout source
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
|
||||
- name: 🐳 Set up Docker CLI
|
||||
uses: https://github.com/docker/setup-docker-action@v3
|
||||
with:
|
||||
docker-binaries: true
|
||||
|
||||
- name: 🛠️ Install Rust toolchain
|
||||
uses: https://github.com/actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: ${{ matrix.target }}
|
||||
override: true
|
||||
components: rust-src
|
||||
|
||||
- name: 🧩 Restore Cargo cache
|
||||
uses: https://github.com/actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-${{ matrix.target }}-
|
||||
|
||||
- name: 🧰 Install Cross
|
||||
run: cargo install cross --locked
|
||||
|
||||
- name: 🚀 Build with cross
|
||||
env:
|
||||
DOCKER_HOST: tcp://localhost:2375
|
||||
CROSS_CONTAINER_IN_CONTAINER: true
|
||||
run: cross build --target ${{ matrix.target }} --release
|
||||
|
||||
- name: 📦 Package artifact
|
||||
run: |
|
||||
mkdir -p artifacts
|
||||
cp target/${{ matrix.target }}/release/zenyx${{ matrix.ext }} artifacts/${{ matrix.binary_name }}
|
||||
|
||||
- name: ⬆️ Upload artifact
|
||||
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.binary_name }}
|
||||
path: artifacts/${{ matrix.binary_name }}
|
||||
name: Build Zenyx ⚡
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build ${{ matrix.target }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
services:
|
||||
docker:
|
||||
image: docker:dind
|
||||
options: >-
|
||||
--privileged
|
||||
--env DOCKER_TLS_CERTDIR=""
|
||||
ports:
|
||||
- 2375:2375
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target:
|
||||
- x86_64-unknown-linux-gnu
|
||||
- aarch64-unknown-linux-gnu
|
||||
- powerpc64le-unknown-linux-gnu
|
||||
- s390x-unknown-linux-gnu
|
||||
- riscv64gc-unknown-linux-gnu
|
||||
- x86_64-pc-windows-gnu
|
||||
- x86_64-pc-windows-msvc
|
||||
include:
|
||||
- target: x86_64-unknown-linux-gnu
|
||||
binary_name: zenyx-x86_64-linux
|
||||
ext: ""
|
||||
- target: aarch64-unknown-linux-gnu
|
||||
binary_name: zenyx-aarch64-linux
|
||||
ext: ""
|
||||
- target: powerpc64le-unknown-linux-gnu
|
||||
binary_name: zenyx-powerpc64le-linux
|
||||
ext: ""
|
||||
- target: s390x-unknown-linux-gnu
|
||||
binary_name: zenyx-s390x-linux
|
||||
ext: ""
|
||||
- target: riscv64gc-unknown-linux-gnu
|
||||
binary_name: zenyx-riscv64-linux
|
||||
ext: ""
|
||||
- target: x86_64-pc-windows-gnu
|
||||
binary_name: zenyx-x86_64-windows-gnu.exe
|
||||
ext: ".exe"
|
||||
- target: x86_64-pc-windows-msvc
|
||||
binary_name: zenyx-x86_64-windows-msvc.exe
|
||||
ext: ".exe"
|
||||
|
||||
steps:
|
||||
- name: 📥 Checkout source
|
||||
uses: https://github.com/actions/checkout@v4
|
||||
|
||||
- name: 🐳 Set up Docker CLI
|
||||
uses: https://github.com/docker/setup-docker-action@v3
|
||||
with:
|
||||
docker-binaries: true
|
||||
|
||||
- name: 🛠️ Install Rust toolchain
|
||||
uses: https://github.com/actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
target: ${{ matrix.target }}
|
||||
override: true
|
||||
components: rust-src
|
||||
|
||||
- name: 🧩 Restore Cargo cache
|
||||
uses: https://github.com/actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cargo-${{ matrix.target }}-
|
||||
|
||||
- name: 🧰 Install Cross
|
||||
run: cargo install cross --locked
|
||||
|
||||
- name: 🚀 Build with cross
|
||||
env:
|
||||
DOCKER_HOST: tcp://localhost:2375
|
||||
CROSS_CONTAINER_IN_CONTAINER: true
|
||||
run: cross build --target ${{ matrix.target }} --release
|
||||
|
||||
- name: 📦 Package artifact
|
||||
run: |
|
||||
mkdir -p artifacts
|
||||
cp target/${{ matrix.target }}/release/zenyx${{ matrix.ext }} artifacts/${{ matrix.binary_name }}
|
||||
|
||||
- name: ⬆️ Upload artifact
|
||||
uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.binary_name }}
|
||||
path: artifacts/${{ matrix.binary_name }}
|
||||
|
|
10
.gitignore
vendored
10
.gitignore
vendored
|
@ -1,6 +1,6 @@
|
|||
/target
|
||||
.idea
|
||||
# Cargo.lock
|
||||
*.log
|
||||
.direnv
|
||||
/target
|
||||
.idea
|
||||
# Cargo.lock
|
||||
*.log
|
||||
.direnv
|
||||
**/result
|
49
Cargo.lock
generated
49
Cargo.lock
generated
|
@ -273,6 +273,47 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"crossbeam-deque",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-queue",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51"
|
||||
dependencies = [
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.12"
|
||||
|
@ -438,6 +479,12 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fbf6a919d6cf397374f7dfeeea91d974c7c0a7221d0d0f4f20d859d329e53fcc"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b112acc8b3adf4b107a8ec20977da0273a8c386765a3ec0229bd500a1443f9f"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.9.0"
|
||||
|
@ -2155,6 +2202,8 @@ checksum = "a62ce76d9b56901b19a74f19431b0d8b3bc7ca4ad685a746dfd78ca8f4fc6bda"
|
|||
name = "zenyx"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"crossbeam",
|
||||
"humantime",
|
||||
"terminator",
|
||||
"thiserror 2.0.12",
|
||||
"tracing",
|
||||
|
|
12
Cargo.toml
12
Cargo.toml
|
@ -25,7 +25,19 @@ split-debuginfo = "off"
|
|||
[profile.dev]
|
||||
debug = 0
|
||||
|
||||
[profile.mini]
|
||||
inherits = "release"
|
||||
opt-level = "z"
|
||||
debug = false
|
||||
strip = true
|
||||
lto = true
|
||||
codegen-units = 1
|
||||
incremental = false
|
||||
panic = "abort"
|
||||
|
||||
[dependencies]
|
||||
crossbeam = "0.8.4"
|
||||
humantime = "2.2.0"
|
||||
terminator = "0.3.2"
|
||||
thiserror = "2.0.12"
|
||||
tracing = "0.1.41"
|
||||
|
|
42
LICENSE.md
42
LICENSE.md
|
@ -1,21 +1,21 @@
|
|||
# MIT License
|
||||
|
||||
## Copyright (c) 2024 Caznix
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.**
|
||||
# MIT License
|
||||
|
||||
## Copyright (c) 2024 Caznix
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
**THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.**
|
||||
|
|
350
README.md
350
README.md
|
@ -1,175 +1,175 @@
|
|||
<div align="center">
|
||||
|
||||
<img src="assets/Logo.svg" alt="Zenyx engine" width="350"/>
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
# What is zenyx?
|
||||
|
||||
Zenyx is a game engine built on top of [wgpu](https://github.com/gfx-rs/wgpu)
|
||||
and [winit](https://github.com/rust-windowing/winit). It is designed to be an
|
||||
intuitive and innovative game engine that can both adapt to your workflow and
|
||||
bring new ideas to the table.
|
||||
|
||||
## Features
|
||||
|
||||
> 🚀 Note: The following features are goals and are not currently implemented:
|
||||
> Zenyx
|
||||
|
||||
### **Zenyx aims to provide:**
|
||||
|
||||
- ✨ **Cross platform support** - Windows, Linux and macOS support
|
||||
- 🎮 **Support for multiple renderers** - Zenyx can use Vulkan. OpenGL, and
|
||||
DirectX. In both 2D and 3D
|
||||
- ⚡ **Safe Performance** - Written in Rust for speed and safety
|
||||
- 🎯 **Intuitive Design** - User-friendly workflows and highly extensible tools
|
||||
- 📝 **Flexible Scripting** - Easy to use scripting language without sacrificing
|
||||
performance
|
||||
- 🔧 **Extensible Architecture** - Modular design for easy customization
|
||||
- 🛠️ **Fully Featured Toolset** - Built in tools for playing spatial audio and
|
||||
level editing
|
||||
- 🖥️ **Real-time Editor** - Live preview and Incredible User experience
|
||||
- 📦 **Asset Management** - Efficient resource handling system
|
||||
- 🎲 **Physics Integration** - Built-in physics simulation
|
||||
- 🗂️ **Improved Scene Management** - Flexible scene organization tools
|
||||
|
||||
## Star history ⭐
|
||||
|
||||
<a href="https://star-history.com/#Caznix/Zenyx&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Caznix/Zenyx&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Caznix/Zenyx&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Caznix/Zenyx&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## FAQ
|
||||
|
||||
<details>
|
||||
<summary><b>What platforms does Zenyx support?</b></summary>
|
||||
|
||||
Zenyx primarily supports Windows and Linux, with secondary support for macOS
|
||||
(requires MoltenVK). See the
|
||||
[Platform support table](#what-platforms-will-be-supported) for more
|
||||
information.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Is Zenyx ready for production use?</b></summary>
|
||||
|
||||
Zenyx is currently in early development and is not yet ready for any simple use
|
||||
cases, but we're working hard to make it the best it can be before we release
|
||||
1.0. If this interests you and you're interested in helping, please check out
|
||||
the [contribution section](CONTRIBUTING.md) for the ways you can help.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>How can I contribute to Zenyx?</b></summary>
|
||||
|
||||
We welcome contributions! Please check our contribution guidelines and open a
|
||||
pull request on GitHub, if you arent a developer, you can also report bugs or
|
||||
feature requests on our [issue tracker](https://github.com/Caznix/Zenyx/issues).
|
||||
For more information, please see the [Contributing section](#contributing).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>What are the system requirements?</b></summary>
|
||||
|
||||
Detailed system requirements will be provided as the engine matures. Currently,
|
||||
the only requirement is a modern OS and a system with atleast a semi-recent GPU.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Is Zenyx free to use?</b></summary>
|
||||
|
||||
Yes, Zenyx is open-source software licensed under MIT. You can Modify,
|
||||
Distribute, and use Zenyx for any purpose you wish.
|
||||
|
||||
</details>
|
||||
|
||||
## What platforms will be supported in the future?
|
||||
|
||||
| Platform | Support Priority | Status | Notes |
|
||||
| :--------: | :--------------: | :----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Windows | Primary | ✅ | |
|
||||
| Linux/*BSD | Primary | ✅ | |
|
||||
| macOS | Secondary | 🌋 | Requires MoltenVK for both editor and exported games due to Wgpu's lack of support for Metal |
|
||||
| Android | TBD | ❓ | |
|
||||
| iOS | TBD | ❓+🌋 | |
|
||||
| Web | TBD | ❓ | |
|
||||
| Consoles | Not planned | ⛔ | Consoles require specific dev kits,proprietary licenses, and substantial fees that we (Caznix & the open source contributors) currently do not have the capacity for. This may change in the future but most likely will not be soon. |
|
||||
|
||||
# Documentation
|
||||
|
||||
## Getting Started
|
||||
|
||||
Zenyx is not yet ready to be used but this may change in the near future.
|
||||
|
||||
# Contributing
|
||||
|
||||
We welcome contributions of any kind! If you're interested in contributing,
|
||||
please check out our CONTRIBUTING.md file for coding standards and guidelines.
|
||||
|
||||
Even if you're not a developer, you can still help tremendously by spreading the
|
||||
word about Zenyx, reporting bugs, suggesting features, or helping improve our
|
||||
documentation.
|
||||
|
||||
If you would like to contribute code to Zenyx, follow the instructions below for
|
||||
your platform:
|
||||
|
||||
## Prerequisites (all platforms)
|
||||
|
||||
0. Install [Rust](https://www.rust-lang.org/tools/install)
|
||||
|
||||
1. Install [git](https://git-scm.com/downloads)
|
||||
|
||||
## Building
|
||||
|
||||
**1**. Clone the repository:
|
||||
|
||||
git clone https://github.com/Caznix/Zenyx.git
|
||||
|
||||
**2**. cd into the project directory
|
||||
|
||||
cd ./Zenyx
|
||||
|
||||
**3**. Build the project
|
||||
|
||||
cargo run
|
||||
|
||||
## macOS
|
||||
|
||||
⚠️ as of this current time, we do not have any macOS contributors to write this
|
||||
guide, so follow the [General](#building) instructions and try to fill in the
|
||||
gaps, you can also ask questions on the [Discord]()
|
||||
|
||||
## Subcrates
|
||||
Zenyx is split into multiple crates to make it easier to maintain and update, you can find the crates in the `subcrates` directory, each crate has its own README file so you can find more information for each crate there. Here is a list of the crates:
|
||||
|
||||
* [Zephyr (ECS)](subcrates/zephyr/README.md)
|
||||
* Aims to provides a lightweight and boilerplate-free ECS framework for modular game development.
|
||||
# Press kit
|
||||
|
||||
## Typefaces
|
||||
|
||||
Main typeface
|
||||
|
||||
<img src="assets/Logo.png" width="200" alt="Zenyx Typeface">
|
||||
|
||||
## Colored badges
|
||||
|
||||
<img src="assets/Badge.png" width="100" alt="Zenyx Logo">
|
||||
|
||||
|
||||
<div align="center">
|
||||
|
||||
<img src="assets/Logo.svg" alt="Zenyx engine" width="350"/>
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||

|
||||
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
# What is zenyx?
|
||||
|
||||
Zenyx is a game engine built on top of [wgpu](https://github.com/gfx-rs/wgpu)
|
||||
and [winit](https://github.com/rust-windowing/winit). It is designed to be an
|
||||
intuitive and innovative game engine that can both adapt to your workflow and
|
||||
bring new ideas to the table.
|
||||
|
||||
## Features
|
||||
|
||||
> 🚀 Note: The following features are goals and are not currently implemented:
|
||||
> Zenyx
|
||||
|
||||
### **Zenyx aims to provide:**
|
||||
|
||||
- ✨ **Cross platform support** - Windows, Linux and macOS support
|
||||
- 🎮 **Support for multiple renderers** - Zenyx can use Vulkan. OpenGL, and
|
||||
DirectX. In both 2D and 3D
|
||||
- ⚡ **Safe Performance** - Written in Rust for speed and safety
|
||||
- 🎯 **Intuitive Design** - User-friendly workflows and highly extensible tools
|
||||
- 📝 **Flexible Scripting** - Easy to use scripting language without sacrificing
|
||||
performance
|
||||
- 🔧 **Extensible Architecture** - Modular design for easy customization
|
||||
- 🛠️ **Fully Featured Toolset** - Built in tools for playing spatial audio and
|
||||
level editing
|
||||
- 🖥️ **Real-time Editor** - Live preview and Incredible User experience
|
||||
- 📦 **Asset Management** - Efficient resource handling system
|
||||
- 🎲 **Physics Integration** - Built-in physics simulation
|
||||
- 🗂️ **Improved Scene Management** - Flexible scene organization tools
|
||||
|
||||
## Star history ⭐
|
||||
|
||||
<a href="https://star-history.com/#Caznix/Zenyx&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=Caznix/Zenyx&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=Caznix/Zenyx&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=Caznix/Zenyx&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## FAQ
|
||||
|
||||
<details>
|
||||
<summary><b>What platforms does Zenyx support?</b></summary>
|
||||
|
||||
Zenyx primarily supports Windows and Linux, with secondary support for macOS
|
||||
(requires MoltenVK). See the
|
||||
[Platform support table](#what-platforms-will-be-supported) for more
|
||||
information.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Is Zenyx ready for production use?</b></summary>
|
||||
|
||||
Zenyx is currently in early development and is not yet ready for any simple use
|
||||
cases, but we're working hard to make it the best it can be before we release
|
||||
1.0. If this interests you and you're interested in helping, please check out
|
||||
the [contribution section](CONTRIBUTING.md) for the ways you can help.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>How can I contribute to Zenyx?</b></summary>
|
||||
|
||||
We welcome contributions! Please check our contribution guidelines and open a
|
||||
pull request on GitHub, if you arent a developer, you can also report bugs or
|
||||
feature requests on our [issue tracker](https://github.com/Caznix/Zenyx/issues).
|
||||
For more information, please see the [Contributing section](#contributing).
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>What are the system requirements?</b></summary>
|
||||
|
||||
Detailed system requirements will be provided as the engine matures. Currently,
|
||||
the only requirement is a modern OS and a system with atleast a semi-recent GPU.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary><b>Is Zenyx free to use?</b></summary>
|
||||
|
||||
Yes, Zenyx is open-source software licensed under MIT. You can Modify,
|
||||
Distribute, and use Zenyx for any purpose you wish.
|
||||
|
||||
</details>
|
||||
|
||||
## What platforms will be supported in the future?
|
||||
|
||||
| Platform | Support Priority | Status | Notes |
|
||||
| :--------: | :--------------: | :----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Windows | Primary | ✅ | |
|
||||
| Linux/*BSD | Primary | ✅ | |
|
||||
| macOS | Secondary | 🌋 | Requires MoltenVK for both editor and exported games due to Wgpu's lack of support for Metal |
|
||||
| Android | TBD | ❓ | |
|
||||
| iOS | TBD | ❓+🌋 | |
|
||||
| Web | TBD | ❓ | |
|
||||
| Consoles | Not planned | ⛔ | Consoles require specific dev kits,proprietary licenses, and substantial fees that we (Caznix & the open source contributors) currently do not have the capacity for. This may change in the future but most likely will not be soon. |
|
||||
|
||||
# Documentation
|
||||
|
||||
## Getting Started
|
||||
|
||||
Zenyx is not yet ready to be used but this may change in the near future.
|
||||
|
||||
# Contributing
|
||||
|
||||
We welcome contributions of any kind! If you're interested in contributing,
|
||||
please check out our CONTRIBUTING.md file for coding standards and guidelines.
|
||||
|
||||
Even if you're not a developer, you can still help tremendously by spreading the
|
||||
word about Zenyx, reporting bugs, suggesting features, or helping improve our
|
||||
documentation.
|
||||
|
||||
If you would like to contribute code to Zenyx, follow the instructions below for
|
||||
your platform:
|
||||
|
||||
## Prerequisites (all platforms)
|
||||
|
||||
0. Install [Rust](https://www.rust-lang.org/tools/install)
|
||||
|
||||
1. Install [git](https://git-scm.com/downloads)
|
||||
|
||||
## Building
|
||||
|
||||
**1**. Clone the repository:
|
||||
|
||||
git clone https://github.com/Caznix/Zenyx.git
|
||||
|
||||
**2**. cd into the project directory
|
||||
|
||||
cd ./Zenyx
|
||||
|
||||
**3**. Build the project
|
||||
|
||||
cargo run
|
||||
|
||||
## macOS
|
||||
|
||||
⚠️ as of this current time, we do not have any macOS contributors to write this
|
||||
guide, so follow the [General](#building) instructions and try to fill in the
|
||||
gaps, you can also ask questions on the [Discord]()
|
||||
|
||||
## Subcrates
|
||||
Zenyx is split into multiple crates to make it easier to maintain and update, you can find the crates in the `subcrates` directory, each crate has its own README file so you can find more information for each crate there. Here is a list of the crates:
|
||||
|
||||
* [Zephyr (ECS)](subcrates/zephyr/README.md)
|
||||
* Aims to provides a lightweight and boilerplate-free ECS framework for modular game development.
|
||||
# Press kit
|
||||
|
||||
## Typefaces
|
||||
|
||||
Main typeface
|
||||
|
||||
<img src="assets/Logo.png" width="200" alt="Zenyx Typeface">
|
||||
|
||||
## Colored badges
|
||||
|
||||
<img src="assets/Badge.png" width="100" alt="Zenyx Logo">
|
||||
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M256 128C256 198.692 198.692 256 128 256C57.3075 256 0 198.692 0 128C0 57.3075 57.3075 0 128 0C198.692 0 256 57.3075 256 128Z" fill="#FFCD4E"/>
|
||||
<mask id="mask0_117_566" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="12" y="12" width="232" height="232">
|
||||
<circle cx="128" cy="128" r="116" fill="#E0A100"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_117_566)">
|
||||
<path d="M107.569 201C97.5992 201 89.5173 192.918 89.5173 182.949C89.5173 180.278 90.1099 177.64 91.2524 175.226L114.486 126.134C123.278 107.558 109.729 86.1563 89.1777 86.1563H-13.9219C-22.8016 86.1563 -30 78.9578 -30 70.0781C-30 61.1984 -22.8016 54 -13.9219 54H147.456C157.426 54 165.508 62.0819 165.508 72.0515C165.508 74.7221 164.915 77.3596 163.773 79.7735L140.539 128.866C131.747 147.442 145.296 168.844 165.847 168.844H278.922C287.802 168.844 295 176.042 295 184.922C295 193.802 287.802 201 278.922 201H107.569Z" fill="black"/>
|
||||
</g>
|
||||
</svg>
|
||||
<svg width="256" height="256" viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M256 128C256 198.692 198.692 256 128 256C57.3075 256 0 198.692 0 128C0 57.3075 57.3075 0 128 0C198.692 0 256 57.3075 256 128Z" fill="#FFCD4E"/>
|
||||
<mask id="mask0_117_566" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="12" y="12" width="232" height="232">
|
||||
<circle cx="128" cy="128" r="116" fill="#E0A100"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_117_566)">
|
||||
<path d="M107.569 201C97.5992 201 89.5173 192.918 89.5173 182.949C89.5173 180.278 90.1099 177.64 91.2524 175.226L114.486 126.134C123.278 107.558 109.729 86.1563 89.1777 86.1563H-13.9219C-22.8016 86.1563 -30 78.9578 -30 70.0781C-30 61.1984 -22.8016 54 -13.9219 54H147.456C157.426 54 165.508 62.0819 165.508 72.0515C165.508 74.7221 164.915 77.3596 163.773 79.7735L140.539 128.866C131.747 147.442 145.296 168.844 165.847 168.844H278.922C287.802 168.844 295 176.042 295 184.922C295 193.802 287.802 201 278.922 201H107.569Z" fill="black"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 1,006 B After Width: | Height: | Size: 1,015 B |
|
@ -1,10 +1,10 @@
|
|||
<svg width="506" height="214" viewBox="0 0 506 214" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="mask0_280_9" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="18" width="137" height="138">
|
||||
<circle cx="68.5" cy="87" r="68.5" fill="#E0A100"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_280_9)">
|
||||
<path d="M53.4665 133.076C47.5793 133.076 42.8068 128.304 42.8068 122.417C42.8068 120.84 43.1567 119.282 43.8314 117.857L57.9126 88.1036C62.9363 77.4889 55.194 65.2591 43.4505 65.2591H-18.2759C-23.5195 65.2591 -27.7703 61.0083 -27.7703 55.7647C-27.7703 50.5211 -23.5195 46.2703 -18.2758 46.2703H77.0208C82.908 46.2703 87.6805 51.0428 87.6805 56.93C87.6805 58.5071 87.3306 60.0645 86.6559 61.49L72.5746 91.243C67.551 101.858 75.2933 114.088 87.0368 114.088H154.653C159.897 114.088 164.148 118.338 164.148 123.582C164.148 128.826 159.897 133.076 154.653 133.076H53.4665Z" fill="white"/>
|
||||
</g>
|
||||
<path d="M138.064 51.44C138.064 49.4773 138.789 47.8133 140.24 46.448C141.776 45.0827 143.653 44.4 145.872 44.4H202.832C202.832 49.008 201.979 52.3787 200.272 54.512C198.651 56.6453 196.005 57.712 192.336 57.712H153.424V82.16H188.112C188.112 86.768 187.259 90.1387 185.552 92.272C183.931 94.4053 181.328 95.472 177.744 95.472H153.424V120.688H195.024C198.608 120.688 201.211 121.755 202.832 123.888C204.539 126.021 205.392 129.392 205.392 134H145.872C143.653 134 141.776 133.317 140.24 131.952C138.789 130.587 138.064 128.88 138.064 126.832V51.44ZM231.364 55.792C231.364 51.8667 232.601 48.7947 235.076 46.576C237.636 44.3573 241.135 43.248 245.572 43.248L290.884 113.52L292.036 112.496L287.3 104.688V43.248C292.335 43.248 296.132 44.2293 298.692 46.192C301.252 48.1547 302.532 51.0987 302.532 55.024V124.144C302.532 127.131 301.337 129.733 298.948 131.952C296.559 134.085 293.657 135.152 290.244 135.152L243.012 61.936L241.86 62.832L246.596 70.768V123.376C246.596 127.216 245.273 130.16 242.628 132.208C240.068 134.171 236.313 135.152 231.364 135.152V55.792ZM356.964 101.744L325.22 44.912C325.988 44.4853 327.14 44.1013 328.676 43.76C330.212 43.4187 331.62 43.248 332.9 43.248C335.716 43.248 338.063 43.8453 339.94 45.04C341.903 46.1493 343.567 47.9413 344.932 50.416L364.388 86.768L361.06 93.424L362.34 94.064L384.484 50.416C386.873 45.6373 390.884 43.248 396.516 43.248C397.796 43.248 399.204 43.4187 400.74 43.76C402.276 44.1013 403.428 44.4853 404.196 44.912L372.452 101.744V123.376C372.452 127.131 371.129 130.032 368.484 132.08C365.839 134.128 361.999 135.152 356.964 135.152V101.744ZM430.352 135.152C426.939 135.152 423.995 133.872 421.52 131.312L452.624 87.792L423.056 46.064C423.995 45.2107 425.189 44.528 426.64 44.016C428.091 43.504 429.627 43.248 431.248 43.248C433.467 43.248 435.515 43.632 437.392 44.4C439.355 45.168 440.763 46.192 441.616 47.472L460.304 75.248L456.976 79.856L458.128 80.624L480.656 47.472C481.595 46.192 483.003 45.168 484.88 44.4C486.757 43.632 488.848 43.248 491.152 43.248C492.688 43.248 494.181 43.504 495.632 44.016C497.083 44.528 498.277 45.2107 499.216 46.064L469.776 87.792L500.752 131.312C498.448 133.872 495.504 135.152 491.92 135.152C490.043 135.152 488.293 134.768 486.672 134C485.136 133.147 483.856 131.995 482.832 130.544L461.2 99.184L439.44 130.544C438.416 131.909 437.093 133.019 435.472 133.872C433.936 134.725 432.229 135.152 430.352 135.152Z" fill="white"/>
|
||||
<path d="M125.52 156.488C125.52 155.293 125.968 154.291 126.864 153.48C127.803 152.627 128.933 152.2 130.256 152.2H158.864C158.864 155.016 158.395 157.064 157.456 158.344C156.517 159.624 155.003 160.264 152.912 160.264H134.928V170.376H151.696C151.696 173.192 151.227 175.24 150.288 176.52C149.349 177.8 147.835 178.44 145.744 178.44H134.928V188.936H154.256C156.304 188.936 157.797 189.576 158.736 190.856C159.675 192.136 160.144 194.184 160.144 197H130.256C128.933 197 127.803 196.595 126.864 195.784C125.968 194.973 125.52 193.949 125.52 192.712V156.488ZM172.295 158.984C172.295 156.723 173.063 154.931 174.599 153.608C176.135 152.285 178.204 151.624 180.807 151.624L201.351 184.136L202.055 183.56L199.175 178.76V151.624C202.204 151.624 204.508 152.2 206.087 153.352C207.666 154.504 208.455 156.189 208.455 158.408V191.368C208.455 192.435 208.114 193.459 207.431 194.44C206.791 195.379 205.916 196.147 204.807 196.744C203.698 197.299 202.524 197.576 201.287 197.576L179.399 162.952L178.695 163.528L181.575 168.328V190.792C181.575 193.011 180.786 194.696 179.207 195.848C177.628 197 175.324 197.576 172.295 197.576V158.984ZM240.194 197.576C236.354 197.576 232.919 196.829 229.89 195.336C226.861 193.843 224.493 191.773 222.786 189.128C221.122 186.44 220.29 183.389 220.29 179.976V169.096C220.29 165.683 221.101 162.653 222.722 160.008C224.386 157.363 226.69 155.315 229.634 153.864C232.621 152.371 236.013 151.624 239.81 151.624C243.607 151.624 246.999 152.2 249.986 153.352C252.973 154.461 255.277 156.019 256.898 158.024C258.562 160.029 259.394 162.333 259.394 164.936C259.394 166.6 258.839 167.923 257.73 168.904C256.621 169.843 255.106 170.312 253.186 170.312C252.077 170.312 250.989 170.163 249.922 169.864C250.05 168.968 250.114 167.901 250.114 166.664C250.114 164.616 249.154 162.952 247.234 161.672C245.314 160.349 242.839 159.688 239.81 159.688C236.823 159.688 234.391 160.563 232.514 162.312C230.637 164.061 229.698 166.323 229.698 169.096V179.976C229.698 182.792 230.658 185.096 232.578 186.888C234.541 188.637 237.079 189.512 240.194 189.512C243.181 189.512 245.613 188.829 247.49 187.464C249.367 186.099 250.306 184.349 250.306 182.216V180.744H245.634C243.885 180.744 242.455 180.061 241.346 178.696C240.279 177.331 239.746 175.56 239.746 173.384H255.298C256.578 173.384 257.623 173.789 258.434 174.6C259.245 175.368 259.65 176.392 259.65 177.672V182.408C259.65 185.352 258.818 187.976 257.154 190.28C255.533 192.584 253.25 194.376 250.306 195.656C247.362 196.936 243.991 197.576 240.194 197.576ZM273.062 158.472C273.062 156.339 273.873 154.675 275.494 153.48C277.158 152.243 279.484 151.624 282.47 151.624V190.728C282.47 192.904 281.638 194.589 279.974 195.784C278.353 196.979 276.049 197.576 273.062 197.576V158.472ZM297.183 158.984C297.183 156.723 297.951 154.931 299.487 153.608C301.023 152.285 303.092 151.624 305.695 151.624L326.239 184.136L326.943 183.56L324.063 178.76V151.624C327.092 151.624 329.396 152.2 330.975 153.352C332.553 154.504 333.343 156.189 333.343 158.408V191.368C333.343 192.435 333.001 193.459 332.319 194.44C331.679 195.379 330.804 196.147 329.695 196.744C328.585 197.299 327.412 197.576 326.175 197.576L304.287 162.952L303.583 163.528L306.463 168.328V190.792C306.463 193.011 305.673 194.696 304.095 195.848C302.516 197 300.212 197.576 297.183 197.576V158.984ZM346.77 156.488C346.77 155.293 347.218 154.291 348.114 153.48C349.053 152.627 350.183 152.2 351.506 152.2H380.114C380.114 155.016 379.645 157.064 378.706 158.344C377.767 159.624 376.253 160.264 374.162 160.264H356.178V170.376H372.946C372.946 173.192 372.477 175.24 371.538 176.52C370.599 177.8 369.085 178.44 366.994 178.44H356.178V188.936H375.506C377.554 188.936 379.047 189.576 379.986 190.856C380.925 192.136 381.394 194.184 381.394 197H351.506C350.183 197 349.053 196.595 348.114 195.784C347.218 194.973 346.77 193.949 346.77 192.712V156.488Z" fill="white"/>
|
||||
</svg>
|
||||
<svg width="506" height="214" viewBox="0 0 506 214" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<mask id="mask0_280_9" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="18" width="137" height="138">
|
||||
<circle cx="68.5" cy="87" r="68.5" fill="#E0A100"/>
|
||||
</mask>
|
||||
<g mask="url(#mask0_280_9)">
|
||||
<path d="M53.4665 133.076C47.5793 133.076 42.8068 128.304 42.8068 122.417C42.8068 120.84 43.1567 119.282 43.8314 117.857L57.9126 88.1036C62.9363 77.4889 55.194 65.2591 43.4505 65.2591H-18.2759C-23.5195 65.2591 -27.7703 61.0083 -27.7703 55.7647C-27.7703 50.5211 -23.5195 46.2703 -18.2758 46.2703H77.0208C82.908 46.2703 87.6805 51.0428 87.6805 56.93C87.6805 58.5071 87.3306 60.0645 86.6559 61.49L72.5746 91.243C67.551 101.858 75.2933 114.088 87.0368 114.088H154.653C159.897 114.088 164.148 118.338 164.148 123.582C164.148 128.826 159.897 133.076 154.653 133.076H53.4665Z" fill="white"/>
|
||||
</g>
|
||||
<path d="M138.064 51.44C138.064 49.4773 138.789 47.8133 140.24 46.448C141.776 45.0827 143.653 44.4 145.872 44.4H202.832C202.832 49.008 201.979 52.3787 200.272 54.512C198.651 56.6453 196.005 57.712 192.336 57.712H153.424V82.16H188.112C188.112 86.768 187.259 90.1387 185.552 92.272C183.931 94.4053 181.328 95.472 177.744 95.472H153.424V120.688H195.024C198.608 120.688 201.211 121.755 202.832 123.888C204.539 126.021 205.392 129.392 205.392 134H145.872C143.653 134 141.776 133.317 140.24 131.952C138.789 130.587 138.064 128.88 138.064 126.832V51.44ZM231.364 55.792C231.364 51.8667 232.601 48.7947 235.076 46.576C237.636 44.3573 241.135 43.248 245.572 43.248L290.884 113.52L292.036 112.496L287.3 104.688V43.248C292.335 43.248 296.132 44.2293 298.692 46.192C301.252 48.1547 302.532 51.0987 302.532 55.024V124.144C302.532 127.131 301.337 129.733 298.948 131.952C296.559 134.085 293.657 135.152 290.244 135.152L243.012 61.936L241.86 62.832L246.596 70.768V123.376C246.596 127.216 245.273 130.16 242.628 132.208C240.068 134.171 236.313 135.152 231.364 135.152V55.792ZM356.964 101.744L325.22 44.912C325.988 44.4853 327.14 44.1013 328.676 43.76C330.212 43.4187 331.62 43.248 332.9 43.248C335.716 43.248 338.063 43.8453 339.94 45.04C341.903 46.1493 343.567 47.9413 344.932 50.416L364.388 86.768L361.06 93.424L362.34 94.064L384.484 50.416C386.873 45.6373 390.884 43.248 396.516 43.248C397.796 43.248 399.204 43.4187 400.74 43.76C402.276 44.1013 403.428 44.4853 404.196 44.912L372.452 101.744V123.376C372.452 127.131 371.129 130.032 368.484 132.08C365.839 134.128 361.999 135.152 356.964 135.152V101.744ZM430.352 135.152C426.939 135.152 423.995 133.872 421.52 131.312L452.624 87.792L423.056 46.064C423.995 45.2107 425.189 44.528 426.64 44.016C428.091 43.504 429.627 43.248 431.248 43.248C433.467 43.248 435.515 43.632 437.392 44.4C439.355 45.168 440.763 46.192 441.616 47.472L460.304 75.248L456.976 79.856L458.128 80.624L480.656 47.472C481.595 46.192 483.003 45.168 484.88 44.4C486.757 43.632 488.848 43.248 491.152 43.248C492.688 43.248 494.181 43.504 495.632 44.016C497.083 44.528 498.277 45.2107 499.216 46.064L469.776 87.792L500.752 131.312C498.448 133.872 495.504 135.152 491.92 135.152C490.043 135.152 488.293 134.768 486.672 134C485.136 133.147 483.856 131.995 482.832 130.544L461.2 99.184L439.44 130.544C438.416 131.909 437.093 133.019 435.472 133.872C433.936 134.725 432.229 135.152 430.352 135.152Z" fill="white"/>
|
||||
<path d="M125.52 156.488C125.52 155.293 125.968 154.291 126.864 153.48C127.803 152.627 128.933 152.2 130.256 152.2H158.864C158.864 155.016 158.395 157.064 157.456 158.344C156.517 159.624 155.003 160.264 152.912 160.264H134.928V170.376H151.696C151.696 173.192 151.227 175.24 150.288 176.52C149.349 177.8 147.835 178.44 145.744 178.44H134.928V188.936H154.256C156.304 188.936 157.797 189.576 158.736 190.856C159.675 192.136 160.144 194.184 160.144 197H130.256C128.933 197 127.803 196.595 126.864 195.784C125.968 194.973 125.52 193.949 125.52 192.712V156.488ZM172.295 158.984C172.295 156.723 173.063 154.931 174.599 153.608C176.135 152.285 178.204 151.624 180.807 151.624L201.351 184.136L202.055 183.56L199.175 178.76V151.624C202.204 151.624 204.508 152.2 206.087 153.352C207.666 154.504 208.455 156.189 208.455 158.408V191.368C208.455 192.435 208.114 193.459 207.431 194.44C206.791 195.379 205.916 196.147 204.807 196.744C203.698 197.299 202.524 197.576 201.287 197.576L179.399 162.952L178.695 163.528L181.575 168.328V190.792C181.575 193.011 180.786 194.696 179.207 195.848C177.628 197 175.324 197.576 172.295 197.576V158.984ZM240.194 197.576C236.354 197.576 232.919 196.829 229.89 195.336C226.861 193.843 224.493 191.773 222.786 189.128C221.122 186.44 220.29 183.389 220.29 179.976V169.096C220.29 165.683 221.101 162.653 222.722 160.008C224.386 157.363 226.69 155.315 229.634 153.864C232.621 152.371 236.013 151.624 239.81 151.624C243.607 151.624 246.999 152.2 249.986 153.352C252.973 154.461 255.277 156.019 256.898 158.024C258.562 160.029 259.394 162.333 259.394 164.936C259.394 166.6 258.839 167.923 257.73 168.904C256.621 169.843 255.106 170.312 253.186 170.312C252.077 170.312 250.989 170.163 249.922 169.864C250.05 168.968 250.114 167.901 250.114 166.664C250.114 164.616 249.154 162.952 247.234 161.672C245.314 160.349 242.839 159.688 239.81 159.688C236.823 159.688 234.391 160.563 232.514 162.312C230.637 164.061 229.698 166.323 229.698 169.096V179.976C229.698 182.792 230.658 185.096 232.578 186.888C234.541 188.637 237.079 189.512 240.194 189.512C243.181 189.512 245.613 188.829 247.49 187.464C249.367 186.099 250.306 184.349 250.306 182.216V180.744H245.634C243.885 180.744 242.455 180.061 241.346 178.696C240.279 177.331 239.746 175.56 239.746 173.384H255.298C256.578 173.384 257.623 173.789 258.434 174.6C259.245 175.368 259.65 176.392 259.65 177.672V182.408C259.65 185.352 258.818 187.976 257.154 190.28C255.533 192.584 253.25 194.376 250.306 195.656C247.362 196.936 243.991 197.576 240.194 197.576ZM273.062 158.472C273.062 156.339 273.873 154.675 275.494 153.48C277.158 152.243 279.484 151.624 282.47 151.624V190.728C282.47 192.904 281.638 194.589 279.974 195.784C278.353 196.979 276.049 197.576 273.062 197.576V158.472ZM297.183 158.984C297.183 156.723 297.951 154.931 299.487 153.608C301.023 152.285 303.092 151.624 305.695 151.624L326.239 184.136L326.943 183.56L324.063 178.76V151.624C327.092 151.624 329.396 152.2 330.975 153.352C332.553 154.504 333.343 156.189 333.343 158.408V191.368C333.343 192.435 333.001 193.459 332.319 194.44C331.679 195.379 330.804 196.147 329.695 196.744C328.585 197.299 327.412 197.576 326.175 197.576L304.287 162.952L303.583 163.528L306.463 168.328V190.792C306.463 193.011 305.673 194.696 304.095 195.848C302.516 197 300.212 197.576 297.183 197.576V158.984ZM346.77 156.488C346.77 155.293 347.218 154.291 348.114 153.48C349.053 152.627 350.183 152.2 351.506 152.2H380.114C380.114 155.016 379.645 157.064 378.706 158.344C377.767 159.624 376.253 160.264 374.162 160.264H356.178V170.376H372.946C372.946 173.192 372.477 175.24 371.538 176.52C370.599 177.8 369.085 178.44 366.994 178.44H356.178V188.936H375.506C377.554 188.936 379.047 189.576 379.986 190.856C380.925 192.136 381.394 194.184 381.394 197H351.506C350.183 197 349.053 196.595 348.114 195.784C347.218 194.973 346.77 193.949 346.77 192.712V156.488Z" fill="white"/>
|
||||
</svg>
|
||||
|
|
Before Width: | Height: | Size: 7 KiB After Width: | Height: | Size: 7 KiB |
148
default.nix
148
default.nix
|
@ -1,75 +1,75 @@
|
|||
{ lib,
|
||||
rustPlatform,
|
||||
nix-gitignore,
|
||||
bash,
|
||||
makeWrapper,
|
||||
dav1d,
|
||||
vulkan-loader,
|
||||
libGL,
|
||||
wayland,
|
||||
pkg-config,
|
||||
libxkbcommon,
|
||||
pkgs,
|
||||
stdenv,
|
||||
targetPackages ? pkgs,
|
||||
}: let
|
||||
version = (builtins.fromTOML (builtins.readFile ./engine/Cargo.toml)).package.version;
|
||||
src = nix-gitignore.gitignoreSource [] ./.;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "zenyx";
|
||||
inherit src version;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
|
||||
targetPackages.darwin.apple_sdk.frameworks.CoreServices
|
||||
];
|
||||
|
||||
buildInputs = with targetPackages; [
|
||||
dav1d
|
||||
] ++ lib.optionals (stdenv.targetPlatform.isLinux || stdenv.targetPlatform.isWindows) [
|
||||
vulkan-loader
|
||||
] ++ lib.optionals stdenv.targetPlatform.isLinux [
|
||||
makeWrapper
|
||||
wayland
|
||||
libxkbcommon
|
||||
libGL
|
||||
xorg.libXcursor
|
||||
xorg.libXrandr
|
||||
xorg.libXi
|
||||
xorg.libX11
|
||||
xorg.libxcb
|
||||
bash
|
||||
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
|
||||
makeWrapper
|
||||
darwin.apple_sdk.frameworks.Cocoa
|
||||
darwin.apple_sdk.frameworks.Metal
|
||||
darwin.apple_sdk.frameworks.CoreVideo
|
||||
darwin.apple_sdk.frameworks.QuartzCore
|
||||
];
|
||||
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER =
|
||||
lib.optionalString stdenv.targetPlatform.isWindows "${stdenv.cc.targetPrefix}gcc";
|
||||
|
||||
NIX_LDFLAGS = lib.optionalString stdenv.targetPlatform.isDarwin "-framework CoreFoundation";
|
||||
|
||||
postInstall = lib.optionalString stdenv.targetPlatform.isLinux ''
|
||||
wrapProgram $out/bin/${pname} \
|
||||
--prefix PATH : ${lib.makeBinPath [ bash ]} \
|
||||
--set LD_LIBRARY_PATH ${lib.makeLibraryPath buildInputs}
|
||||
'' + lib.optionalString stdenv.targetPlatform.isWindows ''
|
||||
mkdir -p $out/bin
|
||||
cp ${targetPackages.vulkan-loader}/bin/vulkan-1.dll $out/bin/
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = {
|
||||
description = "Cross-platform WSYWIG Game Engine";
|
||||
license = lib.licenses.mit;
|
||||
platforms = lib.platforms.all;
|
||||
mainProgram = "zenyx";
|
||||
};
|
||||
{ lib,
|
||||
rustPlatform,
|
||||
nix-gitignore,
|
||||
bash,
|
||||
makeWrapper,
|
||||
dav1d,
|
||||
vulkan-loader,
|
||||
libGL,
|
||||
wayland,
|
||||
pkg-config,
|
||||
libxkbcommon,
|
||||
pkgs,
|
||||
stdenv,
|
||||
targetPackages ? pkgs,
|
||||
}: let
|
||||
version = (builtins.fromTOML (builtins.readFile ./engine/Cargo.toml)).package.version;
|
||||
src = nix-gitignore.gitignoreSource [] ./.;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "zenyx";
|
||||
inherit src version;
|
||||
cargoLock.lockFile = ./Cargo.lock;
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkg-config
|
||||
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
|
||||
targetPackages.darwin.apple_sdk.frameworks.CoreServices
|
||||
];
|
||||
|
||||
buildInputs = with targetPackages; [
|
||||
dav1d
|
||||
] ++ lib.optionals (stdenv.targetPlatform.isLinux || stdenv.targetPlatform.isWindows) [
|
||||
vulkan-loader
|
||||
] ++ lib.optionals stdenv.targetPlatform.isLinux [
|
||||
makeWrapper
|
||||
wayland
|
||||
libxkbcommon
|
||||
libGL
|
||||
xorg.libXcursor
|
||||
xorg.libXrandr
|
||||
xorg.libXi
|
||||
xorg.libX11
|
||||
xorg.libxcb
|
||||
bash
|
||||
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
|
||||
makeWrapper
|
||||
darwin.apple_sdk.frameworks.Cocoa
|
||||
darwin.apple_sdk.frameworks.Metal
|
||||
darwin.apple_sdk.frameworks.CoreVideo
|
||||
darwin.apple_sdk.frameworks.QuartzCore
|
||||
];
|
||||
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER =
|
||||
lib.optionalString stdenv.targetPlatform.isWindows "${stdenv.cc.targetPrefix}gcc";
|
||||
|
||||
NIX_LDFLAGS = lib.optionalString stdenv.targetPlatform.isDarwin "-framework CoreFoundation";
|
||||
|
||||
postInstall = lib.optionalString stdenv.targetPlatform.isLinux ''
|
||||
wrapProgram $out/bin/${pname} \
|
||||
--prefix PATH : ${lib.makeBinPath [ bash ]} \
|
||||
--set LD_LIBRARY_PATH ${lib.makeLibraryPath buildInputs}
|
||||
'' + lib.optionalString stdenv.targetPlatform.isWindows ''
|
||||
mkdir -p $out/bin
|
||||
cp ${targetPackages.vulkan-loader}/bin/vulkan-1.dll $out/bin/
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = {
|
||||
description = "Cross-platform WSYWIG Game Engine";
|
||||
license = lib.licenses.mit;
|
||||
platforms = lib.platforms.all;
|
||||
mainProgram = "zenyx";
|
||||
};
|
||||
}
|
380
flake.lock
generated
380
flake.lock
generated
|
@ -1,190 +1,190 @@
|
|||
{
|
||||
"nodes": {
|
||||
"alejandra": {
|
||||
"inputs": {
|
||||
"fenix": "fenix",
|
||||
"flakeCompat": "flakeCompat",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1730688725,
|
||||
"narHash": "sha256-g0SSfTWZ5mtMOpQic+eqq9sXMy1E/7yKxxfupZd9V4A=",
|
||||
"owner": "kamadorueda",
|
||||
"repo": "alejandra",
|
||||
"rev": "2bb91e309ca99656addff5c74545acbf5813636d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kamadorueda",
|
||||
"ref": "3.1.0",
|
||||
"repo": "alejandra",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"alejandra",
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1730615655,
|
||||
"narHash": "sha256-2HBR3zLn57LXKNRtxBb+O+uDqHM4n0pz51rPayMl4cg=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "efeb50e2535b17ffd4a135e6e3e5fd60a525180c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"locked": {
|
||||
"lastModified": 1733328505,
|
||||
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
|
||||
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||
"revCount": 69,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
|
||||
}
|
||||
},
|
||||
"flakeCompat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1743095683,
|
||||
"narHash": "sha256-gWd4urRoLRe8GLVC/3rYRae1h+xfQzt09xOfb0PaHSk=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5e5402ecbcb27af32284d4a62553c019a3a49ea6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1736320768,
|
||||
"narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4bc9c909d9ac828a039f288cf872d16d38185db8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"alejandra": "alejandra",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1730555913,
|
||||
"narHash": "sha256-KNHZUlqsEibg3YtfUyOFQSofP8hp1HKoY+laoesBxRM=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "f17a5bbfd0969ba2e63a74505a80e55ecb174ed9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rust-lang",
|
||||
"ref": "nightly",
|
||||
"repo": "rust-analyzer",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1743215516,
|
||||
"narHash": "sha256-52qbrkG65U1hyrQWltgHTgH4nm0SJL+9TWv2UDCEPNI=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "524463199fdee49338006b049bc376b965a2cfed",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
{
|
||||
"nodes": {
|
||||
"alejandra": {
|
||||
"inputs": {
|
||||
"fenix": "fenix",
|
||||
"flakeCompat": "flakeCompat",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1730688725,
|
||||
"narHash": "sha256-g0SSfTWZ5mtMOpQic+eqq9sXMy1E/7yKxxfupZd9V4A=",
|
||||
"owner": "kamadorueda",
|
||||
"repo": "alejandra",
|
||||
"rev": "2bb91e309ca99656addff5c74545acbf5813636d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "kamadorueda",
|
||||
"ref": "3.1.0",
|
||||
"repo": "alejandra",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"alejandra",
|
||||
"nixpkgs"
|
||||
],
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1730615655,
|
||||
"narHash": "sha256-2HBR3zLn57LXKNRtxBb+O+uDqHM4n0pz51rPayMl4cg=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "efeb50e2535b17ffd4a135e6e3e5fd60a525180c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"locked": {
|
||||
"lastModified": 1733328505,
|
||||
"narHash": "sha256-NeCCThCEP3eCl2l/+27kNNK7QrwZB1IJCrXfrbv5oqU=",
|
||||
"rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec",
|
||||
"revCount": 69,
|
||||
"type": "tarball",
|
||||
"url": "https://api.flakehub.com/f/pinned/edolstra/flake-compat/1.1.0/01948eb7-9cba-704f-bbf3-3fa956735b52/source.tar.gz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
"url": "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz"
|
||||
}
|
||||
},
|
||||
"flakeCompat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1696426674,
|
||||
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1743095683,
|
||||
"narHash": "sha256-gWd4urRoLRe8GLVC/3rYRae1h+xfQzt09xOfb0PaHSk=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5e5402ecbcb27af32284d4a62553c019a3a49ea6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1736320768,
|
||||
"narHash": "sha256-nIYdTAiKIGnFNugbomgBJR+Xv5F1ZQU+HfaBqJKroC0=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4bc9c909d9ac828a039f288cf872d16d38185db8",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"alejandra": "alejandra",
|
||||
"flake-compat": "flake-compat",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"utils": "utils"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1730555913,
|
||||
"narHash": "sha256-KNHZUlqsEibg3YtfUyOFQSofP8hp1HKoY+laoesBxRM=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "f17a5bbfd0969ba2e63a74505a80e55ecb174ed9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rust-lang",
|
||||
"ref": "nightly",
|
||||
"repo": "rust-analyzer",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1743215516,
|
||||
"narHash": "sha256-52qbrkG65U1hyrQWltgHTgH4nm0SJL+9TWv2UDCEPNI=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "524463199fdee49338006b049bc376b965a2cfed",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
|
|
162
flake.nix
162
flake.nix
|
@ -1,78 +1,84 @@
|
|||
{
|
||||
description = "Zenyx - A WSYWIG game engine written in rust ";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
|
||||
alejandra.url = "github:kamadorueda/alejandra/3.1.0";
|
||||
alejandra.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
utils,
|
||||
rust-overlay,
|
||||
alejandra,
|
||||
...
|
||||
}:
|
||||
{
|
||||
overlays.default = final: prev: {
|
||||
zenyx = final.callPackage ./default.nix {};
|
||||
};
|
||||
}
|
||||
// utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
self.overlays.default
|
||||
(import rust-overlay)
|
||||
];
|
||||
};
|
||||
buildInputs = with pkgs; [
|
||||
vulkan-loader
|
||||
libGL
|
||||
wayland
|
||||
libxkbcommon
|
||||
xorg.libXcursor
|
||||
xorg.libXrandr
|
||||
xorg.libXi
|
||||
xorg.libX11
|
||||
xorg.libxcb
|
||||
pkg-config
|
||||
kdePackages.kdialog
|
||||
];
|
||||
in {
|
||||
packages = {
|
||||
inherit (pkgs) zenyx;
|
||||
default = pkgs.zenyx;
|
||||
windows = let
|
||||
pkgsCross = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
crossSystem = nixpkgs.lib.systems.examples.mingwW64;
|
||||
};
|
||||
in pkgsCross.callPackage ./default.nix {};
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "zenyx";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
(rust-bin.stable.latest.default.override {
|
||||
extensions = ["rust-src" "cargo" "rustfmt" "clippy"];
|
||||
})
|
||||
pkg-config
|
||||
];
|
||||
buildInputs = buildInputs;
|
||||
shellHook = ''
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${builtins.toString (pkgs.lib.makeLibraryPath buildInputs)}"
|
||||
echo "Rust version: $(rustc --version)"
|
||||
'';
|
||||
};
|
||||
|
||||
formatter = alejandra.packages.${system}.default;
|
||||
}
|
||||
);
|
||||
}
|
||||
{
|
||||
description = "Zenyx - A WSYWIG game engine written in rust ";
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
|
||||
alejandra.url = "github:kamadorueda/alejandra/3.1.0";
|
||||
alejandra.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
nixpkgs,
|
||||
utils,
|
||||
rust-overlay,
|
||||
alejandra,
|
||||
...
|
||||
}:
|
||||
{
|
||||
overlays.default = final: prev: {
|
||||
zenyx = final.callPackage ./default.nix {};
|
||||
};
|
||||
}
|
||||
// utils.lib.eachDefaultSystem (
|
||||
system: let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [
|
||||
self.overlays.default
|
||||
(import rust-overlay)
|
||||
];
|
||||
};
|
||||
buildInputs = with pkgs; [
|
||||
vulkan-loader
|
||||
libGL
|
||||
wayland
|
||||
libxkbcommon
|
||||
xorg.libXcursor
|
||||
xorg.libXrandr
|
||||
xorg.libXi
|
||||
xorg.libX11
|
||||
xorg.libxcb
|
||||
pkg-config
|
||||
kdePackages.kdialog
|
||||
cargo-xbuild
|
||||
cargo-pgo
|
||||
cargo-cross
|
||||
cargo-xwin
|
||||
cargo-wizard
|
||||
wine64
|
||||
];
|
||||
in {
|
||||
packages = {
|
||||
inherit (pkgs) zenyx;
|
||||
default = pkgs.zenyx;
|
||||
windows = let
|
||||
pkgsCross = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
crossSystem = nixpkgs.lib.systems.examples.mingwW64;
|
||||
};
|
||||
in pkgsCross.callPackage ./default.nix {};
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
name = "zenyx";
|
||||
nativeBuildInputs = with pkgs; [
|
||||
(rust-bin.stable.latest.default.override {
|
||||
extensions = ["rust-src" "cargo" "rustfmt" "clippy"];
|
||||
targets = [ "x86_64-pc-windows-msvc" "x86_64-unknown-linux-gnu" ];
|
||||
|
||||
})
|
||||
pkg-config
|
||||
];
|
||||
buildInputs = buildInputs;
|
||||
shellHook = ''
|
||||
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${builtins.toString (pkgs.lib.makeLibraryPath buildInputs)}"
|
||||
echo "Rust version: $(rustc --version)"
|
||||
'';
|
||||
};
|
||||
formatter = alejandra.packages.${system}.default;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
14
rustfmt.toml
14
rustfmt.toml
|
@ -1,7 +1,7 @@
|
|||
indent_style = "Block"
|
||||
wrap_comments = true
|
||||
format_code_in_doc_comments = true
|
||||
trailing_comma = "Vertical"
|
||||
group_imports = "StdExternalCrate"
|
||||
reorder_impl_items = true
|
||||
unstable_features = true
|
||||
indent_style = "Block"
|
||||
wrap_comments = true
|
||||
format_code_in_doc_comments = true
|
||||
trailing_comma = "Vertical"
|
||||
group_imports = "StdExternalCrate"
|
||||
reorder_impl_items = true
|
||||
unstable_features = true
|
||||
|
|
30
shell.nix
30
shell.nix
|
@ -1,15 +1,15 @@
|
|||
(
|
||||
import
|
||||
(
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
nodeName = lock.nodes.root.inputs.flake-compat;
|
||||
in
|
||||
fetchTarball {
|
||||
url = lock.nodes.${nodeName}.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.${nodeName}.locked.narHash;
|
||||
}
|
||||
)
|
||||
{src = ./.;}
|
||||
)
|
||||
.shellNix
|
||||
(
|
||||
import
|
||||
(
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
nodeName = lock.nodes.root.inputs.flake-compat;
|
||||
in
|
||||
fetchTarball {
|
||||
url = lock.nodes.${nodeName}.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.${nodeName}.locked.narHash;
|
||||
}
|
||||
)
|
||||
{src = ./.;}
|
||||
)
|
||||
.shellNix
|
||||
|
|
356
src/main.rs
356
src/main.rs
|
@ -1,39 +1,85 @@
|
|||
use crossbeam::channel::{Sender, unbounded};
|
||||
use std::{
|
||||
fs::OpenOptions, io::{self, BufWriter, Stdout, Write}, path::{Path, PathBuf}, str::FromStr, sync::{mpsc, Arc, RwLock}
|
||||
fmt,
|
||||
fs::OpenOptions,
|
||||
io::{BufWriter, Write},
|
||||
path::{Path, PathBuf},
|
||||
str::FromStr,
|
||||
sync::{Arc, RwLock},
|
||||
time::SystemTime,
|
||||
};
|
||||
use tracing::{Event, Level, Subscriber, info};
|
||||
use tracing_subscriber::{
|
||||
EnvFilter,
|
||||
layer::{Context, Layer, SubscriberExt},
|
||||
registry::LookupSpan,
|
||||
util::SubscriberInitExt,
|
||||
};
|
||||
|
||||
use tracing::{error, info};
|
||||
use tracing_subscriber::fmt::format::FmtSpan;
|
||||
use tracing_subscriber::{Layer, Registry, layer::SubscriberExt, util::SubscriberInitExt};
|
||||
use winit::event_loop::EventLoop;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
struct App;
|
||||
|
||||
struct BufferWriter {
|
||||
buffer: Arc<RwLock<Vec<u8>>>,
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct LogEntry {
|
||||
timestamp: SystemTime,
|
||||
level: Level,
|
||||
message: String,
|
||||
}
|
||||
|
||||
impl Write for BufferWriter {
|
||||
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
|
||||
if let Ok(mut guard) = self.buffer.write() {
|
||||
guard.extend_from_slice(buf);
|
||||
Ok(buf.len())
|
||||
struct BufferLayer {
|
||||
log_entries: Arc<RwLock<Vec<LogEntry>>>,
|
||||
sender: Sender<LogEntry>,
|
||||
}
|
||||
|
||||
impl<S> Layer<S> for BufferLayer
|
||||
where
|
||||
S: Subscriber + for<'a> LookupSpan<'a>,
|
||||
{
|
||||
fn on_event(&self, event: &Event<'_>, _ctx: Context<'_, S>) {
|
||||
let metadata = event.metadata();
|
||||
let level = *metadata.level();
|
||||
let timestamp = SystemTime::now();
|
||||
let mut message = String::new();
|
||||
let mut visitor = LogVisitor::new(&mut message);
|
||||
event.record(&mut visitor);
|
||||
|
||||
let log_entry = LogEntry {
|
||||
timestamp,
|
||||
level,
|
||||
message,
|
||||
};
|
||||
|
||||
if let Ok(mut guard) = self.log_entries.write() {
|
||||
guard.push(log_entry.clone());
|
||||
}
|
||||
|
||||
let _ = self.sender.send(log_entry);
|
||||
}
|
||||
}
|
||||
|
||||
struct LogVisitor<'msg> {
|
||||
message: &'msg mut String,
|
||||
}
|
||||
|
||||
impl<'msg> LogVisitor<'msg> {
|
||||
fn new(message: &'msg mut String) -> Self {
|
||||
Self { message }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'msg> tracing::field::Visit for LogVisitor<'msg> {
|
||||
fn record_debug(&mut self, field: &tracing::field::Field, value: &dyn fmt::Debug) {
|
||||
use std::fmt::Write as _;
|
||||
if field.name() == "message" {
|
||||
write!(self.message, "{:?}", value).unwrap();
|
||||
} else {
|
||||
Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"Failed to acquire write lock on log buffer",
|
||||
))
|
||||
write!(self.message, "{}={:?} ", field.name(), value).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||
|
||||
enum LogLevel {
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default)]
|
||||
pub enum LogLevel {
|
||||
Error,
|
||||
#[default]
|
||||
Info,
|
||||
|
@ -41,9 +87,9 @@ enum LogLevel {
|
|||
Trace,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for LogLevel {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f,"{self:?}")
|
||||
impl fmt::Display for LogLevel {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,44 +100,53 @@ impl FromStr for LogLevel {
|
|||
match s {
|
||||
"trace" => Ok(Self::Trace),
|
||||
"debug" => Ok(Self::Debug),
|
||||
"info" => Ok(Self::Info),
|
||||
"info" => Ok(Self::Info),
|
||||
"error" => Ok(Self::Error),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone,PartialEq,Eq,PartialOrd)]
|
||||
pub struct LoggerConfig {
|
||||
pub log_level: LogLevel,
|
||||
pub log_to_file: bool,
|
||||
pub log_file_path: PathBuf,
|
||||
pub log_to_stdout: bool,
|
||||
pub stdout_color: bool,
|
||||
pub log_to_buffer: bool,
|
||||
pub stdout_include_time: bool,
|
||||
pub file_include_time: bool,
|
||||
}
|
||||
|
||||
impl LoggerConfig {
|
||||
pub fn level(mut self,level: LogLevel) -> Self {
|
||||
pub fn level(mut self, level: LogLevel) -> Self {
|
||||
self.log_level = level;
|
||||
self
|
||||
}
|
||||
pub fn log_to_file(mut self,log_to_file: bool ) -> Self {
|
||||
pub fn log_to_file(mut self, log_to_file: bool) -> Self {
|
||||
self.log_to_file = log_to_file;
|
||||
self
|
||||
}
|
||||
pub fn colored_stdout(mut self,show_color: bool ) -> Self {
|
||||
pub fn colored_stdout(mut self, show_color: bool) -> Self {
|
||||
self.stdout_color = show_color;
|
||||
self
|
||||
}
|
||||
pub fn log_to_stdout(mut self,stdout: bool ) -> Self {
|
||||
pub fn log_to_stdout(mut self, stdout: bool) -> Self {
|
||||
self.log_to_stdout = stdout;
|
||||
self
|
||||
}
|
||||
pub fn log_path<P: AsRef<Path>>(mut self,path: P ) -> Self {
|
||||
pub fn log_path<P: AsRef<Path>>(mut self, path: P) -> Self {
|
||||
self.log_file_path = path.as_ref().to_path_buf();
|
||||
self
|
||||
}
|
||||
pub fn stdout_include_time(mut self, include: bool) -> Self {
|
||||
self.stdout_include_time = include;
|
||||
self
|
||||
}
|
||||
pub fn file_include_time(mut self, include: bool) -> Self {
|
||||
self.file_include_time = include;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for LoggerConfig {
|
||||
|
@ -102,118 +157,128 @@ impl Default for LoggerConfig {
|
|||
log_file_path: "zenyx.log".into(),
|
||||
log_to_stdout: true,
|
||||
stdout_color: true,
|
||||
log_to_buffer: true,
|
||||
stdout_include_time: false,
|
||||
file_include_time: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone,Copy, PartialEq,Eq,PartialOrd)]
|
||||
pub enum LogQuery {
|
||||
All,
|
||||
From(SystemTime),
|
||||
}
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Logger {
|
||||
config: LoggerConfig,
|
||||
log_buffer: Arc<RwLock<Vec<u8>>>,
|
||||
}
|
||||
|
||||
enum Log {
|
||||
All,
|
||||
From(std::time::SystemTime),
|
||||
log_entries: Arc<RwLock<Vec<LogEntry>>>,
|
||||
_sender: Sender<LogEntry>,
|
||||
}
|
||||
|
||||
impl Logger {
|
||||
pub fn new(config: LoggerConfig) -> Self {
|
||||
let (sender, receiver) = unbounded();
|
||||
let log_entries = Arc::new(RwLock::new(Vec::new()));
|
||||
|
||||
if config.log_to_stdout {
|
||||
let stdout_receiver = receiver.clone();
|
||||
let stdout_color = config.stdout_color;
|
||||
let stdout_include_time = config.stdout_include_time;
|
||||
std::thread::spawn(move || {
|
||||
for entry in stdout_receiver {
|
||||
let line = format_entry(&entry, stdout_color, stdout_include_time);
|
||||
println!("{}", line);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if config.log_to_file {
|
||||
let file_receiver = receiver.clone();
|
||||
let log_file_path = config.log_file_path.clone();
|
||||
let file_include_time = config.file_include_time;
|
||||
std::thread::spawn(move || {
|
||||
let file = OpenOptions::new()
|
||||
.append(true)
|
||||
.create(true)
|
||||
.open(&log_file_path)
|
||||
.unwrap_or_else(|_| {
|
||||
OpenOptions::new()
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.open(&log_file_path)
|
||||
.expect("Failed to create log file")
|
||||
});
|
||||
let mut writer = BufWriter::new(file);
|
||||
for entry in file_receiver {
|
||||
let line = format_entry(&entry, false, file_include_time);
|
||||
writer
|
||||
.write_all(format!("{}\n", line).as_bytes())
|
||||
.expect("Failed to write to log file");
|
||||
writer.flush().expect("Failed to flush log file");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
let buffer_layer = BufferLayer {
|
||||
log_entries: log_entries.clone(),
|
||||
sender: sender.clone(),
|
||||
};
|
||||
|
||||
let env_filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| {
|
||||
format!("{}={}", env!("CARGO_CRATE_NAME"), config.log_level).into()
|
||||
});
|
||||
|
||||
let subscriber = tracing_subscriber::registry()
|
||||
.with(env_filter)
|
||||
.with(buffer_layer);
|
||||
subscriber.init();
|
||||
|
||||
Self {
|
||||
config,
|
||||
log_buffer: Arc::new(RwLock::new(Vec::new())),
|
||||
log_entries,
|
||||
_sender: sender,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(&self) {
|
||||
let env_filter =
|
||||
tracing_subscriber::EnvFilter::try_from_default_env().unwrap_or_else(|_| {
|
||||
format!("{}={}", env!("CARGO_CRATE_NAME"), self.config.log_level).into()
|
||||
});
|
||||
|
||||
let mut layers = Vec::new();
|
||||
|
||||
if self.config.log_to_stdout {
|
||||
let fmt_layer_stdout = tracing_subscriber::fmt::layer()
|
||||
.with_level(true)
|
||||
.compact()
|
||||
.with_ansi(self.config.stdout_color)
|
||||
.log_internal_errors(false)
|
||||
.without_time()
|
||||
.with_thread_names(true)
|
||||
.with_span_events(FmtSpan::CLOSE)
|
||||
.with_writer(std::io::stdout)
|
||||
.boxed();
|
||||
layers.push(fmt_layer_stdout);
|
||||
}
|
||||
|
||||
if self.config.log_to_file {
|
||||
let log_file_path = self.config.log_file_path.clone();
|
||||
let fmt_layer_file = tracing_subscriber::fmt::layer()
|
||||
.with_level(true)
|
||||
.compact()
|
||||
.with_ansi(false)
|
||||
.log_internal_errors(false)
|
||||
.without_time()
|
||||
.with_thread_names(true)
|
||||
.with_span_events(FmtSpan::CLOSE)
|
||||
.with_writer(move || {
|
||||
let file = OpenOptions::new()
|
||||
.append(true)
|
||||
.open(&log_file_path)
|
||||
.unwrap_or_else(|_| {
|
||||
OpenOptions::new()
|
||||
.write(true)
|
||||
.create(true)
|
||||
.truncate(true)
|
||||
.open(&log_file_path)
|
||||
.expect("Failed to create log file")
|
||||
});
|
||||
BufWriter::new(file)
|
||||
})
|
||||
.boxed();
|
||||
layers.push(fmt_layer_file);
|
||||
}
|
||||
// let (tx,rx) = mpsc::channel();
|
||||
// std::thread::spawn(move || {
|
||||
// for log in rx.iter() {
|
||||
// println!("{log:#?}")
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
if self.config.log_to_buffer {
|
||||
let log_buffer = Arc::clone(&self.log_buffer);
|
||||
let fmt_layer_buffer = tracing_subscriber::fmt::layer()
|
||||
.with_level(true)
|
||||
.compact()
|
||||
.with_ansi(false)
|
||||
.log_internal_errors(false)
|
||||
.without_time()
|
||||
.with_thread_names(true)
|
||||
.with_span_events(FmtSpan::CLOSE)
|
||||
.with_writer(move || BufferWriter {
|
||||
buffer: log_buffer.clone(),
|
||||
})
|
||||
.boxed();
|
||||
layers.push(fmt_layer_buffer);
|
||||
}
|
||||
|
||||
if !layers.is_empty() {
|
||||
let subscriber = Registry::default().with(env_filter).with(layers);
|
||||
subscriber.init();
|
||||
pub fn get_logs(&self, log_query: LogQuery) -> Vec<LogEntry> {
|
||||
let guard = self.log_entries.read().unwrap();
|
||||
match log_query {
|
||||
LogQuery::All => guard.clone(),
|
||||
LogQuery::From(time) => guard
|
||||
.iter()
|
||||
.filter(|e| e.timestamp >= time)
|
||||
.cloned()
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_logs(&self) -> Option<String> {
|
||||
if !self.config.log_to_buffer {
|
||||
return None;
|
||||
fn format_entry(entry: &LogEntry, use_color: bool, include_time: bool) -> String {
|
||||
let timestamp = if include_time {
|
||||
format!(
|
||||
"[{}] ",
|
||||
humantime::format_rfc3339_seconds(entry.timestamp)
|
||||
.to_string()
|
||||
.trim_end_matches('Z')
|
||||
.replace('T', " ")
|
||||
)
|
||||
} else {
|
||||
String::new()
|
||||
};
|
||||
|
||||
let level = if use_color {
|
||||
match entry.level {
|
||||
Level::ERROR => format!("\x1b[31m{}\x1b[0m", entry.level),
|
||||
Level::WARN => format!("\x1b[33m{}\x1b[0m", entry.level),
|
||||
Level::INFO => format!("\x1b[32m{}\x1b[0m", entry.level),
|
||||
Level::DEBUG => format!("\x1b[36m{}\x1b[0m", entry.level),
|
||||
Level::TRACE => format!("\x1b[34m{}\x1b[0m", entry.level),
|
||||
}
|
||||
self.log_buffer
|
||||
.read()
|
||||
.ok()
|
||||
.map(|guard| String::from_utf8_lossy(&guard).into_owned())
|
||||
}
|
||||
} else {
|
||||
entry.level.to_string()
|
||||
};
|
||||
|
||||
format!("{}{} {}", timestamp, level, entry.message)
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
@ -221,25 +286,32 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.colored_stdout(true)
|
||||
.level(LogLevel::Debug)
|
||||
.log_to_file(true)
|
||||
.log_path(format!("{}.log",env!("CARGO_PKG_NAME")));
|
||||
let logger = Logger::new(logger_config);
|
||||
logger.init();
|
||||
.stdout_include_time(false)
|
||||
.file_include_time(true)
|
||||
.log_path(format!("{}.log", env!("CARGO_PKG_NAME")));
|
||||
|
||||
let event_loop = EventLoop::new()?;
|
||||
info!("Application initialized");
|
||||
let logger = Logger::new(logger_config);
|
||||
|
||||
let app = App::default();
|
||||
tracing::info!("Application initialized");
|
||||
tracing::error!("Another log message with value: {}", 42);
|
||||
|
||||
info!("This is a test log message");
|
||||
error!("Another log message with value: {}", 42);
|
||||
|
||||
if let Some(logs) = logger.get_logs() {
|
||||
println!("\n--- Logs from Buffer ---");
|
||||
println!("{}", logs);
|
||||
println!("------------------------");
|
||||
} else {
|
||||
eprintln!("Failed to read logs from buffer or buffer logging is disabled");
|
||||
let logs = logger.get_logs(LogQuery::All);
|
||||
println!("\n--- All Logs ---");
|
||||
for entry in logs {
|
||||
println!("{}", format_entry(&entry, false, true));
|
||||
}
|
||||
|
||||
let now = SystemTime::now();
|
||||
tracing::warn!("This is a warning after the initial logs");
|
||||
let new_logs = logger.get_logs(LogQuery::From(now));
|
||||
println!("\n--- Logs Since Now ---");
|
||||
for entry in new_logs {
|
||||
println!("{}", format_entry(&entry, false, true));
|
||||
}
|
||||
info!("Application finished");
|
||||
|
||||
// logger.get_logs();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue