X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmingwdlltool.cpp;h=5f62a02c954dadbcbc808b15b37d55938d90d812;hb=766dad2d4f7ca73dc182f22e306ba0def6fd8722;hp=582963ea090acea480bd82c01462fa58faf5cf34;hpb=82ae60a647ebb9567f7177c353245f4d72faaf5e;p=builder.git diff --git a/source/mingwdlltool.cpp b/source/mingwdlltool.cpp index 582963e..5f62a02 100644 --- a/source/mingwdlltool.cpp +++ b/source/mingwdlltool.cpp @@ -9,6 +9,7 @@ #include "importlibrary.h" #include "installedfile.h" #include "mingwdlltool.h" +#include "objectfile.h" #include "sharedlibrary.h" #include "sourcepackage.h" @@ -28,9 +29,20 @@ Target *MingwDllTool::create_target(const list &sources, const string { if(sources.size()!=1) throw invalid_argument("MingwDllTool::create_target"); - ExportDefinitions &def = dynamic_cast(*sources.front()); - ImportLibrary *imp = new ImportLibrary(builder, *def.get_component(), def); + SharedLibrary &shlib = dynamic_cast(*sources.front()); + + list objs; + const Target::Dependencies &depends = shlib.get_dependencies(); + for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i) + if(ObjectFile *obj = dynamic_cast(*i)) + objs.push_back(obj); + + ExportDefinitions *exp = new ExportDefinitions(builder, *shlib.get_component(), objs); + exp->set_tool(*this); + + ImportLibrary *imp = new ImportLibrary(builder, *shlib.get_component(), shlib, *exp); imp->set_tool(*this); + return imp; } @@ -41,7 +53,8 @@ Target *MingwDllTool::create_install(Target &target) const const Tool © = builder.get_toolchain().get_tool("CP"); InstalledFile *inst_tgt = dynamic_cast(copy.create_target(target)); string link_name = format("lib%s.dll.a", imp->get_shared_library()->get_libname()); - inst_tgt->set_symlink(link_name); + if(link_name!=FS::basename(inst_tgt->get_path())) + inst_tgt->set_symlink(link_name); return inst_tgt; } else @@ -50,9 +63,14 @@ Target *MingwDllTool::create_install(Target &target) const Task *MingwDllTool::run(const Target &target) const { - const ImportLibrary &imp = dynamic_cast(target); - const ExportDefinitions &exp = dynamic_cast(*imp.get_dependencies().front()); - const SharedLibrary &shlib = exp.get_library(); + const ImportLibrary *imp = dynamic_cast(&target); + const ExportDefinitions *exp = 0; + if(imp) + exp = &dynamic_cast(*imp->get_dependencies().front()); + else + exp = dynamic_cast(&target); + if(!imp && !exp) + throw invalid_argument("MingwDllTool::run"); vector argv; argv.push_back(executable->get_path().str()); @@ -65,20 +83,40 @@ Task *MingwDllTool::run(const Target &target) const random[i] = 'a'+(rand()%26); argv.push_back(string("/tmp/")+string(random, 8)); - const Component &comp = *imp.get_component(); + const Component &comp = *target.get_component(); FS::Path work_dir = comp.get_package().get_source_directory(); - argv.push_back("-d"); - argv.push_back(relative(exp.get_path(), work_dir).str()); + if(imp) + { + const SharedLibrary &shlib = *imp->get_shared_library(); + + argv.push_back("-d"); + argv.push_back(relative(exp->get_path(), work_dir).str()); + + argv.push_back("-D"); + if(shlib.get_install_filename().empty()) + argv.push_back(FS::basename(shlib.get_path())); + else + argv.push_back(shlib.get_install_filename()); - argv.push_back("-D"); - if(shlib.get_install_filename().empty()) - argv.push_back(FS::basename(shlib.get_path())); + argv.push_back("-l"); + argv.push_back(relative(imp->get_path(), work_dir).str()); + } else - argv.push_back(shlib.get_install_filename()); + { + const Target::Dependencies &depends = exp->get_dependencies(); + for(Target::Dependencies::const_iterator i=depends.begin(); i!=depends.end(); ++i) + { + if(ObjectFile *obj = dynamic_cast(*i)) + argv.push_back(relative(obj->get_path(), work_dir).str()); + } + + // XXX Should use dllexport, but that has some other problems to solve + argv.push_back("--export-all-symbols"); - argv.push_back("-l"); - argv.push_back(relative(imp.get_path(), work_dir).str()); + argv.push_back("-z"); + argv.push_back(relative(exp->get_path(), work_dir).str()); + } return new ExternalTask(argv, work_dir); }