Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to compile external module (erlang wrapper) with mix compile #6

Open
Simerax opened this issue May 18, 2021 · 0 comments
Open

Comments

@Simerax
Copy link

Simerax commented May 18, 2021

first of quick reminder: im very new to caramel and have only very limited experience with ocaml so maybe this problem is on my part

Bug Description

When trying to build a project, which contains multiple ml files I get errors that there are unbound modules. When building the files standalone with caramel compile everything works.

Project Layout

I have the standard layout provided by mix new
Additionally a new folder "src" in which I have put my .ml files

λ ~/code/local/caramel_external/ tree -L 2
.
├── _build
│   ├── caramel
│   └── dev
├── deps
│   └── mix_caramel
├── lib
│   └── caramel_external.ex
├── mix.exs
├── mix.lock
├── README.md
├── src
│   ├── rand.ml
│   └── user.ml
└── test
    ├── caramel_external_test.exs
    └── test_helper.exs

8 directories, 8 files

mix.exs

defmodule CaramelExternal.MixProject do
  use Mix.Project

  def project do
    [
      app: :caramel_external,
      version: "0.1.0",
      elixir: "~> 1.11",
      start_permanent: Mix.env() == :prod,
      deps: deps(),

      compilers: [:caramel] ++ Mix.compilers(),
      caramel_paths: ["src"],
      caramel_release: "v0.1.1"
    ]
  end

  # Run "mix help compile.app" to learn about applications.
  def application do
    [
      extra_applications: [:logger]
    ]
  end

  # Run "mix help deps" to learn about dependencies.
  defp deps do
    [
      {:mix_caramel, github: "AbstractMachinesLab/mix_caramel", branch: :main}
    ]
  end
end

user.ml

let do_rand () =
    Rand.uniform()

rand.ml

external uniform : unit -> float = ""

running mix compile:

λ ~/code/local/caramel_external/ mix compile
🍬 Using Caramel v0.1.1
Unbound module Rand

if I howerver compile the files directly the compilation succeeds

λ ~/code/local/caramel_external/src/ caramel compile user.ml rand.ml
Compiling user.erl	OK

after running caramel compile im also able to use the external function:
Yes I know it tries to recompile and fails but when failing it actually does not overwrite the previously created file...

λ ~/code/local/caramel_external/src/ caramel compile rand.ml user.ml
Compiling user.erl	OK
λ ~/code/local/caramel_external/src/ cd ..
λ ~/code/local/caramel_external/ iex -S mix
Erlang/OTP 23 [erts-11.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

🍬 Using Caramel v0.1.1
Unbound module Rand

Compiling 1 file (.erl)
Compiling 1 file (.ex)
Interactive Elixir (1.11.3) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> :user.do_rand
0.7062713648102463
iex(2)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant