mirror of
https://codeberg.org/spire/nix.git
synced 2026-06-03 18:04:10 +02:00
add helper for includes
This commit is contained in:
parent
6e4a4d1ead
commit
06c8e7370f
3 changed files with 30 additions and 11 deletions
|
|
@ -40,5 +40,11 @@ buildSourcePawnScript {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
By default the sourcemod includes are available.
|
By default, the sourcemod includes are available.
|
||||||
|
|
||||||
Additional includes can be added by setting the `includes` argument to an array of packages containing an `include` folder containing the `.inc` files.
|
Additional includes can be added by setting the `includes` argument to an array of packages containing an `include` folder containing the `.inc` files.
|
||||||
|
A helper is provided to create include packages:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
sourcepawn.buildInclude [./cURL.inc ./cURL_header.inc]
|
||||||
|
```
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
sourcemod-includes,
|
|
||||||
sourcepawn,
|
sourcepawn,
|
||||||
which,
|
which,
|
||||||
}: {
|
}: {
|
||||||
|
|
@ -13,7 +12,7 @@
|
||||||
} @ args: let
|
} @ args: let
|
||||||
inherit (lib) optionals;
|
inherit (lib) optionals;
|
||||||
inherit (builtins) removeAttrs;
|
inherit (builtins) removeAttrs;
|
||||||
allIncludes = includes ++ optionals defaultIncludes [sourcemod-includes];
|
allIncludes = includes ++ optionals defaultIncludes [sourcepawn.includes.sourcemod];
|
||||||
forwardAttrs = removeAttrs args ["defaultIncludes" "includes" "entrypoint"];
|
forwardAttrs = removeAttrs args ["defaultIncludes" "includes" "entrypoint"];
|
||||||
spEnv = sourcepawn.buildEnv allIncludes;
|
spEnv = sourcepawn.buildEnv allIncludes;
|
||||||
outPathRelative =
|
outPathRelative =
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,11 @@
|
||||||
python3Packages,
|
python3Packages,
|
||||||
buildEnv,
|
buildEnv,
|
||||||
writeShellScriptBin,
|
writeShellScriptBin,
|
||||||
symlinkJoin
|
symlinkJoin,
|
||||||
|
sourcemod-includes,
|
||||||
|
runCommand,
|
||||||
}: let
|
}: let
|
||||||
|
inherit (builtins) concatStringsSep substring stringLength;
|
||||||
self = stdenv.mkDerivation rec {
|
self = stdenv.mkDerivation rec {
|
||||||
pname = "sourcepawn";
|
pname = "sourcepawn";
|
||||||
version = "1.11";
|
version = "1.11";
|
||||||
|
|
@ -41,7 +44,17 @@
|
||||||
cp spcomp/*/spcomp spshell/*/spshell verifier/*/verifier $out/bin
|
cp spcomp/*/spcomp spshell/*/spshell verifier/*/verifier $out/bin
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru.buildEnv = imports: let
|
passthru = {
|
||||||
|
buildInclude = let
|
||||||
|
fileNameForStorePath = path: substring 44 (stringLength path -44) path;
|
||||||
|
in files: runCommand "sourcepawn-include" {} ''
|
||||||
|
mkdir -p $out/include
|
||||||
|
${concatStringsSep "\n" (map (file: "cp ${file} $out/include/${fileNameForStorePath file}") files)}
|
||||||
|
'';
|
||||||
|
includes = {
|
||||||
|
sourcemod = sourcemod-includes;
|
||||||
|
};
|
||||||
|
buildEnv = imports: let
|
||||||
unwrapped = symlinkJoin {
|
unwrapped = symlinkJoin {
|
||||||
name = "sourcepawn-env-unwrapped";
|
name = "sourcepawn-env-unwrapped";
|
||||||
paths = imports ++ [self];
|
paths = imports ++ [self];
|
||||||
|
|
@ -50,11 +63,12 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
wrapped = writeShellScriptBin "spcomp" "exec -a $0 ${unwrapped}/bin/spcomp.unwrapped $@";
|
wrapped = writeShellScriptBin "spcomp" "exec -a $0 ${unwrapped}/bin/spcomp.unwrapped $@";
|
||||||
in symlinkJoin {
|
in
|
||||||
|
symlinkJoin {
|
||||||
name = "sourcepawn-env";
|
name = "sourcepawn-env";
|
||||||
paths = [unwrapped wrapped];
|
paths = [unwrapped wrapped];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
self
|
self
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue