[ros-diffs] [hpoussin] 32281: Use Rule class to generate instructions for .idl files

hpoussin at svn.reactos.org hpoussin at svn.reactos.org
Mon Feb 11 11:55:35 CET 2008


Author: hpoussin
Date: Mon Feb 11 13:55:33 2008
New Revision: 32281

URL: http://svn.reactos.org/svn/reactos?rev=32281&view=rev
Log:
Use Rule class to generate instructions for .idl files

Modified:
    trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
    trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h

Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp?rev=32281&r1=32280&r2=32281&view=diff
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp Mon Feb 11 13:55:33 2008
@@ -1282,6 +1282,33 @@
                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).spec.def",
                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)$(source_name_noext).stubs.c",
                      "$(INTERMEDIATE)$(SEP)$(source_dir)$(SEP)", NULL );
+Rule widlHeaderRule ( "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext).h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)\\$(source_dir)\n"
+                      "\t$(ECHO_WIDL)\n"
+                      "\t$(Q)$(WIDL_TARGET)  $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext).h $(source)\n",
+                      "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext).h",
+                      "$(INTERMEDIATE)\\$(source_dir)\\", NULL );
+Rule widlServerRule ( "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_s.c $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_s.h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)\\$(source_dir)\n"
+                      "\t$(ECHO_WIDL)\n"
+                      "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_s.h -s -S $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_s.c $(source)\n",
+                      "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_s.h",
+                      "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_s.c",
+                      "$(INTERMEDIATE)\\$(source_dir)\\", NULL );
+Rule widlClientRule ( "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_c.c $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_c.h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)\\$(source_dir)\n"
+                      "\t$(ECHO_WIDL)\n"
+                      "\t$(Q)$(WIDL_TARGET) $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_c.h -c -C $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_c.c $(source)\n",
+                      "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_c.h",
+                      "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_c.c",
+                      "$(INTERMEDIATE)\\$(source_dir)\\", NULL );
+Rule widlProxyRule ( "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_p.c $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_p.h: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)\\$(source_dir)\n"
+                     "\t$(ECHO_WIDL)\n"
+                     "\t$(Q)$(WIDL_TARGET)  $($(module_name)_WIDLFLAGS) -h -H $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_p.h -p -P $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_p.c $(source)\n",
+                     "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_p.h",
+                     "$(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext)_p.c",
+                     "$(INTERMEDIATE)\\$(source_dir)\\", NULL );
+Rule widlTlbRule ( "$(OUTPUT)\\$(source_dir)\\$(module_name).tlb: $(source) $(module_rbuild) $(WIDL_TARGET) | $(INTERMEDIATE)\\$(source_dir)\n"
+                   "\t$(ECHO_WIDL)\n"
+                   "\t$(Q)$(WIDL_TARGET)  $($(module_name)_WIDLFLAGS) -t -T $(INTERMEDIATE)\\$(source_dir)\\$(source_name_noext).tlb $(source)\n",
+                   "$(INTERMEDIATE)\\$(source_dir)\\", NULL );
 
 void
 MingwModuleHandler::GenerateGccCommand (
@@ -1324,12 +1351,6 @@
 		delete pchFilename;
 }
 
-const std::string&
-MingwModuleHandler::GetWidlFlags ( const CompilationUnit& compilationUnit )
-{
-	return compilationUnit.GetSwitches ();
-}
-
 string
 MingwModuleHandler::GetPropertyValue ( const Module& module, const std::string& name )
 {
@@ -1350,44 +1371,6 @@
 	return new FileLocation ( IntermediateDirectory, base->relative_path, newname );
 }
 
-void
-MingwModuleHandler::GenerateWidlCommandsServer (
-	const CompilationUnit& compilationUnit,
-	const string& widlflagsMacro )
-{
-	const FileLocation& sourceFile = compilationUnit.GetFilename ();
-	string dependencies = backend->GetFullName ( sourceFile );
-	dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
-
-	string basename = GetBasename ( sourceFile.name );
-
-	const FileLocation *generatedHeaderFilename = GetRpcServerHeaderFilename ( &sourceFile );
-	CLEAN_FILE ( *generatedHeaderFilename );
-
-	FileLocation generatedServerFilename ( IntermediateDirectory,
-	                                       sourceFile.relative_path,
-	                                       basename + "_s.c" );
-	CLEAN_FILE ( generatedServerFilename );
-
-	fprintf ( fMakefile,
-	          "%s %s: %s $(WIDL_TARGET) | %s\n",
-	          backend->GetFullName ( generatedServerFilename ).c_str (),
-	          backend->GetFullName ( *generatedHeaderFilename ).c_str (),
-	          dependencies.c_str (),
-	          backend->GetFullPath ( generatedServerFilename ).c_str () );
-	fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
-	fprintf ( fMakefile,
-	          "\t%s %s %s -h -H %s -s -S %s %s\n",
-	          "$(Q)$(WIDL_TARGET)",
-	          GetWidlFlags ( compilationUnit ).c_str (),
-	          widlflagsMacro.c_str (),
-	          backend->GetFullName ( *generatedHeaderFilename ).c_str (),
-	          backend->GetFullName ( generatedServerFilename ).c_str (),
-	          backend->GetFullName ( sourceFile ).c_str () );
-
-	delete generatedHeaderFilename;
-}
-
 /* caller needs to delete the returned object */
 const FileLocation*
 MingwModuleHandler::GetRpcClientHeaderFilename ( const FileLocation *base ) const
@@ -1418,165 +1401,6 @@
 {
 	string newname = GetBasename ( base->name ) + ".h";
 	return new FileLocation ( IntermediateDirectory, "include/reactos" , newname );
-}
-
-void
-MingwModuleHandler::GenerateWidlCommandsEmbeddedTypeLib (
-	const CompilationUnit& compilationUnit,
-	const string& widlflagsMacro )
-{
-	const FileLocation& sourceFile = compilationUnit.GetFilename ();
-	string dependencies = backend->GetFullName ( sourceFile );
-	dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
-
-	string basename = GetBasename ( sourceFile.name );
-
-	FileLocation EmbeddedTypeLibFilename ( IntermediateDirectory,
-	                                       sourceFile.relative_path,
-	                                       basename + ".tlb" );
-
-	fprintf ( fMakefile,
-	          "%s: %s $(WIDL_TARGET) | %s\n",
-	          GetTargetMacro ( module ).c_str (),
-	          dependencies.c_str (),
-	          backend->GetFullPath ( EmbeddedTypeLibFilename ).c_str () );
-	fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
-	fprintf ( fMakefile,
-	          "\t%s %s %s -t -T %s %s\n",
-	          "$(Q)$(WIDL_TARGET)",
-	          GetWidlFlags ( compilationUnit ).c_str (),
-	          widlflagsMacro.c_str (),
-	          backend->GetFullName ( EmbeddedTypeLibFilename ).c_str(),
-	          backend->GetFullName ( sourceFile ).c_str () );
-}
-
-void
-MingwModuleHandler::GenerateWidlCommandsClient (
-	const CompilationUnit& compilationUnit,
-	const string& widlflagsMacro )
-{
-	const FileLocation& sourceFile = compilationUnit.GetFilename ();
-	string dependencies = backend->GetFullName ( sourceFile );
-	dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
-
-	string basename = GetBasename ( sourceFile.name );
-
-	const FileLocation *generatedHeaderFilename = GetRpcClientHeaderFilename ( &sourceFile );
-	CLEAN_FILE ( *generatedHeaderFilename );
-
-	FileLocation generatedClientFilename ( IntermediateDirectory,
-	                                       sourceFile.relative_path,
-	                                       basename + "_c.c" );
-	CLEAN_FILE ( generatedClientFilename );
-
-	fprintf ( fMakefile,
-	          "%s %s: %s $(WIDL_TARGET) | %s\n",
-	          backend->GetFullName ( generatedClientFilename ).c_str (),
-	          backend->GetFullName ( *generatedHeaderFilename ).c_str (),
-	          dependencies.c_str (),
-	          backend->GetFullPath ( generatedClientFilename ).c_str () );
-	fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
-	fprintf ( fMakefile,
-	          "\t%s %s %s -h -H %s -c -C %s %s\n",
-	          "$(Q)$(WIDL_TARGET)",
-	          GetWidlFlags ( compilationUnit ).c_str (),
-	          widlflagsMacro.c_str (),
-	          backend->GetFullName ( *generatedHeaderFilename ).c_str (),
-	          backend->GetFullName ( generatedClientFilename ).c_str (),
-	          backend->GetFullName ( sourceFile ).c_str () );
-
-	delete generatedHeaderFilename;
-}
-
-void
-MingwModuleHandler::GenerateWidlCommandsProxy (
-	const CompilationUnit& compilationUnit,
-	const string& widlflagsMacro )
-{
-	const FileLocation& sourceFile = compilationUnit.GetFilename ();
-	string dependencies = backend->GetFullName ( sourceFile );
-	dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
-
-	string basename = GetBasename ( sourceFile.name );
-
-	const FileLocation *generatedHeaderFilename = GetRpcProxyHeaderFilename ( &sourceFile );
-	CLEAN_FILE ( *generatedHeaderFilename );
-
-	FileLocation generatedProxyFilename ( IntermediateDirectory,
-	                                      sourceFile.relative_path,
-	                                      basename + "_p.c" );
-	CLEAN_FILE ( generatedProxyFilename );
-
-	fprintf ( fMakefile,
-	          "%s %s: %s $(WIDL_TARGET) | %s\n",
-	          backend->GetFullName ( generatedProxyFilename ).c_str (),
-	          backend->GetFullName ( *generatedHeaderFilename ).c_str (),
-	          dependencies.c_str (),
-	          backend->GetFullPath ( generatedProxyFilename ).c_str () );
-	fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
-	fprintf ( fMakefile,
-	          "\t%s %s %s -h -H %s -p -P %s %s\n",
-	          "$(Q)$(WIDL_TARGET)",
-	          GetWidlFlags ( compilationUnit ).c_str (),
-	          widlflagsMacro.c_str (),
-	          backend->GetFullName ( *generatedHeaderFilename ).c_str (),
-	          backend->GetFullName ( generatedProxyFilename ).c_str (),
-	          backend->GetFullName ( sourceFile ).c_str () );
-
-	delete generatedHeaderFilename;
-}
-
-void
-MingwModuleHandler::GenerateWidlCommandsIdlHeader (
-	const CompilationUnit& compilationUnit,
-	const string& widlflagsMacro )
-{
-	const FileLocation& sourceFile = compilationUnit.GetFilename ();
-	string dependencies = backend->GetFullName ( sourceFile );
-	dependencies += " " + NormalizeFilename ( module.xmlbuildFile );
-
-	string basename = GetBasename ( sourceFile.name );
-
-	const FileLocation *generatedHeader = GetIdlHeaderFilename ( &sourceFile );
-	CLEAN_FILE ( *generatedHeader );
-
-	fprintf ( fMakefile,
-	          "%s: %s $(WIDL_TARGET) | %s\n",
-	          backend->GetFullName( *generatedHeader ).c_str (),
-	          dependencies.c_str (),
-	          backend->GetFullPath ( *generatedHeader ).c_str () );
-	fprintf ( fMakefile, "\t$(ECHO_WIDL)\n" );
-	fprintf ( fMakefile,
-	          "\t%s %s %s -h -H %s %s\n",
-	          "$(Q)$(WIDL_TARGET)",
-	          GetWidlFlags ( compilationUnit ).c_str (),
-	          widlflagsMacro.c_str (),
-	          backend->GetFullName ( *generatedHeader ).c_str (),
-	          backend->GetFullName ( sourceFile ).c_str () );
-
-	delete generatedHeader;
-}
-
-void
-MingwModuleHandler::GenerateWidlCommands (
-	const CompilationUnit& compilationUnit,
-	const string& widlflagsMacro )
-{
-	if ( module.type == RpcServer )
-		GenerateWidlCommandsServer ( compilationUnit,
-		                             widlflagsMacro );
-	else if ( module.type == RpcClient )
-		GenerateWidlCommandsClient ( compilationUnit,
-		                             widlflagsMacro );
-	else if ( module.type == RpcProxy )
-		GenerateWidlCommandsProxy ( compilationUnit,
-		                            widlflagsMacro );
-	else if ( module.type == EmbeddedTypeLib )
-		GenerateWidlCommandsEmbeddedTypeLib ( compilationUnit,
-		                                      widlflagsMacro );
-	else // applies also for other module.types which include idl files
-		GenerateWidlCommandsIdlHeader ( compilationUnit,
-		                                widlflagsMacro );
 }
 
 void
@@ -1607,6 +1431,11 @@
 		{ HostDontCare, TypeDontCare, ".rc", &windresRule },
 		{ HostDontCare, TypeDontCare, ".mc", &wmcRule },
 		{ HostDontCare, TypeDontCare, ".spec", &winebuildRule },
+		{ HostDontCare, RpcServer, ".idl", &widlServerRule },
+		{ HostDontCare, RpcClient, ".idl", &widlClientRule },
+		{ HostDontCare, RpcProxy, ".idl", &widlProxyRule },
+		{ HostDontCare, EmbeddedTypeLib, ".idl", &widlTlbRule },
+		{ HostDontCare, TypeDontCare, ".idl", &widlHeaderRule },
 	};
 	size_t i;
 	Rule *customRule = NULL;
@@ -1653,17 +1482,13 @@
 		                     cc,
 		                     cflagsMacro );
 	}
-	else if ( extension == ".idl" )
-	{
-		GenerateWidlCommands ( compilationUnit,
-		                       widlflagsMacro );
-		if ( (module.type == RpcServer) || (module.type == RpcClient) || (module.type == RpcProxy) )
-		{
-			GenerateGccCommand ( &sourceFile,
+	else if ( extension == ".idl" &&
+		(module.type == RpcServer) || (module.type == RpcClient) || (module.type == RpcProxy) )
+	{
+		GenerateGccCommand ( &sourceFile,
 			                     GetExtraDependencies ( &sourceFile ),
 			                     cc,
 			                     cflagsMacro );
-		}
 	}
 	else if ( !customRule )
 	{

Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h?rev=32281&r1=32280&r2=32281&view=diff
==============================================================================
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h (original)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.h Mon Feb 11 13:55:33 2008
@@ -155,24 +155,6 @@
 	                          const std::string& extraDependencies,
 	                          const std::string& cc,
 	                          const std::string& cflagsMacro );
-	const std::string& GetWidlFlags ( const CompilationUnit& compilationUnit );
-	void GenerateWidlCommandsServer (
-		const CompilationUnit& compilationUnit,
-		const std::string& widlflagsMacro );
-	void GenerateWidlCommandsClient (
-		const CompilationUnit& compilationUnit,
-		const std::string& widlflagsMacro );
-	void GenerateWidlCommandsProxy (
-		const CompilationUnit& compilationUnit,
-		const std::string& widlflagsMacro );
-	void GenerateWidlCommandsIdlHeader (
-		const CompilationUnit& compilationUnit,
-		const std::string& widlflagsMacro );
-	void GenerateWidlCommandsEmbeddedTypeLib (
-		const CompilationUnit& compilationUnit,
-		const std::string& widlflagsMacro );
-	void GenerateWidlCommands ( const CompilationUnit& compilationUnit,
-	                            const std::string& widlflagsMacro );
 	void GenerateCommands ( const CompilationUnit& compilationUnit,
 	                        const std::string& extraDependencies,
 	                        const std::string& cc,




More information about the Ros-diffs mailing list