const FileLocation*
MingwModuleHandler::GetImportLibraryFilename (
const Module& module,
- string_list* pclean_files )
+ string_list* pclean_files,
+ bool delayimp )
{
- FileLocation *target = new FileLocation ( *module.dependency );
+ FileLocation *target;
+
+ if (module.HasImportLibrary())
+ {
+ if (delayimp)
+ {
+ target = new FileLocation ( *module.delayImportLibrary->target );
+ }
+ else
+ target = new FileLocation ( *module.importLibrary->target );
+ }
+ else
+ target = new FileLocation ( *module.dependency );
+
if ( pclean_files )
{
string_list& clean_files = *pclean_files;
string
MingwModuleHandler::GetImportLibraryDependency (
- const Module& importedModule )
+ const Module& importedModule,
+ bool delayimp )
{
string dep;
if ( ReferenceObjects ( importedModule ) )
}
else
{
- const FileLocation *library_target = GetImportLibraryFilename ( importedModule, NULL );
+ const FileLocation *library_target = GetImportLibraryFilename ( importedModule, NULL, delayimp );
dep = backend->GetFullName ( *library_target );
delete library_target;
}
for ( size_t i = 0; i < libraries.size (); ++ i )
{
dep += " ";
- dep += GetImportLibraryDependency ( *libraries[i]->importedModule );
+ dep += GetImportLibraryDependency ( *libraries[i]->importedModule, libraries[i]->delayimp );
}
}
}
}
else
- targets.push_back ( GetImportLibraryDependency ( dependencyModule ) );
+ targets.push_back ( GetImportLibraryDependency ( dependencyModule, false ) );
}
void
dependencies += " \\\n\t\t", wrap_count = 0;
else if ( dependencies.size () > 0 )
dependencies += " ";
- dependencies += GetImportLibraryDependency ( *libraries[i]->importedModule );
+ dependencies += GetImportLibraryDependency ( *libraries[i]->importedModule, libraries[i]->delayimp );
}
return dependencies;
}
}
void
-MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
+MingwModuleHandler::GenerateImportLibraryTarget (
+ const FileLocation *defFilename,
+ const FileLocation *library_target,
+ bool delayimp)
{
- if ( module.importLibrary != NULL )
- {
- const FileLocation *library_target = GetImportLibraryFilename ( module, &clean_files );
- const FileLocation *defFilename = GetDefinitionFilename ();
- string empty = "tools" + sSep + "rbuild" + sSep + "empty.def";
+ string empty = "tools" + sSep + "rbuild" + sSep + "empty.def";
- fprintf ( fMakefile, "# IMPORT LIBRARY RULE\n" );
+ fprintf ( fMakefile, "# IMPORT LIBRARY RULE\n" );
- fprintf ( fMakefile, "%s:",
- backend->GetFullName ( *library_target ).c_str () );
+ fprintf ( fMakefile, "%s:",
+ backend->GetFullName ( *library_target ).c_str () );
- if ( defFilename )
- {
- fprintf ( fMakefile, " %s",
- backend->GetFullName ( *defFilename ).c_str () );
- }
+ if ( defFilename )
+ {
+ fprintf ( fMakefile, " %s",
+ backend->GetFullName ( *defFilename ).c_str () );
+ }
- fprintf ( fMakefile, " | %s\n",
- backend->GetFullPath ( *library_target ).c_str () );
+ fprintf ( fMakefile, " | %s\n",
+ backend->GetFullPath ( *library_target ).c_str () );
- fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" );
+ fprintf ( fMakefile, "\t$(ECHO_DLLTOOL)\n" );
- fprintf ( fMakefile,
- "\t${dlltool} --dllname %s --def %s --output-lib %s%s%s\n\n",
- module.GetDllName ().c_str (),
- defFilename ? backend->GetFullName ( *defFilename ).c_str ()
- : empty.c_str (),
- backend->GetFullName ( *library_target ).c_str (),
- module.mangledSymbols ? "" : " --kill-at",
- module.underscoreSymbols ? " --add-underscore" : "" );
+ fprintf ( fMakefile,
+ "\t${dlltool} --dllname %s --def %s %s %s%s%s\n\n",
+ module.GetDllName ().c_str (),
+ defFilename ? backend->GetFullName ( *defFilename ).c_str ()
+ : empty.c_str (),
+ delayimp ? "--output-delaylib" : "--output-lib",
+ backend->GetFullName ( *library_target ).c_str (),
+ module.mangledSymbols ? "" : " --kill-at",
+ module.underscoreSymbols ? " --add-underscore" : "" );
+}
+
+void
+MingwModuleHandler::GenerateImportLibraryTargetIfNeeded ()
+{
+ if ( module.importLibrary != NULL )
+ {
+ const FileLocation *library_target = GetImportLibraryFilename ( module, &clean_files, false );
+ const FileLocation *delayimp_target = GetImportLibraryFilename ( module, &clean_files, true );
+ const FileLocation *defFilename = GetDefinitionFilename ();
+
+ GenerateImportLibraryTarget(defFilename, library_target, false);
+ GenerateImportLibraryTarget(defFilename, delayimp_target, true);
if ( defFilename )
delete defFilename;
delete library_target;
+ delete delayimp_target;
+
}
}
static const FileLocation* GetImportLibraryFilename (
const Module& module,
- string_list* pclean_files );
+ string_list* pclean_files,
+ bool delayimp );
static std::string GenerateGccDefineParametersFromVector ( const std::vector<Define*>& defines, std::set<std::string> &used_defs );
static std::string GenerateDefineParametersFromVector ( const std::vector<Define*>& defines, CompilerType compiler );
std::string GetBasename ( const std::string& filename ) const;
std::string GetCompilationUnitDependencies ( const CompilationUnit& compilationUnit ) const;
const FileLocation* GetModuleArchiveFilename () const;
- std::string GetImportLibraryDependency ( const Module& importedModule );
+ std::string GetImportLibraryDependency ( const Module& importedModule, bool delayimp );
void GetTargets ( const Module& dependencyModule,
string_list& targets );
void GetModuleDependencies ( string_list& dependencies );
void GeneratePhonyTarget() const;
void GenerateBuildMapCode ( const FileLocation *mapTarget = NULL );
void GenerateRules ();
+ void GenerateImportLibraryTarget (const FileLocation *defFilename, const FileLocation *library_target, bool delayimp);
void GenerateImportLibraryTargetIfNeeded ();
void GetDefinitionDependencies ( std::vector<FileLocation>& dependencies ) const;
std::string GetLinkingDependencies () const;
: project (project),
node (moduleNode),
importLibrary (NULL),
+ delayImportLibrary (NULL),
metadata (NULL),
bootSector (NULL),
bootstrap (NULL),
}
else if ( e.name == "library" && e.value.size () )
{
+ const XMLAttribute* att = e.GetAttribute ( "delayimport", false );
Library* pLibrary = new Library ( e, *this, e.value );
+ if ( att && !stricmp ( att->value.c_str(), "true" ) )
+ pLibrary->delayimp = true;
non_if_data.libraries.push_back ( pLibrary );
subs_invalid = true;
}
e.location,
"Only one <importlibrary> is valid per module" );
}
- SetImportLibrary ( new ImportLibrary ( project, e, this ) );
+ SetImportLibrary ( new ImportLibrary ( project, e, this, false ) );
+ SetDelayImportLibrary ( new ImportLibrary ( project, e, this, true ) );
subs_invalid = true;
}
else if ( e.name == "if" || e.name == "ifnot" )
HasImportLibrary () ? "lib" + name + ".a" : output->name );
}
+void
+Module::SetDelayImportLibrary ( ImportLibrary* importLibrary )
+{
+ this->delayImportLibrary = importLibrary;
+}
+
std::string
Module::GetDllName () const
{
: node(&_node),
module(_module),
name(_name),
- importedModule(_module.project.LocateModule(_name))
+ importedModule(_module.project.LocateModule(_name)),
+ delayimp(false)
{
if ( module.name == name )
{
: node(NULL),
module(_module),
name(_name),
- importedModule(_module.project.LocateModule(_name))
+ importedModule(_module.project.LocateModule(_name)),
+ delayimp(false)
{
if ( !importedModule )
{
ImportLibrary::~ImportLibrary ()
{
delete source;
+ delete target;
}
ImportLibrary::ImportLibrary ( const Project& project,
const XMLElement& node,
- const Module* module )
+ const Module* module,
+ bool delayimp )
: XmlNode ( project, node ),
module (module)
{
name,
&node );
}
+
+ target = new FileLocation ( IntermediateDirectory,
+ base->output->relative_path,
+ "lib" + module->name + (delayimp ? ".delayimp.a" : ".a" ));
+
}