commit to prepare vs generation: remove makename refs. where we have no more need... 66/5266/3
Allan CORNET [Tue, 18 Oct 2011 13:01:51 +0000 (15:01 +0200)]
Change-Id: Ib7fce8aed496e171e182fa890067a505548ca2ca

scilab/modules/dynamic_link/macros/ilib_build.sci
scilab/modules/dynamic_link/macros/ilib_compile.sci
scilab/modules/dynamic_link/macros/ilib_for_link.sci
scilab/modules/dynamic_link/macros/ilib_gen_Make.sci
scilab/modules/dynamic_link/macros/windows/dlwCompile.sci
scilab/modules/dynamic_link/macros/windows/dlwForceRebuild.sci [new file with mode: 0644]
scilab/modules/dynamic_link/macros/windows/dlwGenerateMakefile.sci
scilab/modules/dynamic_link/macros/windows/dlwGetParamsIlibCompil.sci
scilab/modules/scicos/macros/scicos_scicos/buildnewblock.sci

index ef24289..abe2553 100644 (file)
@@ -115,7 +115,7 @@ function ilib_build(ilib_name, ..
   files = files(:)';
   files = unique([files, file_gw_name]);
 
-  ilib_gen_Make(ilib_name, table, files, libs, makename, %t, ldflags, cflags, fflags, cc);
+  makename = ilib_gen_Make(ilib_name, table, files, libs, makename, %t, ldflags, cflags, fflags, cc);
 
   // we call make
   if ( ilib_verbose() <> 0 ) then
index c3a928c..359257b 100644 (file)
@@ -54,7 +54,7 @@ function libn = ilib_compile(lib_name, ..
   files = files(:)';
 
   [make_command, lib_name_make, lib_name, path, makename, files]= ...
-      ilib_compile_get_names(lib_name, makename, files);
+      ilib_compile_get_names(lib_name, files);
 
   if isdir(path) then
     chdir(path);
@@ -176,19 +176,11 @@ endfunction
 //=============================================================================
 // function only defined in ilib_compile
 //=============================================================================
-function [make_command,lib_name_make,lib_name,path,makename,files] = ..
-             ilib_compile_get_names(lib_name, makename, files)
+function [make_command, lib_name_make, lib_name,path, makename, files] = ..
+             ilib_compile_get_names(lib_name, files)
 
   if getos() <> "Windows" then
-
-    k = strindex(makename,["/","\"]);
-
-    if k~=[] then
-      path = part(makename,1:k($));
-      makename = part(makename,k($)+1:length(makename));
-    else
-      path = "";
-    end
+    path = "";
 
     lib_name = lib_name + getdynlibext();
     lib_name_make = lib_name;
@@ -198,6 +190,8 @@ function [make_command,lib_name_make,lib_name,path,makename,files] = ..
       files = files + ".o";
     end
 
+    makename = 'Makefile';
+
   else // Windows
     // Load dynamic_link Internal lib if it"s not already loaded
     if ~ exists("dynamic_linkwindowslib") then
@@ -205,7 +199,7 @@ function [make_command,lib_name_make,lib_name,path,makename,files] = ..
     end
 
     [make_command, lib_name_make, lib_name, path, makename, files] = ..
-         dlwGetParamsIlibCompil(lib_name, makename, files);
+         dlwGetParamsIlibCompil(lib_name, files);
   end
 
 endfunction
index 69bd310..77fc21f 100644 (file)
@@ -48,13 +48,10 @@ function libn = ilib_for_link(names, ..
   end
 
   if getos() == "Windows" then
-    if ~isdef("makename") | (makename == []) | (makename == "") then
-      // Load dynamic_link Internal lib if it"s not already loaded
-      if ~ exists("dynamic_linkwindowslib") then
-        load("SCI/modules/dynamic_link/macros/windows/lib");
-      end
-      makename = dlwGetDefltMakefileName();
+    if ~ exists("dynamic_linkwindowslib") then
+      load("SCI/modules/dynamic_link/macros/windows/lib");
     end
+    makename = dlwGetDefltMakefileName() + dlwGetMakefileExt();
   else
     makename = "Makefile";
   end
@@ -92,10 +89,9 @@ function libn = ilib_for_link(names, ..
     mprintf(gettext("   Generate a Makefile\n"));
   end
 
-  generateMakefile(names, ..
+  modifiedmakename = generateMakefile(names, ..
                    files, ..
                    libs, ..
-                   makename, ..
                    libname, ..
                    ldflags, ..
                    cflags, ..
@@ -103,6 +99,10 @@ function libn = ilib_for_link(names, ..
                    cc, ..
                    flag);
 
+  if modifiedmakename <> makename then
+    makename = modifiedmakename;
+  end
+
   // we call make
   if ( ilib_verbose() <> 0 ) then
     mprintf(gettext("   Running the Makefile\n"));
@@ -122,10 +122,9 @@ function libn = ilib_for_link(names, ..
 
 endfunction
 //=============================================================================
-function generateMakefile(names, ..
+function makename = generateMakefile(names, ..
                             files, ..
                             libs, ..
-                            makename, ..
                             libname, ..
                             ldflags, ..
                             cflags, ..
@@ -133,7 +132,7 @@ function generateMakefile(names, ..
                             cc, ..
                             flag)
 
-
+  makename = [];
   if getos() <> "Windows" then
     Makename = makename;
     ilib_gen_Make_unix(names, ..
@@ -155,12 +154,11 @@ function generateMakefile(names, ..
 
     names = names(1);
 
-    Makename = dlwGenerateMakefile(names, ..
+    makename = dlwGenerateMakefile(names, ..
                                     [], ..
                                     files, ..
                                     libs, ..
                                     libname, ..
-                                    makename, ..
                                     %f, ..
                                     ldflags, ..
                                     cflags, ..
index 075c096..958ecfb 100644 (file)
@@ -81,7 +81,6 @@ function Makename = ilib_gen_Make(name, ..
                                  files, ..
                                  libs, ..
                                  library_name, ..
-                                 makename, ..
                                  with_gateway, ..
                                  ldflags, ..
                                  cflags, ..
index 0b7d1e6..eb92b2e 100644 (file)
@@ -22,10 +22,16 @@ function dlwCompile(files, make_command, makename)
       mprintf(_("   Building shared library (be patient)\n"));
     end
 
-    [msg, stat] = unix_g(make_command + makename + " all 2>&0");
+    if dlwForceRebuild() then
+      target_build = 'clean all';
+    else
+      target_build = 'all';
+    end
+    
+    [msg, stat] = unix_g(make_command + makename + " " + target_build + " 2>&0");
     if stat <> 0 then
       // more feedback when compilation fails
-      [msg, stat, stderr] = unix_g(make_command + makename + " all 1>&2"); 
+      [msg, stat, stderr] = unix_g(make_command + makename  + " " + target_build + " 1>&2"); 
       disp(stderr);
       error(msprintf(gettext("%s: Error while executing %s.\n"), "ilib_compile", makename));
     else
diff --git a/scilab/modules/dynamic_link/macros/windows/dlwForceRebuild.sci b/scilab/modules/dynamic_link/macros/windows/dlwForceRebuild.sci
new file mode 100644 (file)
index 0000000..38f8d83
--- /dev/null
@@ -0,0 +1,40 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) DIGITEO - 2011  - Allan CORNET
+//
+// 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-en.txt
+//=============================================================================
+function r = dlwForceRebuild(varargin)
+  
+  [lhs, rhs] = argn(0);
+  if rhs > 1 then
+    error(msprintf(gettext("%s: Wrong number of input argument(s).\n"), "dlwForceRebuild"));
+  end
+  
+  if rhs == 1 then
+    newValue = varargin(1);
+    if type(newValue) <> 4 then
+      error(999,msprintf(_("%s: Wrong type for input argument #%d: A boolean expected.\n"), "dlwForceRebuild", 1));
+    end
+
+    if size(newValue,"*") <> 1 then
+      error(999,msprintf(_("%s: Wrong size for input argument #%d: A scalar expected.\n"), "dlwForceRebuild", 1));
+    end
+    
+    if newValue == %t then
+      setenv('FORCE_REBUILD_DYNAMIC_LINK','YES')
+    else
+      setenv('FORCE_REBUILD_DYNAMIC_LINK','NO')
+    end
+  end
+
+  if getenv('FORCE_REBUILD_DYNAMIC_LINK','NO') == "YES" then
+    r = %t;
+  else
+    r = %f;
+  end
+
+endfunction
index 6a95282..8c9768f 100644 (file)
@@ -11,7 +11,6 @@ function Makename = dlwGenerateMakefile(name, ..
                                  files, ..
                                  libs, ..
                                  libname, ..
-                                 makename, ..
                                  with_gateway, ..
                                  ldflags, ..
                                  cflags, ..
index 973a618..98e601b 100644 (file)
 
 //=============================================================================
 function [make_command, lib_name_make, lib_name, path, makename, files] = ..
-             dlwGetParamsIlibCompil(lib_name, makename, files)
+             dlwGetParamsIlibCompil(lib_name, files)
   
-  files = unique(files);
-  k = strindex(makename,['/','\']);
-  
-
-  if k~=[] then
-    path = part(makename,1:k($));
-    makename = part(makename,k($)+1:length(makename));
-  else
-     path='';
-  end
-
-  lib_name = lib_name+getdynlibext();
+  path='';
+  lib_name = lib_name + getdynlibext();
   lib_name_make = lib_name;
-
-  if (makename <> [] & makename <> '') then
-    makename = makename + dlwGetMakefileExt() ;
-  else
-    makename = dlwGetDefltMakefileName() + dlwGetMakefileExt() ;
-  end
-
+  makename = dlwGetDefltMakefileName() + dlwGetMakefileExt() ;
   make_command = 'nmake /Y /nologo /f ';
 
 endfunction
index e8cc5dc..e30db33 100644 (file)
@@ -139,7 +139,20 @@ function [ok]=buildnewblock(blknam, files, filestan, filesint, libs, rpat, ldfla
     chdir(TMPDIR);
   end
   
+  // Since all files Xcos generated files of all diagrams are in the same TEMP directory 
+  // Here, we force to rebuild (not a simple incremental build on Windows)
+  if getos() == "Windows" then
+    VC_rebuild_mode = dlwForceRebuild();
+    dlwForceRebuild(%t);
+  end  
+  
   ierr = execstr("libn =ilib_for_link(blknam,files,"""",""c"","""",""loader.sce"","""",ldflags,cflags)","errcatch");
+  
+  // restore previous build mode
+  if getos() == "Windows" then
+    dlwForceRebuild(VC_rebuild_mode);
+  end  
+  
   if ierr <> 0 then
     ok = %f;
     chdir(oldpath);