diff --git a/CHANGELOG.md b/CHANGELOG.md index 6df509eb..7fbca431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,22 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 See [`UPGRADE.md`](./UPGRADE.md) for additional help when upgrading to newer versions. +## unreleased + +### Added + +- Create a workplace `Cargo.toml` file with `mix rustler.new` (#672) + +### Fixed + +### Changed + +### Removed + +- The linkage override for macOS is not needed anymore and has been removed from + the template (#672) + + ## [0.35.1] - 2024-12-18 ### Fixed diff --git a/rustler_mix/lib/mix/tasks/rustler.new.ex b/rustler_mix/lib/mix/tasks/rustler.new.ex index 5eb37fc4..d6d2ec82 100644 --- a/rustler_mix/lib/mix/tasks/rustler.new.ex +++ b/rustler_mix/lib/mix/tasks/rustler.new.ex @@ -14,7 +14,6 @@ defmodule Mix.Tasks.Rustler.New do """ @basic [ - {:eex, "basic/.cargo/config.toml", ".cargo/config.toml"}, {:eex, "basic/README.md", "README.md"}, {:eex, "basic/Cargo.toml.eex", "Cargo.toml"}, {:eex, "basic/src/lib.rs", "src/lib.rs"}, @@ -68,8 +67,14 @@ defmodule Mix.Tasks.Rustler.New do check_module_name_validity!(module) - path = Path.join([File.cwd!(), "native/", name]) + path = Path.join([File.cwd!(), "native", name]) new(otp_app, path, module, name, opts) + + # Create a Cargo workspace + File.write( + Path.join(path, "Cargo.toml"), + "[workspace]\nresolver = \"2\"\nmembers = [\"native/#{name}\"]\n" + ) end defp new(otp_app, path, module, name, _opts) do diff --git a/rustler_mix/priv/templates/basic/.cargo/config.toml b/rustler_mix/priv/templates/basic/.cargo/config.toml deleted file mode 100644 index 20f03f3d..00000000 --- a/rustler_mix/priv/templates/basic/.cargo/config.toml +++ /dev/null @@ -1,5 +0,0 @@ -[target.'cfg(target_os = "macos")'] -rustflags = [ - "-C", "link-arg=-undefined", - "-C", "link-arg=dynamic_lookup", -] diff --git a/rustler_mix/priv/templates/basic/Cargo.toml.eex b/rustler_mix/priv/templates/basic/Cargo.toml.eex index fd271cfe..bb3159e4 100644 --- a/rustler_mix/priv/templates/basic/Cargo.toml.eex +++ b/rustler_mix/priv/templates/basic/Cargo.toml.eex @@ -6,7 +6,6 @@ edition = "2021" [lib] name = "<%= library_name %>" -path = "src/lib.rs" crate-type = ["cdylib"] [dependencies]