better way to do dll (io module)
Allan CORNET [Fri, 28 Aug 2009 14:18:39 +0000 (16:18 +0200)]
scilab/modules/io/Makefile.am
scilab/modules/io/includes/GetenvB.h
scilab/modules/io/includes/dynlib_io.h [new file with mode: 0644]
scilab/modules/io/includes/getenvc.h
scilab/modules/io/includes/gw_io.h
scilab/modules/io/includes/setenvc.h
scilab/modules/io/src/c/io.vcproj
scilab/modules/io/src/c/io_header.def [deleted file]

index 63f8be2..10a3761 100644 (file)
@@ -98,6 +98,7 @@ libsciio_la_includedir=$(pkgincludedir)/io
 libsciio_la_include_HEADERS = includes/gw_io.h \
 includes/getenvc.h \
 includes/setenvc.h \
-includes/GetenvB.h
+includes/GetenvB.h \
+includes/dynlib_io.h
 
 include $(top_srcdir)/Makefile.incl.am
index b32c288..1d7fcd0 100644 (file)
@@ -13,6 +13,7 @@
 #ifndef __GETENVB_H__
 #define __GETENVB_H__
 
+#include "dynlib_io.h"
 /**
  * getenv + squash trailing white spaces 
  *
@@ -20,6 +21,6 @@
  * @param env   
  * @param len   
  */
-void GetenvB(char *name, char *env, int len);
+IO_IMPEXP void GetenvB(char *name, char *env, int len);
 
 #endif /* __GETENVB_H__ */
\ No newline at end of file
diff --git a/scilab/modules/io/includes/dynlib_io.h b/scilab/modules/io/includes/dynlib_io.h
new file mode 100644 (file)
index 0000000..9e53f57
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+* Copyright (C) DIGITEO - 2009 - 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
+*
+*/
+
+/*--------------------------------------------------------------------------*/ 
+#ifndef __DYNLIB_IO_H__
+#define __DYNLIB_IO_H__
+
+#ifdef _MSC_VER
+#ifdef IO_EXPORTS
+#define IO_IMPEXP __declspec(dllexport)
+#else
+#define IO_IMPEXP __declspec(dllimport)
+#endif
+#else
+#define IO_IMPEXP
+#endif
+
+#endif /* __DYNLIB_IO_H__ */
+/*--------------------------------------------------------------------------*/ 
index 96809e2..b6283c7 100644 (file)
@@ -13,6 +13,8 @@
 
 #ifndef __GETENVC_H__
 #define __GETENVC_H__
+
+#include "dynlib_io.h"
 #include "machine.h"
 
 /**
@@ -23,7 +25,7 @@
  * @param[out] buflen  the length of the variable
  * @param[in] iflag 
  */
-void C2F(getenvc)(int *ierr,char *var,char *buf,int *buflen,int *iflag);
+IO_IMPEXP void C2F(getenvc)(int *ierr,char *var,char *buf,int *buflen,int *iflag);
 
 /**
 * Searches for a file using environment paths
@@ -31,7 +33,7 @@ void C2F(getenvc)(int *ierr,char *var,char *buf,int *buflen,int *iflag);
 * @param[in] environment variable where we search
 * @return path found
 */
-char *searchEnv(const char *name,const char *env_var);
+IO_IMPEXP char *searchEnv(const char *name,const char *env_var);
 
 
 #endif /* __GETENVC_H__ */
index fe4cfb1..35c95bb 100644 (file)
 #define __GW_IO_H__
 /*--------------------------------------------------------------------------*/
 #include "machine.h"
+#include "dynlib_io.h"
 #include "api_common.h"
 /*--------------------------------------------------------------------------*/
-int gw_io(void);
+IO_IMPEXP int gw_io(void);
 /*--------------------------------------------------------------------------*/
-int C2F(sci_read)(char *fname,unsigned long fname_len);
-int C2F(sci_oldsave)(char *fname,unsigned long fname_len);
-int C2F(sci_write)(char *fname,unsigned long fname_len);
-int C2F(sci_rat)(char *fname,unsigned long fname_len);
-int C2F(sci_file)(char *fname,unsigned long fname_len);
-int C2F(sci_host)(char *fname,unsigned long fname_len);
-int C2F(sci_unix)(char *fname,unsigned long fname_len);
-int C2F(sci_readb)(char *fname,unsigned long fname_len);
-int C2F(sci_writb)(char *fname,unsigned long fname_len);
-int C2F(sci_getpid)(char *fname,unsigned long fname_len);
-int C2F(sci_getenv)(char *fname,unsigned long fname_len);
-int C2F(sci_read4b)(char *fname,unsigned long fname_len);
-int C2F(sci_write4b)(char *fname,unsigned long fname_len);
-int C2F(sci_save)(char *fname,unsigned long fname_len);
-int C2F(sci_load)(char *fname,unsigned long fname_len);
-int C2F(sci_mgetl)(char *fname,unsigned long fname_len);
-int C2F(sci_getio)(char *fname,unsigned long fname_len);
-int C2F(sci_setenv)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_read)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_oldsave)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_write)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_rat)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_file)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_host)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_unix)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_readb)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_writb)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_getpid)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_getenv)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_read4b)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_write4b)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_save)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_load)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_mgetl)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_getio)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(sci_setenv)(char *fname,unsigned long fname_len);
 
-int C2F(intgetenv)(char *fname,unsigned long fname_len);
-int C2F(intload) (int *id1, int *k1); /* FORTRAN subroutine */
-int C2F(intsave)(void);
-int C2F(intfile)(void);
-int C2F(intmgetl)(void);
-int C2F(intrat)(void);
-int C2F(intread)(void);
-int C2F(intread4b)(void);
-int C2F(intreadb)(void);
-int C2F(intwrite)(void);
-int C2F(intwrite4b)(void);
-int C2F(intwritb)(void);
+IO_IMPEXP int C2F(intgetenv)(char *fname,unsigned long fname_len);
+IO_IMPEXP int C2F(intload) (int *id1, int *k1); /* FORTRAN subroutine */
+IO_IMPEXP int C2F(intsave)(void);
+IO_IMPEXP int C2F(intfile)(void);
+IO_IMPEXP int C2F(intmgetl)(void);
+IO_IMPEXP int C2F(intrat)(void);
+IO_IMPEXP int C2F(intread)(void);
+IO_IMPEXP int C2F(intread4b)(void);
+IO_IMPEXP int C2F(intreadb)(void);
+IO_IMPEXP int C2F(intwrite)(void);
+IO_IMPEXP int C2F(intwrite4b)(void);
+IO_IMPEXP int C2F(intwritb)(void);
 
 /*--------------------------------------------------------------------------*/
 #endif /* __GW_IO_H__ */
index 1d41a04..d9f7bc4 100644 (file)
@@ -12,7 +12,7 @@
 
 #ifndef __SETENVC_H__
 #define __SETENVC_H__
-
+#include "dynlib_io.h"
 #include "BOOL.h"
 
 /**
  * @param[in] value the value of the variable "string"
  * @return FALSE if there is a problem otherwise TRUE
  */
-BOOL setenvc(char *string,char *value);
+IO_IMPEXP BOOL setenvc(char *string,char *value);
 
 /**
  * TODO : comment 
  * @return 
  */
-int getUpdateEnvVar(void);
+IO_IMPEXP int getUpdateEnvVar(void);
 
 /**
  * TODO : comment 
  * @param val
  */
-void setUpdateEnvVar(int val);
+IO_IMPEXP void setUpdateEnvVar(int val);
 
 #endif /* __SETENVC_H__ */
 /*--------------------------------------------------------------------------*/
index 5f5352e..fcf8fad 100644 (file)
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)io_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)io_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)scilab_windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n io.dll %%f &gt;nul&#x0D;&#x0A;copy *.def iotmp.def &gt;nul&#x0D;&#x0A;copy ..\io_header.def+iotmp.def  ..\io.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)io_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)io_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)scilab_windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies="LibScilab.lib io_f.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
-                               ModuleDefinitionFile="io.def"
+                               ModuleDefinitionFile=""
                                GenerateDebugInformation="true"
                                SubSystem="2"
                                RandomizedBaseAddress="1"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)io_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)io_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)scilab_windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n io.dll %%f &gt;nul&#x0D;&#x0A;copy *.def iotmp.def &gt;nul&#x0D;&#x0A;copy ..\io_header.def+iotmp.def  ..\io.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)io_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)io_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)scilab_windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies="LibScilab.lib io_f.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
-                               ModuleDefinitionFile="io.def"
+                               ModuleDefinitionFile=""
                                GenerateDebugInformation="true"
                                SubSystem="2"
                                RandomizedBaseAddress="1"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)io_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)io_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)scilab_windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n io.dll %%f &gt;nul&#x0D;&#x0A;copy *.def iotmp.def &gt;nul&#x0D;&#x0A;copy ..\io_header.def+iotmp.def  ..\io.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)io_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)io_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)scilab_windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X86 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies="LibScilab.lib io_f.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
-                               ModuleDefinitionFile="io.def"
+                               ModuleDefinitionFile=""
                                GenerateDebugInformation="false"
                                SubSystem="2"
                                OptimizeReferences="2"
                        <Tool
                                Name="VCPreLinkEventTool"
                                Description="Make dependencies"
-                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)io_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)io_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)scilab_windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;cd $(IntDir) &gt;nul&#x0D;&#x0A;for %%f in (*.obj) do  ..\..\..\..\..\bin\dumpexts -o %%~nf.def -n io.dll %%f &gt;nul&#x0D;&#x0A;copy *.def iotmp.def &gt;nul&#x0D;&#x0A;copy ..\io_header.def+iotmp.def  ..\io.def &gt;nul&#x0D;&#x0A;del *.def &gt;nul&#x0D;&#x0A;cd .. &gt;nul&#x0D;&#x0A;"
+                               CommandLine="lib /DEF:&quot;$(InputDir)LibScilab_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)LibScilab.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)io_f_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)io_f.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;lib /DEF:&quot;$(InputDir)scilab_windows_Import.def&quot; /SUBSYSTEM:WINDOWS /MACHINE:X64 /OUT:&quot;$(InputDir)scilab_windows.lib&quot; 1&gt;NUL 2&gt;NUL&#x0D;&#x0A;"
                        />
                        <Tool
                                Name="VCLinkerTool"
                                AdditionalDependencies="LibScilab.lib io_f.lib scilab_windows.lib"
                                OutputFile="../../../../bin/$(ProjectName).dll"
                                LinkIncremental="1"
-                               ModuleDefinitionFile="io.def"
+                               ModuleDefinitionFile=""
                                GenerateDebugInformation="false"
                                SubSystem="2"
                                OptimizeReferences="2"
                        Filter="h;hpp;hxx;hm;inl"
                        >
                        <File
+                               RelativePath="..\..\includes\dynlib_io.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\..\includes\GetenvB.h"
                                >
                        </File>
                <Filter
                        Name="Libraries Dependencies"
                        >
-                       <File
-                               RelativePath=".\io_header.def"
-                               >
-                       </File>
                        <Filter
                                Name="Imports"
                                >
diff --git a/scilab/modules/io/src/c/io_header.def b/scilab/modules/io/src/c/io_header.def
deleted file mode 100644 (file)
index 0b7b7c7..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-LIBRARY    io.dll
-
-
-EXPORTS
-; --------------------------------------- 
-; io
-; ---------------------------------------