Add generation of cleaner_src and set MS env on windows while clean 87/18987/4
Antoine ELIAS [Fri, 27 Jan 2017 09:59:08 +0000 (10:59 +0100)]
Change-Id: Id4a3fe6be6f2a70d1c0055eb7b67bea0fad30e6f

15 files changed:
scilab/contrib/toolbox_skeleton/src/cleaner_src.sce [deleted file]
scilab/modules/dynamic_link/macros/windows/dlwDllInfo.sci
scilab/modules/dynamic_link/macros/windows/dlwGenerateCleaner.sci
scilab/modules/dynamic_link/macros/windows/dlwGetEnvCmd.sci [new file with mode: 0644]
scilab/modules/modules_manager/macros/tbx_build_cleaner.sci
scilab/modules/modules_manager/macros/tbx_build_src_clean.sci [new file with mode: 0644]
scilab/modules/modules_manager/macros/tbx_builder_src.sci
scilab/modules/modules_manager/tests/nonreg_tests/bug_9339.unix.dia.ref
scilab/modules/modules_manager/tests/nonreg_tests/bug_9339.win.dia.ref
scilab/modules/modules_manager/tests/unit_tests/tbx_make.dia.ref
scilab/modules/modules_manager/tests/unit_tests/tbx_make.win.dia.ref
scilab/modules/modules_manager/tests/unit_tests/toolbox_skeleton.unix.dia.ref
scilab/modules/modules_manager/tests/unit_tests/toolbox_skeleton.win.dia.ref
scilab/modules/modules_manager/tests/unit_tests/xcos_toolbox_skeleton.unix.dia.ref
scilab/modules/modules_manager/tests/unit_tests/xcos_toolbox_skeleton.win.dia.ref

diff --git a/scilab/contrib/toolbox_skeleton/src/cleaner_src.sce b/scilab/contrib/toolbox_skeleton/src/cleaner_src.sce
deleted file mode 100644 (file)
index 5de6a02..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// This file is released under the 3-clause BSD license. See COPYING-BSD.
-
-function cleaner_src()
-    src_dir = get_absolute_file_path("cleaner_src.sce");
-
-    for language = ["c","cpp","fortran"]
-        cleaner_file = src_dir + filesep() + language + filesep() + "cleaner.sce";
-        if isfile(cleaner_file) then
-            exec(cleaner_file);
-            mdelete(cleaner_file);
-        end
-    end
-endfunction
-
-cleaner_src();
-clear cleaner_src; // remove cleaner_src on stack
\ No newline at end of file
index 61e7c0b..d56514c 100644 (file)
 function dllinfolist = dlwDllInfo(dllname, options)
     //=============================================================================
     
-    function cmd = getEnvCmd()
-        if win64() then
-            if dlwIsExpress() then
-                arch = "x86_amd64";
-            else
-                arch = "x64";
-            end
-        else
-            arch = "x86";
-        end
-
-        path = dlwGetVisualStudioPath();
-        cmd = """" + path + "\VC\vcvarsall.bat"" " + arch;
-    endfunction
-    
     function symbolslist = dllinfoimports(dllname)
         symbolslist = list();
 
-        cmd = getEnvCmd() + " && dumpbin /IMPORTS """ + dllname +""""
+        cmd = dlwGetEnvCmd() + " && dumpbin /IMPORTS """ + dllname +""""
 
         [result,bOK] = dos(cmd);
         if bOK == %T then
@@ -73,7 +58,7 @@ function dllinfolist = dlwDllInfo(dllname, options)
     function symbolslist = dllinfoexports(dllname)
         symbolslist = list();
         symbolsdll = [];
-        cmd = getEnvCmd() + " && dumpbin /EXPORTS """ + dllname +"""";
+        cmd = dlwGetEnvCmd() + " && dumpbin /EXPORTS """ + dllname +"""";
         [result, bOK] = dos(cmd);
         if bOK == %T then
             result(result == "") = [];
@@ -97,7 +82,7 @@ function dllinfolist = dlwDllInfo(dllname, options)
     function dllinfolist = dllinfomachine(dllname)
         dllinfolist = list();
         machine = "";
-        cmd = getEnvCmd() + " && dumpbin /HEADERS """ + dllname +"""";
+        cmd = dlwGetEnvCmd() + " && dumpbin /HEADERS """ + dllname +"""";
         [result, bOK] = dos(cmd);
         if bOK == %T then
             iMachine = grep(result, "machine (");
index d4bb3f3..82be7fb 100644 (file)
@@ -20,8 +20,7 @@ function dlwGenerateCleaner(fd, makename)
     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,"  unix_s(dlwGetEnvCmd() + '' && %s'');\n", make_command);
     mfprintf(fd,"  mdelete(''%s'');\n", makename);
     mfprintf(fd,"end\n");
     mfprintf(fd,"// ------------------------------------------------------\n");
diff --git a/scilab/modules/dynamic_link/macros/windows/dlwGetEnvCmd.sci b/scilab/modules/dynamic_link/macros/windows/dlwGetEnvCmd.sci
new file mode 100644 (file)
index 0000000..a463ab0
--- /dev/null
@@ -0,0 +1,27 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) Scilab Enterprises - 2017  - Antoine ELIAS
+//
+// Copyright (C) 2012 - 2016 - Scilab Enterprises
+//
+// This file is hereby licensed under the terms of the GNU GPL v2.0,
+// pursuant to article 5.3.4 of the CeCILL v.2.1.
+// This file was originally licensed under the terms of the CeCILL v2.1,
+// and continues to be available under such terms.
+// For more information, see the COPYING file which you should have received
+// along with this program.
+
+//=============================================================================
+function cmd = dlwGetEnvCmd()
+    if win64() then
+        if dlwIsExpress() then
+            arch = "x86_amd64";
+        else
+            arch = "x64";
+        end
+    else
+        arch = "x86";
+    end
+
+    path = dlwGetVisualStudioPath();
+    cmd = """" + path + "\VC\vcvarsall.bat"" " + arch;
+endfunction
index 45a2914..1929287 100644 (file)
@@ -61,65 +61,67 @@ function tbx_build_cleaner(name, path)
     mprintf(gettext("Generating cleaner.sce...\n"))
 
     cleanertxt = [
-    "// This file is released under the 3-clause BSD license. See COPYING-BSD.",
-    "// Generated by builder.sce: Please, do not edit this file",
-    "",
+    "// This file is released under the 3-clause BSD license. See COPYING-BSD."
+    "// Generated by builder.sce: Please, do not edit this file"
+    ""
     "oldmode = mode();"
-    "mode(-1);"
-    "oldlines = lines()(2)"
-    "lines(0)"
+    "oldlines = lines()(2);"
+    "lines(0);"
+    ""
+    "function perform_clean()"
+    "    root_tlbx = get_absolute_file_path(''cleaner.sce'');"
+    ""
+    "    if isfile(root_tlbx + ''/macros/cleanmacros.sce'') then"
+    "        exec(root_tlbx+''/macros/cleanmacros.sce'');"
+    "    else"
+    "        if isdir(root_tlbx + ""/macros/"") then"
+    "            deletefile(root_tlbx + ""/macros/lib"");"
+    "            binfiles = findfiles(root_tlbx + ""/macros/"", ""*.bin"");"
+    "            if ~isempty(binfiles) then"
+    "                deletefile(root_tlbx + ""/macros/"" + binfiles);"
+    "            end"
+    "        end"
+    "    end"
+    ""
+    "    if isfile(root_tlbx + ""/src/cleaner_src.sce"") then"
+    "        exec(root_tlbx + ""/src/cleaner_src.sce"");"
+    "        mdelete(root_tlbx + ""/src/cleaner_src.sce"");"
+    "     end"
+    ""
+    "    if isfile(root_tlbx + ""/sci_gateway/cleaner_gateway.sce"") then"
+    "        exec(root_tlbx + ""/sci_gateway/cleaner_gateway.sce"");"
+    "        mdelete(root_tlbx + ""/sci_gateway/cleaner_gateway.sce"");"
+    "     end"
+    ""
+    "    if isfile(root_tlbx + ""/help/cleaner_help.sce"") then"
+    "        exec(root_tlbx + ""/help/cleaner_help.sce"");"
+    "    else"
+    "        if isdir(root_tlbx + ""/jar/"") then"
+    "            rmdir(root_tlbx + ""/jar/"", ""s"");"
+    "        end"
+    "    end"
+    ""
+    "    if isfile(root_tlbx + ""/loader.sce"") then"
+    "        mdelete(root_tlbx + ""/loader.sce"");"
+    "    end"
+    ""
+    "    if isfile(root_tlbx + ""/unloader.sce"") then"
+    "        mdelete(root_tlbx + ""/unloader.sce"");"
+    "    end"
+    "endfunction"
+    ""
     "try"
-    "function perform_clean()",
-    "  root_tlbx = get_absolute_file_path(''cleaner.sce'');",
-    "",
-    "  if isfile(root_tlbx + ''/macros/cleanmacros.sce'') then",
-    "    exec(root_tlbx+''/macros/cleanmacros.sce'');",
-    "  else",
-    "      if isdir(root_tlbx + ""/macros/"") then",
-    "          deletefile(root_tlbx + ""/macros/lib"");",
-    "          binfiles = findfiles(root_tlbx + ""/macros/"", ""*.bin"");",
-    "          if ~isempty(binfiles) then",
-    "              deletefile(root_tlbx + ""/macros/"" + binfiles);",
-    "          end",
-    "      end",
-    "  end",
-    "",
-    "  if isfile(root_tlbx + ''/src/cleaner_src.sce'') then",
-    "    exec(root_tlbx+''/src/cleaner_src.sce'');",
-    "  end",
-    "",
-    "  if isfile(root_tlbx + ""/sci_gateway/cleaner_gateway.sce"") then",
-    "    exec(root_tlbx + ""/sci_gateway/cleaner_gateway.sce"");",
-    "    mdelete(root_tlbx + ""/sci_gateway/cleaner_gateway.sce"");",
-    "   end",
-    "",
-    "  if isfile(root_tlbx + ""/help/cleaner_help.sce"") then",
-    "    exec(root_tlbx + ""/help/cleaner_help.sce"");",
-    "  else",
-    "      if isdir(root_tlbx + ""/jar/"") then",
-    "          rmdir(root_tlbx + ""/jar/"", ""s"");",
-    "      end",
-    "  end",
-    "",
-    "  if isfile(root_tlbx + ""/loader.sce"") then",
-    "    mdelete(root_tlbx + ""/loader.sce"");",
-    "  end",
-    "",
-    "  if isfile(root_tlbx + ""/unloader.sce"") then",
-    "    mdelete(root_tlbx + ""/unloader.sce"");",
-    "  end",
-
-    "endfunction",
-    "perform_clean();",
+    "    perform_clean();"
     "catch"
-    "    [errmsg, tmp, nline, func] = lasterror()"
-    "    msg = ""%s: error on line #%d: """"%s""""\n"""
-    "    msg = msprintf(msg, func, nline, errmsg)"
-    "    lines(oldlines)"
+    "    [errmsg, tmp, nline, func] = lasterror();"
+    "    msg = ""%s: error on line #%d: """"%s""""\n"";"
+    "    msg = msprintf(msg, func, nline, errmsg);"
+    "    lines(oldlines);"
     "    mode(oldmode);"
     "    clear perform_clean oldlines oldmode tmp nline func errmsg;"
     "    error(msg);"
     "end"
+    ""
     "lines(oldlines)"
     "mode(oldmode);"
     "clear perform_clean oldlines oldmode;"
diff --git a/scilab/modules/modules_manager/macros/tbx_build_src_clean.sci b/scilab/modules/modules_manager/macros/tbx_build_src_clean.sci
new file mode 100644 (file)
index 0000000..b8d8318
--- /dev/null
@@ -0,0 +1,87 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2009-2010 - DIGITEO - Allan CORNET
+// Copyright (C) 2010 - DIGITEO - Pierre MARECHAL
+//
+// Copyright (C) 2012 - 2016 - Scilab Enterprises
+//
+// This file is hereby licensed under the terms of the GNU GPL v2.0,
+// pursuant to article 5.3.4 of the CeCILL v.2.1.
+// This file was originally licensed under the terms of the CeCILL v2.1,
+// and continues to be available under such terms.
+// For more information, see the COPYING file which you should have received
+// along with this program.
+
+// Generate a cleaner_gateway.sce script for the gateway
+
+function tbx_build_src_clean(languages,path)
+
+    rhs = argn(2);
+
+    // Number of input arguments
+
+    if and(rhs<> [1 2]) then
+        error(msprintf(gettext("%s: Wrong number of input arguments: %d to %d expected.\n"),"tbx_build_gateway_clean",1,2));
+    end
+
+    // Input argument N°1
+    // → languages
+
+    if type(languages) <> 10 then
+        error(msprintf(gettext("%s: Wrong type for input argument #%d: string expected.\n"),"tbx_build_gateway_clean",1));
+    end
+
+    // Input argument N°2
+    // → path
+
+    if rhs < 2 then
+        path = pwd();
+
+    else
+        if type(path) <> 10 then
+            error(msprintf(gettext("%s: Wrong type for input argument #%d: string expected.\n"),"tbx_build_gateway_clean",2));
+        end
+
+        if size(path,"*") <> 1 then
+            error(msprintf(gettext("%s: Wrong size for input argument #%d: string expected.\n"),"tbx_build_gateway_clean",2));
+        end
+
+        if ~isdir(path) then
+            error(msprintf(gettext("%s: The directory ''%s'' doesn''t exist or is not read accessible.\n"),"tbx_build_gateway_clean",path));
+        end
+    end
+
+    // build the cleaner file
+
+    mprintf(gettext("Generating cleaner_src.sce...\n"));
+
+    cleanertxt = [
+    "// This file is released under the 3-clause BSD license. See COPYING-BSD.",
+    "// Generated by builder_gateway.sce: Please, do not edit this file",
+    "",
+    "src_dir = get_absolute_file_path(""cleaner_src.sce"");",
+    "current_dir     = pwd();",
+    ""];
+
+    for i = 1:size(languages,"*") do
+        cleanertxt = [cleanertxt,
+        "chdir(src_dir);",
+        "if ( isdir("""+languages(i)+""") ) then",
+        "    chdir("""+languages(i)+""");",
+        "    exec(""cleaner.sce"");",
+        "    mdelete(""cleaner.sce"");",
+        "end",
+        ""
+        ];
+    end
+
+    cleanertxt = [cleanertxt,
+    "chdir(current_dir);",
+    "clear src_dir current_dir;"];
+
+    cleanerfile = pathconvert(path+"/cleaner_src.sce",%F);
+
+    if ~mputl(cleanertxt,cleanerfile) then
+        error(msprintf(gettext("%s: The file %s cannot been created, please check if you have write access on this file.\n"),"tbx_build_src_clean",cleanerfile));
+    end
+
+endfunction
index 06cd199..6255229 100644 (file)
@@ -44,24 +44,26 @@ function tbx_builder_src(module)
         error(msprintf(gettext("%s: This module requires a C or Fortran compiler and it has not been found.\n"),"tbx_builder_src"));
     end
 
-
     // check there is a builder file is  present and if so execute it with tbx_builder
-    builder_src_dir = module + "/src/"
+    builder_src_dir = module + "/src/";
     if isdir(builder_src_dir)
         mprintf(gettext("Building sources...\n"));
         builder_src_file = findfiles(builder_src_dir, "build*.sce");
+
+        d = dir(builder_src_dir);
+        languages = d.name(d.isdir);
+        if isempty(languages)
+            warning(_("No builder file found, nothing to be done"));
+            return
+        end
         if ~isempty(builder_src_file)
             builder_src_file = pathconvert(builder_src_dir + "/" + builder_src_file, %F);
             tbx_builder(builder_src_file);
         else
             // Default mode look in directories to find builder files and execute them
-            d = dir(builder_src_dir);
-            languages = d.name(d.isdir);
-            if isempty(languages)
-                warning(_("No builder file found, nothing to be done"));
-                return
-            end
             tbx_builder_src_lang(languages, builder_src_dir);
         end
+        
+        tbx_build_src_clean(languages, builder_src_dir);
     end
 endfunction
index 5f9712d..bd4f102 100644 (file)
@@ -29,6 +29,7 @@ Building macros...
 genlib: Processing file: scilab_error.sci
 genlib: Processing file: scilab_sum.sci
 Building sources...
+Generating cleaner_src.sce...
 Building gateway...
 Generating loader_gateway.sce...
 Generating cleaner_gateway.sce...
index 4722cb6..2594ebf 100644 (file)
@@ -29,6 +29,7 @@ Building macros...
 genlib: Processing file: scilab_error.sci
 genlib: Processing file: scilab_sum.sci
 Building sources...
+Generating cleaner_src.sce...
 Building gateway...
 Generating loader_gateway.sce...
 Generating cleaner_gateway.sce...
index 17e7b47..4cca9c8 100644 (file)
@@ -51,10 +51,9 @@ genlib: Processing file: scilab_sum.sci
 Building sources...
    Generate a loader file
    Generate a Makefile
-   ilib_gen_Make: configure : Generate Makefile.
    ilib_gen_Make: Copy compilation files (Makefile*, libtool...) to TMPDIR
-   ilib_gen_Make: Copy csum.c to TMPDIR
    ilib_gen_Make: Copy csub.c to TMPDIR
+   ilib_gen_Make: Copy csum.c to TMPDIR
    ilib_gen_Make: Copy multiplybypi.c to TMPDIR
    ilib_gen_Make: configure : Generate Makefile.
    ilib_gen_Make: Modification of the Makefile in TMPDIR.
@@ -72,6 +71,7 @@ Building sources...
    Creating JAR archive TMPDIR/testbox/jar/org.scilab.contrib.toolboxskeleton.jar
    Create loader script for Java loader.sce
    Create cleaner script for Java cleaner.sce
+Generating cleaner_src.sce...
 Building gateway...
    Generate a gateway file
    Generate a loader file
index 14f32cd..e3edbb5 100644 (file)
@@ -68,6 +68,7 @@ Building sources...
    Creating JAR archive TMPDIR\testbox\jar\org.scilab.contrib.toolboxskeleton.jar
    Create loader script for Java loader.sce
    Create cleaner script for Java cleaner.sce
+Generating cleaner_src.sce...
 Building gateway...
    Generate a gateway file
    Generate a loader file
index 6b91138..9001ead 100644 (file)
@@ -41,6 +41,7 @@ Building sources...
    Creating JAR archive TMPDIR/toolbox_skeleton/jar/org.scilab.contrib.toolboxskeleton.jar
    Create loader script for Java loader.sce
    Create cleaner script for Java cleaner.sce
+Generating cleaner_src.sce...
 Building gateway...
    Generate a gateway file
    Generate a loader file
index b06b004..5fbcbe8 100644 (file)
@@ -38,6 +38,7 @@ Building sources...
    Creating JAR archive TMPDIR\toolbox_skeleton\jar\org.scilab.contrib.toolboxskeleton.jar
    Create loader script for Java loader.sce
    Create cleaner script for Java cleaner.sce
+Generating cleaner_src.sce...
 Building gateway...
    Generate a gateway file
    Generate a loader file
index 06a6cd2..e9bb83e 100644 (file)
@@ -36,6 +36,7 @@ Building sources...
    ilib_gen_Make: Modification of the Makefile in TMPDIR.
    Running the Makefile
    Generate a cleaner file
+Generating cleaner_src.sce...
 Building gateway...
    Generate a gateway file
    Generate a loader file
index f1e4ce8..a7bacf4 100644 (file)
@@ -34,6 +34,7 @@ Building sources...
    Compilation of tbx_block_noop.c
    Building shared library (be patient)
    Generate a cleaner file
+Generating cleaner_src.sce...
 Building gateway...
    Generate a gateway file
    Generate a loader file