aboutsummaryrefslogtreecommitdiff
path: root/src/compiler.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-04-01 16:01:06 -0400
committerAndrew Kelley <andrew@ziglang.org>2020-04-01 16:01:06 -0400
commit783f73c7e3590f05825d66f1f0ccb108be74b5c4 (patch)
tree429e9e06852b06bd6758ab2bd7d53a240a71771c /src/compiler.cpp
parent6695fa4f326e807256b9afc6321e63a90b08e1ba (diff)
downloadzig-783f73c7e3590f05825d66f1f0ccb108be74b5c4.tar.gz
zig-783f73c7e3590f05825d66f1f0ccb108be74b5c4.zip
zig cc properly handles -S flag and .ll, .bc extensions
Diffstat (limited to 'src/compiler.cpp')
-rw-r--r--src/compiler.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/compiler.cpp b/src/compiler.cpp
index cddecc2025..8294fc7871 100644
--- a/src/compiler.cpp
+++ b/src/compiler.cpp
@@ -164,3 +164,25 @@ Buf *get_global_cache_dir(void) {
buf_deinit(&app_data_dir);
return &saved_global_cache_dir;
}
+
+FileExt classify_file_ext(const char *filename_ptr, size_t filename_len) {
+ if (mem_ends_with_str(filename_ptr, filename_len, ".c")) {
+ return FileExtC;
+ } else if (mem_ends_with_str(filename_ptr, filename_len, ".C") ||
+ mem_ends_with_str(filename_ptr, filename_len, ".cc") ||
+ mem_ends_with_str(filename_ptr, filename_len, ".cpp") ||
+ mem_ends_with_str(filename_ptr, filename_len, ".cxx"))
+ {
+ return FileExtCpp;
+ } else if (mem_ends_with_str(filename_ptr, filename_len, ".ll")) {
+ return FileExtLLVMIr;
+ } else if (mem_ends_with_str(filename_ptr, filename_len, ".bc")) {
+ return FileExtLLVMBitCode;
+ } else if (mem_ends_with_str(filename_ptr, filename_len, ".s") ||
+ mem_ends_with_str(filename_ptr, filename_len, ".S"))
+ {
+ return FileExtAsm;
+ }
+ // TODO look for .so, .so.X, .so.X.Y, .so.X.Y.Z
+ return FileExtUnknown;
+}