Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
LostKobrakai committed Oct 30, 2024
1 parent c59f9ab commit 81ce392
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion compiler-cli/templates/gleam@@compile.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ compile_package_loop() ->
PrintModuleName = fun(ModuleName) ->
io:put_chars("module:" ++ atom_to_list(ModuleName) ++ "\n")
end,
list:map(PrintModuleName, ModuleNames),
lists:map(PrintModuleName, ModuleNames),
io:put_chars("gleam-compile-result-ok\n");
err ->
io:put_chars("gleam-compile-result-error\n")
Expand Down
28 changes: 13 additions & 15 deletions compiler-core/src/build/package_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,36 +337,34 @@ where
tracing::debug!("skipping_native_file_copying");
}

if self.compile_beam_bytecode && self.write_entrypoint {
self.render_erlang_entrypoint_module(&build_dir, &mut written)?;
} else {
tracing::debug!("skipping_entrypoint_generation");
}

// NOTE: This must come after `copy_project_native_files` to ensure that
// we overwrite any precompiled Erlang that was included in the Hex
// package. Otherwise we will build the potentially outdated precompiled
// version and not the newly compiled version.
Erlang::new(&build_dir, &include_dir).render(io.clone(), modules)?;

if self.compile_beam_bytecode {
written.extend(modules.iter().map(Module::compiled_erlang_path));
native_modules = self.compile_erlang_to_beam(&written)?;
println!("{:?}", native_modules);
} else {
tracing::debug!("skipping_erlang_bytecode_compilation");
native_modules = Vec::new();
}

if let Some(config) = app_file_config {
ErlangApp::new(&self.out.join("ebin"), config).render(
io.clone(),
io,
&self.config,
modules,
native_modules,
)?;
}

if self.compile_beam_bytecode && self.write_entrypoint {
self.render_erlang_entrypoint_module(&build_dir, &mut written)?;
} else {
tracing::debug!("skipping_entrypoint_generation");
}

// NOTE: This must come after `copy_project_native_files` to ensure that
// we overwrite any precompiled Erlang that was included in the Hex
// package. Otherwise we will build the potentially outdated precompiled
// version and not the newly compiled version.
Erlang::new(&build_dir, &include_dir).render(io, modules)?;

Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions compiler-core/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl<'a> ErlangApp<'a> {
.iter()
.map(|m| m.name.replace("/", "@"))
.chain(native_modules)
.unique()
.sorted()
.join(",\n ");

Expand Down
6 changes: 2 additions & 4 deletions compiler-core/src/io/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,7 @@ impl BeamCompiler for InMemoryFileSystem {
_modules: &HashSet<Utf8PathBuf>,
_stdio: Stdio,
) -> Result<Vec<String>, Error> {
// What to do here
let mut l: Vec<String> = Vec::new();
l.push(String::from("erlffi"));
Ok(l) // Always succeed.
// What to do here?
Ok(Vec::new()) // Always succeed.
}
}

This file was deleted.

3 changes: 1 addition & 2 deletions test-package-compiler/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn prepare(path: &str) -> String {
);
compiler.write_entrypoint = false;
compiler.write_metadata = true;
compiler.compile_beam_bytecode = true;
compiler.compile_beam_bytecode = false;
compiler.copy_native_files = false;
let result = compiler.compile(
&warning_emitter,
Expand All @@ -78,7 +78,6 @@ pub fn prepare(path: &str) -> String {
filesystem.delete_file(&path).unwrap();
}
let files = filesystem.into_contents();
println!("{:?}", files);
let warnings = warnings.take();
TestCompileOutput { files, warnings }.as_overview_text()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ expression: "./cases/erlang_app_generation"
simple_json,
ssl]},
{description, "It's very cool"},
{modules, [main,
erlffi]},
{modules, [main]},
{registered, []}
]}.
4 changes: 4 additions & 0 deletions test/external_only_erlang/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ if g run --target=javascript; then
exit 1
fi

echo Running erlang shippment should succeed
g export erlang-shipment
grep "external_only_erlang_ffi" "build/erlang-shipment/external_only_erlang/ebin/external_only_erlang.app"

echo
echo Success! 💖
echo

0 comments on commit 81ce392

Please sign in to comment.