Skip to content

Commit

Permalink
compiler: Add handling of source dir prefix in C code gen
Browse files Browse the repository at this point in the history
DCO-1.1-Signed-off-by: Ellie <[email protected]>
  • Loading branch information
ell1e committed Sep 17, 2024
1 parent d7659f3 commit 789160d
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/compiler/moose64/codegen/c_gen.h64
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,14 @@ func CExportTracker.generate_c_types_header_str(
include_project_files_set.add(entry.project_file)
var target_path = entry.project_file.
modinfo.rel_path
if project_file.project.source_dir_prefix != none and
project_file.project.
source_dir_prefix.len > 0 {
target_path = path.join(
project_file.project.source_dir_prefix,
target_path
)
}
target_path += ".h"
t_m64_include_str += "\n#include " +
textfmt.as_escaped_code_string(
Expand Down Expand Up @@ -1165,9 +1173,20 @@ func get_c_output_uri_from_project_file(
source_dir_prefix + path.sep).len
)
}
if file_relpath.starts(path.sep) {
file_relpath = file_relpath.sub(2)
}
} else {
file_relpath = "unnamed_code_file.m64"
}
if project_file.project.source_dir_prefix != none and
project_file.project.
source_dir_prefix.len > 0 {
file_relpath = path.join(
project_file.project.source_dir_prefix,
file_relpath
)
}
file_relpath = path.normalize(file_relpath + ".c")
if name_as_temp_file {
var fname = path.basename(file_relpath)
Expand Down

0 comments on commit 789160d

Please sign in to comment.