Skip to content

Commit

Permalink
Fix the need of staticlib target to have a build.rs customization
Browse files Browse the repository at this point in the history
  • Loading branch information
yvan-sraka committed Mar 12, 2024
1 parent 16aa8f9 commit b9a71ce
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 24 deletions.
78 changes: 57 additions & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/cabal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ custom-setup
setup-depends: Cabal, base, directory, process"
};

let lib_name = name.replace('-', "_"); // In library generated by Cargo, '-' is replaced by '_'
let package_name = name.replace('_', "-"); // Cabal does not expect '_' for packages names

let extra = if enable_nix {
format!(
"
-- `haskell.nix` tell GHC linker where to find the `libNAME.a` by setting
-- automatically `extra-lib-dirs`:
-- https://input-output-hk.github.io/haskell.nix/tutorials/pkg-map.html
extra-libraries: {name}
extra-libraries: {lib_name}
-- Cross-compilation to target `x86_64-w64-mingw32-cc` thrown a lot of
-- `undefined reference to 'X'` errors during linking stage ...
Expand All @@ -32,7 +35,7 @@ custom-setup
format!(
"
-- Libraries that are bundled with the package.
extra-bundled-libraries: {name}"
extra-bundled-libraries: {lib_name}"
)
};

Expand All @@ -49,7 +52,7 @@ custom-setup
-- documentation, see: http://haskell.org/cabal/users-guide/
--
-- The name of the package.
name: {name}
name: {package_name}
-- The package version.
-- See the Haskell package versioning policy (PVP) for standards
Expand Down

0 comments on commit b9a71ce

Please sign in to comment.