From 9598f59dec998b671a532f59fa2e08b2ed4e39d9 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Tue, 1 Jun 2010 09:31:24 +0000 Subject: [PATCH] [rbuild] msvc backend: - Start implementing real support for vcxproj files - Fix generating sln files - Move msvc rules in a separate folder - Various fixes svn path=/trunk/; revision=47511 --- reactos/tools/rbuild/backend/msvc/msvc.cpp | 111 ++++--- reactos/tools/rbuild/backend/msvc/msvc.h | 67 ++-- .../tools/rbuild/backend/msvc/projmaker.cpp | 90 ++++++ .../tools/rbuild/backend/msvc/propsmaker.cpp | 197 +++++++++++ .../backend/msvc/rules/reactos.defaults.props | 27 ++ .../rbuild/backend/msvc/rules/reactos.targets | 6 + .../backend/msvc/rules/s_as_mscpp.props | 21 ++ .../backend/msvc/{ => rules}/s_as_mscpp.rules | 0 .../backend/msvc/rules/s_as_mscpp.targets | 84 +++++ .../rbuild/backend/msvc/rules/s_as_mscpp.xml | 145 +++++++++ .../rbuild/backend/msvc/rules/spec.props | 38 +++ .../backend/msvc/{ => rules}/spec.rules | 0 .../rbuild/backend/msvc/rules/spec.targets | 159 +++++++++ .../tools/rbuild/backend/msvc/rules/spec.xml | 274 ++++++++++++++++ .../tools/rbuild/backend/msvc/slnmaker.cpp | 61 +--- .../tools/rbuild/backend/msvc/vcprojmaker.cpp | 196 ++--------- .../rbuild/backend/msvc/vcxprojmaker.cpp | 306 +++++++++--------- .../rbuild/backend/msvc/vspropsmaker.cpp | 20 +- reactos/tools/rbuild/module.cpp | 2 +- reactos/tools/rbuild/rbuild.h | 3 + reactos/tools/rbuild/rbuild.mak | 5 + 21 files changed, 1367 insertions(+), 445 deletions(-) create mode 100644 reactos/tools/rbuild/backend/msvc/propsmaker.cpp create mode 100644 reactos/tools/rbuild/backend/msvc/rules/reactos.defaults.props create mode 100644 reactos/tools/rbuild/backend/msvc/rules/reactos.targets create mode 100644 reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.props rename reactos/tools/rbuild/backend/msvc/{ => rules}/s_as_mscpp.rules (100%) create mode 100644 reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.targets create mode 100644 reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.xml create mode 100644 reactos/tools/rbuild/backend/msvc/rules/spec.props rename reactos/tools/rbuild/backend/msvc/{ => rules}/spec.rules (100%) create mode 100644 reactos/tools/rbuild/backend/msvc/rules/spec.targets create mode 100644 reactos/tools/rbuild/backend/msvc/rules/spec.xml diff --git a/reactos/tools/rbuild/backend/msvc/msvc.cpp b/reactos/tools/rbuild/backend/msvc/msvc.cpp index 688758c44a3..6fc993d06b3 100644 --- a/reactos/tools/rbuild/backend/msvc/msvc.cpp +++ b/reactos/tools/rbuild/backend/msvc/msvc.cpp @@ -83,8 +83,6 @@ MSVCBackend::MSVCBackend(Project &project, void MSVCBackend::Process() { - bool only_msvc_headers = false; - while ( m_configurations.size () > 0 ) { const MSVCConfiguration* cfg = m_configurations.back(); @@ -92,17 +90,17 @@ void MSVCBackend::Process() delete cfg; } - m_configurations.push_back ( new MSVCConfiguration( Debug )); - m_configurations.push_back ( new MSVCConfiguration( Release )); -// m_configurations.push_back ( new MSVCConfiguration( Speed )); - m_configurations.push_back ( new MSVCConfiguration( RosBuild )); - - if (!only_msvc_headers) + //Don't generate configurations that require WDK if it can't be found + if(getenv ( "BASEDIR" ) != NULL) { - m_configurations.push_back ( new MSVCConfiguration( Debug, ReactOSHeaders )); - m_configurations.push_back ( new MSVCConfiguration( Release, ReactOSHeaders )); -// m_configurations.push_back ( new MSVCConfiguration( Speed, ReactOSHeaders )); + m_configurations.push_back ( new MSVCConfiguration( Debug )); + m_configurations.push_back ( new MSVCConfiguration( Release )); } + m_configurations.push_back ( new MSVCConfiguration( RosBuild )); + m_configurations.push_back ( new MSVCConfiguration( Debug, ReactOSHeaders )); + m_configurations.push_back ( new MSVCConfiguration( Release, ReactOSHeaders )); + // m_configurations.push_back ( new MSVCConfiguration( Speed )); + // m_configurations.push_back ( new MSVCConfiguration( Speed, ReactOSHeaders )); if ( configuration.CleanAsYouGo ) { _clean_project_files(); @@ -117,34 +115,45 @@ void MSVCBackend::Process() filename_sln += "_auto.sln"; printf ( "Creating MSVC workspace: %s\n", filename_sln.c_str() ); - //Write a property page for each configuration - for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ ) + if (configuration.VSProjectVersion == "10.00") { - MSVCConfiguration* cfg = m_configurations[icfg]; - - //RosBuild doesn't need a property page - if(cfg->optimization == RosBuild) - continue; - - string filename_props( cfg->name ); - filename_props += ".vsprops"; - //Write the propery pages files - PropsMaker propsMaker( configuration, &ProjectNode, filename_props, cfg ); + PropsMaker propsMaker( &ProjectNode, "reactos.props", m_configurations ); propsMaker._generate_props( _get_solution_version(), _get_studio_version() ); } + else + { + //Write a property page for each configuration + for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ ) + { + MSVCConfiguration* cfg = m_configurations[icfg]; + //RosBuild doesn't need a property page + if(cfg->optimization == RosBuild) + continue; + + //Write the propery pages files + string filename_props( cfg->name ); + + filename_props = filename_props + ".vsprops"; + VSPropsMaker propsMaker( configuration, &ProjectNode, filename_props, cfg ); + propsMaker._generate_props( _get_solution_version(), _get_studio_version() ); + } + } // Write out the project files ProcessModules(); - // Write the solution file - SlnMaker slnMaker( configuration, ProjectNode, m_configurations, filename_sln ); - slnMaker._generate_sln ( _get_solution_version(), _get_studio_version() ); - printf ( "Done.\n" ); } void MSVCBackend::ProcessModules() { + string filename_sln ( ProjectNode.name ); + + filename_sln += "_auto.sln"; + + // Write the solution file + SlnMaker slnMaker( configuration, m_configurations, filename_sln, _get_solution_version(), _get_studio_version() ); + for(std::map::const_iterator p = ProjectNode.modules.begin(); p != ProjectNode.modules.end(); ++ p) { Module &module = *p->second; @@ -156,17 +165,21 @@ void MSVCBackend::ProcessModules() if (configuration.VSProjectVersion == "10.00") { string vcxproj_file = VcxprojFileName(module); - projMaker = new VCXProjMaker( configuration, m_configurations, vcxproj_file ); + projMaker = new VCXProjMaker( configuration, m_configurations, vcxproj_file, module ); } else { string vcproj_file = VcprojFileName(module); - projMaker = new VCProjMaker( configuration, m_configurations, vcproj_file ); + projMaker = new VCProjMaker( configuration, m_configurations, vcproj_file, module ); } projMaker->_generate_proj_file ( module ); + + slnMaker._add_project(*projMaker, module); + delete projMaker; } + } static bool FileExists(string &filename) @@ -262,6 +275,25 @@ void MSVCBackend::OutputFolders() #endif } +std::string +MSVCBackend::UserFileName ( const Module& module, std::string vcproj_file ) const +{ + string computername; + string username; + + if (getenv ( "USERNAME" ) != NULL) + username = getenv ( "USERNAME" ); + if (getenv ( "COMPUTERNAME" ) != NULL) + computername = getenv ( "COMPUTERNAME" ); + else if (getenv ( "HOSTNAME" ) != NULL) + computername = getenv ( "HOSTNAME" ); + + if ((computername != "") && (username != "")) + return vcproj_file + "." + computername + "." + username + ".user"; + else + return ""; +} + std::string MSVCBackend::SuoFileName ( const Module& module ) const { @@ -416,25 +448,10 @@ MSVCBackend::_clean_project_files ( void ) vector out; printf("Cleaning project %s %s %s\n", module.name.c_str (), module.output->relative_path.c_str (), NcbFileName ( module ).c_str () ); - string basepath = module.output->relative_path; - remove ( NcbFileName ( module ).c_str () ); - remove ( SlnFileName ( module ).c_str () ); - remove ( SuoFileName ( module ).c_str () ); + string vcproj_file_user = UserFileName(module, VcprojFileName ( module )); + if(vcproj_file_user != "") + remove ( vcproj_file_user.c_str () ); - if ( configuration.VSProjectVersion == "10.00" ) - remove ( VcxprojFileName ( module ).c_str () ); - else - remove ( VcprojFileName ( module ).c_str () ); - - string username = getenv ( "USERNAME" ); - string computername = getenv ( "COMPUTERNAME" ); - string vcproj_file_user = ""; -#if 0 - if ((computername != "") && (username != "")) - vcproj_file_user = VcprojFileName ( module ) + "." + computername + "." + username + ".user"; - - remove ( vcproj_file_user.c_str () ); -#endif _get_object_files ( module, out ); _get_def_files ( module, out ); for ( size_t j = 0; j < out.size (); j++) diff --git a/reactos/tools/rbuild/backend/msvc/msvc.h b/reactos/tools/rbuild/backend/msvc/msvc.h index a917c12e187..25bc70d0aa6 100644 --- a/reactos/tools/rbuild/backend/msvc/msvc.h +++ b/reactos/tools/rbuild/backend/msvc/msvc.h @@ -106,6 +106,7 @@ class MSVCBackend : public Backend std::string VcxprojFileName ( const Module& module ) const; std::string SlnFileName ( const Module& module ) const; std::string SuoFileName ( const Module& module ) const; + std::string UserFileName ( const Module& module, std::string vcproj_file ) const; std::string NcbFileName ( const Module& module ) const; std::vector m_configurations; @@ -141,6 +142,8 @@ class ProjMaker virtual void _generate_proj_file ( const Module& module ) = 0; virtual void _generate_user_configuration (); + std::string VcprojFileName ( const Module& module ) const; + protected: Configuration configuration; std::vector m_configurations; @@ -148,20 +151,24 @@ class ProjMaker FILE* OUT; std::vector header_files; + std::vector source_files; + std::vector resource_files; + std::vector generated_files; + std::vector defines; std::vector includes; - std::vector includes_ros; std::vector libraries; - std::set common_defines; + std::string baseaddr; + BinaryType binaryType; - std::string VcprojFileName ( const Module& module ) const; std::string _get_vc_dir ( void ) const; - std::string _strip_gcc_deffile(std::string Filename, std::string sourcedir, std::string objdir); std::string _get_solution_version ( void ); std::string _get_studio_version ( void ); std::string _replace_str( std::string string1, const std::string &find_str, const std::string &replace_str); + std::string _get_file_path( FileLocation* file, std::string relative_path); + void _collect_files(const Module& module); void _generate_standard_configuration( const Module& module, const MSVCConfiguration& cfg, BinaryType binaryType ); void _generate_makefile_configuration( const Module& module, const MSVCConfiguration& cfg ); }; @@ -170,13 +177,14 @@ class VCProjMaker : public ProjMaker { public: VCProjMaker ( ); - VCProjMaker ( Configuration& buildConfig, const std::vector& msvc_configs, std::string filename ); + VCProjMaker ( Configuration& buildConfig, const std::vector& msvc_configs, std::string filename, const Module& module ); virtual ~VCProjMaker (); void _generate_proj_file ( const Module& module ); void _generate_user_configuration (); private: + void _generate_standard_configuration( const Module& module, const MSVCConfiguration& cfg, BinaryType binaryType ); void _generate_makefile_configuration( const Module& module, const MSVCConfiguration& cfg ); std::string _get_file_path( FileLocation* file, std::string relative_path); @@ -186,13 +194,15 @@ class VCXProjMaker : public ProjMaker { public: VCXProjMaker ( ); - VCXProjMaker ( Configuration& buildConfig, const std::vector& msvc_configs, std::string filename ); + VCXProjMaker ( Configuration& buildConfig, const std::vector& msvc_configs, std::string filename, const Module& module ); virtual ~VCXProjMaker (); void _generate_proj_file ( const Module& module ); void _generate_user_configuration (); private: + std::string _get_configuration_type (); + void _generate_item_group (std::vector); void _generate_standard_configuration( const Module& module, const MSVCConfiguration& cfg, BinaryType binaryType ); void _generate_makefile_configuration( const Module& module, const MSVCConfiguration& cfg ); }; @@ -200,38 +210,30 @@ class VCXProjMaker : public ProjMaker class SlnMaker { public: - SlnMaker ( Configuration& buildConfig, Project& ProjectNode, const std::vector& configurations, std::string filename_sln ); + SlnMaker ( Configuration& buildConfig, const std::vector& configurations, std::string filename_sln, std::string solution_version, std::string studio_version); ~SlnMaker (); - void _generate_sln ( std::string solution_version, std::string studio_version ); - + void _add_project(ProjMaker &project, Module &module); private: Configuration m_configuration; - Project* m_ProjectNode; std::vector m_configurations; FILE* OUT; + std::vector modules; void _generate_sln_header ( std::string solution_version, std::string studio_version ); void _generate_sln_footer ( ); - //void _generate_rules_file ( FILE* OUT ); - void _generate_sln_project ( - const Module& module, - std::string vcproj_file, - std::string sln_guid, - std::string vcproj_guid, - const std::vector& libraries ); void _generate_sln_configurations ( std::string vcproj_guid ); }; -class PropsMaker +class VSPropsMaker { public: - PropsMaker ( Configuration& buildConfig, + VSPropsMaker ( Configuration& buildConfig, Project* ProjectNode, std::string filename_props, MSVCConfiguration* msvc_configs); - ~PropsMaker (); + ~VSPropsMaker (); void _generate_props ( std::string solution_version, std::string studio_version ); @@ -253,3 +255,28 @@ class PropsMaker void _generate_footer(); }; + + +class PropsMaker +{ + public: + PropsMaker ( Project* ProjectNode, + std::string filename_props, + std::vector configurations); + + ~PropsMaker (); + + void _generate_props ( std::string solution_version, std::string studio_version ); + + private: + Project* m_ProjectNode; + FILE* OUT; + std::vector m_configurations; + + void _generate_macro(std::string Name, std::string Value); + void _generate_global_includes(bool debug, bool use_ros_headers); + void _generate_global_definitions(bool debug, bool use_ros_headers); + void _generate_header(); + void _generate_footer(); + +}; \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/projmaker.cpp b/reactos/tools/rbuild/backend/msvc/projmaker.cpp index 89bf13bb5ef..2986e859d04 100644 --- a/reactos/tools/rbuild/backend/msvc/projmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/projmaker.cpp @@ -238,3 +238,93 @@ ProjMaker::_replace_str(std::string string1, const std::string &find_str, const return string1; } + + +std::string +ProjMaker::_get_file_path( FileLocation* file, std::string relative_path) +{ + if (file->directory == SourceDirectory) + { + // We want the full path here for directory support later on + return Path::RelativeFromDirectory (file->relative_path, relative_path ); + } + else if(file->directory == IntermediateDirectory) + { + return std::string("$(RootIntDir)\\") + file->relative_path; + } + else if(file->directory == OutputDirectory) + { + return std::string("$(RootOutDir)\\") + file->relative_path; + } + + return std::string(""); +} + +void +ProjMaker::_collect_files(const Module& module) +{ + size_t i; + const IfableData& data = module.non_if_data; + const vector& files = data.files; + for ( i = 0; i < files.size(); i++ ) + { + string path = _get_file_path(&files[i]->file, module.output->relative_path); + string file = path + std::string("\\") + files[i]->file.name; + + if (files[i]->file.directory != SourceDirectory) + generated_files.push_back ( file ); + else if ( !stricmp ( Right(file,3).c_str(), ".rc" ) ) + resource_files.push_back ( file ); + else if ( !stricmp ( Right(file,2).c_str(), ".h" ) ) + header_files.push_back ( file ); + else + source_files.push_back ( file ); + } + const vector& incs = data.includes; + for ( i = 0; i < incs.size(); i++ ) + { + includes.push_back ( _get_file_path(incs[i]->directory, module.output->relative_path) ); + } + const vector& libs = data.libraries; + for ( i = 0; i < libs.size(); i++ ) + { + string libpath = "$(RootOutDir)\\" + libs[i]->importedModule->output->relative_path + "\\" + _get_vc_dir() + "\\$(ConfigurationName)\\" + libs[i]->name + ".lib"; + libraries.push_back ( libpath ); + } + const vector& defs = data.defines; + for ( i = 0; i < defs.size(); i++ ) + { + if ( defs[i]->backend != "" && defs[i]->backend != "msvc" ) + continue; + + if( module.isUnicode && (defs[i]->name == "UNICODE" || defs[i]->name == "_UNICODE")) + continue; + + if ( defs[i]->value != "" ) + defines.push_back( defs[i]->name + "=" + defs[i]->value ); + else + defines.push_back( defs[i]->name ); + } + for ( std::map::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.importLibrary) + { + std::string ImportLibraryPath = _get_file_path(module.importLibrary->source, module.output->relative_path); + + switch (module.IsSpecDefinitionFile()) + { + case PSpec: + generated_files.push_back("$(IntDir)\\" + ReplaceExtension(module.importLibrary->source->name,".spec")); + case Spec: + generated_files.push_back("$(IntDir)\\" + ReplaceExtension(module.importLibrary->source->name,".stubs.c")); + generated_files.push_back("$(IntDir)\\" + ReplaceExtension(module.importLibrary->source->name,".def")); + default: + source_files.push_back(ImportLibraryPath + std::string("\\") + module.importLibrary->source->name); + } + } +} \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/propsmaker.cpp b/reactos/tools/rbuild/backend/msvc/propsmaker.cpp new file mode 100644 index 00000000000..5fc860e5f58 --- /dev/null +++ b/reactos/tools/rbuild/backend/msvc/propsmaker.cpp @@ -0,0 +1,197 @@ +#ifdef _MSC_VER +#pragma warning ( disable : 4786 ) +#endif//_MSC_VER + +#include +#include +#include +#include +#include +#include + +#include + +#include "msvc.h" + +using std::string; +using std::vector; +using std::set; + +typedef set StringSet; + +#ifdef OUT +#undef OUT +#endif//OUT + + +PropsMaker::PropsMaker (Project* ProjectNode, + std::string filename_props, + std::vector configurations) +{ + m_ProjectNode = ProjectNode; + m_configurations = configurations; + + OUT = fopen ( filename_props.c_str(), "wb" ); + + if ( !OUT ) + { + printf ( "Could not create file '%s'.\n", filename_props.c_str() ); + } +} + +PropsMaker::~PropsMaker ( ) +{ + fclose ( OUT ); +} + +void +PropsMaker::_generate_header() +{ + fprintf ( OUT, "\r\n"); + fprintf ( OUT, "\r\n"); +} + +void +PropsMaker::_generate_footer() +{ + fprintf ( OUT, "\r\n"); +} + +void +PropsMaker::_generate_macro(std::string Name, std::string Value) +{ + fprintf ( OUT, "\t\t<%s>%s\r\n", Name.c_str(), Value.c_str(), Name.c_str()); +} + +void +PropsMaker::_generate_global_includes(bool debug, bool use_ros_headers) +{ + fprintf ( OUT, "\t\t"); + + const IfableData& data = m_ProjectNode->non_if_data; + //const vector& files = data.files; + size_t i; + const vector& incs = data.includes; + for ( i = 0; i < incs.size(); i++ ) + { + if ((incs[i]->directory->relative_path == "include\\crt" || + incs[i]->directory->relative_path == "include\\ddk" || + incs[i]->directory->relative_path == "include\\GL" || + incs[i]->directory->relative_path == "include\\psdk") && + ! use_ros_headers) + { + continue; + } + + if(incs[i]->directory->directory == SourceDirectory) + fprintf ( OUT, "\"$(RootSrcDir)\\"); + else if (incs[i]->directory->directory == IntermediateDirectory) + fprintf ( OUT, "\"$(RootIntDir)\\"); + else if (incs[i]->directory->directory == OutputDirectory) + fprintf ( OUT, "\"$(RootOutDir)\\"); + else + continue; + + fprintf ( OUT, incs[i]->directory->relative_path.c_str()); + fprintf ( OUT, "\" ; "); + } + + fprintf ( OUT, "\"$(RootIntDir)\\include\" ; "); + fprintf ( OUT, "\"$(RootIntDir)\\include\\reactos\" ; "); + + if ( !use_ros_headers ) + { + // Add WDK or PSDK paths, if user provides them + if (getenv ( "BASEDIR" ) != NULL) + { + string WdkBase = getenv ( "BASEDIR" ); + fprintf ( OUT, "\"%s\\inc\\api\" ; ", WdkBase.c_str()); + fprintf ( OUT, "\"%s\\inc\\crt\" ; ", WdkBase.c_str()); + fprintf ( OUT, "\"%s\\inc\\ddk\" ; ", WdkBase.c_str()); + } + } + fprintf ( OUT, "\t\r\n"); +} + +void +PropsMaker::_generate_global_definitions(bool debug, bool use_ros_headers) +{ + fprintf ( OUT, "\t\t"); + + // Always add _CRT_SECURE_NO_WARNINGS to disable warnings about not + // using the safe functions introduced in MSVC8. + fprintf ( OUT, "_CRT_SECURE_NO_WARNINGS ; ") ; + + if ( debug ) + { + fprintf ( OUT, "_DEBUG ; "); + } + + if ( !use_ros_headers ) + { + // this is a define in MinGW w32api, but not Microsoft's headers + fprintf ( OUT, "STDCALL=__stdcall ; "); + } + + const IfableData& data = m_ProjectNode->non_if_data; + const vector& defs = data.defines; + size_t i; + + for ( i = 0; i < defs.size(); i++ ) + { + if ( defs[i]->backend != "" && defs[i]->backend != "msvc" ) + continue; + + if ( defs[i]->value != "" ) + fprintf ( OUT, "%s=%s",defs[i]->name.c_str(), defs[i]->value.c_str()); + else + fprintf ( OUT, defs[i]->name.c_str()); + fprintf ( OUT, " ; "); + } + + fprintf ( OUT, "\t\r\n"); +} + +void +PropsMaker::_generate_props ( std::string solution_version, std::string studio_version ) +{ + + string srcdir = Environment::GetSourcePath(); + string intdir = Environment::GetIntermediatePath (); + string outdir = Environment::GetOutputPath (); + string rosbedir = Environment::GetVariable("_ROSBE_BASEDIR"); + + if ( intdir == "obj-i386" ) + intdir = srcdir + "\\obj-i386"; /* append relative dir from project dir */ + + if ( outdir == "output-i386" ) + outdir = srcdir + "\\output-i386"; + + _generate_header(); + + fprintf ( OUT, "\t\r\n"); + _generate_macro("RootSrcDir", srcdir); + _generate_macro("RootOutDir", outdir); + _generate_macro("RootIntDir", intdir); + _generate_macro("Tools", "$(RootOutDir)\\tools"); + _generate_macro("RosBE", rosbedir); + fprintf ( OUT, "\t\r\n"); + + for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ ) + { + MSVCConfiguration* cfg = m_configurations[icfg]; + + if(cfg->optimization == RosBuild) + continue; + + fprintf ( OUT, "\t\r\n", cfg->name.c_str() ); + _generate_global_includes(cfg->optimization == Debug, cfg->headers == ReactOSHeaders); + _generate_global_definitions(cfg->optimization == Debug, cfg->headers == ReactOSHeaders); + fprintf ( OUT, "\t\r\n"); + } + + _generate_footer(); +} diff --git a/reactos/tools/rbuild/backend/msvc/rules/reactos.defaults.props b/reactos/tools/rbuild/backend/msvc/rules/reactos.defaults.props new file mode 100644 index 00000000000..205d35ad44b --- /dev/null +++ b/reactos/tools/rbuild/backend/msvc/rules/reactos.defaults.props @@ -0,0 +1,27 @@ + + + + + + $(globalIncludes);$(IncludePath) + + + + $(globalIncludes);$(ProjectIncludes);%(AdditionalIncludeDirectories) + $(ProjectDefines);$(globalDefines);%(PreprocessorDefinitions) + true + CompileAsC + Cdecl + + + $(globalIncludes);$(ProjectIncludes) + __ASM__ + + + $(globalIncludes);$(ProjectIncludes) + + + $(globalIncludes);$(ProjectIncludes);%(AdditionalIncludeDirectories) + + + \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/rules/reactos.targets b/reactos/tools/rbuild/backend/msvc/rules/reactos.targets new file mode 100644 index 00000000000..e7b583b4f0c --- /dev/null +++ b/reactos/tools/rbuild/backend/msvc/rules/reactos.targets @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.props b/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.props new file mode 100644 index 00000000000..67e87c81933 --- /dev/null +++ b/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.props @@ -0,0 +1,21 @@ + + + + Midl + CustomBuild + + + _SelectedFiles;$(s_as_mscppDependsOn) + + + + $(IntDir)%(Filename).obj + $(globalIncludes) + cl /nologo /E [sIncPaths] [sPPDefs] "%(FullPath)" | "$(RosBE)\i386\bin\as" -o [sOutF] + %(sOutF) + Assembling + + + \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/s_as_mscpp.rules b/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.rules similarity index 100% rename from reactos/tools/rbuild/backend/msvc/s_as_mscpp.rules rename to reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.rules diff --git a/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.targets b/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.targets new file mode 100644 index 00000000000..731117271f0 --- /dev/null +++ b/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.targets @@ -0,0 +1,84 @@ + + + + + + _s_as_mscpp + + + + $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml + + + + + + + + @(s_as_mscpp, '|') + + + + + + + + + $(ComputeLinkInputsTargets); + Computes_as_mscppOutput; + + + $(ComputeLibInputsTargets); + Computes_as_mscppOutput; + + + + + + + + + + + + \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.xml b/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.xml new file mode 100644 index 00000000000..b2a71f56073 --- /dev/null +++ b/reactos/tools/rbuild/backend/msvc/rules/s_as_mscpp.xml @@ -0,0 +1,145 @@ + + + + + + + + + + General + + + + + Command Line + + + + + + + + + + + + + + + Execute Before + + + Specifies the targets for the build customization to run before. + + + + + + + + + + + Execute After + + + Specifies the targets for the build customization to run after. + + + + + + + + + + + + + + Additional Options + + + Additional Options + + + + + + + \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/rules/spec.props b/reactos/tools/rbuild/backend/msvc/rules/spec.props new file mode 100644 index 00000000000..5e738c7db6f --- /dev/null +++ b/reactos/tools/rbuild/backend/msvc/rules/spec.props @@ -0,0 +1,38 @@ + + + + Midl + Pspec + + + _SelectedFiles;$(specDependsOn) + + + + $(IntDir)%(Filename).def + $(IntDir)%(Filename).stubs.c + "$(Tools)\winebuild\winebuild.exe" -F $(TargetFileName) -o [DefFile] --def -k -E [inputs] | "$(Tools)\winebuild\winebuild.exe" -F $(TargetFileName) -o [StubsFile] --pedll -k -E [inputs] + [DefFile] + Generating module definition file + + + + spec + CustomBuild + + + _SelectedFiles;$(PspecDependsOn) + + + + $(IntDir)%(Filename).spec + cl /nologo /EP [includes] [inputs] > [Specfile] + [Specfile] + Generating module definition file + + + \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/spec.rules b/reactos/tools/rbuild/backend/msvc/rules/spec.rules similarity index 100% rename from reactos/tools/rbuild/backend/msvc/spec.rules rename to reactos/tools/rbuild/backend/msvc/rules/spec.rules diff --git a/reactos/tools/rbuild/backend/msvc/rules/spec.targets b/reactos/tools/rbuild/backend/msvc/rules/spec.targets new file mode 100644 index 00000000000..4671ea1cd36 --- /dev/null +++ b/reactos/tools/rbuild/backend/msvc/rules/spec.targets @@ -0,0 +1,159 @@ + + + + + + _spec + + + _Pspec + + + + $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml + + + $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml + + + + + + + + @(spec, '|') + + + + + + + + + $(ComputeLinkInputsTargets); + ComputespecOutput; + + + $(ComputeLibInputsTargets); + ComputespecOutput; + + + + + + + + + + + + + + + + + + @(Pspec, '|') + + + + + + + + + $(ComputeLinkInputsTargets); + ComputePspecOutput; + + + $(ComputeLibInputsTargets); + ComputePspecOutput; + + + + + + + + + + + + \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/rules/spec.xml b/reactos/tools/rbuild/backend/msvc/rules/spec.xml new file mode 100644 index 00000000000..db15656b23b --- /dev/null +++ b/reactos/tools/rbuild/backend/msvc/rules/spec.xml @@ -0,0 +1,274 @@ + + + + + + + + + + General + + + + + Command Line + + + + + + + + + + + + + + Execute Before + + + Specifies the targets for the build customization to run before. + + + + + + + + + + + Execute After + + + Specifies the targets for the build customization to run after. + + + + + + + + + + + + + + Additional Options + + + Additional Options + + + + + + + + + + + + + + General + + + + + Command Line + + + + + + + + + + + + + + Execute Before + + + Specifies the targets for the build customization to run before. + + + + + + + + + + + Execute After + + + Specifies the targets for the build customization to run after. + + + + + + + + + + + + + + Additional Options + + + Additional Options + + + + + + + \ No newline at end of file diff --git a/reactos/tools/rbuild/backend/msvc/slnmaker.cpp b/reactos/tools/rbuild/backend/msvc/slnmaker.cpp index c17c510c300..ebc2dc8d6c5 100644 --- a/reactos/tools/rbuild/backend/msvc/slnmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/slnmaker.cpp @@ -42,12 +42,12 @@ using std::set; SlnMaker::SlnMaker ( Configuration& buildConfig, - Project& ProjectNode, const std::vector& configurations, - std::string filename_sln ) + std::string filename_sln, + std::string solution_version, + std::string studio_version) { m_configuration = buildConfig; - m_ProjectNode = &ProjectNode; m_configurations = configurations; OUT = fopen ( filename_sln.c_str(), "wb" ); @@ -56,10 +56,13 @@ SlnMaker::SlnMaker ( Configuration& buildConfig, { printf ( "Could not create file '%s'.\n", filename_sln.c_str() ); } + + _generate_sln_header( solution_version, studio_version); } SlnMaker::~SlnMaker() { + _generate_sln_footer ( ); fclose ( OUT ); } @@ -73,35 +76,6 @@ SlnMaker::_generate_sln_header ( std::string solution_version, std::string studi fprintf ( OUT, "\r\n" ); } - -void -SlnMaker::_generate_sln_project ( - const Module& module, - std::string vcproj_file, - std::string sln_guid, - std::string vcproj_guid, - const std::vector& libraries ) -{ - vcproj_file = DosSeparator ( std::string(".\\") + vcproj_file ); - - fprintf ( OUT, "Project(\"%s\") = \"%s\", \"%s\", \"%s\"\r\n", sln_guid.c_str() , module.name.c_str(), vcproj_file.c_str(), vcproj_guid.c_str() ); -/* - //FIXME: only omit ProjectDependencies in VS 2005 when there are no dependencies - //NOTE: VS 2002 do not use ProjectSection; it uses GlobalSection instead - if ((configuration.VSProjectVersion == "7.10") || (libraries.size() > 0)) { - fprintf ( OUT, "\tProjectSection(ProjectDependencies) = postProject\r\n" ); - for ( size_t i = 0; i < libraries.size(); i++ ) - { - const Module& module = *libraries[i]->importedModule; - fprintf ( OUT, "\t\t%s = %s\r\n", module.guid.c_str(), module.guid.c_str() ); - } - fprintf ( OUT, "\tEndProjectSection\r\n" ); - } -*/ - fprintf ( OUT, "EndProject\r\n" ); -} - - void SlnMaker::_generate_sln_footer ( ) { @@ -112,11 +86,9 @@ SlnMaker::_generate_sln_footer ( ) fprintf ( OUT, "\tEndGlobalSection\r\n" ); fprintf ( OUT, "\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\r\n" ); - for( std::map::const_iterator p = m_ProjectNode->modules.begin(); p != m_ProjectNode->modules.end(); ++ p ) + for ( size_t i = 0; i < modules.size (); i++) { - Module& module = *p->second; - std::string guid = module.guid; - _generate_sln_configurations ( guid.c_str() ); + _generate_sln_configurations ( modules[i]->guid.c_str() ); } fprintf ( OUT, "\tEndGlobalSection\r\n" ); /* @@ -153,20 +125,13 @@ SlnMaker::_generate_sln_configurations ( std::string vcproj_guid ) } } -void -SlnMaker::_generate_sln ( std::string solution_version, std::string studio_version ) +void +SlnMaker::_add_project(ProjMaker &project, Module &module) { string sln_guid = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"; - vector guids; - _generate_sln_header( solution_version, studio_version); - // TODO FIXME - is it necessary to sort them? - for( std::map::const_iterator p = m_ProjectNode->modules.begin(); p != m_ProjectNode->modules.end(); ++ p ) - { - Module& module = *p->second; + fprintf ( OUT, "Project(\"%s\") = \"%s\", \".\\%s\",\"%s\"\n", sln_guid.c_str(), module.name.c_str() , project.VcprojFileName(module).c_str() , module.guid.c_str()); + fprintf ( OUT, "EndProject\r\n" ); - //std::string vcproj_file = - _generate_sln_project ( module, module.name, sln_guid, module.guid, module.non_if_data.libraries ); - } - _generate_sln_footer ( ); + modules.push_back(&module); } diff --git a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp index ecd04e0d22b..b09658d18df 100644 --- a/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/vcprojmaker.cpp @@ -61,7 +61,8 @@ VCProjMaker::VCProjMaker ( ) VCProjMaker::VCProjMaker ( Configuration& buildConfig, const std::vector& msvc_configs, - std::string filename ) + std::string filename, + const Module& module) { configuration = buildConfig; m_configurations = msvc_configs; @@ -73,6 +74,21 @@ VCProjMaker::VCProjMaker ( Configuration& buildConfig, { printf ( "Could not create file '%s'.\n", vcproj_file.c_str() ); } + + // Set the binary type + string module_type = GetExtension(*module.output); + + if ((module.type == ObjectLibrary) || (module.type == RpcClient) ||(module.type == RpcServer) || (module_type == ".lib") || (module_type == ".a")) + binaryType = Lib; + else if ((module_type == ".dll") || (module_type == ".cpl")) + binaryType = Dll; + else if ((module_type == ".exe") || (module_type == ".scr")) + binaryType = Exe; + else if (module_type == ".sys") + binaryType = Sys; + else + binaryType = BinUnknown; + } VCProjMaker::~VCProjMaker() @@ -80,117 +96,16 @@ VCProjMaker::~VCProjMaker() fclose ( OUT ); } -std::string -VCProjMaker::_get_file_path( FileLocation* file, std::string relative_path) -{ - if (file->directory == SourceDirectory) - { - // We want the full path here for directory support later on - return Path::RelativeFromDirectory (file->relative_path, relative_path ); - } - else if(file->directory == IntermediateDirectory) - { - return std::string("$(RootIntDir)\\") + file->relative_path; - } - else if(file->directory == OutputDirectory) - { - return std::string("$(RootOutDir)\\") + file->relative_path; - } - - return std::string(""); -} - - - void VCProjMaker::_generate_proj_file ( const Module& module ) { size_t i; - // make sure the containers are empty - header_files.clear(); - includes.clear(); - libraries.clear(); - common_defines.clear(); - printf ( "Creating MSVC project: '%s'\n", vcproj_file.c_str() ); string path_basedir = module.GetPathToBaseDir (); - bool include_idl = false; - - vector source_files, resource_files, generated_files; - - const IfableData& data = module.non_if_data; - const vector& files = data.files; - for ( i = 0; i < files.size(); i++ ) - { - string path = _get_file_path(&files[i]->file, module.output->relative_path); - string file = path + std::string("\\") + files[i]->file.name; - - if (files[i]->file.directory != SourceDirectory) - generated_files.push_back ( file ); - else if ( !stricmp ( Right(file,3).c_str(), ".rc" ) ) - resource_files.push_back ( file ); - else if ( !stricmp ( Right(file,2).c_str(), ".h" ) ) - header_files.push_back ( file ); - else - source_files.push_back ( file ); - } - const vector& incs = data.includes; - for ( i = 0; i < incs.size(); i++ ) - { - string path = _get_file_path(incs[i]->directory, module.output->relative_path); - - if ( module.type != RpcServer && module.type != RpcClient ) - { - if ( path.find ("/include/reactos/idl") != string::npos) - { - include_idl = true; - continue; - } - } - includes.push_back ( path ); - } - const vector& libs = data.libraries; - for ( i = 0; i < libs.size(); i++ ) - { - string libpath = "$(RootOutDir)\\" + libs[i]->importedModule->output->relative_path + "\\" + _get_vc_dir() + "\\$(ConfigurationName)\\" + libs[i]->name + ".lib"; - libraries.push_back ( libpath ); - } - const vector& defs = data.defines; - for ( i = 0; i < defs.size(); i++ ) - { - if ( defs[i]->backend != "" && defs[i]->backend != "msvc" ) - continue; - - if ( defs[i]->value[0] ) - common_defines.insert( defs[i]->name + "=" + defs[i]->value ); - else - common_defines.insert( defs[i]->name ); - } - for ( std::map::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.importLibrary) - { - std::string ImportLibraryPath = _get_file_path(module.importLibrary->source, module.output->relative_path); - - switch (module.IsSpecDefinitionFile()) - { - case PSpec: - generated_files.push_back("$(IntDir)\\" + ReplaceExtension(module.importLibrary->source->name,".spec")); - case Spec: - generated_files.push_back("$(IntDir)\\" + ReplaceExtension(module.importLibrary->source->name,".stubs.c")); - generated_files.push_back("$(IntDir)\\" + ReplaceExtension(module.importLibrary->source->name,".def")); - default: - source_files.push_back(ImportLibraryPath + std::string("\\") + module.importLibrary->source->name); - } - } + _collect_files(module); fprintf ( OUT, "\r\n" ); fprintf ( OUT, "\r\n" ); fprintf ( OUT, "\t\t\r\n" ); fprintf ( OUT, "\t\t\r\n" ); fprintf ( OUT, "\t\r\n" ); - // Set the binary type - string module_type = GetExtension(*module.output); - BinaryType binaryType; - if ((module.type == ObjectLibrary) || (module.type == RpcClient) ||(module.type == RpcServer) || (module_type == ".lib") || (module_type == ".a")) - binaryType = Lib; - else if ((module_type == ".dll") || (module_type == ".cpl")) - binaryType = Dll; - else if ((module_type == ".exe") || (module_type == ".scr")) - binaryType = Exe; - else if (module_type == ".sys") - binaryType = Sys; - else - binaryType = BinUnknown; - // Write out all the configurations fprintf ( OUT, "\t\r\n" ); for ( size_t icfg = 0; icfg < m_configurations.size(); icfg++ ) @@ -389,9 +290,8 @@ VCProjMaker::_generate_proj_file ( const Module& module ) fprintf ( OUT, "\t\t\tFilter=\"h;hpp;hxx;hm;inl\">\r\n" ); for ( i = 0; i < header_files.size(); i++ ) { - const string& header_file = header_files[i]; fprintf ( OUT, "\t\t\t\r\n", header_file.c_str() ); + fprintf ( OUT, "\t\t\t\tRelativePath=\"%s\">\r\n", header_files[i].c_str() ); fprintf ( OUT, "\t\t\t\r\n" ); } fprintf ( OUT, "\t\t\r\n" ); @@ -402,9 +302,8 @@ VCProjMaker::_generate_proj_file ( const Module& module ) fprintf ( OUT, "\t\t\tFilter=\"ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe\">\r\n" ); for ( i = 0; i < resource_files.size(); i++ ) { - const string& resource_file = resource_files[i]; fprintf ( OUT, "\t\t\t\r\n", resource_file.c_str() ); + fprintf ( OUT, "\t\t\t\tRelativePath=\"%s\">\r\n", resource_files[i].c_str() ); fprintf ( OUT, "\t\t\t\r\n" ); } fprintf ( OUT, "\t\t\r\n" ); @@ -481,8 +380,8 @@ void VCProjMaker::_generate_standard_configuration( const Module& module, fprintf ( OUT, "\t\t\tConfigurationType=\"%d\"\r\n", CfgType ); - fprintf ( OUT, "\t\t\tInheritedPropertySheets=\"%s%s.vsprops\"\r\n", path_basedir.c_str (), cfg.name.c_str ()); - fprintf ( OUT, "\t\t\tCharacterSet=\"2\"\r\n" ); + fprintf ( OUT, "\t\t\tInheritedPropertySheets=\"%s\\%s.vsprops\"\r\n", path_basedir.c_str (), cfg.name.c_str ()); + fprintf ( OUT, "\t\t\tCharacterSet=\"%s\"\r\n", module.isUnicode ? "1" : "2" ); fprintf ( OUT, "\t\t\t>\r\n" ); fprintf ( OUT, "\t\t\t& msvc_configs, - std::string filename ) + std::string filename, + const Module& module) { configuration = buildConfig; m_configurations = msvc_configs; @@ -65,157 +66,10 @@ VCXProjMaker::VCXProjMaker ( Configuration& buildConfig, { printf ( "Could not create file '%s'.\n", vcproj_file.c_str() ); } -} - -VCXProjMaker::~VCXProjMaker() -{ - fclose ( OUT ); -} - -void -VCXProjMaker::_generate_proj_file ( const Module& module ) -{ - size_t i; - - string computername; - string username; - - // make sure the containers are empty - header_files.clear(); - includes.clear(); - includes_ros.clear(); - libraries.clear(); - common_defines.clear(); - - if (getenv ( "USERNAME" ) != NULL) - username = getenv ( "USERNAME" ); - if (getenv ( "COMPUTERNAME" ) != NULL) - computername = getenv ( "COMPUTERNAME" ); - else if (getenv ( "HOSTNAME" ) != NULL) - computername = getenv ( "HOSTNAME" ); - - string vcproj_file_user = ""; - - if ((computername != "") && (username != "")) - vcproj_file_user = vcproj_file + "." + computername + "." + username + ".user"; - - printf ( "Creating MSVC project: '%s'\n", vcproj_file.c_str() ); - - string path_basedir = module.GetPathToBaseDir (); - string intenv = Environment::GetIntermediatePath (); - string outenv = Environment::GetOutputPath (); - string outdir; - string intdir; - string vcdir; - - if ( intenv == "obj-i386" ) - intdir = path_basedir + "obj-i386"; /* append relative dir from project dir */ - else - intdir = intenv; - - if ( outenv == "output-i386" ) - outdir = path_basedir + "output-i386"; - else - outdir = outenv; - - if ( configuration.UseVSVersionInPath ) - { - vcdir = DEF_SSEP + _get_vc_dir(); - } - - bool include_idl = false; - - vector source_files, resource_files; - vector 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& files = data.files; - for ( i = 0; i < files.size(); i++ ) - { - if (files[i]->file.directory != SourceDirectory) - continue; - - // We want the full path here for directory support later on - string path = Path::RelativeFromDirectory ( - files[i]->file.relative_path, - module.output->relative_path ); - string file = path + std::string("\\") + files[i]->file.name; - - if ( !stricmp ( Right(file,3).c_str(), ".rc" ) ) - resource_files.push_back ( file ); - else if ( !stricmp ( Right(file,2).c_str(), ".h" ) ) - header_files.push_back ( file ); - else - source_files.push_back ( file ); - } - const vector& incs = data.includes; - for ( i = 0; i < incs.size(); i++ ) - { - string path = Path::RelativeFromDirectory ( - incs[i]->directory->relative_path, - module.output->relative_path ); - if ( module.type != RpcServer && module.type != RpcClient ) - { - if ( path.find ("/include/reactos/idl") != string::npos) - { - include_idl = true; - continue; - } - } - // switch between general headers and ros headers - if ( !strncmp(incs[i]->directory->relative_path.c_str(), "include\\crt", 11 ) || - !strncmp(incs[i]->directory->relative_path.c_str(), "include\\ddk", 11 ) || - !strncmp(incs[i]->directory->relative_path.c_str(), "include\\GL", 10 ) || - !strncmp(incs[i]->directory->relative_path.c_str(), "include\\psdk", 12 ) || - !strncmp(incs[i]->directory->relative_path.c_str(), "include\\reactos\\wine", 20 ) ) - { - if (strncmp(incs[i]->directory->relative_path.c_str(), "include\\crt", 11 )) - // not crt include - includes_ros.push_back ( path ); - } - else - { - includes.push_back ( path ); - } - } - const vector& libs = data.libraries; - for ( i = 0; i < libs.size(); i++ ) - { - string libpath = outdir + "\\" + libs[i]->importedModule->output->relative_path + "\\" + _get_vc_dir() + "\\---\\" + libs[i]->name + ".lib"; - libraries.push_back ( libpath ); - } - const vector& defs = data.defines; - for ( i = 0; i < defs.size(); i++ ) - { - if ( defs[i]->backend != "" && defs[i]->backend != "msvc" ) - continue; - - if ( defs[i]->value[0] ) - common_defines.insert( defs[i]->name + "=" + defs[i]->value ); - else - common_defines.insert( defs[i]->name ); - } - for ( std::map::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; - } - } - /* include intermediate path for reactos.rc */ - string version = intdir + "\\include"; - includes.push_back (version); - version += "\\reactos"; - includes.push_back (version); // Set the binary type string module_type = GetExtension(*module.output); - BinaryType binaryType; + if ((module.type == ObjectLibrary) || (module.type == RpcClient) ||(module.type == RpcServer) || (module_type == ".lib") || (module_type == ".a")) binaryType = Lib; else if ((module_type == ".dll") || (module_type == ".cpl")) @@ -226,13 +80,76 @@ VCXProjMaker::_generate_proj_file ( const Module& module ) binaryType = Sys; else binaryType = BinUnknown; +} - string include_string; +VCXProjMaker::~VCXProjMaker() +{ + fclose ( OUT ); +} + +void +VCXProjMaker::_generate_item_group (std::vector files) +{ + size_t i; + + for( i = 0; i\r\n", files[i].c_str()); + else if( extension == ".s") + fprintf ( OUT, "\t\t\r\n", files[i].c_str()); + else if( extension == ".spec") + fprintf ( OUT, "\t\t\r\n", files[i].c_str()); + else if( extension == ".pspec") + fprintf ( OUT, "\t\t\r\n", files[i].c_str()); + else if( extension == ".rc") + fprintf ( OUT, "\t\t\r\n", files[i].c_str()); + else if( extension == ".h") + fprintf ( OUT, "\t\t\r\n", files[i].c_str()); + else + fprintf ( OUT, "\t\t\r\n", files[i].c_str()); + } +} + +string +VCXProjMaker::_get_configuration_type () +{ + switch (binaryType) + { + case Exe: + return "Application"; + case Dll: + case Sys: + return "DynamicLibrary"; + case Lib: + return "StaticLibrary"; + default: + return ""; + } +} + +void +VCXProjMaker::_generate_proj_file ( const Module& module ) +{ + string path_basedir = module.GetPathToBaseDir (); + size_t i; + string vcdir; + + if ( configuration.UseVSVersionInPath ) + { + vcdir = DEF_SSEP + _get_vc_dir(); + } + + printf ( "Creating MSVC project: '%s'\n", vcproj_file.c_str() ); + + _collect_files(module); fprintf ( OUT, "\r\n" ); fprintf ( OUT, "\r\n" ); if (configuration.VSProjectVersion.empty()) @@ -245,15 +162,11 @@ VCXProjMaker::_generate_proj_file ( const Module& module ) const MSVCConfiguration& cfg = *m_configurations[icfg]; if ( cfg.optimization == RosBuild ) - { _generate_makefile_configuration( module, cfg ); - } else - { _generate_standard_configuration( module, cfg, binaryType ); - } } - fprintf ( OUT, "\t\r\n" ); + fprintf ( OUT, "\t\r\n\r\n" ); // Write out the global info fprintf ( OUT, "\t\r\n" ); @@ -261,9 +174,88 @@ VCXProjMaker::_generate_proj_file ( const Module& module ) fprintf ( OUT, "\t\t%s\r\n", "Win32Proj" ); //FIXME: Win32Proj??? fprintf ( OUT, "\t\t%s\r\n", module.name.c_str() ); //FIXME: shouldn't this be the soltion name? fprintf ( OUT, "\t\r\n" ); - fprintf ( OUT, "" ); + fprintf ( OUT, "\r\n" ); + fprintf ( OUT, "\t\r\n"); + if( binaryType != BinUnknown) + fprintf ( OUT, "\t\t%s\r\n" , _get_configuration_type().c_str()); + fprintf ( OUT, "\t\t%s\r\n", module.isUnicode ? "Unicode" : "MultiByte"); + fprintf ( OUT, "\t\r\n"); + fprintf ( OUT, "\t\r\n" ); + fprintf ( OUT, "\t\r\n" ); + fprintf ( OUT, "\t\r\n"); + fprintf ( OUT, "\t\t\r\n", path_basedir.c_str()); + fprintf ( OUT, "\t\t\r\n", path_basedir.c_str()); + fprintf ( OUT, "\t\r\n"); + + fprintf ( OUT, "\t\r\n"); + fprintf ( OUT, "\t\t$(RootOutDir)\\%s%s\\$(Configuration)\\\r\n", module.output->relative_path.c_str (), vcdir.c_str ()); + fprintf ( OUT, "\t\t$(RootIntDir)\\%s%s\\$(Configuration)\\\r\n", module.output->relative_path.c_str (), vcdir.c_str ()); + + if( includes.size() != 0) + { + fprintf( OUT, "\t\t"); + for ( i = 0; i < includes.size(); i++ ) + fprintf ( OUT, "%s;", includes[i].c_str() ); + fprintf( OUT, "\r\n"); + } + + if(defines.size() != 0) + { + fprintf( OUT, "\t\t"); + for ( i = 0; i < defines.size(); i++ ) + fprintf ( OUT, "%s;", defines[i].c_str() ); + fprintf( OUT, "\r\n"); + } + + fprintf ( OUT, "\t\r\n\r\n"); + + fprintf ( OUT, "\t\r\n"); + fprintf ( OUT, "\t\t\r\n"); + if ( module.cplusplus ) + fprintf ( OUT, "\t\t\tCompileAsCpp\r\n"); + fprintf ( OUT, "\t\t\r\n"); + + fprintf ( OUT, "\t\t\r\n"); + if(libraries.size() != 0) + { + fprintf ( OUT, "\t\t\t"); + for ( i = 0; i < libraries.size(); i++ ) + { + string libpath = libraries[i].c_str(); + libpath = libpath.erase (0, libpath.find_last_of ("\\") + 1 ); + fprintf ( OUT, "%s;", libpath.c_str() ); + } + fprintf ( OUT, "%%(AdditionalDependencies)\r\n"); + + fprintf ( OUT, "\t\t\t"); + for ( i = 0; i < libraries.size(); i++ ) + { + string libpath = libraries[i].c_str(); + libpath = libpath.substr (0, libpath.find_last_of ("\\") ); + fprintf ( OUT, "%s;", libpath.c_str() ); + } + fprintf ( OUT, "%%(AdditionalLibraryDirectories)\r\n"); + } + + if( module.CRT != "msvcrt") + fprintf ( OUT, "\t\t\ttrue\r\n"); + + fprintf ( OUT, "\t\t\r\n"); + fprintf ( OUT, "\t\r\n"); + + fprintf ( OUT, "\t\r\n"); + _generate_item_group(header_files); + _generate_item_group(source_files); + _generate_item_group(resource_files); + _generate_item_group(generated_files); + fprintf ( OUT, "\t\r\n\r\n"); + + fprintf ( OUT, "\t\r\n"); + fprintf ( OUT, "\t\r\n", path_basedir.c_str()); + + fprintf ( OUT, "\r\n"); } void diff --git a/reactos/tools/rbuild/backend/msvc/vspropsmaker.cpp b/reactos/tools/rbuild/backend/msvc/vspropsmaker.cpp index 02ba4e376de..2e7bdf7d7f1 100644 --- a/reactos/tools/rbuild/backend/msvc/vspropsmaker.cpp +++ b/reactos/tools/rbuild/backend/msvc/vspropsmaker.cpp @@ -23,7 +23,7 @@ typedef set StringSet; #undef OUT #endif//OUT -PropsMaker::PropsMaker ( Configuration& buildConfig, +VSPropsMaker::VSPropsMaker ( Configuration& buildConfig, Project* ProjectNode, std::string filename_props, MSVCConfiguration* msvc_configs) @@ -46,13 +46,13 @@ PropsMaker::PropsMaker ( Configuration& buildConfig, } } -PropsMaker::~PropsMaker ( ) +VSPropsMaker::~VSPropsMaker ( ) { fclose ( OUT ); } void -PropsMaker::_generate_header() +VSPropsMaker::_generate_header() { fprintf ( OUT, "\r\n" ); fprintf ( OUT, "backend != "" && defs[i]->backend != "msvc" ) continue; - if ( defs[i]->value[0] ) + if ( defs[i]->value != "" ) fprintf ( OUT, "%s=%s",defs[i]->name.c_str(), defs[i]->value.c_str()); else fprintf ( OUT, defs[i]->name.c_str()); @@ -233,14 +233,14 @@ PropsMaker::_generate_global_definitions() } void -PropsMaker::_generate_footer() +VSPropsMaker::_generate_footer() { fprintf ( OUT, "\r\n"); } void -PropsMaker::_generate_props ( std::string solution_version, +VSPropsMaker::_generate_props ( std::string solution_version, std::string studio_version ) { _generate_header(); diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp index 38a104a12f9..d1c31385acc 100644 --- a/reactos/tools/rbuild/module.cpp +++ b/reactos/tools/rbuild/module.cpp @@ -138,7 +138,7 @@ GetSubPath ( return FixSeparator(path + cSep + att_value); } -static string +string GetExtension ( const string& filename ) { size_t index = filename.find_last_of ( '/' ); diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h index fe2aca15d96..04d2d69e7f7 100644 --- a/reactos/tools/rbuild/rbuild.h +++ b/reactos/tools/rbuild/rbuild.h @@ -1087,6 +1087,9 @@ GetSubPath ( const std::string& path, const std::string& att_value ); +extern std::string +GetExtension ( const std::string& filename ); + extern std::string GetExtension ( const FileLocation& file ); diff --git a/reactos/tools/rbuild/rbuild.mak b/reactos/tools/rbuild/rbuild.mak index bf328f71fd1..5b0c5b55efe 100644 --- a/reactos/tools/rbuild/rbuild.mak +++ b/reactos/tools/rbuild/rbuild.mak @@ -184,6 +184,7 @@ RBUILD_BACKEND_MSVC_BASE_SOURCES = $(addprefix $(RBUILD_MSVC_BASE_), \ genguid.cpp \ msvc.cpp \ projmaker.cpp \ + propsmaker.cpp \ slnmaker.cpp \ vcprojmaker.cpp \ vcxprojmaker.cpp \ @@ -471,6 +472,10 @@ $(RBUILD_MSVC_INT_)vspropsmaker.o: $(RBUILD_MSVC_BASE_)vspropsmaker.cpp $(RBUILD $(ECHO_HOSTCC) ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ +$(RBUILD_MSVC_INT_)propsmaker.o: $(RBUILD_MSVC_BASE_)propsmaker.cpp $(RBUILD_HEADERS) | $(RBUILD_MSVC_INT) + $(ECHO_HOSTCC) + ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@ + $(RBUILD_MSVC_INT_)slnmaker.o: $(RBUILD_MSVC_BASE_)slnmaker.cpp $(RBUILD_HEADERS) | $(RBUILD_MSVC_INT) $(ECHO_HOSTCC) ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@