Cycles: Allow paths customization via environment variables
authorSergey Sharybin <sergey.vfx@gmail.com>
Sat, 31 Jan 2015 10:40:09 +0000 (15:40 +0500)
committerSergey Sharybin <sergey.vfx@gmail.com>
Sun, 1 Feb 2015 21:02:10 +0000 (02:02 +0500)
This is for development and test environment setup only, not for
regular users usage hence no mentioning in the man page needed.

intern/cycles/device/device_cuda.cpp
intern/cycles/util/util_path.cpp

index 7f2f141bd2f52a0098d1ac11916012a48ee93ced..f6ad6c018937d3a01ef61dbc88d7a4a45d87183b 100644 (file)
@@ -282,6 +282,10 @@ public:
                if(experimental)
                        command += " -D__KERNEL_CUDA_EXPERIMENTAL__";
 
+               if(getenv("CYCLES_CUDA_EXTRA_CFLAGS")) {
+                       command += string(" ") + getenv("CYCLES_CUDA_EXTRA_CFLAGS");
+               }
+
 #ifdef WITH_CYCLES_DEBUG
                command += " -D__KERNEL_DEBUG__";
 #endif
index b688033fc9b2246e6104a1646590dc011d56f225..a3dbad08e32c3dd52bc09e640daee93f93e1c2fc 100644 (file)
@@ -49,6 +49,25 @@ static string from_boost(const boost::filesystem::path& path)
        return path.string().c_str();
 }
 
+static char *path_specials(const string& sub)
+{
+       static bool env_init = false;
+       static char *env_shader_path;
+       static char *env_kernel_path;
+       if(!env_init) {
+               env_shader_path = getenv("CYCLES_SHADER_PATH");
+               env_kernel_path = getenv("CYCLES_KERNEL_PATH");
+               env_init = true;
+       }
+       if(env_shader_path != NULL && sub == "shader") {
+               return env_shader_path;
+       }
+       else if(env_shader_path != NULL && sub == "kernel") {
+               return env_kernel_path;
+       }
+       return NULL;
+}
+
 void path_init(const string& path, const string& user_path)
 {
        cached_path = path;
@@ -62,6 +81,10 @@ void path_init(const string& path, const string& user_path)
 
 string path_get(const string& sub)
 {
+       char *special = path_specials(sub);
+       if(special != NULL)
+               return special;
+
        if(cached_path == "")
                cached_path = path_dirname(Sysutil::this_program_path());