diff options
author | jofret | 2010-03-31 17:00:57 +0000 |
---|---|---|
committer | jofret | 2010-03-31 17:00:57 +0000 |
commit | f2ea96cb82202061c197a2fd8dbd56cf59694f3c (patch) | |
tree | 8b9c546375a894677bd70357b27730b2214d441d | |
parent | 1b6d4e44e771db92ee5c42886ab3e1bea9908bfe (diff) | |
download | scilab2c-f2ea96cb82202061c197a2fd8dbd56cf59694f3c.tar.gz scilab2c-f2ea96cb82202061c197a2fd8dbd56cf59694f3c.tar.bz2 scilab2c-f2ea96cb82202061c197a2fd8dbd56cf59694f3c.zip |
Add capability to generate Makefile or Makefile.mak
-rw-r--r-- | scilab2c/macros/CCodeGeneration/C_GenerateMakefile.sci | 2 | ||||
-rw-r--r-- | scilab2c/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci | 2 | ||||
-rw-r--r-- | scilab2c/macros/cb_sci2c_gui.sci | 21 | ||||
-rw-r--r-- | scilab2c/macros/runsci2c.sci | 10 | ||||
-rw-r--r-- | scilab2c/macros/sci2c_gui.sci | 76 | ||||
-rw-r--r-- | scilab2c/macros/scilab2c.sci | 92 |
6 files changed, 115 insertions, 88 deletions
diff --git a/scilab2c/macros/CCodeGeneration/C_GenerateMakefile.sci b/scilab2c/macros/CCodeGeneration/C_GenerateMakefile.sci index 1d11b736..3914d4dc 100644 --- a/scilab2c/macros/CCodeGeneration/C_GenerateMakefile.sci +++ b/scilab2c/macros/CCodeGeneration/C_GenerateMakefile.sci @@ -24,7 +24,7 @@ SCI2CNInArgCheck(argn(2),2,2); // ----------------------- // --- Initialization. --- // ----------------------- -PrintStepInfo('Generating Makefile '+FileInfo.MakefileFilename,... +PrintStepInfo('Generating Builder '+FileInfo.MakefileFilename,... FileInfo.GeneralReport,'both'); // --------------------------- // --- End Initialization. --- diff --git a/scilab2c/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci b/scilab2c/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci index 0e8e1773..6890c140 100644 --- a/scilab2c/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci +++ b/scilab2c/macros/CCodeGeneration/C_GenerateMakefile_msvc.sci @@ -21,7 +21,7 @@ MakefileFilename = FileInfo.MakefileFilename + '.mak'; // ----------------------- // --- Initialization. --- // ----------------------- -PrintStepInfo('Generating Makefile '+FileInfo.MakefileFilename,... +PrintStepInfo('Generating Builder '+MakefileFilename,... FileInfo.GeneralReport,'both'); PrintStringInfo('# SCI2C Makefile (Visual Studio 2008)',MakefileFilename,'file','y','y'); diff --git a/scilab2c/macros/cb_sci2c_gui.sci b/scilab2c/macros/cb_sci2c_gui.sci index 0cf970c5..1b532d64 100644 --- a/scilab2c/macros/cb_sci2c_gui.sci +++ b/scilab2c/macros/cb_sci2c_gui.sci @@ -65,13 +65,12 @@ elseif or(get(gcbo, "tag")==["sciintocradioyes","sciintocradiono"]) then set(gcbo, "value", 1); // -// --- Paths style option --- +// --- Build Tool option --- // -elseif or(get(gcbo, "tag")==["pathsradiowin","pathsradiounix","pathsradiocygwin"]) then +elseif or(get(gcbo, "tag")==["buildtoolradiowin","buildtoolradiounix"]) then - set(findobj("tag", "pathsradiowin"), "value", 0); - set(findobj("tag", "pathsradiounix"), "value", 0); - set(findobj("tag", "pathsradiocygwin"), "value", 0); + set(findobj("tag", "buildtoolradiowin"), "value", 0); + set(findobj("tag", "buildtoolradiounix"), "value", 0); set(gcbo, "value", 1); @@ -103,10 +102,10 @@ elseif get(gcbo, "tag")=="convertbtn" then CopySciCodeIntoCCode = get(findobj("tag", "sciintocradioyes"), "value") == 1; - if get(findobj("tag", "pathsradiowin"), "value") == 1 then - CCompilerPathStyle = "windows"; - elseif get(findobj("tag", "pathsradiounix"), "value") == 1 then - CCompilerPathStyle = "unix"; + if get(findobj("tag", "buildtoolradiowin"), "value") == 1 then + NativeBuild = "nmake"; + elseif get(findobj("tag", "buildtoolradiounix"), "value") == 1 then + NativeBuild = "make"; // else // CCompilerPathStyle = "cygwin"; end @@ -117,8 +116,8 @@ elseif get(gcbo, "tag")=="convertbtn" then mprintf("UserSciCodeMainDir = {%s}\n", UserSciCodeMainDir); mprintf("RunMode = {%s}\n", RunMode); mprintf("CopySciCodeIntoCCode = {%d}\n", bool2s(CopySciCodeIntoCCode)); - mprintf("CCompilerPathStyle = {%s}\n", CCompilerPathStyle); - scilab2c(UserScilabMainFile, UserSciCodeMainDir, UserSciFilesPaths, RunMode); + mprintf("NativeBuild = {%s}\n", NativeBuild); + scilab2c(UserScilabMainFile, UserSciCodeMainDir, UserSciFilesPaths, RunMode, NativeBuild); // // --- sci2c help --- // diff --git a/scilab2c/macros/runsci2c.sci b/scilab2c/macros/runsci2c.sci index 2b6ee1dc..ea6937ff 100644 --- a/scilab2c/macros/runsci2c.sci +++ b/scilab2c/macros/runsci2c.sci @@ -1,4 +1,4 @@ -function runsci2c(UserScilabMainFile, UserSciFilesPaths, SCI2COutputPath, Runmode)
+function runsci2c(UserScilabMainFile, UserSciFilesPaths, SCI2COutputPath, Runmode, BuildTool)
// function runsci2c(SCI2CInputPrmFile)
// -----------------------------------------------------------------
// === hArtes/PoliBa/GAP SCI2C tool ===
@@ -129,7 +129,13 @@ end // --------------------------
// --- Generate Makefile. ---
// --------------------------
-C_GenerateMakefile(FileInfo,SharedInfo);
+if BuildTool == "make"
+ C_GenerateMakefile(FileInfo,SharedInfo);
+end
+if BuildTool == "nmake"
+ // FIXME : Add copy of missing dll before.
+ C_GenerateMakefile_msvc(FileInfo,SharedInfo);
+end
// -----------------
// --- Epilogue. ---
diff --git a/scilab2c/macros/sci2c_gui.sci b/scilab2c/macros/sci2c_gui.sci index fca04fb8..aaae2ac2 100644 --- a/scilab2c/macros/sci2c_gui.sci +++ b/scilab2c/macros/sci2c_gui.sci @@ -13,6 +13,7 @@ function sci2c_gui() // Sizes widgeth = 20; +widgetLabelWidth = 220; btnh = 22; btnw = 80; defaultfont = "arial"; @@ -36,8 +37,8 @@ h = uimenu("parent", sci2cfig, "label", gettext("?")); uimenu("parent", h, "label", gettext("Sci2c help page"), "callback", "cb_sci2c_gui", "tag", "sci2c_help_menu"); uimenu("parent", h, "label", gettext("About SCI2C tools..."), "callback", "cb_sci2c_gui", "tag", "about_sci2c_menu"); -figw = 500; -figh = 15*margin + btnh + 6*widgeth; +figw = 800; +figh = 15*margin + btnh + 7*widgeth; sci2cfig.axes_size = [figw figh]; sci2cfig.auto_resize = "off"; sci2cfig.visible = "off"; // to be sure that no plot can appear in the window @@ -78,7 +79,7 @@ optframe = uicontrol("parent", sci2cfig,... "relief", "groove",... "style", "frame",... "units", "pixels",... - "position", [margin 2*margin+btnh figw-2*margin 4*margin+3*widgeth],... + "position", [margin 2*margin+btnh figw-2*margin 4*margin+4*widgeth],... "fontname", defaultfont,... "fontunits", "points",... "fontsize", 12,... @@ -89,26 +90,26 @@ opttitle = uicontrol("parent", sci2cfig,... "style", "text",... "string", gettext("Options"),... "units", "pixels",... - "position", [2*margin 2*margin+btnh+4*margin+3*widgeth-8 50 14],... + "position", [2*margin 2*margin+btnh+4*margin+4*widgeth-8 50 14],... "fontname", defaultfont,... "fontunits", "points",... "fontsize", 11,... "horizontalalignment", "center"); -// --- Paths style --- -pathsy = 2*margin+btnh+margin; -pathslabel = uicontrol("parent", sci2cfig,... +// --- Building Tool --- +buildtooly = 2 * margin + 2 * btnh + margin; +buildtoollabel = uicontrol("parent", sci2cfig,... "style", "text",... - "string", gettext("Paths style in C code: "),... - "position",[2*margin pathsy 160 widgeth],... + "string", gettext("Tool to compile generated C code: "),... + "position",[2*margin buildtooly widgetLabelWidth widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... "fontsize", 12); -pathsradiowin = uicontrol("parent", sci2cfig,... +buildtoolradiowin = uicontrol("parent", sci2cfig,... "style", "radiobutton",... - "string", gettext("Windows"),... - "position",[2*margin+160 pathsy radiow widgeth],... + "string", gettext("nmake for Windows with Visual Studio / Visual Express"),... + "position",[2*margin+widgetLabelWidth buildtooly 5 * radiow widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... @@ -116,11 +117,11 @@ pathsradiowin = uicontrol("parent", sci2cfig,... "min", 0, ... "max", 1, ... "callback", "cb_sci2c_gui",... - "tag", "pathsradiowin"); -pathsradiounix = uicontrol("parent", sci2cfig,... + "tag", "buildtoolradiowin"); +buildtoolradiounix = uicontrol("parent", sci2cfig,... "style", "radiobutton",... - "string", gettext("Unix"),... - "position",[2*margin+160+radiow pathsy radiow widgeth],... + "string", gettext("make for Unix / Windows with Cygwin"),... + "position",[2*margin+widgetLabelWidth buildtooly-widgeth 5 * radiow widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... @@ -128,34 +129,21 @@ pathsradiounix = uicontrol("parent", sci2cfig,... "min", 0, ... "max", 1, ... "callback", "cb_sci2c_gui",... - "tag", "pathsradiounix"); + "tag", "buildtoolradiounix"); if MSDOS - set(pathsradiowin, "value", 1); - set(pathsradiounix, "value", 0); + set(buildtoolradiowin, "value", 1); + set(buildtoolradiounix, "value", 0); else - set(pathsradiowin, "value", 0); - set(pathsradiounix, "value", 1); + set(buildtoolradiowin, "value", 0); + set(buildtoolradiounix, "value", 1); end -// pathsradiocygwin = uicontrol("parent", sci2cfig,... -// "style", "radiobutton",... -// "string", gettext("Cygwin"),... -// "position",[2*margin+160+2*radiow pathsy radiow widgeth],... -// "horizontalalignment", "left",... -// "fontname", defaultfont,... -// "fontunits", "points",... -// "fontsize", 12,... -// "min", 0, ... -// "max", 1, ... -// "value", 0,... -// "callback", "cb_sci2c_gui",... -// "tag", "pathsradiocygwin"); // --- Copy Scilab code into C option --- -sciintocy = pathsy + margin + btnh ; +sciintocy = buildtooly + margin + btnh ; sciintoclabel = uicontrol("parent", sci2cfig,... "style", "text",... "string", gettext("Copy Scilab code into C: "),... - "position",[2*margin sciintocy 160 widgeth],... + "position",[2*margin sciintocy widgetLabelWidth widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... @@ -163,7 +151,7 @@ sciintoclabel = uicontrol("parent", sci2cfig,... sciintocradioyes = uicontrol("parent", sci2cfig,... "style", "radiobutton",... "string", gettext("Yes"),... - "position",[2*margin+160 sciintocy radiow widgeth],... + "position",[2*margin+widgetLabelWidth sciintocy radiow widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... @@ -176,7 +164,7 @@ sciintocradioyes = uicontrol("parent", sci2cfig,... sciintocradiono = uicontrol("parent", sci2cfig,... "style", "radiobutton",... "string", gettext("No"),... - "position",[2*margin+160+radiow sciintocy radiow widgeth],... + "position",[2*margin+widgetLabelWidth+radiow sciintocy radiow widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... @@ -192,7 +180,7 @@ runy = sciintocy + margin + widgeth; runlabel = uicontrol("parent", sci2cfig,... "style", "text",... "string", gettext("Run mode: "),... - "position",[2*margin runy 160 widgeth],... + "position",[2*margin runy widgetLabelWidth widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... @@ -200,7 +188,7 @@ runlabel = uicontrol("parent", sci2cfig,... runradioall = uicontrol("parent", sci2cfig,... "style", "radiobutton",... "string", gettext("All"),... - "position",[2*margin+160 runy radiow widgeth],... + "position",[2*margin+widgetLabelWidth runy radiow widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... @@ -213,7 +201,7 @@ runradioall = uicontrol("parent", sci2cfig,... runradiotranslate = uicontrol("parent", sci2cfig,... "style", "radiobutton",... "string", gettext("Translate"),... - "position",[2*margin+160+radiow runy radiow widgeth],... + "position",[2*margin+widgetLabelWidth+radiow runy radiow widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... @@ -226,7 +214,7 @@ runradiotranslate = uicontrol("parent", sci2cfig,... runradiogenlib = uicontrol("parent", sci2cfig,... "style", "radiobutton",... "string", gettext("Generate library"),... - "position",[2*margin+160+2*radiow runy 120 widgeth],... + "position",[2*margin+widgetLabelWidth+2*radiow runy 120 widgeth],... "horizontalalignment", "left",... "fontname", defaultfont,... "fontunits", "points",... @@ -241,7 +229,7 @@ runradiogenlib = uicontrol("parent", sci2cfig,... // --- Output directory --- // ------------------------ // Frame -optframemaxy = 2*margin+btnh + 4*margin+3*widgeth; +optframemaxy = 2*margin+btnh + 4*margin+4*widgeth; outframe = uicontrol("parent", sci2cfig,... "relief", "groove",... "style", "frame",... @@ -272,7 +260,7 @@ outlabel = uicontrol("parent", sci2cfig,... "fontsize", 12); outedit = uicontrol("parent", sci2cfig,... "style", "edit",... - "string", pwd(),... + "string", TMPDIR,... "units", "pixels",... "position",[3*margin+100 optframemaxy+2*margin-1 figw-6*margin-100-btnw widgeth],... "fontname", defaultfont,... diff --git a/scilab2c/macros/scilab2c.sci b/scilab2c/macros/scilab2c.sci index 83cbde76..b0265931 100644 --- a/scilab2c/macros/scilab2c.sci +++ b/scilab2c/macros/scilab2c.sci @@ -1,6 +1,6 @@ // // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab -// Copyright (C) 2009-2009 - DIGITEO - Bruno JOFRET +// Copyright (C) 2009-2010 - DIGITEO - Bruno JOFRET // // This file must be used under the terms of the CeCILL. // This source file is licensed as described in the file COPYING, which @@ -14,36 +14,35 @@ function scilab2c(varargin) [lhs, rhs] = argn(); select rhs - // - // scilab2c() - // +// +// scilab2c() +// case 0 sci2c_gui(); return - // - // scilab2c(UserScilabMainFile, CCodeOutputDir) - // +// +// scilab2c(UserScilabMainFile, CCodeOutputDir) +// case 2 for i = 1:2 if typeof(varargin(i)) <> "string" - error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i)); - return + error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i)); + return end end UserScilabMainFile = varargin(1); CCodeOutputDir = varargin(2); UserSciFilesPaths = []; RunMode = 'All'; - //RunMode = 'GenLibraryStructure'; - //RunMode = 'Translate'; - // - // scilab2c(UserScilabMainFile, CCodeOutputDir, UserSciFilesPaths) + BuildTool = getNativeBuildTool(); // +// scilab2c(UserScilabMainFile, CCodeOutputDir, UserSciFilesPaths) +// case 3 for i = 1:3 if typeof(varargin(i)) <> "string" - error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i)); - return + error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i)); + return end end UserScilabMainFile = varargin(1); @@ -54,19 +53,19 @@ function scilab2c(varargin) UserSciFilesPaths = varargin(3); end RunMode = "All"; - // - // scilab2c(UserScilabMainFile, CCodeOutputDir, UserSciFilesPaths, RunMode) - // + BuildTool = getNativeBuildTool(); + // +// scilab2c(UserScilabMainFile, CCodeOutputDir, UserSciFilesPaths, RunMode) +// case 4 for i = 1:4 if typeof(varargin(i)) <> "string" - error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i)); - return + error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i)); + return end end if varargin(4) <> "All" & varargin(4) <> "Translate" & varargin(4) <> "GenLibraryStructure" - error(msprintf(gettext("%s: argument #%d must be: ""All"", ""Translate"" or ""GenLibraryStructure"".\n"),"scilab2c",4)); - return + error(msprintf(gettext("%s: argument #%d must be: ""All"", ""Translate"" or ""GenLibraryStructure"".\n"),"scilab2c",4)); return end UserScilabMainFile = varargin(1); @@ -77,20 +76,55 @@ function scilab2c(varargin) UserSciFilesPaths = varargin(3); end RunMode = varargin(4); + BuildTool = getNativeBuildTool(); + case 5 + for i = 1:4 + if typeof(varargin(i)) <> "string" + error(msprintf(gettext("%s: Wrong type for input argument #%d: String expected.\n"),"scilab2c",i)); + return + end + end + if varargin(4) <> "All" & varargin(4) <> "Translate" & varargin(4) <> "GenLibraryStructure" + error(msprintf(gettext("%s: argument #%d must be: ""All"", ""Translate"" or ""GenLibraryStructure"".\n"),"scilab2c",4)); + return + end + if varargin(5) <> "make" & varargin(5) <> "nmake" + error(msprintf(gettext("%s: argument #%d must be: ""make"" or ""nmake"".\n"),"scilab2c",5)); + return + end + UserScilabMainFile = varargin(1); + CCodeOutputDir = varargin(2); + if varargin(3) == "" + UserSciFilesPaths = []; + else + UserSciFilesPaths = varargin(3); + end + RunMode = varargin(4); + BuildTool = varargin(5); else - error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"scilab2c",2)); +// +// Calling scilab2c with more than understood values +// +error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"scilab2c",2)); end // --- LAUNCH USER SCI CODE TO TEST IT BEFORE TRANSLATING IT!!! --- - runscicode(UserScilabMainFile, UserSciFilesPaths); + runscicode(UserScilabMainFile, UserSciFilesPaths); // --- ASK USER FOR CONTINUATION. --- -// -- FIXME : bypass this for now !! - userchoice = messagebox("Exection Succesfull. Start translation ?", "modal", "info", ["Yes" "No"]) - if (userchoice == 1) + userchoice = messagebox("Exection Succesfull. Start translation ?", "modal", "info", ["Yes" "No"]) + if (userchoice == 1) // --- LAUNCH SCI2C --- - runsci2c(UserScilabMainFile, UserSciFilesPaths, CCodeOutputDir, RunMode); - end + runsci2c(UserScilabMainFile, UserSciFilesPaths, CCodeOutputDir, RunMode, BuildTool); + end endfunction + +function BuildTool = getNativeBuildTool() + if MSDOS + BuildTool = "nmake" + else + BuildTool = "make" + end +endfunction
\ No newline at end of file |