Skip to content

Commit 638b8a3

Browse files
committed
Expand gleam deps deps paths
Otherwise they are calculated from the current mix project and won't be found.
1 parent b75dc61 commit 638b8a3

File tree

10 files changed

+67
-12
lines changed

10 files changed

+67
-12
lines changed

lib/mix/lib/mix/gleam.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ defmodule Mix.Gleam do
4545
{dep, version, opts}
4646

4747
%{"path" => path} ->
48-
{dep, Keyword.merge(opts, path: path)}
48+
{dep, Keyword.merge(opts, path: Path.expand(path))}
4949

5050
%{"git" => git, "ref" => ref} ->
5151
{dep, git: git, ref: ref}

lib/mix/lib/mix/tasks/deps.compile.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ defmodule Mix.Tasks.Deps.Compile do
371371
build_path: Mix.Project.build_path() |> Path.split() |> Enum.drop(-1) |> Path.join(),
372372
deps_path: deps_path,
373373
erlc_paths: [src],
374+
elixirc_paths: [src],
374375
erlc_include_path: Path.join(build, "include")
375376
]
376377

lib/mix/test/fixtures/gleam_dep/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# The directory Mix will write compiled artifacts to.
22
/_build/
33

4+
# The directory gleam will write compiled artifacts to.
5+
/build/
6+
47
# If the VM crashes, it generates a dump, let's ignore it too.
58
erl_crash.dump
69

lib/mix/test/fixtures/gleam_dep/gleam.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ gleeunit = ">= 1.0.0 and < 2.0.0"
2121

2222
[erlang]
2323
extra_applications = ["ssl"]
24-
application_start_module = "gleam_dep@somemodule"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# The directory Mix will write compiled artifacts to.
2+
/_build/
3+
4+
# The directory gleam will write compiled artifacts to.
5+
/build/
6+
7+
# If the VM crashes, it generates a dump, let's ignore it too.
8+
erl_crash.dump
9+
10+
# BEAM bytecode files.
11+
*.beam
12+
13+
# Also ignore archive artifacts (built via "mix archive.build").
14+
*.ez
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name = "deeper_gleam_dep"
2+
version = "1.0.0"
3+
4+
# Fill out these fields if you intend to generate HTML documentation or publish
5+
# your project to the Hex package manager.
6+
#
7+
# description = ""
8+
# licences = ["Apache-2.0"]
9+
# repository = { type = "github", user = "", repo = "" }
10+
# links = [{ title = "Website", href = "" }]
11+
#
12+
# For a full reference of all the available options, you can have a look at
13+
# https://gleam.run/writing-gleam/gleam-toml/.
14+
15+
[dependencies]
16+
gleam_dep = { path = "../../gleam_dep" }
17+
gleam_stdlib = ">= 0.59.0 and < 1.0.0"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# This file was generated by Gleam
2+
# You typically do not need to edit this file
3+
4+
packages = [
5+
{ name = "gleam_dep", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_otp", "gleam_stdlib"], source = "local", path = "../../gleam_dep" },
6+
{ name = "gleam_erlang", version = "0.34.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "0C38F2A128BAA0CEF17C3000BD2097EB80634E239CE31A86400C4416A5D0FDCC" },
7+
{ name = "gleam_otp", version = "0.16.1", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "50DA1539FC8E8FA09924EB36A67A2BBB0AD6B27BCDED5A7EF627057CF69D035E" },
8+
{ name = "gleam_stdlib", version = "0.59.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "F8FEE9B35797301994B81AF75508CF87C328FE1585558B0FFD188DC2B32EAA95" },
9+
]
10+
11+
[requirements]
12+
gleam_dep = { path = "../../gleam_dep" }
13+
gleam_stdlib = { version = ">= 0.59.0 and < 1.0.0" }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import gleam_dep
2+
3+
pub fn main() -> Bool {
4+
gleam_dep.main()
5+
}

lib/mix/test/mix/gleam_test.exs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ defmodule Mix.GleamTest do
88
use MixTest.Case
99
@moduletag :gleam
1010

11-
@compile {:no_warn_undefined, [:gleam_dep, :gleam@int]}
11+
@compile {:no_warn_undefined, [:gleam_dep, :gleam@int, :deeper_gleam_dep]}
1212

1313
defmodule GleamAsDep do
1414
def project do
1515
[
1616
app: :gleam_as_dep,
1717
version: "0.1.0",
1818
deps: [
19-
{:gleam_dep, path: MixTest.Case.tmp_path("gleam_dep"), app: false}
19+
{:deeper_gleam_dep, path: MixTest.Case.tmp_path("subfolder/deeper_gleam_dep")}
2020
]
2121
]
2222
end
@@ -46,8 +46,7 @@ defmodule Mix.GleamTest do
4646
"gleam" => ">= 1.8.0",
4747
"dependencies" => %{
4848
"git_dep" => %{"git" => "../git_dep", "ref" => "957b83b"},
49-
"gleam_stdlib" => %{"version" => ">= 0.18.0 and < 2.0.0"},
50-
"my_other_project" => %{"path" => "../my_other_project"}
49+
"gleam_stdlib" => %{"version" => ">= 0.18.0 and < 2.0.0"}
5150
},
5251
"dev-dependencies" => %{
5352
"gleeunit" => %{"version" => ">= 1.0.0 and < 2.0.0"}
@@ -66,7 +65,6 @@ defmodule Mix.GleamTest do
6665
deps: [
6766
{:git_dep, git: "../git_dep", ref: "957b83b"},
6867
{:gleam_stdlib, ">= 0.18.0 and < 2.0.0"},
69-
{:my_other_project, path: "../my_other_project"},
7068
{:gleeunit, ">= 1.0.0 and < 2.0.0", only: :dev}
7169
],
7270
application: [
@@ -90,6 +88,7 @@ defmodule Mix.GleamTest do
9088
assert :gleam_dep.main()
9189
assert :gleam_dep.erl() == ~c'Hello from Collocated Erlang!'
9290
assert :gleam@int.to_string(1) == "1"
91+
assert :deeper_gleam_dep.main()
9392

9493
{:ok, content} = :file.consult("_build/dev/lib/gleam_dep/ebin/gleam_dep.app")
9594

@@ -108,6 +107,8 @@ defmodule Mix.GleamTest do
108107
]
109108
}
110109
]
110+
111+
assert File.exists?("_build/dev/lib/deeper_gleam_dep/ebin/deeper_gleam_dep.app")
111112
end)
112113
end
113114
end

lib/mix/test/test_helper.exs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,12 +287,14 @@ end)
287287

288288
## Set up Gleam fixtures
289289

290-
fixture = "gleam_dep"
290+
fixtures = ~w(gleam_dep subfolder)
291291

292-
source = MixTest.Case.fixture_path(fixture)
293-
dest = MixTest.Case.tmp_path(fixture)
294-
File.mkdir_p!(dest)
295-
File.cp_r!(source, dest)
292+
Enum.each(fixtures, fn fixture ->
293+
source = MixTest.Case.fixture_path(fixture)
294+
dest = MixTest.Case.tmp_path(fixture)
295+
File.mkdir_p!(dest)
296+
File.cp_r!(source, dest)
297+
end)
296298

297299
## Set up Git fixtures
298300

0 commit comments

Comments
 (0)