Skip to content

Commit

Permalink
fix: library std code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmasoldi3r committed Dec 26, 2023
1 parent 64f7376 commit 786e595
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 12 additions & 8 deletions janus/src/compilation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,19 @@ impl CompilationHost {
.arg("-o")
.arg(&out);
// If not the main file, skip the STD header injection
match &info.main {
PathBufOrPathBufList::PathBuf(main) => {
if main != file_path {
cmd.arg("--no-std");
if info.no_std || info.mode == CompilationMode::Lib {
cmd.arg("--no-std");
} else {
match &info.main {
PathBufOrPathBufList::PathBuf(main) => {
if main != file_path {
cmd.arg("--no-std");
}
}
}
PathBufOrPathBufList::PathBufList(mains) => {
if !mains.contains(file_path) {
cmd.arg("--no-std");
PathBufOrPathBufList::PathBufList(mains) => {
if !mains.contains(file_path) {
cmd.arg("--no-std");
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/lua/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/// Generates the given source as a virtual module, used by Lua target.
pub fn generate_module_chunk(name: &String, source: &String) -> String {
let tmp = format!("_G[\"__saturnus_module_{name}\"]");
let tmp = format!("__saturnus_module_{name}");
format!(
"{tmp} = function()
"local {tmp} = function()
{source}
end;
if jit then
Expand Down

0 comments on commit 786e595

Please sign in to comment.