Skip to content

Commit

Permalink
Merge pull request #2 from yvan-sraka/staticlib-build.rs
Browse files Browse the repository at this point in the history
Fix the need of `staticlib` target to have a `build.rs` customization
  • Loading branch information
yvan-sraka authored Mar 18, 2024
2 parents 16aa8f9 + b9a71ce commit 8a6a36a
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 8a6a36a

Please sign in to comment.