Bug fixes

This commit is contained in:
2026-01-02 21:04:42 +00:00
parent 6ce1c89e4b
commit 3b8bcf29cd

View File

@@ -1586,26 +1586,29 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
char* libName = in->args.args[0].value.value.data.stringVal;
char path[1024];
int found = 0;
// care about mac and windows later
char* extension = "so";
char* envPath = getenv("GROUND_LIBS");
if (envPath) {
snprintf(path, sizeof(path), "%s/%s", envPath, libName);
snprintf(path, sizeof(path), "%s/%s.%s", envPath, libName, extension);
if (access(path, F_OK) == 0) found = 1;
}
if (!found) {
snprintf(path, sizeof(path), "/usr/lib/ground/%s", libName);
snprintf(path, sizeof(path), "/usr/lib/ground/%s.%s", libName, extension);
if (access(path, F_OK) == 0) found = 1;
}
if (!found) {
snprintf(path, sizeof(path), "./%s", libName);
snprintf(path, sizeof(path), "./%s.%s", libName, extension);
if (access(path, F_OK) == 0) found = 1;
}
if (!found) {
char errorMsg[1100];
snprintf(errorMsg, sizeof(errorMsg), "Could not find external library: %s", libName);
snprintf(errorMsg, sizeof(errorMsg), "Could not find external library: %s, in path: %s", libName, path);
runtimeError(FIXME, errorMsg, in, currentInstruction);
}