mirror of
https://codeberg.org/demostf/parser.git
synced 2026-06-03 10:14:06 +02:00
flake reorg
This commit is contained in:
parent
ce289200f8
commit
4d97759eca
11 changed files with 109 additions and 391 deletions
85
.github/workflows/ci.yml
vendored
85
.github/workflows/ci.yml
vendored
|
|
@ -1,100 +1,37 @@
|
|||
name: CI
|
||||
|
||||
name: "CI"
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
check:
|
||||
checks:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: cachix/install-nix-action@v27
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#check
|
||||
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||
- run: nix flake check --keep-going
|
||||
|
||||
clippy:
|
||||
semver:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check
|
||||
needs: checks
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: cachix/install-nix-action@v27
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#clippy
|
||||
|
||||
msrv:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#msrv
|
||||
|
||||
matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- id: set-matrix
|
||||
run: echo "matrix=$(nix eval --json ".#matrix.x86_64-linux")" | tee $GITHUB_OUTPUT
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [check, matrix]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#${{ matrix.target }}
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: parser-${{ matrix.target }}
|
||||
path: result/bin/${{ matrix.artifact_name }}
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
- run: nix build .#test
|
||||
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||
- run: nix run .#semver-checks
|
||||
|
||||
check-schema:
|
||||
runs-on: ubuntu-latest
|
||||
needs: check
|
||||
needs: checks
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
|
|
|
|||
22
.github/workflows/release.yml
vendored
22
.github/workflows/release.yml
vendored
|
|
@ -4,36 +4,40 @@ on:
|
|||
release:
|
||||
types: [created]
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
matrix:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
cross-matrix: ${{ steps.set-matrix.outputs.cross-matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: cachix/install-nix-action@v27
|
||||
- id: set-matrix
|
||||
run: echo "matrix=$(nix eval --json ".#releaseMatrix.x86_64-linux")" | tee $GITHUB_OUTPUT
|
||||
run: |
|
||||
echo "cross-matrix={\"include\":$(nix eval --json '.#lib.crossMatrix')}" | tee -a $GITHUB_OUTPUT
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: matrix
|
||||
needs: [matrix]
|
||||
strategy:
|
||||
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
|
||||
fail-fast: false
|
||||
matrix: ${{fromJson(needs.matrix.outputs.cross-matrix)}}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: cachix/install-nix-action@v25
|
||||
- uses: cachix/install-nix-action@v27
|
||||
- uses: icewind1991/attic-action@v1
|
||||
with:
|
||||
name: ci
|
||||
instance: https://cache.icewind.me
|
||||
authToken: '${{ secrets.ATTIC_TOKEN }}'
|
||||
authToken: "${{ secrets.ATTIC_TOKEN }}"
|
||||
- run: nix build .#${{ matrix.target }}
|
||||
- name: Upload binary to release
|
||||
uses: svenstaro/upload-release-action@v2
|
||||
with:
|
||||
repo_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
file: result/bin/${{ matrix.artifact_name }}
|
||||
asset_name: ${{ matrix.asset_name }}
|
||||
file: result/bin/parse_demo${{ matrix.binary-suffix }}
|
||||
asset_name: parser-${{ matrix.target }}${{ matrix.binary-suffix }}
|
||||
tag: ${{ github.ref }}
|
||||
|
|
@ -107,6 +107,3 @@ harness = false
|
|||
name = "bench"
|
||||
harness = false
|
||||
|
||||
[[bench]]
|
||||
name = "sendprop"
|
||||
harness = false
|
||||
|
|
|
|||
|
|
@ -1,62 +0,0 @@
|
|||
#![allow(dead_code)]
|
||||
#![allow(unused_imports)]
|
||||
#![allow(unused_variables)]
|
||||
|
||||
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::fs;
|
||||
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use tf_demo_parser::demo::message::Message;
|
||||
use tf_demo_parser::demo::packet::datatable::{ParseSendTable, SendTableName};
|
||||
use tf_demo_parser::demo::packet::stringtable::StringTableEntry;
|
||||
use tf_demo_parser::demo::parser::MessageHandler;
|
||||
use tf_demo_parser::demo::sendprop::RawSendPropDefinition;
|
||||
use tf_demo_parser::{Demo, DemoParser, MatchState, MessageType, MessageTypeAnalyser, ParserState};
|
||||
|
||||
pub struct SendPropAnalyser;
|
||||
|
||||
impl MessageHandler for SendPropAnalyser {
|
||||
type Output = Vec<ParseSendTable>;
|
||||
|
||||
fn does_handle(message_type: MessageType) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn into_output(self, state: &ParserState) -> Self::Output {
|
||||
state
|
||||
.send_tables
|
||||
.iter()
|
||||
.map(|v| ParseSendTable {
|
||||
name: v.name.clone(),
|
||||
props: v.raw_props.clone(),
|
||||
needs_decoder: v.needs_decoder,
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
fn flatten_bench(input_file: &str, b: &mut Criterion) {
|
||||
let file = fs::read(input_file).expect("Unable to read file");
|
||||
let demo = Demo::new(&file);
|
||||
let stream = demo.get_stream();
|
||||
let (_, send_tables) = DemoParser::new_with_analyser(stream.clone(), SendPropAnalyser)
|
||||
.parse()
|
||||
.unwrap();
|
||||
b.bench_function(&format!("flatten {}", input_file), |b| {
|
||||
b.iter(|| {
|
||||
let flat: Vec<_> = send_tables
|
||||
.iter()
|
||||
.map(|table| table.flatten_props(&send_tables))
|
||||
.collect();
|
||||
black_box(flat);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
fn sendprop_test_gully(b: &mut Criterion) {
|
||||
flatten_bench("test_data/gully.dem", b);
|
||||
}
|
||||
|
||||
criterion_group!(benches, sendprop_test_gully);
|
||||
criterion_main!(benches);
|
||||
143
flake.lock
generated
143
flake.lock
generated
|
|
@ -1,116 +1,98 @@
|
|||
{
|
||||
"nodes": {
|
||||
"cross-naersk": {
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1733688869,
|
||||
"narHash": "sha256-KrhxxFj1CjESDrL5+u/zsVH0K+Ik9tvoac/oFPoxSB8=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "604637106e420ad99907cae401e13ab6b452e7d9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flakelight": {
|
||||
"inputs": {
|
||||
"naersk": [
|
||||
"naersk"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1717704286,
|
||||
"narHash": "sha256-zrLB/FTKODEAlJjgO8TwbK7teTseYbjLESp8QJ/FJYc=",
|
||||
"owner": "icewind1991",
|
||||
"repo": "cross-naersk",
|
||||
"rev": "9068daceb8f0d248dcf629944f60e92b81391bdb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "icewind1991",
|
||||
"repo": "cross-naersk",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1710146030,
|
||||
"narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"naersk": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1717067539,
|
||||
"narHash": "sha256-oIs5EF+6VpHJRvvpVWuqCYJMMVW/6h59aYUv9lABLtY=",
|
||||
"lastModified": 1739796086,
|
||||
"narHash": "sha256-jxpUiVJ6O+V1YsXsvWdMgqnv8zk9TFiqF86CRdGGGH4=",
|
||||
"owner": "nix-community",
|
||||
"repo": "naersk",
|
||||
"rev": "fa19d8c135e776dc97f4dcca08656a0eeb28d5c0",
|
||||
"repo": "flakelight",
|
||||
"rev": "540efca2f9015aff7dc574c7a03404e5fa72d42f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "naersk",
|
||||
"repo": "flakelight",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"mill-scale": {
|
||||
"inputs": {
|
||||
"crane": "crane",
|
||||
"flakelight": [
|
||||
"flakelight"
|
||||
],
|
||||
"rust-overlay": "rust-overlay"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1735052218,
|
||||
"narHash": "sha256-I30wh6G8fSUO4EseexxiDXcxyUhXR6C8BvEeKn6xyfE=",
|
||||
"owner": "icewind1991",
|
||||
"repo": "mill-scale",
|
||||
"rev": "7e45bb598ff63a8416ee3c26743b20644563bd93",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "icewind1991",
|
||||
"repo": "mill-scale",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1717952948,
|
||||
"narHash": "sha256-mJi4/gjiwQlSaxjA6AusXBN/6rQRaPCycR7bd8fydnQ=",
|
||||
"path": "/nix/store/giq1qbcwfx5gq0g9jf6id0b3m55a860j-source",
|
||||
"rev": "2819fffa7fa42156680f0d282c60d81e8fb185b7",
|
||||
"type": "path"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1718457333,
|
||||
"narHash": "sha256-vJcyHvKbBmPF35/akyPqmMbe9OA2Tiw4vpG3mIhZmk4=",
|
||||
"lastModified": 1739758141,
|
||||
"narHash": "sha256-uq6A2L7o1/tR6VfmYhZWoVAwb3gTy7j4Jx30MIrH0rE=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "56c7d80efdad9212a54a3ef0a3f185a500dad89f",
|
||||
"rev": "c618e28f70257593de75a7044438efc1c1fc0791",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "release-24.05",
|
||||
"ref": "nixos-24.11",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"cross-naersk": "cross-naersk",
|
||||
"flake-utils": "flake-utils",
|
||||
"naersk": "naersk",
|
||||
"nixpkgs": "nixpkgs_2",
|
||||
"rust-overlay": "rust-overlay"
|
||||
"flakelight": "flakelight",
|
||||
"mill-scale": "mill-scale",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"mill-scale",
|
||||
"flakelight",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1718417877,
|
||||
"narHash": "sha256-s8QrTANEtY6UxzfkcBfoN93bgW9aCRIq54LPRVNu/4c=",
|
||||
"lastModified": 1733884434,
|
||||
"narHash": "sha256-8GXR9kC07dyOIshAyfZhG11xfvBRSZzYghnZ2weOKJU=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "7c2d603cb67c974ef8c5cfee1150060dbb299e04",
|
||||
"rev": "d0483df44ddf0fd1985f564abccbe568e020ddf2",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
@ -118,21 +100,6 @@
|
|||
"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"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
|
|||
175
flake.nix
175
flake.nix
|
|
@ -1,167 +1,34 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/release-24.05";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
naersk.url = "github:nix-community/naersk";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
rust-overlay.inputs.flake-utils.follows = "flake-utils";
|
||||
cross-naersk.url = "github:icewind1991/cross-naersk";
|
||||
cross-naersk.inputs.nixpkgs.follows = "nixpkgs";
|
||||
cross-naersk.inputs.naersk.follows = "naersk";
|
||||
nixpkgs.url = "nixpkgs/nixos-24.11";
|
||||
flakelight = {
|
||||
url = "github:nix-community/flakelight";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
mill-scale = {
|
||||
url = "github:icewind1991/mill-scale";
|
||||
inputs.flakelight.follows = "flakelight";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = {
|
||||
self,
|
||||
flake-utils,
|
||||
cross-naersk,
|
||||
naersk,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
...
|
||||
}: let
|
||||
inherit (flake-utils.lib) eachDefaultSystem eachSystem;
|
||||
in (eachDefaultSystem (system: let
|
||||
overlays = [
|
||||
(import rust-overlay)
|
||||
(import ./nix/overlay.nix)
|
||||
];
|
||||
pkgs = (import nixpkgs) {
|
||||
inherit system overlays;
|
||||
};
|
||||
lib = pkgs.lib;
|
||||
inherit (builtins) listToAttrs fromTOML readFile;
|
||||
|
||||
hostTarget = pkgs.hostPlatform.config;
|
||||
targets = [
|
||||
outputs = {mill-scale, ...}:
|
||||
mill-scale ./. {
|
||||
crossTargets = [
|
||||
"x86_64-unknown-linux-musl"
|
||||
"i686-unknown-linux-musl"
|
||||
"armv7-unknown-linux-musleabihf"
|
||||
"aarch64-unknown-linux-musl"
|
||||
"x86_64-pc-windows-gnu"
|
||||
hostTarget
|
||||
];
|
||||
|
||||
releaseTargets = lib.lists.remove hostTarget targets;
|
||||
|
||||
artifactForTarget = target: "parse_demo${cross-naersk'.execSufficForTarget target}";
|
||||
assetNameForTarget = target: "parser-${builtins.replaceStrings ["-unknown" "-gnu" "-musl" "eabihf" "-pc"] ["" "" "" "" ""] target}${cross-naersk'.execSufficForTarget target}";
|
||||
|
||||
cross-naersk' = pkgs.callPackage cross-naersk {inherit naersk;};
|
||||
nearskOpt = {
|
||||
inherit (pkgs.demostf-parser) pname src;
|
||||
extraPaths = [./test_data ./examples ./benches ./tests];
|
||||
withOverlays = [(import ./nix/overlay.nix)];
|
||||
packages = {
|
||||
demostf-parser = pkgs: pkgs.demostf-parser;
|
||||
demostf-parser-codegen-events = pkgs: pkgs.demostf-parser-codegen-events;
|
||||
demostf-parser-codegen-props = pkgs: pkgs.demostf-parser-codegen-props;
|
||||
demostf-parser-schema = pkgs: pkgs.demostf-parser-schema;
|
||||
};
|
||||
|
||||
buildMatrix = targets: {
|
||||
include =
|
||||
builtins.map (target: {
|
||||
inherit target;
|
||||
artifact_name = artifactForTarget target;
|
||||
asset_name = assetNameForTarget target;
|
||||
})
|
||||
targets;
|
||||
};
|
||||
hostNaersk = cross-naersk'.hostNaersk;
|
||||
|
||||
msrv = (fromTOML (readFile ./Cargo.toml)).package.rust-version;
|
||||
msrvToolchain = pkgs.rust-bin.stable."${msrv}".default;
|
||||
naerskMsrv = let
|
||||
toolchain = msrvToolchain;
|
||||
in
|
||||
pkgs.callPackage naersk {
|
||||
cargo = toolchain;
|
||||
rustc = toolchain;
|
||||
};
|
||||
|
||||
mkHydraJobs = system: {
|
||||
parser = derivation {
|
||||
name = "parser";
|
||||
builder = "mybuilder";
|
||||
inherit system;
|
||||
};
|
||||
nested = {
|
||||
attribute = derivation {
|
||||
name = "nested-attribute";
|
||||
builder = "mybuilder";
|
||||
inherit system;
|
||||
};
|
||||
};
|
||||
};
|
||||
overlayPackages = builtins.attrNames ((import ./nix/overlay.nix) {} {});
|
||||
in rec {
|
||||
packages =
|
||||
lib.attrsets.genAttrs targets (target:
|
||||
(cross-naersk'.buildPackage target) (nearskOpt
|
||||
// {
|
||||
overrideMain = args:
|
||||
args
|
||||
// {
|
||||
preConfigure = ''
|
||||
cargo_build_options="$cargo_build_options --bin parse_demo"
|
||||
'';
|
||||
};
|
||||
}))
|
||||
// rec {
|
||||
inherit (pkgs) demostf-parser demostf-parser-codegen demostf-parser-codegen-events demostf-parser-codegen-props demostf-parser-schema;
|
||||
check = hostNaersk.buildPackage (nearskOpt
|
||||
// {
|
||||
mode = "check";
|
||||
});
|
||||
clippy = hostNaersk.buildPackage (nearskOpt
|
||||
// {
|
||||
mode = "clippy";
|
||||
});
|
||||
test = hostNaersk.buildPackage (nearskOpt
|
||||
// {
|
||||
release = false;
|
||||
mode = "test";
|
||||
});
|
||||
msrv = naerskMsrv.buildPackage (nearskOpt
|
||||
// {
|
||||
mode = "check";
|
||||
});
|
||||
default = demostf-parser;
|
||||
};
|
||||
|
||||
inherit targets;
|
||||
inherit releaseTargets;
|
||||
matrix = buildMatrix targets;
|
||||
releaseMatrix = buildMatrix releaseTargets;
|
||||
|
||||
apps = rec {
|
||||
tf-demo-parser = flake-utils.lib.mkApp {
|
||||
drv = packages.tf-demo-parser;
|
||||
exePath = "/bin/parse_demo";
|
||||
};
|
||||
default = tf-demo-parser;
|
||||
};
|
||||
|
||||
checks = {
|
||||
fmt-check = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "fmt-check";
|
||||
src = ./.;
|
||||
doCheck = true;
|
||||
dontBuild = true;
|
||||
nativeBuildInputs = with pkgs; [alejandra shellcheck shfmt];
|
||||
checkPhase = ''
|
||||
alejandra -c .
|
||||
'';
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
formatter = pkgs.alejandra;
|
||||
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = with pkgs; [rust-bin.stable.latest.default bacon cargo-edit cargo-outdated rustfmt clippy cargo-audit hyperfine valgrind cargo-insta cargo-semver-checks];
|
||||
};
|
||||
})
|
||||
// {
|
||||
overlays.default = import ./nix/overlay.nix;
|
||||
hydraJobs = eachSystem ["x86_64-linux" "aarch64-linux"] (system: {
|
||||
parser = self.packages.${system}.demostf-parser;
|
||||
});
|
||||
});
|
||||
tools = pkgs: with pkgs; [cargo-insta];
|
||||
};
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ struct JsonDemo {
|
|||
}
|
||||
|
||||
fn main() -> Result<(), MainError> {
|
||||
#[cfg(feature = "better_panic")]
|
||||
#[cfg(feature = "better-panic")]
|
||||
better_panic::install();
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ pub use tf_demo_parser::{Demo, DemoParser, Parse, ParseError, ParserState, Strea
|
|||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||
|
||||
fn main() -> Result<(), MainError> {
|
||||
#[cfg(feature = "better_panic")]
|
||||
#[cfg(feature = "better-panic")]
|
||||
better_panic::install();
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ struct JsonDemo {
|
|||
}
|
||||
|
||||
fn main() -> Result<(), MainError> {
|
||||
#[cfg(feature = "better_panic")]
|
||||
#[cfg(feature = "better-panic")]
|
||||
better_panic::install();
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ fn main() -> Result<(), MainError> {
|
|||
#[cfg(feature = "trace")]
|
||||
tracing_subscriber::fmt::init();
|
||||
|
||||
#[cfg(feature = "better_panic")]
|
||||
#[cfg(feature = "better-panic")]
|
||||
better_panic::install();
|
||||
|
||||
let args: Vec<_> = env::args().collect();
|
||||
|
|
|
|||
|
|
@ -3,17 +3,17 @@ use std::env;
|
|||
use std::fs;
|
||||
|
||||
use main_error::MainError;
|
||||
pub use tf_demo_parser::{Demo, DemoParser, Parse, ParserState};
|
||||
use tf_demo_parser::demo::packet::stringtable::{StringTableEntry};
|
||||
use tf_demo_parser::demo::packet::stringtable::StringTableEntry;
|
||||
use tf_demo_parser::demo::parser::MessageHandler;
|
||||
use tf_demo_parser::MessageType;
|
||||
pub use tf_demo_parser::{Demo, DemoParser, Parse, ParserState};
|
||||
|
||||
#[cfg(feature = "jemallocator")]
|
||||
#[global_allocator]
|
||||
static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
||||
|
||||
fn main() -> Result<(), MainError> {
|
||||
#[cfg(feature = "better_panic")]
|
||||
#[cfg(feature = "better-panic")]
|
||||
better_panic::install();
|
||||
|
||||
#[cfg(feature = "trace")]
|
||||
|
|
@ -60,10 +60,19 @@ impl MessageHandler for StringTableHandler {
|
|||
type Output = HashMap<String, Vec<String>>;
|
||||
|
||||
fn does_handle(message_type: MessageType) -> bool {
|
||||
matches!(message_type, MessageType::CreateStringTable | MessageType::UpdateStringTable)
|
||||
matches!(
|
||||
message_type,
|
||||
MessageType::CreateStringTable | MessageType::UpdateStringTable
|
||||
)
|
||||
}
|
||||
|
||||
fn handle_string_entry(&mut self, table: &str, index: usize, entries: &StringTableEntry, _parser_state: &ParserState) {
|
||||
fn handle_string_entry(
|
||||
&mut self,
|
||||
table: &str,
|
||||
index: usize,
|
||||
entries: &StringTableEntry,
|
||||
_parser_state: &ParserState,
|
||||
) {
|
||||
let table = self.tables.entry(table.into()).or_default();
|
||||
if index < table.len() {
|
||||
table[index] = entries.text().into();
|
||||
|
|
@ -72,7 +81,6 @@ impl MessageHandler for StringTableHandler {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
fn into_output(self, _state: &ParserState) -> Self::Output {
|
||||
self.tables
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue