add ilib_language to retrieve compiler capabilities 00/18700/2
Antoine ELIAS [Mon, 21 Nov 2016 07:41:54 +0000 (08:41 +0100)]
Change-Id: Ifaa4262ee048de0b9e1f5f80ab32cec3ee2e912f

scilab/contrib/toolbox_skeleton/sci_gateway/cpp/builder_gateway_cpp.sce
scilab/modules/dynamic_link/includes/dynamiclibrary_others.h
scilab/modules/dynamic_link/macros/ilib_build.sci
scilab/modules/dynamic_link/macros/ilib_language.sci [new file with mode: 0644]
scilab/modules/dynamic_link/macros/windows/dlwGenerateMakefile.sci
scilab/modules/dynamic_link/src/c/dynamic_link.vcxproj
scilab/modules/dynamic_link/src/c/dynamic_link.vcxproj.filters
scilab/modules/modules_manager/macros/tbx_build_cleaner.sci
scilab/modules/string/includes/os_string.h

index c691b1a..b27d887 100644 (file)
@@ -4,19 +4,30 @@ function builder_gw_cpp()
 
     includes_src_c = ilib_include_flag(get_absolute_file_path("builder_gateway_cpp.sce") + "../../src/c");
 
-    tbx_build_gateway("skeleton_cpp", ..
-        ["cpp_find","sci_cpp_find", "csci"; ..
-        "cpp_error", "sci_cpperror", "cppsci"; ..
-        "cpp_foo", "sci_cppfoo", "cppsci"; ..
-        "cpp_sum", "sci_cppsum", "cppsci"; ..
-        "cpp_sub", "sci_cppsub", "cppsci"; ..
-        "cpp_multiplybypi", "sci_cppmultiplybypi", "cppsci"], ..
-        ["sci_cpp_find.cxx", "sci_cpperror.cpp", "sci_cppfoo.cpp", "sci_cppsum.cpp", "sci_cppsub.cpp", "sci_cppmultiplybypi.cpp"], ..
-        get_absolute_file_path("builder_gateway_cpp.sce"), ..
-        ["../../src/c/libcsum"], ..
-        "", ..
-        includes_src_c);
-
+    //adapt to compiler capabilities
+    l = ilib_language();
+    if ~isempty(grep(l, "cppsci")) then
+        tbx_build_gateway("skeleton_cpp", ..
+            ["cpp_find","sci_cpp_find", "csci"; ..
+            "cpp_error", "sci_cpperror", "cppsci"; ..
+            "cpp_foo", "sci_cppfoo", "cppsci"; ..
+            "cpp_sum", "sci_cppsum", "cppsci"; ..
+            "cpp_sub", "sci_cppsub", "cppsci"; ..
+            "cpp_multiplybypi", "sci_cppmultiplybypi", "cppsci"], ..
+            ["sci_cpp_find.cxx", "sci_cpperror.cpp", "sci_cppfoo.cpp", "sci_cppsum.cpp", "sci_cppsub.cpp", "sci_cppmultiplybypi.cpp"], ..
+            get_absolute_file_path("builder_gateway_cpp.sce"), ..
+            ["../../src/c/libcsum"], ..
+            "", ..
+            includes_src_c);
+    else
+        tbx_build_gateway("skeleton_cpp", ..
+            ["cpp_find","sci_cpp_find", "csci"], ..
+            ["sci_cpp_find.cxx"], ..
+            get_absolute_file_path("builder_gateway_cpp.sce"), ..
+            ["../../src/c/libcsum"], ..
+            "", ..
+            includes_src_c);
+    end
 endfunction
 
 builder_gw_cpp();
index 5555b92..c1d13a2 100644 (file)
@@ -15,7 +15,7 @@
  */
 #ifndef __DYNAMICLIBRARY_OTHERS_H__
 #define __DYNAMICLIBRARY_OTHERS_H__
-#if defined(__APPLE__) || defined(__unix__) // guard against mis-compilation
+#if defined(__GNUC__) // guard against mis-compilation
 
 #include <dlfcn.h>
 #include <wchar.h>
index 86ebebf..cdef2f1 100644 (file)
@@ -98,6 +98,20 @@ function ilib_build(ilib_name, ..
         mprintf(_("   Generate a gateway file\n"));
     end
 
+    //check supported language
+    l = ilib_language();
+    if size(table, "c") > 2 then
+        lang = table(:, 3);
+    else
+        lang(1:size(table, "r")) = "csci";
+    end
+
+    for i = 1:size(lang, "*")
+        if isempty(grep(l, lang(i))) then
+            error(999, msprintf(_("%s: ""%s"" format is not supported by your compiler."), "ilib_build", lang(i)));
+        end
+    end
+
     file_gw_name = ilib_gen_gateway(ilib_name, table);
 
     // generate a loader file
diff --git a/scilab/modules/dynamic_link/macros/ilib_language.sci b/scilab/modules/dynamic_link/macros/ilib_language.sci
new file mode 100644 (file)
index 0000000..0d46ebe
--- /dev/null
@@ -0,0 +1,16 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) Scilab Enterprises - 2016 - 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 l = ilib_language()
+    l = ["cmex","fmex","Fmex","csci","csci6","fsci","cppsci","cppsciopt","direct"];
+endfunction
+//=============================================================================
index 588a653..0add43d 100644 (file)
@@ -80,7 +80,7 @@ function Makename = dlwGenerateMakefile(name, ..
 endfunction
 //=============================================================================
 function ilib_gen_Make_win32(name, ..
-    table, ..
+    tables, ..
     files, ..
     libs, ..
     libname, ..
index d4f0397..c6a4fa1 100644 (file)
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\includes\addinter.h" />
+    <ClInclude Include="..\..\includes\dynamiclibrary.h" />
     <ClInclude Include="..\..\includes\dynamiclibrary_windows.h" />
     <ClInclude Include="dllinfo.h" />
     <ClInclude Include="dl_genErrorMessage.h" />
index e04ae61..151ea82 100644 (file)
@@ -73,6 +73,9 @@
     <ClInclude Include="..\..\includes\dynamiclibrary_windows.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\includes\dynamiclibrary.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="core_import.def">
index d2ae71c..45a2914 100644 (file)
@@ -113,7 +113,7 @@ function tbx_build_cleaner(name, path)
     "perform_clean();",
     "catch"
     "    [errmsg, tmp, nline, func] = lasterror()"
-    "    msg = ""%s: error on line #%d: ""%s""\n"""
+    "    msg = ""%s: error on line #%d: """"%s""""\n"""
     "    msg = msprintf(msg, func, nline, errmsg)"
     "    lines(oldlines)"
     "    mode(oldmode);"
index a2a35f0..bbeb64b 100644 (file)
 #define os_splitpath    _splitpath_s
 #define os_wsplitpath   _wsplitpath_s
 #define os_makepath     _makepath_s
-#endif
-
-// Linux
-#ifdef __linux__
 
-#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 10
-/* Fixes crash issues with wcsdup when: */
-/* - Scilab is compiled against old GLIBC (<2.10) */
-/* - AND executed against recent GLIBC (>=2.10) */
-/* See man wcsdup */
-/* Using #define _GNU_SOURCE is not enough in Scilab because */
-/* <wchar.h> can be included before "os_string.h" */
-wchar_t *_sciwcsdup(const wchar_t *_pwcsSource);
-#define os_wcsdup       _sciwcsdup
 #else
-#define os_wcsdup       wcsdup
-#endif
 
-#define os_strdup       strdup
-#define os_swprintf     swprintf
-#define os_sprintf      sprintf
-#define os_wcsicmp      wcscasecmp
-#define stricmp         strcasecmp
-#define strnicmp        strncasecmp
-#define wcsicmp         wcscasecmp
-#define wcsnicmp        wcsncasecmp
-#define os_strcpy       strcpy
-#define os_splitpath    _splitpath
-#define os_wsplitpath   _wsplitpath
-#define os_makepath     _makepath
-#endif
-
-// MacOS X
 #ifdef __APPLE__
 wchar_t *_sciwcsdup(const wchar_t *_pwcsSource);
 #define os_wcsdup       _sciwcsdup
@@ -114,6 +84,38 @@ static inline int macOSwcscasecmp(const wchar_t *_pwcsS1, const wchar_t *_pwcsS2
 #define os_splitpath    _splitpath
 #define os_wsplitpath   _wsplitpath
 #define os_makepath     _makepath
+
+#else //linux or MinGw
+
+#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 10
+/* Fixes crash issues with wcsdup when: */
+/* - Scilab is compiled against old GLIBC (<2.10) */
+/* - AND executed against recent GLIBC (>=2.10) */
+/* See man wcsdup */
+/* Using #define _GNU_SOURCE is not enough in Scilab because */
+/* <wchar.h> can be included before "os_string.h" */
+wchar_t *_sciwcsdup(const wchar_t *_pwcsSource);
+#define os_wcsdup       _sciwcsdup
+#else
+#define os_wcsdup       wcsdup
 #endif
 
+#define os_strdup       strdup
+#define os_swprintf     swprintf
+#define os_sprintf      sprintf
+#define os_wcsicmp      wcscasecmp
+#define stricmp         strcasecmp
+#define strnicmp        strncasecmp
+#define wcsicmp         wcscasecmp
+#define wcsnicmp        wcsncasecmp
+#define os_strcpy       strcpy
+#define os_splitpath    _splitpath
+#define os_wsplitpath   _wsplitpath
+#define os_makepath     _makepath
+
+#endif //if __APPLE__
+#endif //if _MSC_VER
+
+// MacOS X
+
 #endif /* !__OS_STRING_H__ */