From dffafa95f3d60de7e73f0cc6cecaccfcd19bfddc Mon Sep 17 00:00:00 2001 From: Jamie Madill Date: Wed, 6 Apr 2016 18:26:46 -0400 Subject: loader: Add compile-time option for layer search paths. This enables programatically specifying search directories for the layer JSON files. This makes deploying and running compiled layers in local and automated testing with multiple configurations a much simpler process. Change-Id: I0904ef230d020004d8d71cbe265e83cdb6120db8 --- loader/loader.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'loader/loader.c') diff --git a/loader/loader.c b/loader/loader.c index 17c2f557..59572474 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -2182,11 +2182,12 @@ loader_add_layer_properties(const struct loader_instance *inst, * Linux Layer| dirs | dirs */ static void loader_get_manifest_files(const struct loader_instance *inst, - const char *env_override, bool is_layer, + const char *env_override, + const char *source_override, bool is_layer, const char *location, const char *home_location, struct loader_manifest_files *out_files) { - char *override = NULL; + const char *override = NULL; char *loc; char *file, *next_file, *name; size_t alloced_count = 64; @@ -2198,7 +2199,9 @@ static void loader_get_manifest_files(const struct loader_instance *inst, out_files->count = 0; out_files->filename_list = NULL; - if (env_override != NULL && (override = loader_getenv(env_override))) { + if (source_override != NULL) { + override = source_override; + } else if (env_override != NULL && (override = loader_getenv(env_override))) { #if !defined(_WIN32) if (geteuid() != getuid() || getegid() != getgid()) { /* Don't allow setuid apps to use the env var: */ @@ -2260,7 +2263,9 @@ static void loader_get_manifest_files(const struct loader_instance *inst, return; } strcpy(loc, override); - loader_free_getenv(override); + if (source_override == NULL) { + loader_free_getenv(override); + } } // Print out the paths being searched if debugging is enabled @@ -2410,7 +2415,7 @@ void loader_icd_scan(const struct loader_instance *inst, loader_scanned_icd_init(inst, icds); // Get a list of manifest files for ICDs - loader_get_manifest_files(inst, "VK_ICD_FILENAMES", false, + loader_get_manifest_files(inst, "VK_ICD_FILENAMES", NULL, false, DEFAULT_VK_DRIVERS_INFO, HOME_VK_DRIVERS_INFO, &manifest_files); if (manifest_files.count == 0) @@ -2525,12 +2530,12 @@ void loader_layer_scan(const struct loader_instance *inst, uint32_t implicit; // Get a list of manifest files for explicit layers - loader_get_manifest_files(inst, LAYERS_PATH_ENV, true, + loader_get_manifest_files(inst, LAYERS_PATH_ENV, LAYERS_SOURCE_PATH, true, DEFAULT_VK_ELAYERS_INFO, HOME_VK_ELAYERS_INFO, &manifest_files[0]); // Pass NULL for environment variable override - implicit layers are not // overridden by LAYERS_PATH_ENV - loader_get_manifest_files(inst, NULL, true, DEFAULT_VK_ILAYERS_INFO, + loader_get_manifest_files(inst, NULL, NULL, true, DEFAULT_VK_ILAYERS_INFO, HOME_VK_ILAYERS_INFO, &manifest_files[1]); if (manifest_files[0].count == 0 && manifest_files[1].count == 0) return; @@ -2585,7 +2590,7 @@ void loader_implicit_layer_scan(const struct loader_instance *inst, // Pass NULL for environment variable override - implicit layers are not // overridden by LAYERS_PATH_ENV - loader_get_manifest_files(inst, NULL, true, DEFAULT_VK_ILAYERS_INFO, + loader_get_manifest_files(inst, NULL, NULL, true, DEFAULT_VK_ILAYERS_INFO, HOME_VK_ILAYERS_INFO, &manifest_files); if (manifest_files.count == 0) { return; -- cgit v1.2.3