Make assert messages more readable

Use lib.assertOneOf and lib.assertMsg
This commit is contained in:
Ryze 2024-09-20 22:27:44 +03:00
parent 30302d23ac
commit ec2fffc12f
Signed by: ryze
GPG key ID: 9B296C5CEAEAAAC1
2 changed files with 17 additions and 8 deletions

View file

@ -9,7 +9,16 @@
pkg:
assert builtins.elem optimizationLevel [ "O0" "O1" "O2" "O3" "Ofast" "Os" "Oz" "Og" ];
assert lib.assertOneOf "optimizationLevel" optimizationLevel [
"O0"
"O1"
"O2"
"O3"
"Ofast"
"Os"
"Oz"
"Og"
];
let
flags = [ "-${optimizationLevel}" ]

View file

@ -21,13 +21,13 @@
pkg:
assert builtins.elem opt-level [ "0" "1" "2" "3" "s" "z" ];
assert builtins.elem debug [ "none" "line-directives-only" "line-tables-only" "limited" "full" ];
assert builtins.elem split-debuginfo [ "off" "packed" "unpacked" ];
assert builtins.elem strip [ "none" "debuginfo" "symbols" ];
assert builtins.elem lto [ "off" "thin" "fat" ];
assert builtins.elem panic [ "unwind" "abort" ];
assert codegen-units > 0;
assert lib.assertOneOf "opt-level" opt-level [ "0" "1" "2" "3" "s" "z" ];
assert lib.assertOneOf "debug" debug [ "none" "line-directives-only" "line-tables-only" "limited" "full" ];
assert lib.assertOneOf "split-debug-info" split-debuginfo [ "off" "packed" "unpacked" ];
assert lib.assertOneOf "strip" strip [ "none" "debuginfo" "symbols" ];
assert lib.assertOneOf "lto" lto [ "off" "thin" "fat" ];
assert lib.assertOneOf "panic" panic [ "unwind" "abort" ];
assert lib.assertMsg (codegen-units > 0 && lib.mod codegen-units 1 == 0) "codegen-units must be a positive integer";
let
codegenOptions = [