Merge pull request #71 from smarchetto/gsoc2012-scilab

Merge, fix makefiles, and add build verbosity level
This commit is contained in:
Sylvestre Ledru 2013-08-07 05:28:31 -07:00
commit 9a71a7ae9a
6 changed files with 95 additions and 41 deletions

8
.gitignore vendored
View file

@ -128,3 +128,11 @@ Examples/test-suite/uffi/*/
# Scratch directories # Scratch directories
Examples/scratch Examples/scratch
# Scilab generated files
builder.sce
loader.sce
cleaner.sce
*_wrap.c
*_wrap.cxx
lib*lib*.c

View file

@ -1572,9 +1572,10 @@ r_clean:
################################################################## ##################################################################
# Make sure these locate your Scilab installation # Make sure these locate your Scilab installation
SCILAB_INCLUDE= $(DEFS) @SCILABINCLUDE@ SCILAB_INCLUDE = $(DEFS) @SCILABINCLUDE@
SCILAB_LIB = @SCILABLIB@ SCILAB_LIB = @SCILABLIB@
SCILAB = @SCILAB@ SCILAB = @SCILAB@
SCILABOPT =
# ---------------------------------------------------------------- # ----------------------------------------------------------------
# Build a C dynamically loadable module # Build a C dynamically loadable module
@ -1583,15 +1584,15 @@ SCILAB = @SCILAB@
scilab: $(SRCS) scilab: $(SRCS)
@if test ! -z "$(SRCS)"; then \ @if test ! -z "$(SRCS)"; then \
if test ! -z "$(INCLUDES)"; then \ if test ! -z "$(INCLUDES)"; then \
$(SWIG) -scilab -addsrc $(SRCS) -addcflag $(INCLUDES) $(SWIGOPT) $(INTERFACEPATH); \ $(SWIG) -scilab $(SWIGOPT) $(SCILABOPT) -addsrc $(SRCS) -addcflag $(INCLUDES) $(INTERFACEPATH); \
else \ else \
$(SWIG) -scilab -addsrc $(SRCS) $(SWIGOPT) $(INTERFACEPATH); \ $(SWIG) -scilab $(SWIGOPT) $(SCILABOPT) -addsrc $(SRCS) $(INTERFACEPATH); \
fi \ fi \
else \ else \
if test ! -z "$(INCLUDES)"; then \ if test ! -z "$(INCLUDES)"; then \
$(SWIG) -scilab -addcflag $(INCLUDES) $(SWIGOPT) $(INTERFACEPATH); \ $(SWIG) -scilab $(SWIGOPT) $(SCILABOPT) -addcflag $(INCLUDES) $(INTERFACEPATH); \
else \ else \
$(SWIG) -scilab $(SWIGOPT) $(INTERFACEPATH); \ $(SWIG) -scilab $(SWIGOPT) $(SCILABOPT) $(INTERFACEPATH); \
fi \ fi \
fi fi
@if [ -f builder.sce ]; then \ @if [ -f builder.sce ]; then \
@ -1605,15 +1606,15 @@ scilab: $(SRCS)
scilab_cpp: $(SRCS) scilab_cpp: $(SRCS)
@if test ! -z "$(SRCS)"; then \ @if test ! -z "$(SRCS)"; then \
if test ! -z "$(INCLUDES)"; then \ if test ! -z "$(INCLUDES)"; then \
$(SWIG) -scilab -c++ -addsrc $(SRCS) -addcflag $(INCLUDES) $(SWIGOPT) $(INTERFACEPATH); \ $(SWIG) -scilab -c++ $(SWIGOPT) $(SCILABOPT) -addsrc $(SRCS) -addcflag $(INCLUDES) $(INTERFACEPATH); \
else \ else \
$(SWIG) -scilab -c++ -addsrc $(SRCS) $(SWIGOPT) $(INTERFACEPATH); \ $(SWIG) -scilab -c++ $(SWIGOPT) $(SCILABOPT) -addsrc $(SRCS) $(INTERFACEPATH); \
fi \ fi \
else \ else \
if test ! -z "$(INCLUDES)"; then \ if test ! -z "$(INCLUDES)"; then \
$(SWIG) -scilab -c++ -addcflag $(INCLUDES) $(SWIGOPT) $(INTERFACEPATH); \ $(SWIG) -scilab -c++ $(SWIGOPT) $(SCILABOPT) -addcflag $(INCLUDES) $(INTERFACEPATH); \
else \ else \
$(SWIG) -scilab -c++ $(SWIGOPT) $(INTERFACEPATH); \ $(SWIG) -scilab -c++ $(SWIGOPT) $(SCILABOPT) $(INTERFACEPATH); \
fi \ fi \
fi fi
@if [ -f builder.sce ]; then \ @if [ -f builder.sce ]; then \

View file

@ -40,9 +40,9 @@ run_testcase = \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) echo 'exit(1)' |$(SCILAB) -nwni -nb -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ; ) \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) echo 'exit(1)' |$(SCILAB) -nwni -nb -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ; ) \
fi; fi;
# Clean: remove the generated .sci file # Clean: remove the generated files
%.clean: %.clean:
@rm -f $*.sci *_wrap.c *.h *_wrap.cxx @rm -f builder.sce loader.sce cleaner.sce $*_wrap.c $*_wrap.cxx lib$*lib.*
clean: clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile scilab_clean $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile scilab_clean

View file

@ -23,7 +23,6 @@
#define SWIG_From_SequenceItem_frag(Type...) %fragment_name(From_SequenceItem, Type) #define SWIG_From_SequenceItem_frag(Type...) %fragment_name(From_SequenceItem, Type)
#define SWIG_From_SequenceItem_dec(Type...) %symbol_name(From_SequenceItem, Type) #define SWIG_From_SequenceItem_dec(Type...) %symbol_name(From_SequenceItem, Type)
%include <scisequencepointer.swg> %include <scisequencepointer.swg>
%include <scisequenceint.swg> %include <scisequenceint.swg>
%include <scisequencedouble.swg> %include <scisequencedouble.swg>
@ -39,10 +38,35 @@
fragment=SWIG_AsGet_Sequence_frag(ptr), fragment=SWIG_AsGet_Sequence_frag(ptr),
fragment=SWIG_AsSize_Sequence_frag(ptr), fragment=SWIG_AsSize_Sequence_frag(ptr),
fragment=SWIG_FromCreate_Sequence_frag(ptr), fragment=SWIG_FromCreate_Sequence_frag(ptr),
fragment=SWIG_FromSet_Sequence_frag(ptr)) { fragment=SWIG_FromSet_Sequence_frag(ptr),
fragment="StdTraits") {
namespace swig { namespace swig {
// Returns an error for default (not specialized) value containers
template <typename T> struct traits_as_sequence { template <typename T> struct traits_as_sequence {
static int check(SciObject obj) {
SWIG_Error(SWIG_TypeError, type_name<T>());
}
static int get(SciObject obj, void **sequence) {
SWIG_Error(SWIG_TypeError, type_name<T>());
}
static int size(SciObject obj, int *size) {
SWIG_Error(SWIG_TypeError, type_name<T>());
}
};
template <typename T> struct traits_from_sequence {
static int create(int size, void **sequence) {
SWIG_Error(SWIG_TypeError, type_name<T>());
}
static SciObject set(int size, void *sequence) {
SWIG_Error(SWIG_TypeError, type_name<T>());
}
};
// But supports containers of pointers
template <typename T> struct traits_as_sequence<T*> {
static int check(SciObject obj) { static int check(SciObject obj) {
return SWIG_AsCheck_Sequence_dec(ptr)(obj); return SWIG_AsCheck_Sequence_dec(ptr)(obj);
} }
@ -53,12 +77,12 @@ namespace swig {
return SWIG_AsSize_Sequence_dec(ptr)(obj, size); return SWIG_AsSize_Sequence_dec(ptr)(obj, size);
} }
}; };
template <typename T> struct traits_from_sequence { template <typename T> struct traits_from_sequence<T*> {
static int create(int size, void **sequence) { static int create(int size, void **sequence) {
return SWIG_FromCreate_Sequence_dec(ptr)(size, (int ***)sequence); return SWIG_FromCreate_Sequence_dec(ptr)(size, (long long **)sequence);
} }
static SciObject set(int size, void *sequence) { static SciObject set(int size, void *sequence) {
return SWIG_FromSet_Sequence_dec(ptr)(size, (int **)sequence); return SWIG_FromSet_Sequence_dec(ptr)(size, (long long *)sequence);
} }
}; };
} }
@ -104,17 +128,33 @@ namespace swig {
%fragment(SWIG_Traits_SequenceItem_frag(ptr), "header", %fragment(SWIG_Traits_SequenceItem_frag(ptr), "header",
fragment=SWIG_AsVal_SequenceItem_frag(ptr), fragment=SWIG_AsVal_SequenceItem_frag(ptr),
fragment=SWIG_From_SequenceItem_frag(ptr)) { fragment=SWIG_From_SequenceItem_frag(ptr),
fragment="StdTraits") {
namespace swig { namespace swig {
// Returns an error for default (not specialized) value containers
template <typename T> struct traits_asval_sequenceitem { template <typename T> struct traits_asval_sequenceitem {
static int asval(SciObject obj, void *pSequence, int iItemIndex, T *pItemValue) { static int asval(SciObject obj, void *pSequence, int iItemIndex, T *pItemValue) {
return SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex, (int **)pItemValue); SWIG_Error(SWIG_TypeError, type_name<T>());
} }
}; };
template <typename T> struct traits_from_sequenceitem { template <typename T> struct traits_from_sequenceitem {
static int from(void *pSequence, int iItemIndex, T itemValue) { static int from(void *pSequence, int iItemIndex, T itemValue) {
return SWIG_From_SequenceItem_dec(ptr)((int **)pSequence, iItemIndex, (int*)itemValue); SWIG_Error(SWIG_TypeError, type_name<T>());
}
};
// But supports containers of pointers
template <typename T> struct traits_asval_sequenceitem<T*> {
static int asval(SciObject obj, void *pSequence, int iItemIndex, T **pItemValue) {
return SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex, (void **)pItemValue);
}
};
template <typename T> struct traits_from_sequenceitem<T*> {
static int from(void *pSequence, int iItemIndex, T *itemValue) {
return SWIG_From_SequenceItem_dec(ptr)((long long *)pSequence, iItemIndex, (long long) itemValue);
} }
}; };
} }

View file

@ -36,8 +36,8 @@ SWIG_AsSize_Sequence_dec(ptr)(SciObject _obj, int *_piSize) {
%fragment(SWIG_FromCreate_Sequence_frag(ptr), "header") { %fragment(SWIG_FromCreate_Sequence_frag(ptr), "header") {
SWIGINTERN int SWIGINTERN int
SWIG_FromCreate_Sequence_dec(ptr)(int _size, int ***_sequence) { SWIG_FromCreate_Sequence_dec(ptr)(int _size, long long **_sequence) {
*_sequence = new int*[_size]; *_sequence = new long long[_size];
return *_sequence != NULL ? SWIG_OK : SWIG_ERROR; return *_sequence != NULL ? SWIG_OK : SWIG_ERROR;
} }
} }
@ -45,7 +45,7 @@ SWIG_FromCreate_Sequence_dec(ptr)(int _size, int ***_sequence) {
%fragment(SWIG_FromSet_Sequence_frag(ptr), "header") { %fragment(SWIG_FromSet_Sequence_frag(ptr), "header") {
SWIGINTERN SciObject SWIGINTERN SciObject
SWIG_FromSet_Sequence_dec(ptr)(int _size, int **_sequence) { SWIG_FromSet_Sequence_dec(ptr)(int _size, long long *_sequence) {
SciErr sciErr; SciErr sciErr;
int *piListAddr; int *piListAddr;
@ -75,7 +75,7 @@ SWIG_FromSet_Sequence_dec(ptr)(int _size, int **_sequence) {
%fragment(SWIG_AsVal_SequenceItem_frag(ptr), "header") { %fragment(SWIG_AsVal_SequenceItem_frag(ptr), "header") {
SWIGINTERN int SWIGINTERN int
SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int* _piSequence, int _itemIndex, int **_pItemValue) SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int *_piSequence, int _itemIndex, void **_pItemValue)
{ {
SciErr sciErr; SciErr sciErr;
int *piItemAddr; int *piItemAddr;
@ -115,7 +115,7 @@ SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int* _piSequence, int _itemInde
%fragment(SWIG_From_SequenceItem_frag(ptr), "header") { %fragment(SWIG_From_SequenceItem_frag(ptr), "header") {
SWIGINTERN int SWIGINTERN int
SWIG_From_SequenceItem_dec(ptr)(int **_pSequence, int _iItemIndex, int *_itemValue) { SWIG_From_SequenceItem_dec(ptr)(long long *_pSequence, int _iItemIndex, long long _itemValue) {
_pSequence[_iItemIndex] = _itemValue; _pSequence[_iItemIndex] = _itemValue;
} }
} }

View file

@ -18,9 +18,10 @@
static const char *usage = (char*) "\ static const char *usage = (char*) "\
Scilab options\n\ Scilab options\n\
-addsrc <source files> additionnal source files (separated by comma) to include in build script (ex: myfile.cxx myfile2.cxx)\n\ -addsrc <source files> additionnal source files (separated by space) to include in build script (ex: myfile.cxx myfile2.cxx)\n\
-addcflag -I<path> additionnal include path to include in build script (ex: -I/usr/includes/)\n\ -addcflag -I<path> additionnal include path to include in build script (ex: -I/usr/includes/)\n\
-addldlag <flag> additionnal link flag to include in build script (ex: -lm)\n\n"; -addldlag <flag> additionnal link flag to include in build script (ex: -lm)\n\
-vbl <level> sets the build verbose level (default 0)\n\n";
const char* SWIG_INIT_FUNCTION_NAME = "SWIG_Init"; const char* SWIG_INIT_FUNCTION_NAME = "SWIG_Init";
@ -41,6 +42,8 @@ protected:
String *cflag; String *cflag;
String *ldflag; String *ldflag;
String* verboseBuildLevel;
public: public:
/* ------------------------------------------------------------------------ /* ------------------------------------------------------------------------
* main() * main()
@ -50,6 +53,7 @@ public:
sourceFileList = NewList(); sourceFileList = NewList();
ldflag = NULL; ldflag = NULL;
cflag = NULL; cflag = NULL;
verboseBuildLevel = NULL;
/* Manage command line arguments */ /* Manage command line arguments */
for (int argIndex = 1; argIndex < argc; argIndex++) { for (int argIndex = 1; argIndex < argc; argIndex++) {
@ -82,10 +86,18 @@ public:
ldflag = NewString(argv[argIndex+1]); ldflag = NewString(argv[argIndex+1]);
Swig_mark_arg(argIndex+1); Swig_mark_arg(argIndex+1);
} }
} else if (strcmp(argv[argIndex], "-vbl") == 0) {
Swig_mark_arg(argIndex);
verboseBuildLevel = NewString(argv[argIndex+1]);
Swig_mark_arg(argIndex+1);
} }
} }
} }
if (verboseBuildLevel == NULL) {
verboseBuildLevel = NewString("0");
}
/* Set language-specific subdirectory in SWIG library */ /* Set language-specific subdirectory in SWIG library */
SWIG_library_directory("scilab"); SWIG_library_directory("scilab");
@ -138,12 +150,9 @@ public:
builderCode = NewString(""); builderCode = NewString("");
Printf(builderCode, "mode(-1);\n"); Printf(builderCode, "mode(-1);\n");
Printf(builderCode, "lines(0);\n"); /* Useful for automatic tests */ Printf(builderCode, "lines(0);\n"); /* Useful for automatic tests */
#ifdef SWIG_DEBUG
Printf(builderCode, "try\n"); Printf(builderCode, "ilib_verbose(%s);\n", verboseBuildLevel);
Printf(builderCode, "ilib_verbose(1);\n");
#else
Printf(builderCode, "ilib_verbose(0);\n");
#endif
Printf(builderCode, "ilib_name = \"%slib\";\n", moduleName); Printf(builderCode, "ilib_name = \"%slib\";\n", moduleName);
Printf(builderCode, "libs = [];\n"); Printf(builderCode, "libs = [];\n");
@ -197,11 +206,7 @@ public:
Printf(builderCode, "if ~isempty(table) then\n"); Printf(builderCode, "if ~isempty(table) then\n");
Printf(builderCode, " ilib_build(ilib_name, table, files, libs, [], ldflags, cflags);\n"); Printf(builderCode, " ilib_build(ilib_name, table, files, libs, [], ldflags, cflags);\n");
Printf(builderCode, "end\n"); Printf(builderCode, "end\n");
#ifdef SWIG_DEBUG
Printf(builderCode, "catch\n");
Printf(builderCode, " printf(\"\"*** builder.sce file execution FAILED ***\"\");\n");
Printf(builderCode, "end\n");
#endif
Printf(builderCode, "exit"); Printf(builderCode, "exit");
builderFile = NewFile(NewStringf("%sbuilder.sce", SWIG_output_directory()), "w", SWIG_output_files()); builderFile = NewFile(NewStringf("%sbuilder.sce", SWIG_output_directory()), "w", SWIG_output_files());
Printv(builderFile, builderCode, NIL); Printv(builderFile, builderCode, NIL);