* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifdef _MSC_VER
#pragma warning ( disable : 4786 )
#undef OUT
#endif//OUT
+#define IsStaticLibrary( module ) ( ( module.type == StaticLibrary ) || ( module.type == HostStaticLibrary ) )
static class CBFactory : public Backend::Factory
{
{
return new CBBackend(project, configuration);
}
-
+
} factory;
filename_wrkspace += "_auto.workspace";
printf ( "Creating Code::Blocks workspace: %s\n", filename_wrkspace.c_str() );
-
+
ProcessModules();
m_wrkspaceFile = fopen ( filename_wrkspace.c_str(), "wb" );
void CBBackend::ProcessModules()
{
- for(size_t i = 0; i < ProjectNode.modules.size(); i++)
+ for( std::map<std::string, Module*>::const_iterator p = ProjectNode.modules.begin(); p != ProjectNode.modules.end(); ++ p )
{
- Module &module = *ProjectNode.modules[i];
+ Module &module = *p->second;
+ MingwAddImplicitLibraries( module );
_generate_cbproj ( module );
}
}
+static std::string
+GetExtension ( const std::string& filename )
+{
+ size_t index = filename.find_last_of ( '/' );
+ if (index == string::npos) index = 0;
+ string tmp = filename.substr( index, filename.size() - index );
+ size_t ext_index = tmp.find_last_of( '.' );
+ if (ext_index != string::npos)
+ return filename.substr ( index + ext_index, filename.size() );
+ return "";
+}
+
static bool FileExists(string &filename)
{
ifstream file(filename.c_str());
folder = filepath;
folder.erase(pos, folder.length() - pos);
}
-
+
FileUnit fileUnit;
fileUnit.filename = filepath;
fileUnit.folder = folder;
// Check if this folder was already added. true if it was, false otherwise.
if(CheckFolderAdded(folder))
return;
-
+
m_folders.push_back(folder);
-
+
size_t pos = folder.rfind(string("/"), folder.length() - 1);
if(pos == string::npos)
CBBackend::CbpFileName ( const Module& module ) const
{
return DosSeparator(
- ReplaceExtension ( module.GetPath(), + "_auto.cbp" )
+ ReplaceExtension ( module.output->relative_path + sSep + module.output->name, "_auto.cbp" )
);
}
CBBackend::LayoutFileName ( const Module& module ) const
{
return DosSeparator(
- ReplaceExtension ( module.GetPath(), + "_auto.layout" )
+ ReplaceExtension ( module.output->relative_path + sSep + module.output->name, "_auto.layout" )
);
}
CBBackend::DependFileName ( const Module& module ) const
{
return DosSeparator(
- ReplaceExtension ( module.GetPath(), + "_auto.depend" )
+ ReplaceExtension ( module.output->relative_path + sSep + module.output->name, "_auto.depend" )
);
}
-void
+void
CBBackend::_get_object_files ( const Module& module, vector<string>& out) const
{
- string basepath = module.GetBasePath ();
+ string basepath = module.output->relative_path;
size_t i;
- string intenv = Environment::GetIntermediatePath () + "\\" + basepath + "\\";
- string outenv = Environment::GetOutputPath () + "\\" + basepath + "\\";
+ string intenv = Environment::GetIntermediatePath () + sSep + basepath + sSep;
+ string outenv = Environment::GetOutputPath () + sSep + basepath + sSep;
vector<string> cfgs;
const vector<File*>& files = data.files;
for ( i = 0; i < files.size (); i++ )
{
- string file = files[i]->name;
- string::size_type pos = file.find_last_of ("\\");
+ string file = files[i]->file.relative_path + sSep + files[i]->file.name;
+ string::size_type pos = file.find_last_of (sSep);
if ( pos != string::npos )
file.erase ( 0, pos+1 );
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
else
file = ReplaceExtension ( file, ".obj" );
for ( size_t j = 0; j < cfgs.size () / 2; j++ )
- out.push_back ( cfgs[j] + "\\" + file );
+ out.push_back ( cfgs[j] + sSep + file );
}
}
void
CBBackend::_clean_project_files ( void )
{
- for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )
+ for( std::map<std::string, Module*>::const_iterator p = ProjectNode.modules.begin(); p != ProjectNode.modules.end(); ++ p )
{
- Module& module = *ProjectNode.modules[i];
+ Module& module = *p->second;
vector<string> out;
- printf("Cleaning project %s %s\n", module.name.c_str (), module.GetBasePath ().c_str () );
-
- string basepath = module.GetBasePath ();
- remove ( CbpFileName ( module ).c_str () );
- remove ( DependFileName ( module ).c_str () );
- remove ( LayoutFileName ( module ).c_str () );
+ printf("Cleaning project %s %s\n", module.name.c_str (), module.output->relative_path.c_str () );
+
+ string basepath = module.output->relative_path;
+ remove ( CbpFileName ( module ).c_str () );
+ remove ( DependFileName ( module ).c_str () );
+ remove ( LayoutFileName ( module ).c_str () );
_get_object_files ( module, out );
for ( size_t j = 0; j < out.size (); j++)
fprintf ( OUT, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\r\n" );
fprintf ( OUT, "<CodeBlocks_workspace_file>\r\n" );
fprintf ( OUT, "\t<Workspace title=\"ReactOS\">\r\n" );
- for ( size_t i = 0; i < ProjectNode.modules.size(); i++ )
+ for( std::map<std::string, Module*>::const_iterator p = ProjectNode.modules.begin(); p != ProjectNode.modules.end(); ++ p )
{
- Module& module = *ProjectNode.modules[i];
-
- std::string Cbp_file = CbpFileName ( module );
- fprintf ( OUT, "\t\t<Project filename=\"%s\" />\r\n", Cbp_file.c_str());
-
+ Module& module = *p->second;
+
+ if ((module.type != Iso) &&
+ (module.type != LiveIso))
+ {
+ std::string Cbp_file = CbpFileName ( module );
+ fprintf ( OUT, "\t\t<Project filename=\"%s\">\r\n", Cbp_file.c_str());
+
+ /* dependencies */
+ vector<const IfableData*> ifs_list;
+ ifs_list.push_back ( &module.project.non_if_data );
+ ifs_list.push_back ( &module.non_if_data );
+ while ( ifs_list.size() )
+ {
+ const IfableData& data = *ifs_list.back();
+ ifs_list.pop_back();
+ const vector<Library*>& libs = data.libraries;
+ for ( size_t j = 0; j < libs.size(); j++ )
+ fprintf ( OUT, "\t\t\t<Depends filename=\"%s%s%s_auto.cbp\" />\r\n", libs[j]->importedModule->output->relative_path.c_str(), sSep.c_str(), libs[j]->name.c_str() );
+ }
+ fprintf ( OUT, "\t\t</Project>\r\n" );
+ }
}
fprintf ( OUT, "\t</Workspace>\r\n" );
fprintf ( OUT, "</CodeBlocks_workspace_file>\r\n" );
string path_basedir = module.GetPathToBaseDir ();
string intenv = Environment::GetIntermediatePath ();
string outenv = Environment::GetOutputPath ();
- string module_type = GetExtension(module.GetTargetName());
- string cbproj_path = module.GetBasePath();
+ string module_type = GetExtension(*module.output);
+ string cbproj_path = module.output->relative_path;
string CompilerVar;
-
- bool lib = (module.type == ObjectLibrary) || (module.type == RpcClient) ||(module.type == RpcServer) || (module_type == ".lib") || (module_type == ".a");
+ string baseaddr;
+ string windres_defines;
+ string widl_options;
+ string project_linker_flags = "-Wl,--enable-stdcall-fixup ";
+ project_linker_flags += GenerateProjectLinkerFlags();
+
+ bool lib = (module.type == ObjectLibrary) ||
+ (module.type == RpcClient) ||
+ (module.type == RpcServer) ||
+ (module.type == RpcProxy) ||
+ (module_type == ".lib") ||
+ (module_type == ".a");
bool dll = (module_type == ".dll") || (module_type == ".cpl");
bool exe = (module_type == ".exe") || (module_type == ".scr");
bool sys = (module_type == ".sys");
vector<string> source_files, resource_files, includes, libraries, libpaths;
vector<string> header_files, common_defines, compiler_flags;
vector<string> vars, values;
-
+
+ /* do not create project files for these targets
+ use virtual targets instead */
+ switch (module.type)
+ {
+ case Iso:
+ case LiveIso:
+ return;
+ default:
+ break;
+ }
+
compiler_flags.push_back ( "-Wall" );
// Always force disabling of sibling calls optimisation for GCC
if ( module.pch != NULL )
{
string pch_path = Path::RelativeFromDirectory (
- module.pch->file.name,
- module.GetBasePath() );
+ module.pch->file->name,
+ module.output->relative_path );
header_files.push_back ( pch_path );
}
const vector<File*>& files = data.files;
for ( i = 0; i < files.size(); i++ )
{
- string file = string(".") + &files[i]->name[cbproj_path.size()];
+ string fullpath = files[i]->file.relative_path + sSep + files[i]->file.name;
+ string file = string(".") + &fullpath[cbproj_path.size()];
if ( !stricmp ( Right(file,3).c_str(), ".rc" ) )
resource_files.push_back ( file );
for ( i = 0; i < incs.size(); i++ )
{
string path = Path::RelativeFromDirectory (
- incs[i]->directory,
- module.GetBasePath() );
+ incs[i]->directory->relative_path,
+ module.output->relative_path );
includes.push_back ( path );
+ widl_options += "-I" + path + " ";
}
const vector<Library*>& libs = data.libraries;
for ( i = 0; i < libs.size(); i++ )
{
- string libpath = outdir + "\\" + libs[i]->importedModule->GetBasePath() + "\\" + libs[i]->name;
+ string libpath = intdir + sSep + libs[i]->importedModule->output->relative_path;
libraries.push_back ( libs[i]->name );
libpaths.push_back ( libpath );
}
for ( i = 0; i < defs.size(); i++ )
{
if ( defs[i]->value[0] )
- common_defines.push_back( defs[i]->name + "=" + defs[i]->value );
+ {
+ const string& escaped = _replace_str(defs[i]->value, "\"",""");
+ common_defines.push_back( defs[i]->name + "=" + escaped );
+ windres_defines += "-D" + defs[i]->name + "=" + escaped + " ";
+ }
else
+ {
common_defines.push_back( defs[i]->name );
+ windres_defines += "-D" + defs[i]->name + " ";
+ }
}
/*const vector<Property*>& variables = data.properties;
for ( i = 0; i < variables.size(); i++ )
vars.push_back( variables[i]->name );
values.push_back( variables[i]->value );
}*/
+ for ( std::map<std::string, Property*>::const_iterator p = data.properties.begin(); p != data.properties.end(); ++ p )
+ {
+ Property& prop = *p->second;
+ if ( strstr ( module.baseaddress.c_str(), prop.name.c_str() ) )
+ baseaddr = prop.value;
+ }
}
if ( !module.allowWarnings )
compiler_flags.push_back ( "-Werror" );
+ if ( IsStaticLibrary ( module ) && module.isStartupLib )
+ compiler_flags.push_back ( "-Wno-main" );
+
+
FILE* OUT = fopen ( cbproj_file.c_str(), "wb" );
fprintf ( OUT, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?>\r\n" );
fprintf ( OUT, "<CodeBlocks_project_file>\r\n" );
- fprintf ( OUT, "\t<FileVersion major=\"1\" minor=\"5\" />\r\n" );
+ fprintf ( OUT, "\t<FileVersion major=\"1\" minor=\"6\" />\r\n" );
fprintf ( OUT, "\t<Project>\r\n" );
fprintf ( OUT, "\t\t<Option title=\"%s\" />\r\n", module.name.c_str() );
fprintf ( OUT, "\t\t<Option pch_mode=\"2\" />\r\n" );
fprintf ( OUT, "\t\t<Option default_target=\"\" />\r\n" );
fprintf ( OUT, "\t\t<Option compiler=\"gcc\" />\r\n" );
+ fprintf ( OUT, "\t\t<Option extended_obj_names=\"1\" />\r\n" );
fprintf ( OUT, "\t\t<Option virtualFolders=\"\" />\r\n" );
fprintf ( OUT, "\t\t<Build>\r\n" );
if ( configuration.UseConfigurationInPath )
{
- fprintf ( OUT, "\t\t\t\t<Option output=\"%s\\%s%s\\%s%s\" prefix_auto=\"1\" extension_auto=\"1\" />\r\n", outdir.c_str (), module.GetBasePath ().c_str (), cfg.name.c_str(), module.name.c_str(), module_type.c_str());
- fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s\\%s%s\" />\r\n", intdir.c_str(), module.GetBasePath ().c_str (), cfg.name.c_str() );
+ if ( IsStaticLibrary ( module ) ||module.type == ObjectLibrary )
+ fprintf ( OUT, "\t\t\t\t<Option output=\"%s%s%s%s%s%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", intdir.c_str (), sSep.c_str(), module.output->relative_path.c_str (), cfg.name.c_str(), sSep.c_str(), module.name.c_str(), module_type.c_str());
+ else
+ fprintf ( OUT, "\t\t\t\t<Option output=\"%s%s%s%s%s%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", outdir.c_str (), sSep.c_str(), module.output->relative_path.c_str (), cfg.name.c_str(), sSep.c_str(), module.name.c_str(), module_type.c_str());
+ fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s%s%s%s\" />\r\n", intdir.c_str(), sSep.c_str(), module.output->relative_path.c_str (), cfg.name.c_str() );
}
else
{
- fprintf ( OUT, "\t\t\t\t<Option output=\"%s\\%s\\%s%s\" prefix_auto=\"1\" extension_auto=\"1\" />\r\n", outdir.c_str (), module.GetBasePath ().c_str (), module.name.c_str(), module_type.c_str() );
- fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s\\%s\" />\r\n", intdir.c_str(), module.GetBasePath ().c_str () );
+ if ( IsStaticLibrary ( module ) || module.type == ObjectLibrary )
+ fprintf ( OUT, "\t\t\t\t<Option output=\"%s%s%s%s%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", intdir.c_str (), sSep.c_str(), module.output->relative_path.c_str (), sSep.c_str(), module.name.c_str(), module_type.c_str() );
+ else
+ fprintf ( OUT, "\t\t\t\t<Option output=\"%s%s%s%s%s%s\" prefix_auto=\"0\" extension_auto=\"0\" />\r\n", outdir.c_str (), sSep.c_str(), module.output->relative_path.c_str (), sSep.c_str(), module.name.c_str(), module_type.c_str() );
+ fprintf ( OUT, "\t\t\t\t<Option object_output=\"%s%s%s\" />\r\n", intdir.c_str(), sSep.c_str(), module.output->relative_path.c_str () );
}
if ( lib )
+ {
fprintf ( OUT, "\t\t\t\t<Option type=\"2\" />\r\n" );
- else if ( dll )
+ }
+ else if ( dll )
fprintf ( OUT, "\t\t\t\t<Option type=\"3\" />\r\n" );
else if ( sys )
- fprintf ( OUT, "\t\t\t\t<Option type=\"?\" />\r\n" ); /*FIXME*/
+ fprintf ( OUT, "\t\t\t\t<Option type=\"5\" />\r\n" );
else if ( exe )
{
if ( module.type == Kernel )
- fprintf ( OUT, "\t\t\t\t<Option type=\"?\" />\r\n" ); /*FIXME*/
+ fprintf ( OUT, "\t\t\t\t<Option type=\"5\" />\r\n" );
else if ( module.type == NativeCUI )
- fprintf ( OUT, "\t\t\t\t<Option type=\"?\" />\r\n" ); /*FIXME*/
+ fprintf ( OUT, "\t\t\t\t<Option type=\"5\" />\r\n" );
else if ( module.type == Win32CUI || module.type == Win32GUI || module.type == Win32SCR)
{
if ( console )
fprintf ( OUT, "\t\t\t\t<Option type=\"0\" />\r\n" );
}
}
-
-
+
fprintf ( OUT, "\t\t\t\t<Option compiler=\"gcc\" />\r\n" );
+
+ if ( module_type == ".cpl" )
+ {
+ fprintf ( OUT, "\t\t\t\t<Option parameters=\"shell32,Control_RunDLL "$exe_output",@\" />\r\n" );
+ fprintf ( OUT, "\t\t\t\t<Option host_application=\"rundll32.exe\" />\r\n" );
+ }
fprintf ( OUT, "\t\t\t\t<Compiler>\r\n" );
-
+
bool debug = ( cfg.optimization == Debug );
if ( debug )
}
fprintf ( OUT, "\t\t\t\t</ResourceCompiler>\r\n" );
- /* libraries */
fprintf ( OUT, "\t\t\t\t<Linker>\r\n" );
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s\" />\r\n", project_linker_flags.c_str() );
+
+ if ( sys )
+ {
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint() == "" ? "DriverEntry@8" : module.GetEntryPoint().c_str ());
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--image-base,%s\" />\r\n", baseaddr == "" ? "0x10000" : baseaddr.c_str () );
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-nostartfiles -Wl,--nostdlib\" />\r\n" );
+ }
+ else if ( exe )
+ {
+ if ( module.type == Kernel )
+ {
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,_KiSystemStartup\" />\r\n" );
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--image-base,%s\" />\r\n", baseaddr.c_str () );
+ }
+ else if ( module.type == NativeCUI )
+ {
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,_NtProcessStartup@4\" />\r\n" );
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--image-base,%s\" />\r\n", baseaddr.c_str () );
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-nostartfiles -Wl,--nostdlib\" />\r\n" );
+ }
+ else
+ {
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s\" />\r\n", module.cplusplus ? "-nostartfiles" : "-nostartfiles -Wl,--nostdlib" );
+ fprintf ( OUT, "\t\t\t\t\t<Add library=\"gcc\" />\r\n" );
+ }
+ }
+ else if ( dll )
+ {
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--entry,%s%s\" />\r\n", "_", module.GetEntryPoint().c_str () );
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--image-base,%s\" />\r\n", baseaddr == "" ? "0x40000" : baseaddr.c_str () );
+
+ if ( module.type == Win32DLL)
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--shared\" />\r\n" );
+ else if ( module.type == NativeDLL)
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--shared\" />\r\n" );
+ else if ( module.type == NativeDLL)
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-nostartfiles -Wl,--shared\" />\r\n" );
+
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s\" />\r\n", module.cplusplus ? "-nostartfiles" : "-nostartfiles -Wl,--nostdlib" );
+ fprintf ( OUT, "\t\t\t\t\t<Add library=\"gcc\" />\r\n" );
+ }
+
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--file-alignment,0x1000\" />\r\n" );
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"-Wl,--section-alignment,0x1000\" />\r\n" );
+
+ if ( dll )
+ fprintf ( OUT, "\t\t\t\t\t<Add option=\"%s.temp.exp\" />\r\n", module.name.c_str() );
+
+ /* libraries */
for ( i = 0; i < libraries.size(); i++ )
{
const string& lib = libraries[i];
}
fprintf ( OUT, "\t\t\t\t</Linker>\r\n" );
+ fprintf ( OUT, "\t\t\t\t<ExtraCommands>\r\n" );
+
+#if 0
+ if ( IsStaticLibrary ( module ) && module.importLibrary )
+ fprintf ( OUT, "\t\t\t\t\t<Add after=\"dlltool --dllname %s --def %s --output-lib $exe_output; %s -U\" />\r\n", module.importLibrary->dllname.c_str (), module.importLibrary->definition.c_str(), module.mangledSymbols ? "" : "--kill-at" );
+ else if ( module.importLibrary != NULL )
+ fprintf ( OUT, "\t\t\t\t\t<Add after=\"dlltool --dllname %s --def %s --output-lib "$(TARGET_OBJECT_DIR)lib$(TARGET_OUTPUT_BASENAME).a" %s\" />\r\n", module.GetTargetName ().c_str(), module.importLibrary->definition.c_str(), module.mangledSymbols ? "" : "--kill-at" );
+#endif
+
+
+ for ( i = 0; i < resource_files.size(); i++ )
+ {
+ const string& resource_file = resource_files[i];
+#ifdef WIN32
+ fprintf ( OUT, "\t\t\t\t\t<Add after=\"cmd /c del $(TARGET_OBJECT_DIR)%s%s.rci.tmp 2>NUL\" />\r\n", sSep.c_str(), resource_file.c_str() );
+ fprintf ( OUT, "\t\t\t\t\t<Add after=\"cmd /c del $(TARGET_OBJECT_DIR)%s%s.res.tmp 2>NUL\" />\r\n", sSep.c_str(), resource_file.c_str() );
+#else
+ fprintf ( OUT, "\t\t\t\t\t<Add after=\"rm $(TARGET_OBJECT_DIR)/%s.rci.tmp 2>/dev/null\" />\r\n", resource_file.c_str() );
+ fprintf ( OUT, "\t\t\t\t\t<Add after=\"rm $(TARGET_OBJECT_DIR)/%s.res.tmp 2>/dev/null\" />\r\n", resource_file.c_str() );
+#endif
+ }
+
+#if 0
+ if ( dll )
+ {
+ if (IsSpecDefinitionFile( module ))
+ fprintf ( OUT, "\t\t\t\t\t<Add before=\"%s%stools%swinebuild%swinebuild.exe -o %s --def -E %s.spec\" />\r\n", outdir.c_str(), sSep, sSep, sSep, module.importLibrary->definition.c_str(), module.name.c_str());
+ fprintf ( OUT, "\t\t\t\t\t<Add before=\"dlltool --dllname %s --def %s --output-exp %s.temp.exp %s\" />\r\n", module.GetTargetName ().c_str(), module.importLibrary->definition.c_str(), module.name.c_str(), module.mangledSymbols ? "" : "--kill-at" );
+ fprintf ( OUT, "\t\t\t\t\t<Add after=\"%s%stools%spefixup $exe_output -exports\" />\r\n", outdir.c_str(), sSep, sSep );
+#ifdef WIN32
+ fprintf ( OUT, "\t\t\t\t\t<Add after=\"cmd /c del %s.temp.exp 2>NUL\" />\r\n", module.name.c_str() );
+#else
+ fprintf ( OUT, "\t\t\t\t\t<Add after=\"rm %s.temp.exp 2>/dev/null\" />\r\n", module.name.c_str() );
+#endif
+ fprintf ( OUT, "\t\t\t\t\t<Mode after=\"always\" />\r\n" );
+ }
+#endif
+
+ fprintf ( OUT, "\t\t\t\t</ExtraCommands>\r\n" );
+
fprintf ( OUT, "\t\t\t</Target>\r\n" );
}
fprintf ( OUT, "\t\t</Build>\r\n" );
+#ifdef FORCE_CPP
+ CompilerVar = "CPP"
+#else
if ( module.cplusplus )
CompilerVar = "CPP";
else
CompilerVar = "CC";
+#endif
/* header files */
for ( i = 0; i < header_files.size(); i++ )
string source_file = DosSeparator(source_files[isrcfile]);
fprintf ( OUT, "\t\t<Unit filename=\"%s\">\r\n", source_file.c_str() );
fprintf ( OUT, "\t\t\t<Option compilerVar=\"%s\" />\r\n", CompilerVar.c_str() );
+
+ string extension = GetExtension ( source_file );
+ if ( extension == ".s" || extension == ".S" )
+ {
+ fprintf ( OUT, "\t\t\t<Option compile=\"1\" />\r\n" );
+ fprintf ( OUT, "\t\t\t<Option link=\"1\" />\r\n" );
+ fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"gcc -x assembler-with-cpp -c $file -o $link_objects $includes -D__ASM__ $options\" />\r\n" );
+ }
+ else if ( extension == ".asm" || extension == ".ASM" )
+ {
+ fprintf ( OUT, "\t\t\t<Option compile=\"1\" />\r\n" );
+ fprintf ( OUT, "\t\t\t<Option link=\"1\" />\r\n" );
+ fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"nasm -f win32 $file -o $link_objects\" />\r\n" );
+ }
+ else if ( extension == ".idl" || extension == ".IDL" )
+ {
+ fprintf ( OUT, "\t\t\t<Option compile=\"1\" />\r\n" );
+ fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"%s%stools%swidl%swidl.exe %s %s -h -H "$(TARGET_OUTPUT_DIR)$filetitle_c.h" -c -C "$(TARGET_OUTPUT_DIR)$filetitle_c.c" $file%sngcc %s -c "$(TARGET_OUTPUT_DIR)$filetitle_c.c" -o "$(TARGET_OUTPUT_DIR)$file_c.o"\" />\r\n", outdir.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str(), widl_options.c_str(), windres_defines.c_str(), sSep.c_str(), widl_options.c_str() );
+ }
+ else if ( extension == ".spec" || extension == ".SPEC" )
+ {
+ fprintf ( OUT, "\t\t\t<Option compile=\"1\" />\r\n" );
+ fprintf ( OUT, "\t\t\t<Option link=\"1\" />\r\n" );
+ fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"%s%stools%swinebuild%swinebuild.exe -o $file.stubs.c --pedll $file\\n$compiler -c $options $includes $file.stubs.c -o $(TARGET_OBJECT_DIR)%s$file.o\" />\r\n", outdir.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str() );
+ }
+
for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )
{
const CBConfiguration& cfg = *m_configurations[icfg];
const string& resource_file = resource_files[i];
fprintf ( OUT, "\t\t<Unit filename=\"%s\">\r\n", resource_file.c_str() );
fprintf ( OUT, "\t\t\t<Option compilerVar=\"WINDRES\" />\r\n" );
+ string extension = GetExtension ( resource_file );
+ fprintf ( OUT, "\t\t\t<Option compiler=\"gcc\" use=\"1\" buildCommand=\"gcc -xc -E -DRC_INVOKED $includes %s $file -o $(TARGET_OBJECT_DIR)%s$file.rci.tmp\\n%s%stools%swrc%swrc.exe $includes %s $(TARGET_OBJECT_DIR)%s$file.rci.tmp $(TARGET_OBJECT_DIR)%s$file.res.tmp\\n$rescomp --output-format=coff $(TARGET_OBJECT_DIR)%s$file.res.tmp -o $resource_output\" />\r\n" , windres_defines.c_str(), sSep.c_str(), outdir.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str(), windres_defines.c_str(), sSep.c_str(), sSep.c_str(), sSep.c_str() );
for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ )
{
const CBConfiguration& cfg = *m_configurations[icfg];
this->name = "Unknown";
}
}
+
+std::string
+CBBackend::_replace_str(std::string string1, const std::string &find_str, const std::string &replace_str)
+{
+ std::string::size_type pos = string1.find(find_str, 0);
+ int intLen = find_str.length();
+
+ while(std::string::npos != pos)
+ {
+ string1.replace(pos, intLen, replace_str);
+ pos = string1.find(find_str, intLen + pos);
+ }
+
+ return string1;
+}
+
+std::string
+CBBackend::GenerateProjectLinkerFlags() const
+{
+ std::string lflags;
+ for ( size_t i = 0; i < ProjectNode.linkerFlags.size (); i++ )
+ {
+ LinkerFlag& linkerFlag = *ProjectNode.linkerFlags[i];
+ if ( lflags.length () > 0 )
+ lflags += " ";
+ lflags += linkerFlag.flag;
+ }
+ return lflags;
+}
+
+void
+CBBackend::MingwAddImplicitLibraries( Module &module )
+{
+ Library* pLibrary;
+
+ if ( !module.isDefaultEntryPoint )
+ return;
+
+ if ( module.IsDLL () )
+ {
+ //pLibrary = new Library ( module, "__mingw_dllmain" );
+ //module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
+ }
+ else
+ {
+ pLibrary = new Library ( module, module.isUnicode ? "mingw_wmain" : "mingw_main" );
+ module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin(), pLibrary );
+ }
+
+ pLibrary = new Library ( module, "mingw_common" );
+ module.non_if_data.libraries.insert ( module.non_if_data.libraries.begin() + 1, pLibrary );
+
+ if ( module.name != "msvcrt" )
+ {
+ // always link in msvcrt to get the basic routines
+ pLibrary = new Library ( module, "msvcrt" );
+ module.non_if_data.libraries.push_back ( pLibrary );
+ }
+}
+
+const Property*
+CBBackend::_lookup_property ( const Module& module, const std::string& name ) const
+{
+ std::map<std::string, Property*>::const_iterator p;
+
+ /* Check local values */
+ p = module.non_if_data.properties.find(name);
+
+ if ( p != module.non_if_data.properties.end() )
+ return p->second;
+
+ // TODO FIXME - should we check local if-ed properties?
+ p = module.project.non_if_data.properties.find(name);
+
+ if ( p != module.project.non_if_data.properties.end() )
+ return p->second;
+
+ // TODO FIXME - should we check global if-ed properties?
+ return NULL;
+}
+
+bool
+CBBackend::IsSpecDefinitionFile ( const Module& module ) const
+{
+ if ( module.importLibrary == NULL)
+ return false;
+
+ size_t index = module.importLibrary->source->name.rfind ( ".spec" );
+ return ( index != string::npos );
+}