diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-03-17 20:17:37 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-03-17 20:17:37 -0400 |
| commit | 7f525588cb1e5f1b56e79e4c0407b909b4b5ff52 (patch) | |
| tree | 027af07c3fb1a39d9d9f2f6314332a8d4f7ec8f7 /compile.c | |
| parent | 4c2d3c68df922ad45c9a0371bafabaa2504fe070 (diff) | |
Move to using a .build/ folder for generated files instead of foo.tm.c
in the same folder
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -14,6 +14,7 @@ #include "environment.h" #include "stdlib/integers.h" #include "stdlib/nums.h" +#include "stdlib/paths.h" #include "stdlib/patterns.h" #include "stdlib/text.h" #include "stdlib/util.h" @@ -4214,8 +4215,10 @@ CORD compile_top_level_code(env_t *env, ast_t *ast) switch (ast->tag) { case Use: { auto use = Match(ast, Use); - if (use->what == USE_C_CODE) - return CORD_all("#include \"", use->path, "\"\n"); + if (use->what == USE_C_CODE) { + Path_t path = Path$relative_to(Path$from_str(use->path), Path(".build")); + return CORD_all("#include \"", Path$as_c_string(path), "\"\n"); + } return CORD_EMPTY; } case Declare: { @@ -4387,8 +4390,12 @@ CORD compile_statement_type_header(env_t *env, ast_t *ast) case USE_MODULE: { return CORD_all("#include <", use->path, "/", use->path, ".h>\n"); } - case USE_LOCAL: - return CORD_all("#include \"", use->path, ".h\"\n"); + case USE_LOCAL: { + Path_t path = Path$relative_to(Path$from_str(use->path), Path(".build")); + Path_t build_dir = Path$with_component(Path$parent(path), Text(".build")); + path = Path$with_component(build_dir, Texts(Path$base_name(path), Text(".h"))); + return CORD_all("#include \"", Path$as_c_string(path), "\"\n"); + } case USE_HEADER: if (use->path[0] == '<') return CORD_all("#include ", use->path, "\n"); |
