added an (actual) makefile to parts generated by wrap
parent
fa4947b99c
commit
a38b7245be
|
@ -14,6 +14,7 @@
|
||||||
* @author Frank Dellaert
|
* @author Frank Dellaert
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
@ -93,3 +94,46 @@ void Class::matlab_make_fragment(ofstream& ofs,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
void Class::makefile_fragment(ofstream& ofs) {
|
||||||
|
// 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)
|
||||||
|
|
||||||
|
// collect names
|
||||||
|
vector<string> file_names;
|
||||||
|
BOOST_FOREACH(Constructor c, constructors) {
|
||||||
|
string file_base = c.matlab_wrapper_name(name);
|
||||||
|
file_names.push_back(file_base);
|
||||||
|
}
|
||||||
|
BOOST_FOREACH(StaticMethod c, static_methods) {
|
||||||
|
string file_base = name + "_" + c.name_;
|
||||||
|
file_names.push_back(file_base);
|
||||||
|
}
|
||||||
|
BOOST_FOREACH(Method c, methods) {
|
||||||
|
string file_base = "@" + name + "/" + c.name_;
|
||||||
|
file_names.push_back(file_base);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOST_FOREACH(const string& file_base, file_names) {
|
||||||
|
ofs << file_base << ".$(MEXENDING): " << file_base << ".cpp" << endl;
|
||||||
|
ofs << "\t$(MEX) $(mex_flags) " << file_base << ".cpp -output " << file_base << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// class target
|
||||||
|
ofs << "\n" << name << ": ";
|
||||||
|
BOOST_FOREACH(const string& file_base, file_names) {
|
||||||
|
ofs << file_base << ".$(MEXENDING) ";
|
||||||
|
}
|
||||||
|
ofs << "\n" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ************************************************************************* */
|
||||||
|
|
|
@ -49,6 +49,7 @@ struct Class {
|
||||||
void matlab_make_fragment(std::ofstream& ofs,
|
void matlab_make_fragment(std::ofstream& ofs,
|
||||||
const std::string& toolboxPath,
|
const std::string& toolboxPath,
|
||||||
const std::string& mexFlags); ///< emit make fragment for global make script
|
const std::string& mexFlags); ///< emit make fragment for global make script
|
||||||
|
void makefile_fragment(std::ofstream& ofs); ///< emit makefile fragment
|
||||||
};
|
};
|
||||||
|
|
||||||
} // \namespace wrap
|
} // \namespace wrap
|
||||||
|
|
|
@ -207,12 +207,17 @@ void Module::matlab_code(const string& toolboxPath,
|
||||||
system(installCmd.c_str());
|
system(installCmd.c_str());
|
||||||
|
|
||||||
// create make m-file
|
// create make m-file
|
||||||
string makeFile = toolboxPath + "/make_" + name + ".m";
|
string matlabMakeFile = toolboxPath + "/make_" + name + ".m";
|
||||||
ofstream ofs(makeFile.c_str());
|
ofstream ofs(matlabMakeFile.c_str());
|
||||||
if(!ofs) throw CantOpenFile(makeFile);
|
if(!ofs) throw CantOpenFile(matlabMakeFile);
|
||||||
|
|
||||||
if (verbose_) cerr << "generating " << makeFile << endl;
|
// create the (actual) make file
|
||||||
wrap::emit_header_comment(ofs,"%");
|
string makeFile = toolboxPath + "/Makefile";
|
||||||
|
ofstream make_ofs(makeFile.c_str());
|
||||||
|
if(!make_ofs) throw CantOpenFile(makeFile);
|
||||||
|
|
||||||
|
if (verbose_) cerr << "generating " << matlabMakeFile << endl;
|
||||||
|
emit_header_comment(ofs,"%");
|
||||||
ofs << "echo on" << endl << endl;
|
ofs << "echo on" << endl << endl;
|
||||||
ofs << "toolboxpath = mfilename('fullpath');" << endl;
|
ofs << "toolboxpath = mfilename('fullpath');" << endl;
|
||||||
ofs << "delims = find(toolboxpath == '/');" << endl;
|
ofs << "delims = find(toolboxpath == '/');" << endl;
|
||||||
|
@ -220,6 +225,12 @@ void Module::matlab_code(const string& toolboxPath,
|
||||||
ofs << "clear delims" << endl;
|
ofs << "clear delims" << endl;
|
||||||
ofs << "addpath(toolboxpath);" << endl << endl;
|
ofs << "addpath(toolboxpath);" << endl << endl;
|
||||||
|
|
||||||
|
if (verbose_) cerr << "generating " << makeFile << endl;
|
||||||
|
emit_header_comment(make_ofs,"#");
|
||||||
|
make_ofs << "\nMEX = mex\n";
|
||||||
|
make_ofs << "MEXENDING = mexa64\n";
|
||||||
|
make_ofs << "mex_flags = " << mexFlags << "\n\n";
|
||||||
|
|
||||||
// generate proxy classes and wrappers
|
// generate proxy classes and wrappers
|
||||||
BOOST_FOREACH(Class cls, classes) {
|
BOOST_FOREACH(Class cls, classes) {
|
||||||
// create directory if needed
|
// create directory if needed
|
||||||
|
@ -240,12 +251,30 @@ void Module::matlab_code(const string& toolboxPath,
|
||||||
ofs << "%% " << cls.name << endl;
|
ofs << "%% " << cls.name << endl;
|
||||||
ofs << "cd(toolboxpath)" << endl;
|
ofs << "cd(toolboxpath)" << endl;
|
||||||
cls.matlab_make_fragment(ofs, toolboxPath, mexFlags);
|
cls.matlab_make_fragment(ofs, toolboxPath, mexFlags);
|
||||||
|
|
||||||
|
// add section to the (actual) make file
|
||||||
|
make_ofs << "# " << cls.name << endl;
|
||||||
|
cls.makefile_fragment(make_ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// finish make m-file
|
// finish make m-file
|
||||||
ofs << "cd(toolboxpath)" << endl << endl;
|
ofs << "cd(toolboxpath)" << endl << endl;
|
||||||
ofs << "echo off" << endl;
|
ofs << "echo off" << endl;
|
||||||
ofs.close();
|
ofs.close();
|
||||||
|
|
||||||
|
// add 'all' and 'clean' to Makefile
|
||||||
|
make_ofs << "\nall: ";
|
||||||
|
BOOST_FOREACH(Class cls, classes)
|
||||||
|
make_ofs << cls.name << " ";
|
||||||
|
|
||||||
|
make_ofs << "\n\nclean: \n";
|
||||||
|
make_ofs << "\trm -rf *.$(MEXENDING)\n";
|
||||||
|
BOOST_FOREACH(Class cls, classes)
|
||||||
|
make_ofs << "\trm -rf @" << cls.name << "/*.$(MEXENDING)\n";
|
||||||
|
|
||||||
|
// finish Makefile
|
||||||
|
make_ofs << "\n" << endl;
|
||||||
|
make_ofs.close();
|
||||||
}
|
}
|
||||||
catch(exception &e) {
|
catch(exception &e) {
|
||||||
cerr << "generate_matlab_toolbox failed because " << e.what() << endl;
|
cerr << "generate_matlab_toolbox failed because " << e.what() << endl;
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
# automatically generated by wrap on 2011-Dec-05
|
||||||
|
|
||||||
|
MEX = mex
|
||||||
|
MEXENDING = mexa64
|
||||||
|
mex_flags = -O5
|
||||||
|
|
||||||
|
# Point2
|
||||||
|
new_Point2_.$(MEXENDING): new_Point2_.cpp
|
||||||
|
$(MEX) $(mex_flags) new_Point2_.cpp -output new_Point2_
|
||||||
|
new_Point2_dd.$(MEXENDING): new_Point2_dd.cpp
|
||||||
|
$(MEX) $(mex_flags) new_Point2_dd.cpp -output new_Point2_dd
|
||||||
|
@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)
|
||||||
|
|
||||||
|
# Point3
|
||||||
|
new_Point3_ddd.$(MEXENDING): new_Point3_ddd.cpp
|
||||||
|
$(MEX) $(mex_flags) new_Point3_ddd.cpp -output new_Point3_ddd
|
||||||
|
Point3_StaticFunction.$(MEXENDING): Point3_StaticFunction.cpp
|
||||||
|
$(MEX) $(mex_flags) Point3_StaticFunction.cpp -output Point3_StaticFunction
|
||||||
|
@Point3/norm.$(MEXENDING): @Point3/norm.cpp
|
||||||
|
$(MEX) $(mex_flags) @Point3/norm.cpp -output @Point3/norm
|
||||||
|
|
||||||
|
Point3: new_Point3_ddd.$(MEXENDING) Point3_StaticFunction.$(MEXENDING) @Point3/norm.$(MEXENDING)
|
||||||
|
|
||||||
|
# Test
|
||||||
|
new_Test_.$(MEXENDING): new_Test_.cpp
|
||||||
|
$(MEX) $(mex_flags) new_Test_.cpp -output new_Test_
|
||||||
|
@Test/return_bool.$(MEXENDING): @Test/return_bool.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_bool.cpp -output @Test/return_bool
|
||||||
|
@Test/return_size_t.$(MEXENDING): @Test/return_size_t.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_size_t.cpp -output @Test/return_size_t
|
||||||
|
@Test/return_int.$(MEXENDING): @Test/return_int.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_int.cpp -output @Test/return_int
|
||||||
|
@Test/return_double.$(MEXENDING): @Test/return_double.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_double.cpp -output @Test/return_double
|
||||||
|
@Test/return_string.$(MEXENDING): @Test/return_string.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_string.cpp -output @Test/return_string
|
||||||
|
@Test/return_vector1.$(MEXENDING): @Test/return_vector1.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_vector1.cpp -output @Test/return_vector1
|
||||||
|
@Test/return_matrix1.$(MEXENDING): @Test/return_matrix1.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_matrix1.cpp -output @Test/return_matrix1
|
||||||
|
@Test/return_vector2.$(MEXENDING): @Test/return_vector2.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_vector2.cpp -output @Test/return_vector2
|
||||||
|
@Test/return_matrix2.$(MEXENDING): @Test/return_matrix2.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_matrix2.cpp -output @Test/return_matrix2
|
||||||
|
@Test/return_pair.$(MEXENDING): @Test/return_pair.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_pair.cpp -output @Test/return_pair
|
||||||
|
@Test/return_field.$(MEXENDING): @Test/return_field.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_field.cpp -output @Test/return_field
|
||||||
|
@Test/return_TestPtr.$(MEXENDING): @Test/return_TestPtr.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_TestPtr.cpp -output @Test/return_TestPtr
|
||||||
|
@Test/return_Point2Ptr.$(MEXENDING): @Test/return_Point2Ptr.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_Point2Ptr.cpp -output @Test/return_Point2Ptr
|
||||||
|
@Test/create_ptrs.$(MEXENDING): @Test/create_ptrs.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/create_ptrs.cpp -output @Test/create_ptrs
|
||||||
|
@Test/return_ptrs.$(MEXENDING): @Test/return_ptrs.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/return_ptrs.cpp -output @Test/return_ptrs
|
||||||
|
@Test/print.$(MEXENDING): @Test/print.cpp
|
||||||
|
$(MEX) $(mex_flags) @Test/print.cpp -output @Test/print
|
||||||
|
|
||||||
|
Test: new_Test_.$(MEXENDING) @Test/return_bool.$(MEXENDING) @Test/return_size_t.$(MEXENDING) @Test/return_int.$(MEXENDING) @Test/return_double.$(MEXENDING) @Test/return_string.$(MEXENDING) @Test/return_vector1.$(MEXENDING) @Test/return_matrix1.$(MEXENDING) @Test/return_vector2.$(MEXENDING) @Test/return_matrix2.$(MEXENDING) @Test/return_pair.$(MEXENDING) @Test/return_field.$(MEXENDING) @Test/return_TestPtr.$(MEXENDING) @Test/return_Point2Ptr.$(MEXENDING) @Test/create_ptrs.$(MEXENDING) @Test/return_ptrs.$(MEXENDING) @Test/print.$(MEXENDING)
|
||||||
|
|
||||||
|
|
||||||
|
all: Point2 Point3 Test
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf *.$(MEXENDING)
|
||||||
|
rm -rf @Point2/*.$(MEXENDING)
|
||||||
|
rm -rf @Point3/*.$(MEXENDING)
|
||||||
|
rm -rf @Test/*.$(MEXENDING)
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,7 @@ TEST( wrap, matlab_code ) {
|
||||||
EXPECT(files_equal(path + "/tests/expected/@Test/print.cpp" , "actual/@Test/print.cpp" ));
|
EXPECT(files_equal(path + "/tests/expected/@Test/print.cpp" , "actual/@Test/print.cpp" ));
|
||||||
|
|
||||||
EXPECT(files_equal(path + "/tests/expected/make_geometry.m" , "actual/make_geometry.m" ));
|
EXPECT(files_equal(path + "/tests/expected/make_geometry.m" , "actual/make_geometry.m" ));
|
||||||
|
EXPECT(files_equal(path + "/tests/expected/Makefile" , "actual/Makefile" ));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ************************************************************************* */
|
/* ************************************************************************* */
|
||||||
|
|
Loading…
Reference in New Issue