fix dynamic_link generation 71/11971/2
Antoine ELIAS [Mon, 8 Jul 2013 15:44:01 +0000 (17:44 +0200)]
Change-Id: Ic168b7dc8096098db6e06b7152175cb7c0536d3b

scilab/modules/dynamic_link/macros/gencompilationflags_unix.sci
scilab/modules/dynamic_link/macros/ilib_compile.sci
scilab/modules/dynamic_link/macros/ilib_gen_cleaner.sci
scilab/modules/dynamic_link/macros/ilib_gen_loader.sci
scilab/modules/dynamic_link/macros/windows/dlwGenerateMakefile.sci
scilab/modules/dynamic_link/macros/windows/dlwGetScilabIncludes.sci
scilab/modules/dynamic_link/macros/windows/dlwGetScilabLibraries.sci
scilab/modules/dynamic_link/macros/windows/dlwGetSdkPath.sci
scilab/modules/dynamic_link/src/scripts/Makefile.incl.mak
scilab/modules/dynamic_link/src/scripts/TEMPLATE_MAKEFILE.VC

index abdf985..83f2e8c 100644 (file)
@@ -27,9 +27,9 @@ function cmd = gencompilationflags_unix(ldflags, cflags, fflags, cc, flagsType)
     tbxFlag = " -D__SCILAB_TOOLBOX__ ";
     envFlag = "";
 
-    //if getenv('__USE_DEPRECATED_STACK_FUNCTIONS__', 'NO') == "YES" then
-    //  envFlag = " -D__USE_DEPRECATED_STACK_FUNCTIONS__ ";
-    //end
+    if getenv("__USE_DEPRECATED_STACK_FUNCTIONS__", "NO") == "YES" then
+        envFlag = " -D__USE_DEPRECATED_STACK_FUNCTIONS__ ";
+    end
 
     if getenv("DEBUG_SCILAB_DYNAMIC_LINK","NO") == "YES" then
         envFlag = envFlag + " -g ";
index 86cd1f3..8cd52fb 100644 (file)
@@ -61,31 +61,13 @@ function libn = ilib_compile(lib_name, ..
 
     if getos() == "Windows" then
         //** ----------- Windows section  -----------------
-        msgs_make = "";
-        nf = size(files,"*");
 
-        for i=1:nf
-            if ( ilib_verbose() <> 0 ) then
-                mprintf(_("   Compilation of ") + string(files(i)) +"\n");
-            end
-        end
-
-        // then the shared library
-        if ( ilib_verbose() <> 0 ) then
-            mprintf(_("   Building shared library (be patient)\n"));
+        // 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
 
-        [msg, stat] = unix_g(make_command + makename + " all 2>&0");
-        if stat <> 0 then
-            // more feedback when compilation fails
-            [msg, stat, stderr] = unix_g(make_command + makename + " all 1>&2");
-            disp(stderr);
-            error(msprintf(gettext("%s: Error while executing %s.\n"), "ilib_compile", makename));
-        else
-            if ilib_verbose() > 1 then
-                disp(msg);
-            end
-        end
+        dlwCompile(files, make_command, makename);
 
     else
         //** ---------- Linux/MacOS/Unix section ---------------------
@@ -95,7 +77,7 @@ function libn = ilib_compile(lib_name, ..
         // Source tree version
         // Headers are dispatched in the source tree
         if isdir(SCI+"/modules/core/includes/") then
-            defaultModulesCHeader=[ "core", "mexlib","api_scilab","output_stream","localization", "operations", "symbol", "types" ];
+            defaultModulesCHeader=[ "core", "mexlib","api_scilab","output_stream","localization" ];
             defaultModulesFHeader=[ "core" ];
             ScilabTreeFound=%t
 
index e5b24e6..ecb4532 100644 (file)
@@ -1,5 +1,5 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-// Copyright (C) DIGITEO - 2009-2010 - Allan CORNET
+// Copyright (C) DIGITEO - 2009-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
@@ -40,12 +40,12 @@ function ilib_gen_cleaner(makename,loadername,files)
     mfprintf(fd,"// ------------------------------------------------------\n");
 
     if getos() == "Windows" then
-        make_command = get_make_command(makename);
-        mfprintf(fd,"if fileinfo(''%s%s'') <> [] then\n",makename,get_makefile_ext());
-        mfprintf(fd,"  unix_s(''%s'');\n",make_command);
-        mfprintf(fd,"  mdelete(''%s%s'');\n",makename,get_makefile_ext());
-        mfprintf(fd,"end\n");
-        mfprintf(fd,"// ------------------------------------------------------\n");
+        // 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
+
+        dlwGenerateCleaner(fd, makename);
     end
 
     if getos() == "Windows" then
@@ -79,27 +79,3 @@ function ilib_gen_cleaner(makename,loadername,files)
     end
 endfunction
 //=============================================================================
-function cmd = get_make_command(makename)
-    if getos() == "Windows" then // WINDOWS
-        // 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
-        cmd = dlwGetMakefileCmdCleaner(makename);
-    else // LINUX
-        cmd = "make " + makename + " clean";
-    end
-endfunction
-//=============================================================================
-function ext = get_makefile_ext()
-    if getos() == "Windows" then // WINDOWS
-        // 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
-        ext = dlwGetMakefileExt();
-    else // LINUX
-        ext = "";
-    end
-endfunction
-//=============================================================================
index 1210e5a..88a161c 100644 (file)
@@ -11,6 +11,7 @@
 function ilib_gen_loader(varargin)
     // varargin (max) name, tables, libs, libname, flag, loadername
     [lhs, rhs] = argn(0);
+
     if and(rhs <> [2 3 6]) then
         error(msprintf(_("%s: Wrong number of input argument(s): %d,%d or %d expected.\n"), "ilib_gen_loader", 2, 3, 6));
     end
@@ -190,7 +191,7 @@ function bOK = generateLoader(name, tables, libs, libname, flag, loadername)
             mfprintf(fd, "list_functions = [ ");
             withoutSpace = %T;
             for x = table(1:$,1)'
-                if withoutSpace == %t then
+                if withoutSpace then
                     withoutSpace = %F;
                     mfprintf(fd, "''%s'';\n", x);
                 else
index 5423479..1106333 100644 (file)
@@ -68,9 +68,9 @@ function Makename = dlwGenerateMakefile(name, ..
         libname = "lib" + libname;
     end
 
-    //if getenv('__USE_DEPRECATED_STACK_FUNCTIONS__', 'NO') == "YES" then
-    //  cflags = cflags + " -D__USE_DEPRECATED_STACK_FUNCTIONS__";
-    //end
+    if getenv("__USE_DEPRECATED_STACK_FUNCTIONS__", "NO") == "YES" then
+        cflags = cflags + " -D__USE_DEPRECATED_STACK_FUNCTIONS__";
+    end
 
     ilib_gen_Make_win32(name, tables, files, libs, libname, Makename, with_gateway, ldflags, cflags, fflags)
 
@@ -90,7 +90,6 @@ function ilib_gen_Make_win32(name, ..
     managed_ext = [".cxx", ".cpp", ".c", ".f90", ".f"];
 
     SCIDIR = SCI;
-    SCIDIR1 = pathconvert(SCI,%f,%f,"w");
     LIBRARY = name;
     FILES_SRC = "";
     OBJS = "";
@@ -104,6 +103,16 @@ function ilib_gen_Make_win32(name, ..
     MEXFFLAGS = "";
     LDFLAGS = ldflags;
 
+    SCILAB_INCLUDES = dlwGetScilabIncludes();
+    SCILAB_INCLUDES = "-I""" + SCILAB_INCLUDES + """";
+    SCILAB_INCLUDES = [SCILAB_INCLUDES(1:$-1) + " \"; SCILAB_INCLUDES($)];
+    SCILAB_INCLUDES = strcat(SCILAB_INCLUDES, ascii(10));
+
+    SCILAB_LIBS = dlwGetScilabLibraries();
+    SCILAB_LIBS = """$(SCIDIR)/bin/" + SCILAB_LIBS + """";
+    SCILAB_LIBS = [SCILAB_LIBS(1:$-1) + " \"; SCILAB_LIBS($)];
+    SCILAB_LIBS = strcat(SCILAB_LIBS, ascii(10));
+
     if isempty(libname) then
         LIBRARY = name;
     else
@@ -219,7 +228,8 @@ function ilib_gen_Make_win32(name, ..
     end
 
     MAKEFILE_VC = strsubst(MAKEFILE_VC, "__SCI__", SCIDIR);
-    MAKEFILE_VC = strsubst(MAKEFILE_VC, "__SCIDIR1__", SCIDIR1);
+    MAKEFILE_VC = strsubst(MAKEFILE_VC, "__SCILAB_INCLUDES__", SCILAB_INCLUDES);
+    MAKEFILE_VC = strsubst(MAKEFILE_VC, "__SCILAB_LIBS__",SCILAB_LIBS);
     MAKEFILE_VC = strsubst(MAKEFILE_VC, "__LIBNAME__", LIBRARY);
     MAKEFILE_VC = strsubst(MAKEFILE_VC, "__FILES_SRC__", FILES_SRC);
     MAKEFILE_VC = strsubst(MAKEFILE_VC, "__OBJS__", OBJS);
index 4432695..fb2f68d 100644 (file)
@@ -12,7 +12,6 @@ function scilabincludeslist = dlwGetScilabIncludes()
 
     scilabincludeslist = ["$(SCIDIR)/libs/MALLOC/includes"; ..
     "$(SCIDIR)/libs/f2c"; ..
-    "$(SCIDIR)/libs/hashtable"; ..
     "$(SCIDIR)/libs/intl"; ..
     "$(SCIDIR)/modules/core/includes"; ..
     "$(SCIDIR)/modules/api_scilab/includes"; ..
@@ -23,6 +22,9 @@ function scilabincludeslist = dlwGetScilabIncludes()
     "$(SCIDIR)/modules/dynamic_link/includes"; ..
     "$(SCIDIR)/modules/mexlib/includes"; ..
     "$(SCIDIR)/modules/time/includes"; ..
-    "$(SCIDIR)/modules/windows_tools/includes"];
+    "$(SCIDIR)/modules/windows_tools/includes"; ..
+    "$(SCIDIR)/modules/symbol/includes"; ..
+    "$(SCIDIR)/modules/types/includes"; ..
+    "$(SCIDIR)/modules/operations/includes"];
 endfunction
 //=============================================================================
\ No newline at end of file
index 624ba71..2c84fed 100644 (file)
@@ -15,7 +15,6 @@ function scilablibrarieslist = dlwGetScilabLibraries()
     "core_f.lib"; ..
     "lapack.lib"; ..
     "libintl.lib"; ..
-    "intersci.lib"; ..
     "output_stream.lib"; ..
     "dynamic_link.lib"; ..
     "integer.lib"; ..
@@ -26,7 +25,9 @@ function scilablibrarieslist = dlwGetScilabLibraries()
     "call_scilab.lib"; ..
     "time.lib"; ..
     "api_scilab.lib"; ..
-    "scilab_windows.lib"];
-
+    "scilab_windows.lib"; ..
+    "types.lib"; ..
+    "operations.lib"; ..
+    "symbol.lib"];
 endfunction
 //=============================================================================
\ No newline at end of file
index 5043a94..24a5bf5 100644 (file)
@@ -34,7 +34,5 @@ function SDKpath = dlwGetSdkPath()
         end
     end
 
-    //clear lasterror before exit
-    lasterror();
 endfunction
 //=============================================================================
index 6c38b6b..5c9c273 100644 (file)
@@ -33,25 +33,6 @@ CC__OPTIMISATION_MODE=-Z7 -O2 -MD -DNDEBUG
 CC_COMMON=-D__MSC__ -DFORDLL $(DWIN) -c -DSTRICT -D_CRT_SECURE_NO_DEPRECATE -D__MAKEFILEVC__ -nologo $(INCLUDES)
 LINKER_FLAGS=/NOLOGO $(MACHINE) /DYNAMICBASE:NO /NXCOMPAT:NO $(LINKER_OPTIMISATION_MODE)
 CC_OPTIONS = $(CC_COMMON) -W3 -Gd $(CC__OPTIMISATION_MODE) /Fo"$(DIR_OBJ)/" /Fd"$(DIR_OBJ)/"
-
-# include options 
-INCLUDES=-I"$(SCIDIR)/libs/MALLOC/includes" \
--I"$(SCIDIR)/modules/core/includes" \
--I"$(SCIDIR)/modules/api_scilab/includes" \
--I"$(SCIDIR)/modules/call_scilab/includes" \
--I"$(SCIDIR)/modules/output_stream/includes" \
--I"$(SCIDIR)/modules/jvm/includes" \
--I"$(SCIDIR)/modules/localization/includes" \
--I"$(SCIDIR)/modules/dynamic_link/includes" \
--I"$(SCIDIR)/modules/mexlib/includes" \
--I"$(SCIDIR)/modules/time/includes" \
--I"$(SCIDIR)/modules/windows_tools/includes" \
--I"$(SCIDIR)/libs/f2c" \
--I"$(SCIDIR)/libs/hashtable" \
--I"$(SCIDIR)/libs/intl" \
--I"$(SCIDIR)/modules/operations/includes" \
--I"$(SCIDIR)/modules/symbol/includes" \
--I"$(SCIDIR)/modules/types/includes"
 #==================================================
 CC_LDFLAGS = 
 #==================================================
@@ -89,7 +70,7 @@ FC_OPTIONS_COMMON=/nologo /DFORDLL /assume:underscore \
 /noaltparam /f77rtl /fpscomp:nolibs /names:lowercase \
 /iface:cref /threads /c /Qvc9 \
 /Fo"$(DIR_OBJ)/" /Fd"$(DIR_OBJ)/" \
-/include:"$(SCIDIR1)/modules/core/includes"
+/include:"$(SCIDIR)/modules/core/includes"
 #==================================================
 !IF "$(DEBUG_SCILAB_DYNAMIC_LINK)" == "YES"
 FC_OPTIONS=$(FC_OPTIONS_COMMON) /Zi /Od /debug /dbglibs
@@ -106,22 +87,6 @@ LINKER_FLAGS=$(LINKER_FLAGS) /force:multiple
 RC=rc
 RCVARS=-r -DWIN32
 #==================================================
-# Libraries 
-#==================================================
-# SCILAB_LIBS is used by the binary version of Scilab for linking external codes
-SCILAB_LIBS="$(SCIDIR1)/bin/MALLOC.lib" "$(SCIDIR1)/bin/blasplus.lib" \
-"$(SCIDIR1)/bin/libf2c.lib" "$(SCIDIR1)/bin/lapack.lib" \
-"$(SCIDIR1)/bin/intersci.lib" \
-"$(SCIDIR1)/bin/output_stream.lib" "$(SCIDIR1)/bin/dynamic_link.lib" \
-"$(SCIDIR1)/bin/integer.lib" "$(SCIDIR1)/bin/optimization_f.lib" \
-"$(SCIDIR1)/bin/libjvm.lib" "$(SCIDIR1)/bin/scilocalization.lib" \
-"$(SCIDIR1)/bin/libintl.lib" "$(SCIDIR1)/bin/linpack_f.lib" \
-"$(SCIDIR1)/bin/call_scilab.lib" "$(SCIDIR1)/bin/time.lib" \
-"$(SCIDIR1)/bin/api_scilab.lib" "$(SCIDIR1)/bin/hashtable.lib" \
-"$(SCIDIR1)/bin/scilab_windows.lib" "$(SCIDIR1)/bin/operations.lib" \
-"$(SCIDIR1)/bin/symbol.lib"
-
-#==================================================
 # default rules for Fortran 77 & 90 Compilation 
 #==================================================
 !IF "$(USE_F2C)" == "YES"
@@ -131,9 +96,9 @@ SCILAB_LIBS="$(SCIDIR1)/bin/MALLOC.lib" "$(SCIDIR1)/bin/blasplus.lib" \
 .f{$(DIR_OBJ)}.obj     :
        @echo ----------- Compile file $< (using f2c) -------------
 !IF "$(F2C_IMPORT_COMMON)" == "YES"    
-       @"$(SCIDIR1)/bin/f2c.exe" -E -I"$(SCIDIR1)/modules/core/includes" $(FFLAGS) $< 2>NUL
+       @"$(SCIDIR)/bin/f2c.exe" -E -I"$(SCIDIR)/modules/core/includes" $(FFLAGS) $< 2>NUL
 !ELSE
-       @"$(SCIDIR1)/bin/f2c.exe" -I"$(SCIDIR1)/modules/core/includes" $(FFLAGS) $< 2>NUL
+       @"$(SCIDIR)/bin/f2c.exe" -I"$(SCIDIR)/modules/core/includes" $(FFLAGS) $< 2>NUL
 !ENDIF
        -IF NOT EXIST  $(DIR_OBJ) mkdir $(DIR_OBJ)
 
index 2dcc5ea..873ce76 100644 (file)
@@ -4,7 +4,12 @@
 # see SCI/modules/dynamic_link/src/scripts/TEMPLATE_MAKEFILE.VC
 # ------------------------------------------------------
 SCIDIR = __SCI__
-SCIDIR1 = __SCIDIR1__
+# ------------------------------------------------------
+# default include options 
+INCLUDES = __SCILAB_INCLUDES__
+# ------------------------------------------------------
+# SCILAB_LIBS is used by the binary version of Scilab for linking external codes
+SCILAB_LIBS = __SCILAB_LIBS__
 # ------------------------------------------------------
 # name of the dll to be built
 LIBRARY = __LIBNAME__
@@ -20,7 +25,7 @@ OBJS_WITH_PATH = __OBJS_WITH_PATH__
 FORTRAN_RUNTIME_LIBRARIES = __FORTRAN_RUNTIME__
 OTHERLIBS = __OTHERSLIBS__
 # ------------------------------------------------------
-!include $(SCIDIR1)\modules\dynamic_link\src\scripts\Makefile.incl.mak
+!include $(SCIDIR)\modules\dynamic_link\src\scripts\Makefile.incl.mak
 # ------------------------------------------------------
 CC = __CC__
 # ------------------------------------------------------
@@ -30,5 +35,5 @@ FFLAGS = $(FC_OPTIONS) -DFORDLL __FFLAGS__ __MEXFFLAGS__
 # ------------------------------------------------------
 EXTRA_LDFLAGS = __LDFLAGS__
 # ------------------------------------------------------
-!include $(SCIDIR1)\modules\dynamic_link\src\scripts\Makedll.incl
+!include $(SCIDIR)\modules\dynamic_link\src\scripts\Makedll.incl
 # ------------------------------------------------------