allow user to forced used msvc compiler via SCILAB_PREFERED_MSVC env var 00/15600/1
Antoine ELIAS [Thu, 27 Nov 2014 10:45:34 +0000 (11:45 +0100)]
Change-Id: Ie71175f206b4df22c0460ed70eb8719ff650da38

scilab/modules/dynamic_link/etc/dynamic_link.start
scilab/modules/dynamic_link/macros/configure_msvc.sci
scilab/modules/dynamic_link/macros/windows/dlwCompile.sci
scilab/modules/dynamic_link/macros/windows/dlwConfigureEnv.sci [new file with mode: 0644]
scilab/modules/dynamic_link/macros/windows/dlwFindMsVcCompiler.sci
scilab/modules/dynamic_link/macros/windows/dlwGenerateCleaner.sci
scilab/modules/dynamic_link/macros/windows/dlwGetSdkPath.sci

index 79ae343..dc37ee6 100644 (file)
@@ -13,23 +13,6 @@ function dynamic_linklib = startModule()
 //Load  functions libraries
 // =============================================================================
   load('SCI/modules/dynamic_link/macros/lib');
-
-// Configure Environment Variables for Microsoft Visual Studio C and
-// Intel Fortran
-  if getos() == 'Windows' then
-    if findmsvccompiler() <> 'unknown' then
-      // Configure Ms VC environment
-      configure_msvc();
-      if findmsifortcompiler() <> 'unknown' then
-        // Configure Intel Fortran environment
-        configure_msifort();
-      else
-        // Use F2C 
-        setenv('USE_F2C', 'YES');
-      end
-    end
-  end
-
 endfunction
 
 dynamic_linklib = startModule();
index 10209bc..faddb55 100644 (file)
@@ -36,6 +36,10 @@ function bOK = configure_msvc()
         end
     end
 
+    if bOK then
+        val = setenv("SCILAB_MSVC", "1");
+    end
+
 
 endfunction
 //=============================================================================
index 536b821..9cc48c9 100644 (file)
@@ -9,6 +9,8 @@
 //=============================================================================
 function dlwCompile(files, make_command, makename)
 
+    dlwConfigureEnv();
+
     nf = size(files,"*");
 
     for i=1:nf
diff --git a/scilab/modules/dynamic_link/macros/windows/dlwConfigureEnv.sci b/scilab/modules/dynamic_link/macros/windows/dlwConfigureEnv.sci
new file mode 100644 (file)
index 0000000..c6c526b
--- /dev/null
@@ -0,0 +1,24 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) Scilab Enterprises - 2014 - Antoine ELIAS
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+//=============================================================================
+function dlwConfigureEnv()
+    if getenv("SCILAB_MSVC", "0") == "0" then
+        printf("Configure msvc environment.\n");
+        // Configure Ms VC environment
+        configure_msvc();
+        if findmsifortcompiler() <> 'unknown' then
+            // Configure Intel Fortran environment
+            configure_msifort();
+        else
+            // Use F2C
+            setenv('USE_F2C', 'YES');
+        end
+    end
+endfunction
\ No newline at end of file
index ca34c35..d015a74 100644 (file)
@@ -14,6 +14,26 @@ function MSCompiler = dlwFindMsVcCompiler()
 
     // We use always last version of MS compiler
 
+    val = getenv("SCILAB_PREFERED_MSVC", "");
+    if val <> "" then
+        funcs = list(dlwIsVc12Express,dlwIsVc12Pro,dlwIsVc11Express,dlwIsVc11Pro,dlwIsVc10Express,dlwIsVc10Pro);
+        compilers = ["msvc120express";
+                    "msvc120pro";
+                    "msvc110express";
+                    "msvc110pro";
+                    "msvc100express";
+                    "msvc100pro";];
+        idx = find(val == compilers);
+        if idx <> [] then
+            func = funcs(idx);
+            if func() then
+                MSCompiler = val;
+                return;
+            end
+        end
+
+//        printf("SCILAB_PREFERED_MSVC ignored.\n");
+    end
 
     if dlwIsVc12Express() then
       MSCompiler = 'msvc120express';     // Microsoft Visual 2013 Express
index 979f7c1..e7562bb 100644 (file)
@@ -8,8 +8,16 @@
 // http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
 //=============================================================================
 function dlwGenerateCleaner(fd, makename)
+    val = getenv("SCILAB_PREFERED_MSVC", "");
     make_command = dlwGetMakefileCmdCleaner(makename);
     mfprintf(fd,"if fileinfo(''%s'') <> [] then\n", makename);
+    if val <> "" then
+        mfprintf(fd,"  setenv(""SCILAB_PREFERED_MSVC"", ""%s"");\n", val);
+    end
+    mfprintf(fd,"  if ~ exists(""dynamic_linkwindowslib"") then\n");
+    mfprintf(fd,"    load(""SCI/modules/dynamic_link/macros/windows/lib"")\n");
+    mfprintf(fd,"  end\n");
+    mfprintf(fd,"  dlwConfigureEnv();\n");
     mfprintf(fd,"  unix_s(''%s'');\n", make_command);
     mfprintf(fd,"  mdelete(''%s'');\n", makename);
     mfprintf(fd,"end\n");
index 9b6cdf6..31e839d 100644 (file)
@@ -12,15 +12,25 @@ function SDKpath = dlwGetSdkPath()
 
     SDKpath = [];
 
-    entries = [
-        "Software\Microsoft\Microsoft SDKs\Windows\v8.0A" "InstallationFolder" ; .. // Windows 8 A
-        "Software\Microsoft\Microsoft SDKs\Windows\v8.0" "InstallationFolder" ; .. // Windows 8    
+    compiler = findmsvccompiler();
+    entries = [];
+
+    //detect sdk 8 only for VS >= 2012
+    if find(compiler == ["msvc120express";"msvc120pro";"msvc110express";"msvc110pro"]) <> [] then;
+        entries = [entries ;
+            "Software\Microsoft\Microsoft SDKs\Windows\v8.0A" "InstallationFolder" ; .. // Windows 8 A
+            "Software\Microsoft\Microsoft SDKs\Windows\v8.0" "InstallationFolder" .. // Windows 8
+        ];
+    end
+
+    entries = [entries;
         "Software\Microsoft\Microsoft SDKs\Windows\v7.0" "InstallationFolder"; .. // Microsoft Windows SDK 7.0
         "Software\Microsoft\Microsoft SDKs\Windows\v7.0A" "InstallationFolder"; .. // Microsoft Windows SDK 7.0A
         "Software\Microsoft\Microsoft SDKs\Windows\v7.1" "InstallationFolder"; .. // Microsoft Windows SDK 7.1
         "Software\Microsoft\Microsoft SDKs\Windows" "CurrentInstallFolder" ; .. // Vista & Seven SDK
         "Software\Microsoft\MicrosoftSDK\InstalledSDKs\D2FF9F89-8AA2-4373-8A31-C838BF4DBBE1" "Install Dir" ; .. // Windows 2003 R2 SDK
-        "Software\Microsoft\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3" "Install Dir"]; // Windows 2003 SDK
+        "Software\Microsoft\MicrosoftSDK\InstalledSDKs\8F9E5EF3-A9A5-491B-A889-C58EFFECE8B3" "Install Dir" .. // Windows 2003 SDK
+    ];
 
     for i = 1:size(entries(:,1),"*")
         err = execstr("SDKpath = winqueryreg(""HKEY_LOCAL_MACHINE"", entries(i,1), entries(i,2))", "errcatch");