aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorMarc Tiehuis <marctiehuis@gmail.com>2018-03-31 19:04:01 +1300
committerMarc Tiehuis <marctiehuis@gmail.com>2018-04-01 17:03:06 +1200
commit2e5115b0687ee9b7078dbf70da7d7070a7c80399 (patch)
tree23f3acc2db17931b0bbb2ef4837de7b06dcfcc25 /src/ir.cpp
parent67f11190d10caac1d08b76d60ec28eb2f5173946 (diff)
downloadzig-2e5115b0687ee9b7078dbf70da7d7070a7c80399.tar.gz
zig-2e5115b0687ee9b7078dbf70da7d7070a7c80399.zip
Add run compiler command
'zig run file.zig' builds a file and stores the artifacts in the global cache. On successful compilation the binary is executed. 'zig run file.zig -- a b c' does the same, but passes the arguments a, b and c as runtime arguments to the program. Everything after an '--' are treated as runtime arguments. On a posix system, a shebang can be used to run a zig file directly. An example shebang would be '#!/usr/bin/zig run'. You may not be able pass extra compile arguments currently as part of the shebang. Linux for example treats all arguments after the first as a single argument which will result in an 'invalid command'. Currently there is no customisability for the cache path as a compile argument. For a posix system you can use `TMPDIR=. zig run file.zig` to override, in this case using the current directory for the run cache. The input file is always recompiled, even if it has changed. This is intended to be cached but further discussion/thought needs to go into this. Closes #466.
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index 18fd02c297..4fe6769f78 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -14709,7 +14709,7 @@ static TypeTableEntry *ir_analyze_instruction_import(IrAnalyze *ira, IrInstructi
return ira->codegen->builtin_types.entry_namespace;
}
- if ((err = os_fetch_file_path(abs_full_path, import_code))) {
+ if ((err = os_fetch_file_path(abs_full_path, import_code, true))) {
if (err == ErrorFileNotFound) {
ir_add_error_node(ira, source_node,
buf_sprintf("unable to find '%s'", buf_ptr(import_target_path)));
@@ -15570,7 +15570,7 @@ static TypeTableEntry *ir_analyze_instruction_embed_file(IrAnalyze *ira, IrInstr
// load from file system into const expr
Buf *file_contents = buf_alloc();
int err;
- if ((err = os_fetch_file_path(&file_path, file_contents))) {
+ if ((err = os_fetch_file_path(&file_path, file_contents, false))) {
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;