void parrot_init_library_paths(PARROT_INTERP) { ASSERT_ARGS(parrot_init_library_paths) PMC *paths; STRING *entry; STRING *versionlib = NULL; STRING *builddir = NULL; PMC * const iglobals = interp->iglobals; PMC * const config_hash = VTABLE_get_pmc_keyed_int(interp, iglobals, (INTVAL)IGLOBALS_CONFIG_HASH); /* create the lib_paths array */ PMC * const lib_paths = Parrot_pmc_new_init_int(interp, enum_class_FixedPMCArray, PARROT_LIB_PATH_SIZE); VTABLE_set_pmc_keyed_int(interp, iglobals, IGLOBALS_LIB_PATHS, lib_paths); if (VTABLE_elements(interp, config_hash)) { STRING * const libkey = CONST_STRING(interp, "libdir"); STRING * const verkey = CONST_STRING(interp, "versiondir"); STRING * const builddirkey = CONST_STRING(interp, "build_dir"); STRING * const installed = CONST_STRING(interp, "installed"); versionlib = VTABLE_get_string_keyed_str(interp, config_hash, libkey); entry = VTABLE_get_string_keyed_str(interp, config_hash, verkey); versionlib = Parrot_str_concat(interp, versionlib, entry); if (!VTABLE_get_integer_keyed_str(interp, config_hash, installed)) builddir = VTABLE_get_string_keyed_str(interp, config_hash, builddirkey); } /* each is an array of strings */ /* define include paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_INCLUDE, paths); { /* EXPERIMENTAL: add include path from environment */ const char *envvar = Parrot_getenv(interp, Parrot_str_new_constant(interp, "PARROT_INCLUDE")); if (envvar != NULL && envvar[0]) { entry = Parrot_str_new(interp, envvar, 0); VTABLE_push_string(interp, paths, entry); } } if (!STRING_IS_NULL(builddir)) { entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/")); VTABLE_push_string(interp, paths, entry); entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/runtime/parrot/include/")); VTABLE_push_string(interp, paths, entry); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); if (!STRING_IS_NULL(versionlib)) { entry = Parrot_str_concat(interp, versionlib, CONST_STRING(interp, "/include/")); VTABLE_push_string(interp, paths, entry); } /* define library paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_LIBRARY, paths); { /* EXPERIMENTAL: add library path from environment */ const char *envvar = Parrot_getenv(interp, Parrot_str_new_constant(interp, "PARROT_LIBRARY")); if (envvar != NULL && envvar[0]) { entry = Parrot_str_new(interp, envvar, 0); VTABLE_push_string(interp, paths, entry); } } if (!STRING_IS_NULL(builddir)) { entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/runtime/parrot/library/")); VTABLE_push_string(interp, paths, entry); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); if (!STRING_IS_NULL(versionlib)) { entry = Parrot_str_concat(interp, versionlib, CONST_STRING(interp, "/library/")); VTABLE_push_string(interp, paths, entry); } /* define languages paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_LANG, paths); if (!STRING_IS_NULL(builddir)) { entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/runtime/parrot/languages/")); VTABLE_push_string(interp, paths, entry); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); if (!STRING_IS_NULL(versionlib)) { entry = Parrot_str_concat(interp, versionlib, CONST_STRING(interp, "/languages/")); VTABLE_push_string(interp, paths, entry); } /* define dynext paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_DYNEXT, paths); if (!STRING_IS_NULL(builddir)) { entry = Parrot_str_concat(interp, builddir, CONST_STRING(interp, "/runtime/parrot/dynext/")); VTABLE_push_string(interp, paths, entry); } entry = CONST_STRING(interp, "dynext/"); VTABLE_push_string(interp, paths, entry); if (!STRING_IS_NULL(versionlib)) { entry = Parrot_str_concat(interp, versionlib, CONST_STRING(interp, "/dynext/")); VTABLE_push_string(interp, paths, entry); } /* shared exts */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_DYN_EXTS, paths); /* no CONST_STRING here - the c2str.pl preprocessor needs "real strs" */ entry = Parrot_str_new_constant(interp, PARROT_LOAD_EXT); VTABLE_push_string(interp, paths, entry); /* OS/X has .dylib and .bundle */ if (!STREQ(PARROT_LOAD_EXT, PARROT_SHARE_EXT)) { entry = Parrot_str_new_constant(interp, PARROT_SHARE_EXT); VTABLE_push_string(interp, paths, entry); } #ifdef PARROT_PLATFORM_LIB_PATH_INIT_HOOK PARROT_PLATFORM_LIB_PATH_INIT_HOOK(interp, lib_paths); #endif }
void parrot_init_library_paths(PARROT_INTERP) { ASSERT_ARGS(parrot_init_library_paths) PMC *paths; STRING *entry; PMC * const iglobals = interp->iglobals; /* create the lib_paths array */ PMC * const lib_paths = Parrot_pmc_new_init_int(interp, enum_class_FixedPMCArray, PARROT_LIB_PATH_SIZE); VTABLE_set_pmc_keyed_int(interp, iglobals, IGLOBALS_LIB_PATHS, lib_paths); /* each is an array of strings */ /* define include paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_INCLUDE, paths); { /* EXPERIMENTAL: add include path from environment */ STRING *envvar = Parrot_getenv(interp, CONST_STRING(interp, "PARROT_INCLUDE")); Parrot_warn_experimental(interp, "PARROT_INCLUDE environment variable is experimental"); if (!STRING_IS_NULL(envvar) && !STRING_IS_EMPTY(envvar)) VTABLE_push_string(interp, paths, envvar); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); /* define library paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_LIBRARY, paths); { /* EXPERIMENTAL: add library path from environment */ STRING *envvar = Parrot_getenv(interp, CONST_STRING(interp, "PARROT_LIBRARY")); Parrot_warn_experimental(interp, "PARROT_LIBRARY environment variable is experimental"); if (!STRING_IS_NULL(envvar) && !STRING_IS_EMPTY(envvar)) VTABLE_push_string(interp, paths, envvar); } entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); /* define languages paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_LANG, paths); entry = CONST_STRING(interp, "./"); VTABLE_push_string(interp, paths, entry); /* define dynext paths */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_PATH_DYNEXT, paths); entry = CONST_STRING(interp, "dynext/"); VTABLE_push_string(interp, paths, entry); /* shared exts */ paths = Parrot_pmc_new(interp, enum_class_ResizableStringArray); VTABLE_set_pmc_keyed_int(interp, lib_paths, PARROT_LIB_DYN_EXTS, paths); /* no CONST_STRING here - the c2str.pl preprocessor needs "real strs" */ entry = Parrot_str_new_constant(interp, PARROT_LOAD_EXT); VTABLE_push_string(interp, paths, entry); /* OS/X has .dylib and .bundle */ if (!STREQ(PARROT_LOAD_EXT, PARROT_SHARE_EXT)) { entry = Parrot_str_new_constant(interp, PARROT_SHARE_EXT); VTABLE_push_string(interp, paths, entry); } #ifdef PARROT_PLATFORM_LIB_PATH_INIT_HOOK PARROT_PLATFORM_LIB_PATH_INIT_HOOK(interp, lib_paths); #endif }