Added ilib_include_flag macro to handle platform 77/1777/14
Vincent LEJEUNE [Wed, 1 Sep 2010 15:16:39 +0000 (17:16 +0200)]
dependant way of passing includes paths to system compiler

Change-Id: I70a3b2a2f23fc9ce25279406d916395bdbf54dbb

SEP/SEP_55_ilib_include_flag.odt [new file with mode: 0644]
scilab/CHANGES_5.3.X
scilab/modules/dynamic_link/help/en_US/ilib_include_flag.xml [new file with mode: 0644]
scilab/modules/dynamic_link/macros/ilib_include_flag.sci [new file with mode: 0644]
scilab/modules/dynamic_link/tests/unit_tests/ilib_include_flag.dia.ref [new file with mode: 0644]
scilab/modules/dynamic_link/tests/unit_tests/ilib_include_flag.tst [new file with mode: 0644]

diff --git a/SEP/SEP_55_ilib_include_flag.odt b/SEP/SEP_55_ilib_include_flag.odt
new file mode 100644 (file)
index 0000000..c9a5f1e
Binary files /dev/null and b/SEP/SEP_55_ilib_include_flag.odt differ
index 976074c..17e6f45 100644 (file)
@@ -116,6 +116,9 @@ Dynamic link:
   of TMPDIR instead of doing everything in the same directory. This could have
   lead to unexpected side effects.
 
+* Added 'ilib_include_path' macro to handle includes flag for platform
+  compiler. See SEP 55.
+
 
 Graphics:
 =========
diff --git a/scilab/modules/dynamic_link/help/en_US/ilib_include_flag.xml b/scilab/modules/dynamic_link/help/en_US/ilib_include_flag.xml
new file mode 100644 (file)
index 0000000..ae4d5c3
--- /dev/null
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab * 
+       Copyright (C) 2008 - INRIA * * 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 
+       * -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+       xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
+       xmlns:db="http://docbook.org/ns/docbook" version="5.0-subset Scilab"
+       xml:lang="en" xml:id="ilib_include_flag">
+       <info>
+               <pubdate>$LastChangedDate$</pubdate>
+       </info>
+       <refnamediv>
+               <refname>ilib_include_flag</refname>
+               <refpurpose> Return a formated includes related string to pass to
+                       system compiler</refpurpose>
+       </refnamediv>
+       <refsynopsisdiv>
+               <title>Call Sequence</title>
+               <synopsis>compiler_flag = ilib_include_flag(path_strings)</synopsis>
+       </refsynopsisdiv>
+       <refsection>
+               <title>Arguments</title>
+               <variablelist>
+                       <varlistentry>
+                               <term>path_strings</term>
+                               <listitem>
+                                       <para>Vector of relative or absolute path as string.</para>
+                               </listitem>
+                       </varlistentry>
+                       <varlistentry>
+                               <term>compiler_flag</term>
+                               <listitem>
+                                       <para>Compiler flag as string</para>
+                               </listitem>
+                       </varlistentry>
+               </variablelist>
+       </refsection>
+
+       <refsection>
+               <title>Description</title>
+               <para>This function is an utility function provided to handle several
+                       includes path. The result can be passed to tbx_build_gateway.</para>
+       </refsection>
+
+       <refsection>
+               <title>Exemples</title>
+               <programlisting role="example"><![CDATA[ 
+    
+    includes_path = ["../src/includes";"/usr/include/somelib/includes";"."];
+    includes_src_c = ilib_include_flag(includes_path);
+    
+    ilib_build('somelib',['myfun',sci_myfun'],['myfile.c'],[],[],includes_src_c);
+    
+]]></programlisting>
+       </refsection>
+       <refsection>
+               <title>See Also</title>
+               <simplelist type="inline">
+                       <member>
+                               <link linkend="tbx_build_gateway">tbx_build_gateway</link>
+                               <link linkend="ilib_build">ilib_build</link>
+                       </member>
+               </simplelist>
+       </refsection>
+</refentry>
diff --git a/scilab/modules/dynamic_link/macros/ilib_include_flag.sci b/scilab/modules/dynamic_link/macros/ilib_include_flag.sci
new file mode 100644 (file)
index 0000000..48a5b48
--- /dev/null
@@ -0,0 +1,29 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) DIGITEO - 2010 - Vincent LEJEUNE
+//
+// 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
+//=============================================================================
+
+function ret = ilib_include_flag(path_strings)
+
+  if type(path_strings) <> 10 then
+    error(msprintf(gettext("%s: Wrong type for input argument #%d: A string expected.\n"), "ilib_include_flag", 1));
+  end
+
+  ret = "";
+
+  for path = path_strings
+    if ~isdir(fullpath(path)) then
+      error(msprintf(gettext("%s: Failed to add include path : %s"), "ilib_include_flag", path));
+    end
+    if (getos() == "Windows") then
+      ret = ret + " -I""" + fullpath(path) + """";
+    else
+      ret = ret + " -I" + fullpath(path);
+    end
+  end
+endfunction
diff --git a/scilab/modules/dynamic_link/tests/unit_tests/ilib_include_flag.dia.ref b/scilab/modules/dynamic_link/tests/unit_tests/ilib_include_flag.dia.ref
new file mode 100644 (file)
index 0000000..f686966
--- /dev/null
@@ -0,0 +1,25 @@
+// =============================================================================                                                                                                                                  
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab                                                                                                                                                                                                                                                                                                                              
+// Copyright (C) 2010 - DIGITEO - Vincent LEJEUNE
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// Check failure case
+if ( execstr('ilib_include_flag(3)','errcatch') == 0 ) then bugmes();quit;end
+// not a dir, should fail
+if ( execstr('ilib_include_flag(/usr/include/stdlib.h)','errcatch')  == 0 ) then bugmes();quit;end
+ // should not exist, should fail
+if ( execstr('ilib_include_flag(/usr/my_exotic_dir/);','errcatch')  == 0 ) then bugmes();quit;end
+cd TMPDIR;
+mkdir("myincludespath");
+if getos() == "Windows" then 
+  ref_flag = " -I""" + WSCI + "/bin"" " + "-I""" + WSCI + "/modules"" -I""" + getlongpathname(TMPDIR) + filesep() + "myincludespath""";
+  ref_flag = strsubst(ref_flag, "/", filesep());
+else
+  ref_flag = " -I" + SCI + "/bin " + "-I" + SCI + "/modules -I" + TMPDIR + filesep() + "myincludespath";
+end 
+includes_path = [ "bin" , "modules" , TMPDIR + filesep() + "myincludespath"];
+cd SCI;
+output_flag = ilib_include_flag(includes_path);
+if (ref_flag ~= output_flag) then bugmes();quit;end
diff --git a/scilab/modules/dynamic_link/tests/unit_tests/ilib_include_flag.tst b/scilab/modules/dynamic_link/tests/unit_tests/ilib_include_flag.tst
new file mode 100644 (file)
index 0000000..a8f94e8
--- /dev/null
@@ -0,0 +1,33 @@
+// =============================================================================                                                                                                                                  
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab                                                                                                                                                                                                                                                                                                                              
+// Copyright (C) 2010 - DIGITEO - Vincent LEJEUNE
+// Copyright (C) 2011 - DIGITEO - Allan CORNET
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// Check failure case
+if ( execstr('ilib_include_flag(3)','errcatch') == 0 ) then pause, end
+
+// not a dir, should fail
+
+if ( execstr('ilib_include_flag(/usr/include/stdlib.h)','errcatch')  == 0 ) then pause, end
+
+ // should not exist, should fail
+if ( execstr('ilib_include_flag(/usr/my_exotic_dir/);','errcatch')  == 0 ) then pause, end
+
+cd TMPDIR;
+mkdir("myincludespath");
+
+if getos() == "Windows" then 
+  ref_flag = " -I""" + WSCI + "/bin"" " + "-I""" + WSCI + "/modules"" -I""" + getlongpathname(TMPDIR) + filesep() + "myincludespath""";
+  ref_flag = strsubst(ref_flag, "/", filesep());
+else
+  ref_flag = " -I" + SCI + "/bin " + "-I" + SCI + "/modules -I" + TMPDIR + filesep() + "myincludespath";
+end 
+
+includes_path = [ "bin" , "modules" , TMPDIR + filesep() + "myincludespath"];
+cd SCI;
+output_flag = ilib_include_flag(includes_path);
+
+if (ref_flag ~= output_flag) then pause, end