aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-09-10 13:46:23 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-09-10 13:46:23 -0400
commit32be6e9b2a9e6de501aadbe271c554a4682a10f8 (patch)
treeee37daa15c6e8c2d3a3a9dafc30c060eb52ca10c /src/ir.cpp
parentfbe5737c84c783cd31e6e2d595fc47eb782c5e3c (diff)
downloadzig-32be6e9b2a9e6de501aadbe271c554a4682a10f8.tar.gz
zig-32be6e9b2a9e6de501aadbe271c554a4682a10f8.zip
caching is working
* add almost all the input parameter state to the hash - missing items are the detected MSVC installation on Windows and detected libc installation on POSIX - also missing are C files and .h files that libclang finds * artifacts are created in global cache directory instead of zig-cache. - exception: builtin.zig is still in zig-cache * zig run uses the new cache correctly * zig run uses execv on posix systems
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 0269c29b1a..22d9a9bc49 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -16232,6 +16232,8 @@ static ZigType *ir_analyze_instruction_union_tag(IrAnalyze *ira, IrInstructionUn
}
static ZigType *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImport *import_instruction) {
+ Error err;
+
IrInstruction *name_value = import_instruction->name->other;
Buf *import_target_str = ir_resolve_str(ira, name_value);
if (!import_target_str)
@@ -16275,8 +16277,7 @@ static ZigType *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImpor
return ira->codegen->builtin_types.entry_namespace;
}
- int err;
- if ((err = os_fetch_file_path(resolved_path, import_code, true))) {
+ if ((err = cache_add_file_fetch(&ira->codegen->cache_hash, resolved_path, import_code))) {
if (err == ErrorFileNotFound) {
ir_add_error_node(ira, source_node,
buf_sprintf("unable to find '%s'", buf_ptr(import_target_path)));
@@ -16287,6 +16288,7 @@ static ZigType *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructionImpor
return ira->codegen->builtin_types.entry_invalid;
}
}
+
ImportTableEntry *target_import = add_source_file(ira->codegen, target_package, resolved_path, import_code);
scan_import(ira->codegen, target_import);
@@ -18106,7 +18108,7 @@ static ZigType *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionE
// load from file system into const expr
Buf *file_contents = buf_alloc();
int err;
- if ((err = os_fetch_file_path(&file_path, file_contents, false))) {
+ if ((err = cache_add_file_fetch(&ira->codegen->cache_hash, &file_path, file_contents))) {
if (err == ErrorFileNotFound) {
ir_add_error(ira, instruction->name, buf_sprintf("unable to find '%s'", buf_ptr(&file_path)));
return ira->codegen->builtin_types.entry_invalid;
@@ -18116,9 +18118,6 @@ static ZigType *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstructionE
}
}
- // TODO add dependency on the file we embedded so that we know if it changes
- // we'll have to invalidate the cache
-
ConstExprValue *out_val = ir_build_const_from(ira, &instruction->base);
init_const_str_lit(ira->codegen, out_val, file_contents);