diff options
| author | vassvik <mvassvik@gmail.com> | 2017-11-10 21:31:13 +0100 |
|---|---|---|
| committer | vassvik <mvassvik@gmail.com> | 2017-11-10 21:31:13 +0100 |
| commit | 9e0b69312b949f6f0e1e1851db3ecb79be25cfa1 (patch) | |
| tree | 5228118ba4ce80d0186380082bb319971480175f /src/parser.cpp | |
| parent | bbddbba34062b18eba6b6ce53b31a350e0816ff1 (diff) | |
Fixed foreign import for linux. Modified .gitignore to ignore temp files and files in shared/. Added a Makefile for linux
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index f81bb1a39..1c90bf274 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -4880,7 +4880,22 @@ bool determine_path_from_string(Parser *p, AstNode *node, String base_dir, Strin syntax_error(node, "Unknown library collection: `%.*s`", LIT(collection_name)); return false; } + } else { +#if !defined(GB_SYSTEM_WINDOWS) + // @NOTE(vassvik): foreign imports of shared libraries that are not in the system collection on + // linux/mac have to be local to the executable for consistency with shared libraries. + // Unix does not have a concept of "import library" for shared/dynamic libraries, + // so we need to pass the relative path to the linker, and add the current + // working directory of the exe to the library search paths. + // Static libraries can be linked directly with the full pathname + // + if (node->kind == AstNode_ForeignImportDecl && string_has_extension(file_str, str_lit("so"))) { + *path = file_str; + return true; + } +#endif } + String fullpath = string_trim_whitespace(get_fullpath_relative(a, base_dir, file_str)); *path = fullpath; |