1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 10:14:06 +02:00

more cross

This commit is contained in:
Robin Appelman 2023-06-11 17:32:21 +02:00
commit 500e43c9de
4 changed files with 157 additions and 55 deletions

View file

@ -36,15 +36,22 @@ jobs:
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#clippy
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- id: set-matrix
run: echo "matrix=$(nix eval --json ".#matrix.x86_64-linux")" | tee $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: check
needs: [check, matrix]
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
@ -57,7 +64,7 @@ jobs:
- uses: actions/upload-artifact@v3
with:
name: parser-${{ matrix.target }}
path: result/bin/parse_demo
path: result/bin/${{ matrix.artifact_name }}
test:
runs-on: ubuntu-latest

View file

@ -4,10 +4,23 @@ on:
release:
types: [created]
jobs:
release-binaries:
name: Build release binaries
matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
- id: set-matrix
run: echo "matrix=$(nix eval --json ".#releaseMatrix.x86_64-linux")" | tee $GITHUB_OUTPUT
build:
runs-on: ubuntu-latest
needs: matrix
strategy:
matrix: ${{fromJson(needs.matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
@ -16,11 +29,11 @@ jobs:
name: ci
instance: https://cache.icewind.me
authToken: '${{ secrets.ATTIC_TOKEN }}'
- run: nix build .#x86_64-unknown-linux-musl
- 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/parse_demo
asset_name: parse_demo
file: result/bin/${{ matrix.artifact_name }}
asset_name: ${{ matrix.asset_name }}
tag: ${{ github.ref }}

87
flake.lock generated
View file

@ -1,27 +1,79 @@
{
"nodes": {
"naersk": {
"cross-naersk": {
"inputs": {
"naersk": [
"naersk"
],
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1685804727,
"narHash": "sha256-9kd2ac4MmTRLDX2MnXGIzJM9eDvWocQrXhWWkWj/0zI=",
"lastModified": 1686501881,
"narHash": "sha256-qFxW9cuCfvo7Kcc7mSt53wkP1ti4Y5PTXJKLARPIWm8=",
"owner": "icewind1991",
"repo": "cross-naersk",
"rev": "95a73c480942aa9910fab37c29e3412bd915252e",
"type": "github"
},
"original": {
"owner": "icewind1991",
"repo": "cross-naersk",
"type": "github"
}
},
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"naersk": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1686242667,
"narHash": "sha256-I7Kwp06WX/9E+rEND1i1wjdKQQm3XiDxYOyNK9fuJu0=",
"owner": "icewind1991",
"repo": "naersk",
"rev": "21b870efb320d44ec1c2f661f6e6e8deca9bb239",
"rev": "6d245a3bbb2ee31ec726bb57b9a8b206302e7110",
"type": "github"
},
"original": {
"owner": "icewind1991",
"repo": "naersk",
"rev": "21b870efb320d44ec1c2f661f6e6e8deca9bb239",
"rev": "6d245a3bbb2ee31ec726bb57b9a8b206302e7110",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1685620773,
"narHash": "sha256-iQ+LmporQNdLz8uMJdP62TaAWeLUwl43/MYUBtWqulM=",
"path": "/nix/store/ipbqg8zvymxjlw96pl2mvgpigzc3wm7p-source",
"rev": "f0ba8235153dd2e25cf06cbf70d43efdd4443592",
"type": "path"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1685789966,
"narHash": "sha256-pyqctu5Cq1jwymO3Os0/RNj5Nm3q5kmRCT24p7gtG70=",
@ -38,16 +90,17 @@
},
"root": {
"inputs": {
"cross-naersk": "cross-naersk",
"flake-utils": "flake-utils",
"naersk": "naersk",
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay",
"utils": "utils"
"nixpkgs": "nixpkgs_2",
"rust-overlay": "rust-overlay"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": [
"utils"
"flake-utils"
],
"nixpkgs": [
"nixpkgs"
@ -67,18 +120,18 @@
"type": "github"
}
},
"utils": {
"systems": {
"locked": {
"lastModified": 1667395993,
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}

View file

@ -1,63 +1,92 @@
{
inputs = {
nixpkgs.url = "nixpkgs/release-23.05";
utils.url = "github:numtide/flake-utils";
naersk.url = "github:icewind1991/naersk?rev=21b870efb320d44ec1c2f661f6e6e8deca9bb239";
naersk.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:icewind1991/naersk?rev=6d245a3bbb2ee31ec726bb57b9a8b206302e7110";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
rust-overlay.inputs.flake-utils.follows = "utils";
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";
};
outputs = {
self,
nixpkgs,
utils,
flake-utils,
cross-naersk,
naersk,
nixpkgs,
rust-overlay,
...
}:
utils.lib.eachDefaultSystem (system: let
flake-utils.lib.eachDefaultSystem (system: let
overlays = [ (import rust-overlay) ];
pkgs = (import nixpkgs) {
inherit system overlays;
};
naersk' = pkgs.callPackage naersk {};
hostTarget = pkgs.hostPlatform.config;
targets = ["x86_64-unknown-linux-musl" hostTarget];
lib = pkgs.lib;
naerskForTarget = target: let
toolchain = pkgs.rust-bin.stable.latest.default.override { targets = [target]; };
in pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
};
hostNaersk = naerskForTarget hostTarget;
hostTarget = pkgs.hostPlatform.config;
targets = [
"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;
toolchain = (pkgs.rust-bin.stable.latest.default.override { inherit targets; });
execSufficForTarget = target: if lib.strings.hasInfix "windows" target then ".exe" else "";
artifactForTarget = target: "parse_demo${execSufficForTarget target}";
assetNameForTarget = target: "parser-${builtins.replaceStrings ["-unknown" "-gnu" "-musl" "eabihf" "-pc"] ["" "" "" "" ""] target}${execSufficForTarget target}";
cross-naersk' = pkgs.callPackage cross-naersk {inherit naersk;};
src = lib.sources.sourceByRegex (lib.cleanSource ./.) ["Cargo.*" "(src|benches|tests|test_data)(/.*)?"];
nearskOpt = {
pname = "dispenser";
root = src;
};
buildMatrix = targets: {
include = builtins.map (target: {
inherit target;
artifact_name = artifactForTarget target;
asset_name = assetNameForTarget target;
}) targets;
};
in rec {
packages = (lib.attrsets.genAttrs targets (target: (naerskForTarget target).buildPackage {
pname = "tf-demo-parser";
root = src;
packages = lib.attrsets.genAttrs targets (target: (cross-naersk' target).buildPackage (nearskOpt // {
overrideMain = args: args // {
preConfigure = ''
cargo_build_options="$cargo_build_options --bin parse_demo"
'';
};
})) // rec {
tf-demo-parser = packages.${hostTarget};
check = hostNaersk.buildPackage (nearskOpt // {
checkOnly = true;
check = (cross-naersk' hostTarget).buildPackage (nearskOpt // {
mode = "check";
});
clippy = hostNaersk.buildPackage (nearskOpt // {
clippyOnly = true;
clippy = (cross-naersk' hostTarget).buildPackage (nearskOpt // {
mode = "clippy";
});
test = hostNaersk.buildPackage (nearskOpt // {
test = (cross-naersk' hostTarget).buildPackage (nearskOpt // {
release = false;
testOnly = true;
mode = "test";
});
default = tf-demo-parser;
};
inherit targets;
inherit releaseTargets;
matrix = buildMatrix targets;
releaseMatrix = buildMatrix releaseTargets;
apps = rec {
tf-demo-parser = utils.lib.mkApp {
tf-demo-parser = flake-utils.lib.mkApp {
drv = packages.tf-demo-parser;
exePath = "/bin/parse_demo";
};