diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index e719e0315..5a8692c74 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -132,8 +132,6 @@ if (GTSAM_BUILD_WRAP) endif() # Generate, build and install toolbox - string(TOUPPER ${CMAKE_BUILD_TYPE} build_type_toupper) - get_target_property(gtsam_library_file gtsam-static LOCATION_${build_type_toupper}) set(mexFlags ${GTSAM_BUILD_MEX_BINARY_FLAGS} -I${Boost_INCLUDE_DIR} -I${MEX_INCLUDE_ROOT} -I${MEX_INCLUDE_ROOT}/gtsam -I${MEX_INCLUDE_ROOT}/gtsam/base -I${MEX_INCLUDE_ROOT}/gtsam/geometry -I${MEX_INCLUDE_ROOT}/gtsam/linear -I${MEX_INCLUDE_ROOT}/gtsam/discrete -I${MEX_INCLUDE_ROOT}/gtsam/inference -I${MEX_INCLUDE_ROOT}/gtsam/nonlinear -I${MEX_INCLUDE_ROOT}/gtsam/slam) # Macro to handle details of setting up targets diff --git a/wrap/Class.cpp b/wrap/Class.cpp index 0485de5bd..418c4706e 100644 --- a/wrap/Class.cpp +++ b/wrap/Class.cpp @@ -120,65 +120,6 @@ void Class::matlab_static_methods(const string& toolboxPath, const string& wrapp } } -/* ************************************************************************* */ -void Class::matlab_make_fragment(FileWriter& file, - const string& toolboxPath, - const string& mexFlags) const { - string mex = "mex " + mexFlags + " "; - string matlabClassName = qualifiedName(); - file.oss << mex << constructor.matlab_wrapper_name(matlabClassName) << ".cpp" << endl; - BOOST_FOREACH(StaticMethod sm, static_methods) - file.oss << mex << matlabClassName + "_" + sm.name << ".cpp" << endl; - file.oss << endl << "cd @" << matlabClassName << endl; - BOOST_FOREACH(Method m, methods) - file.oss << mex << m.name << ".cpp" << endl; - file.oss << endl; -} - -/* ************************************************************************* */ -void Class::makefile_fragment(FileWriter& file) const { -// new_Point2_.$(MEXENDING): new_Point2_.cpp -// $(MEX) $(mex_flags) new_Point2_.cpp -// new_Point2_dd.$(MEXENDING): new_Point2_dd.cpp -// $(MEX) $(mex_flags) new_Point2_dd.cpp -// @Point2/x.$(MEXENDING): @Point2/x.cpp -// $(MEX) $(mex_flags) @Point2/x.cpp -output @Point2/x -// @Point2/y.$(MEXENDING): @Point2/y.cpp -// $(MEX) $(mex_flags) @Point2/y.cpp -output @Point2/y -// @Point2/dim.$(MEXENDING): @Point2/dim.cpp -// $(MEX) $(mex_flags) @Point2/dim.cpp -output @Point2/dim -// -// Point2: new_Point2_.$(MEXENDING) new_Point2_dd.$(MEXENDING) @Point2/x.$(MEXENDING) @Point2/y.$(MEXENDING) @Point2/dim.$(MEXENDING) - - string matlabName = qualifiedName(); - - // collect names - vector file_names; - string file_base = constructor.matlab_wrapper_name(matlabName); - file_names.push_back(file_base); - BOOST_FOREACH(StaticMethod c, static_methods) { - string file_base = matlabName + "_" + c.name; - file_names.push_back(file_base); - } - BOOST_FOREACH(Method c, methods) { - string file_base = "@" + matlabName + "/" + c.name; - file_names.push_back(file_base); - } - - BOOST_FOREACH(const string& file_base, file_names) { - file.oss << file_base << ".$(MEXENDING): " << file_base << ".cpp"; - file.oss << " $(PATH_TO_WRAP)/matlab.h" << endl; - file.oss << "\t$(MEX) $(mex_flags) " << file_base << ".cpp -output " << file_base << endl; - } - - // class target - file.oss << "\n" << matlabName << ": "; - BOOST_FOREACH(const string& file_base, file_names) { - file.oss << file_base << ".$(MEXENDING) "; - } - file.oss << "\n" << endl; -} - /* ************************************************************************* */ string Class::qualifiedName(const string& delim) const { string result; diff --git a/wrap/Class.h b/wrap/Class.h index bef7467c3..0f6ac899c 100644 --- a/wrap/Class.h +++ b/wrap/Class.h @@ -49,10 +49,6 @@ struct Class { FileWriter& wrapperFile, std::vector& functionNames) const; ///< emit proxy class void matlab_static_methods(const std::string& toolboxPath, const std::string& wrapperName, FileWriter& wrapperFile, std::vector& functionNames) const; ///< emit static method wrappers - void matlab_make_fragment(FileWriter& file, - const std::string& toolboxPath, - const std::string& mexFlags) const; ///< emit make fragment for global make script - void makefile_fragment(FileWriter& file) const; ///< emit makefile fragment std::string qualifiedName(const std::string& delim = "") const; ///< creates a namespace-qualified name, optional delimiter }; diff --git a/wrap/Module.cpp b/wrap/Module.cpp index 2f1b1f252..400658044 100644 --- a/wrap/Module.cpp +++ b/wrap/Module.cpp @@ -286,19 +286,10 @@ void verifyReturnTypes(const vector& validtypes, const vector& vt) { } /* ************************************************************************* */ -void Module::matlab_code(const string& mexCommand, const string& toolboxPath, - const string& mexExt, const string& headerPath,const string& mexFlags) const { +void Module::matlab_code(const string& toolboxPath, const string& headerPath) const { fs::create_directories(toolboxPath); - // create make m-file - string matlabMakeFileName = toolboxPath + "/make_" + name + ".m"; - FileWriter makeModuleMfile(matlabMakeFileName, verbose, "%"); - - // create the (actual) make file - string makeFileName = toolboxPath + "/Makefile"; - FileWriter makeModuleMakefile(makeFileName, verbose, "#"); - // create the unified .cpp switch file const string wrapperName = name + "_wrapper"; string wrapperFileName = toolboxPath + "/" + wrapperName + ".cpp"; @@ -309,18 +300,6 @@ void Module::matlab_code(const string& mexCommand, const string& toolboxPath, wrapperFile.oss << "#include \n"; wrapperFile.oss << "\n"; - makeModuleMfile.oss << "echo on" << endl << endl; - makeModuleMfile.oss << "toolboxpath = mfilename('fullpath');" << endl; - makeModuleMfile.oss << "delims = find(toolboxpath == '/' | toolboxpath == '\\');" << endl; - makeModuleMfile.oss << "toolboxpath = toolboxpath(1:(delims(end)-1));" << endl; - makeModuleMfile.oss << "clear delims" << endl; - makeModuleMfile.oss << "addpath(toolboxpath);" << endl << endl; - - makeModuleMakefile.oss << "\nMEX = " << mexCommand << "\n"; - makeModuleMakefile.oss << "MEXENDING = " << mexExt << "\n"; - makeModuleMakefile.oss << "PATH_TO_WRAP = " << headerPath << "\n"; - makeModuleMakefile.oss << "mex_flags = " << mexFlags << "\n\n"; - // Dependency check list vector validTypes = forward_declarations; validTypes.push_back("void"); @@ -333,15 +312,10 @@ void Module::matlab_code(const string& mexCommand, const string& toolboxPath, validTypes.push_back("double"); validTypes.push_back("Vector"); validTypes.push_back("Matrix"); - - // add 'all' to Makefile - makeModuleMakefile.oss << "all: "; - BOOST_FOREACH(Class cls, classes) { - makeModuleMakefile.oss << cls.qualifiedName() << " "; - //Create a list of parsed classes for dependency checking - validTypes.push_back(cls.qualifiedName("::")); - } - makeModuleMakefile.oss << "\n\n"; + //Create a list of parsed classes for dependency checking + BOOST_FOREACH(Class cls, classes) { + validTypes.push_back(cls.qualifiedName("::")); + } // Generate all includes BOOST_FOREACH(Class cls, classes) { @@ -391,32 +365,8 @@ void Module::matlab_code(const string& mexCommand, const string& toolboxPath, // create constructor and method wrappers cls.matlab_static_methods(toolboxPath, wrapperName, wrapperFile, functionNames); - - // add lines to make m-file - makeModuleMfile.oss << "%% " << cls.qualifiedName() << endl; - makeModuleMfile.oss << "cd(toolboxpath)" << endl; - cls.matlab_make_fragment(makeModuleMfile, toolboxPath, mexFlags); - - // add section to the (actual) make file - makeModuleMakefile.oss << "# " << cls.qualifiedName() << endl; - cls.makefile_fragment(makeModuleMakefile); } - // finish make m-file - makeModuleMfile.oss << "cd(toolboxpath)" << endl << endl; - makeModuleMfile.oss << "echo off" << endl; - makeModuleMfile.emit(true); // By default, compare existing file first - - // make clean at end of Makefile - makeModuleMakefile.oss << "\n\nclean: \n"; - makeModuleMakefile.oss << "\trm -rf *.$(MEXENDING)\n"; - BOOST_FOREACH(Class cls, classes) - makeModuleMakefile.oss << "\trm -rf @" << cls.qualifiedName() << "/*.$(MEXENDING)\n"; - - // finish Makefile - makeModuleMakefile.oss << "\n" << endl; - makeModuleMakefile.emit(true); - // finish wrapper file finish_wrapper(wrapperFile, functionNames); diff --git a/wrap/Module.h b/wrap/Module.h index 8df6abbba..a04a861c4 100644 --- a/wrap/Module.h +++ b/wrap/Module.h @@ -41,11 +41,8 @@ struct Module { /// MATLAB code generation: void matlab_code( - const std::string& mexCommand, const std::string& path, - const std::string& mexExt, - const std::string& headerPath, - const std::string& mexFlags) const; + const std::string& headerPath) const; void finish_wrapper(FileWriter& file, const std::vector& functionNames) const; }; diff --git a/wrap/wrap.cpp b/wrap/wrap.cpp index f818094f7..05763d892 100644 --- a/wrap/wrap.cpp +++ b/wrap/wrap.cpp @@ -24,42 +24,33 @@ using namespace std; /** * Top-level function to wrap a module - * @param mexCommand is a sufficiently qualified command to execute mex within a makefile - * @param mexExt is the extension for mex binaries for this os/cpu * @param interfacePath path to where interface file lives, e.g., borg/gtsam * @param moduleName name of the module to be generated e.g. gtsam * @param toolboxPath path where the toolbox should be generated, e.g. borg/gtsam/build * @param headerPath is the path to matlab.h - * @param mexFlags extra arguments for mex script, i.e., include flags etc... */ void generate_matlab_toolbox( - const string& mexCommand, - const string& mexExt, const string& interfacePath, const string& moduleName, const string& toolboxPath, - const string& headerPath, - const string& mexFlags) + const string& headerPath) { // Parse interface file into class object // This recursively creates Class objects, Method objects, etc... wrap::Module module(interfacePath, moduleName, false); // Then emit MATLAB code - module.matlab_code(mexCommand,toolboxPath,mexExt,headerPath,mexFlags); + module.matlab_code(toolboxPath,headerPath); } /** Displays usage information */ void usage() { cerr << "wrap parses an interface file and produces a MATLAB toolbox" << endl; - cerr << "usage: wrap mexExecutable mexExtension interfacePath moduleName toolboxPath [mexFlags]" << endl; - cerr << " mexExecutable : command to execute mex if on path, use 'mex'" << endl; - cerr << " mexExtension : OS/CPU-dependent extension for MEX binaries" << endl; + cerr << "usage: wrap interfacePath moduleName toolboxPath headerPath" << endl; cerr << " interfacePath : *absolute* path to directory of module interface file" << endl; cerr << " moduleName : the name of the module, interface file must be called moduleName.h" << endl; cerr << " toolboxPath : the directory in which to generate the wrappers" << endl; cerr << " headerPath : path to matlab.h" << endl; - cerr << " [mexFlags] : extra flags for the mex command" << endl; } /** @@ -67,7 +58,7 @@ void usage() { * Typically called from "make all" using appropriate arguments */ int main(int argc, const char* argv[]) { - if (argc<7 || argc>8) { + if (argc != 5) { cerr << "Invalid arguments:\n"; for (int i=0; i