1
1
mirror of https://github.com/nmattia/snack.git synced 2024-10-26 12:38:49 +03:00

Merge pull request #104 from nmattia/nm-exe-name

Force and infer executable names
This commit is contained in:
Nicolas Mattia 2019-01-30 19:39:16 +01:00 committed by GitHub
commit 443bb89c5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 7 deletions

View File

@ -27,15 +27,19 @@ rec {
buildLibrary = ghcWith: modSpecs:
buildModulesRec ghcWith {} modSpecs;
linkMainModule = ghcWith: mod: # main module
linkMainModule =
{ ghcWith
, moduleSpec # The module to build
, name # The name to give the executable
}:
let
objAttrs = buildMain ghcWith mod;
objAttrs = buildMain ghcWith moduleSpec;
objList = lib.attrsets.mapAttrsToList (x: y: y) objAttrs;
deps = allTransitiveDeps [mod];
deps = allTransitiveDeps [moduleSpec];
ghc = ghcWith deps;
ghcOptsArgs = lib.strings.escapeShellArgs mod.moduleGhcOpts;
ghcOptsArgs = lib.strings.escapeShellArgs moduleSpec.moduleGhcOpts;
packageList = map (p: "-package ${p}") deps;
relExePath = "bin/${lib.strings.toLower mod.moduleName}";
relExePath = "bin/${name}";
drv = runCommand "linker" {}
''
mkdir -p $out/bin

View File

@ -41,7 +41,10 @@ let
buildLibrary ghcWith (libraryModSpecs pkgSpec);
buildAsExecutable = pkgSpec:
let drv = linkMainModule ghcWith (executableMainModSpec pkgSpec);
let
moduleSpec = executableMainModSpec pkgSpec;
name = pkgSpec.packageName;
drv = linkMainModule { inherit moduleSpec name ghcWith; };
in
{ out = drv.out;
exe_path = "${drv.out}/${drv.relExePath}";

View File

@ -18,8 +18,16 @@ rec {
, extra-directories ? []
, packages ? []
}:
with
rec {
isExe = ! builtins.isNull main;
pName =
if isExe && builtins.isNull name
then lib.strings.toLower main
else name;
};
{ packageIsExe = ! builtins.isNull main;
packageName = name;
packageName = pName;
packageMain = main;
packageSourceDirs =
if builtins.isList src