on iko/ghcjs-patch-master help sign in
More component configuration options (#336)

* allow patchelf, stripping binaries, static building, dead code eliminiation, and other doc flags to be controlled via component options * add ability to turn off shared libraries

commit1de76b7b1ab3b9b615df90c9ea6765e0deb2e6e2 authorRichard Wallace <richard.wallace@simspace.com> dateTue 3 Dec 2019, 19:21 (7 years ago) parent0b36398
2 files changed+54−12
builder/comp-builder.nix+19−12 modules/plan.nix+35
builder/comp-builder.nix+19−12
@@ -20,16 +20,17 @@
2020, preHaddock ? component.preHaddock , postHaddock ? component.postHaddock
2121, shellHook ? ""
2222
23−, dontPatchELF ? true
24−, dontStrip ? true
23+, dontPatchELF ? component.dontPatchELF
24+, dontStrip ? component.dontStrip
2525
26−, static ? stdenv.hostPlatform.isMusl
27−, deadCodeElimination ? true
26+, enableStatic ? component.enableStatic
27+, enableShared ? component.enableShared
28+, enableDeadCodeElimination ? component.enableDeadCodeElimination
2829
2930# Options for Haddock generation
3031, doHaddock ? component.doHaddock # Enable haddock and hoogle generation
31−, doHoogle ? true # Also build a hoogle index
32−, hyperlinkSource ? true # Link documentation to the source code
32+, doHoogle ? component.doHoogle # Also build a hoogle index
33+, hyperlinkSource ? component.doHyperlinkSource # Link documentation to the source code
3334
3435# Profiling
3536, enableLibraryProfiling ? component.enableLibraryProfiling
@@ -55,6 +56,11 @@ let
5556 inherit component fullName flags;
5657 };
5758
59+ enableFeature = enable: feature:
60+ (if enable then "--enable-" else "--disable-") + feature;
61+
62+ disableFeature = disable: enableFeature (!disable);
63+
5864 finalConfigureFlags = lib.concatStringsSep " " (
5965 [ "--prefix=$out"
6066 "${haskellLib.componentTarget componentId}"
@@ -82,15 +88,16 @@ let
8288 "--with-strip=${stdenv.cc.bintools.targetPrefix}strip"
8389 ]
8490 ) ++ [ # other flags
85− (if dontStrip then "--disable-executable-stripping" else "--enable-executable-stripping")
86− (if dontStrip then "--disable-library-stripping" else "--enable-library-stripping")
87− (if enableLibraryProfiling then "--enable-library-profiling" else "--disable-library-profiling" )
88− (if enableExecutableProfiling then "--enable-executable-profiling" else "--disable-executable-profiling" )
91+ (disableFeature dontStrip "executable-stripping")
92+ (disableFeature dontStrip "library-stripping")
93+ (enableFeature enableLibraryProfiling "library-profiling")
94+ (enableFeature enableExecutableProfiling "executable-profiling")
95+ (enableFeature enableStatic "static")
96+ (enableFeature enableShared "shared")
8997 ] ++ lib.optional enableSeparateDataOutput "--datadir=$data/share/${ghc.name}"
9098 ++ lib.optional doHaddock' "--docdir=${docdir "$doc"}"
9199 ++ lib.optional (enableLibraryProfiling || enableExecutableProfiling) "--profiling-detail=${profilingDetail}"
92− ++ lib.optional (deadCodeElimination && stdenv.hostPlatform.isLinux) "--enable-split-sections"
93− ++ lib.optional (static) "--enable-static"
100+ ++ lib.optional stdenv.hostPlatform.isLinux (enableFeature enableDeadCodeElimination "split-sections")
94101 ++ lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) (
95102 map (arg: "--hsc2hs-option=" + arg) (["--cross-compile"] ++ lib.optionals (stdenv.hostPlatform.isWindows) ["--via-asm"])
96103 ++ lib.optional (package.buildType == "Configure") "--configure-option=--host=${stdenv.hostPlatform.config}" )
modules/plan.nix+35
@@ -93,6 +93,41 @@ let
9393 type = bool;
9494 default = (def.doHaddock or true);
9595 };
96+ doHoogle = mkOption {
97+ description = "Also build a hoogle index.";
98+ type = bool;
99+ default = (def.doHoogle or true);
100+ };
101+ doHyperlinkSource = mkOption {
102+ description = "Link documentation to the source code.";
103+ type = bool;
104+ default = (def.doHoogle or true);
105+ };
106+ dontPatchELF = mkOption {
107+ description = "If set, the patchelf command is not used to remove unnecessary RPATH entries. Only applies to Linux.";
108+ type = bool;
109+ default = (def.dontPatchELF or true);
110+ };
111+ dontStrip = mkOption {
112+ description = "If set, libraries and executables are not stripped.";
113+ type = bool;
114+ default = (def.dontStrip or true);
115+ };
116+ enableDeadCodeElimination = mkOption {
117+ description = "If set, enables split sections for link-time dead-code stripping. Only applies to Linux";
118+ type = bool;
119+ default = (def.enableDeadCodeElimination or true);
120+ };
121+ enableStatic = mkOption {
122+ description = "If set, enables building static libraries and executables.";
123+ type = bool;
124+ default = (def.enableStatic or true);
125+ };
126+ enableShared = mkOption {
127+ description = "If set, enables building shared libraries.";
128+ type = bool;
129+ default = (def.enableShared or true);
130+ };
96131 shellHook = mkOption {
97132 description = "Hook to run when entering a shell";
98133 type = unspecified; # Can be either a string or a function