2 * Copyright (C) 2005 Casper S. Hornstrup
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 #include "../../pch.h"
25 #include "modulehandler.h"
28 #define MKDIR(s) mkdir(s)
30 #define MKDIR(s) mkdir(s, 0755)
38 typedef set
<string
> set_string
;
42 v2s ( const string_list
& v
, int wrap_at
)
48 for ( size_t i
= 0; i
< v
.size(); i
++ )
52 if ( wrap_at
> 0 && wrap_count
++ == wrap_at
)
62 Directory::Directory ( const string
& name_
)
68 Directory::Add ( const char* subdir
)
71 string s1
= string ( subdir
);
72 if ( ( i
= s1
.find ( '$' ) ) != string::npos
)
74 throw InvalidOperationException ( __FILE__
,
76 "No environment variables can be used here. Path was %s",
80 const char* p
= strpbrk ( subdir
, "/\\" );
82 p
= subdir
+ strlen(subdir
);
83 string
s ( subdir
, p
-subdir
);
84 if ( subdirs
.find(s
) == subdirs
.end() )
85 subdirs
[s
] = new Directory(s
);
87 subdirs
[s
]->Add ( p
);
91 Directory::mkdir_p ( const char* path
)
95 directory
= opendir ( path
);
96 if ( directory
!= NULL
)
98 closedir ( directory
);
103 if ( MKDIR ( path
) != 0 )
106 if ( errno
== EEXIST
)
109 throw AccessDeniedException ( string ( path
) );
115 Directory::CreateDirectory ( string path
)
119 if ( isalpha ( path
[0] ) && path
[1] == ':' && path
[2] == CSEP
)
121 nextIndex
= path
.find ( CSEP
, 3);
124 nextIndex
= path
.find ( CSEP
);
126 bool directoryWasCreated
= false;
127 while ( nextIndex
!= string::npos
)
129 nextIndex
= path
.find ( CSEP
, index
+ 1 );
130 directoryWasCreated
= mkdir_p ( path
.substr ( 0, nextIndex
).c_str () );
133 return directoryWasCreated
;
137 Directory::ReplaceVariable ( string name
,
141 size_t i
= path
.find ( name
);
142 if ( i
!= string::npos
)
143 return path
.replace ( i
, name
.length (), value
);
149 Directory::ResolveVariablesInPath ( char* buf
,
152 string s
= ReplaceVariable ( "$(INTERMEDIATE)", Environment::GetIntermediatePath (), path
);
153 s
= ReplaceVariable ( "$(OUTPUT)", Environment::GetOutputPath (), s
);
154 s
= ReplaceVariable ( "$(INSTALL)", Environment::GetInstallPath (), s
);
155 strcpy ( buf
, s
.c_str () );
159 Directory::GenerateTree ( const string
& parent
,
164 if ( parent
.size () > 0 )
168 path
= parent
+ SSEP
+ name
;
169 ResolveVariablesInPath ( buf
, path
);
170 if ( CreateDirectory ( buf
) && verbose
)
171 printf ( "Created %s\n", buf
);
176 for ( directory_map::iterator i
= subdirs
.begin ();
180 i
->second
->GenerateTree ( path
, verbose
);
185 Directory::EscapeSpaces ( string path
)
192 newpath
= newpath
+ "\\ ";
194 newpath
= newpath
+ *p
;
201 Directory::CreateRule ( FILE* f
,
202 const string
& parent
)
206 if ( parent
.size() > 0 )
208 string escapedParent
= EscapeSpaces ( parent
);
211 escapedParent
.c_str (),
213 EscapeSpaces ( name
).c_str (),
214 escapedParent
.c_str () );
217 "\t$(ECHO_MKDIR)\n" );
222 path
= parent
+ SSEP
+ name
;
227 for ( directory_map::iterator i
= subdirs
.begin();
231 i
->second
->CreateRule ( f
, path
);
236 static class MingwFactory
: public Backend::Factory
239 MingwFactory() : Factory ( "mingw" ) {}
240 Backend
* operator() ( Project
& project
,
241 Configuration
& configuration
)
243 return new MingwBackend ( project
,
249 MingwBackend::MingwBackend ( Project
& project
,
250 Configuration
& configuration
)
251 : Backend ( project
, configuration
),
252 intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ),
253 outputDirectory ( new Directory ( "$(OUTPUT)" ) ),
254 installDirectory ( new Directory ( "$(INSTALL)" ) )
259 MingwBackend::~MingwBackend()
261 delete intermediateDirectory
;
262 delete outputDirectory
;
263 delete installDirectory
;
267 MingwBackend::AddDirectoryTarget ( const string
& directory
,
268 Directory
* directoryTree
)
270 if ( directory
.length () > 0)
271 directoryTree
->Add ( directory
.c_str() );
272 return directoryTree
->name
;
276 MingwBackend::ProcessModules ()
278 printf ( "Processing modules..." );
280 vector
<MingwModuleHandler
*> v
;
282 for ( i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
284 Module
& module
= *ProjectNode
.modules
[i
];
285 if ( !module
.enabled
)
287 MingwModuleHandler
* h
= MingwModuleHandler::InstanciateHandler (
290 if ( module
.host
== HostDefault
)
292 module
.host
= h
->DefaultHost();
293 assert ( module
.host
!= HostDefault
);
298 size_t iend
= v
.size ();
300 for ( i
= 0; i
< iend
; i
++ )
301 v
[i
]->GenerateObjectMacro();
302 fprintf ( fMakefile
, "\n" );
303 for ( i
= 0; i
< iend
; i
++ )
304 v
[i
]->GenerateTargetMacro();
305 fprintf ( fMakefile
, "\n" );
307 GenerateAllTarget ( v
);
308 GenerateInitTarget ();
309 GenerateRegTestsRunTarget ();
311 for ( i
= 0; i
< iend
; i
++ )
312 v
[i
]->GenerateOtherMacros();
314 for ( i
= 0; i
< iend
; i
++ )
316 MingwModuleHandler
& h
= *v
[i
];
317 h
.GeneratePreconditionDependencies ();
319 h
.GenerateInvocations ();
320 h
.GenerateCleanTarget ();
321 h
.GenerateInstallTarget ();
322 h
.GenerateDependsTarget ();
330 MingwBackend::Process ()
332 if ( configuration
.CheckDependenciesForModuleOnly
)
333 CheckAutomaticDependenciesForModuleOnly ();
339 MingwBackend::CheckAutomaticDependenciesForModuleOnly ()
341 if ( configuration
.AutomaticDependencies
)
343 Module
* module
= ProjectNode
.LocateModule ( configuration
.CheckDependenciesForModuleOnlyModule
);
344 if ( module
== NULL
)
346 printf ( "Module '%s' does not exist\n",
347 configuration
.CheckDependenciesForModuleOnlyModule
.c_str () );
351 printf ( "Checking automatic dependencies for module '%s'...",
352 module
->name
.c_str () );
353 AutomaticDependency
automaticDependency ( ProjectNode
);
354 automaticDependency
.CheckAutomaticDependenciesForModule ( *module
,
355 configuration
.Verbose
);
361 MingwBackend::ProcessNormal ()
364 DetectNetwideAssembler ();
365 DetectPipeSupport ();
369 GenerateGlobalVariables ();
370 GenerateXmlBuildFilesMacro ();
372 GenerateInstallTarget ();
373 GenerateTestTarget ();
374 GenerateDirectoryTargets ();
375 GenerateDirectories ();
376 UnpackWineResources ();
377 GenerateTestSupportCode ();
378 GenerateProxyMakefiles ();
379 CheckAutomaticDependencies ();
384 MingwBackend::CreateMakefile ()
386 fMakefile
= fopen ( ProjectNode
.makefile
.c_str (), "w" );
388 throw AccessDeniedException ( ProjectNode
.makefile
);
389 MingwModuleHandler::SetBackend ( this );
390 MingwModuleHandler::SetMakefile ( fMakefile
);
391 MingwModuleHandler::SetUsePch ( use_pch
);
395 MingwBackend::CloseMakefile () const
398 fclose ( fMakefile
);
402 MingwBackend::GenerateHeader () const
404 fprintf ( fMakefile
, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
408 MingwBackend::GenerateIncludesAndDefines ( IfableData
& data
) const
410 string includeParameters
= MingwModuleHandler::GenerateGccIncludeParametersFromVector ( data
.includes
);
411 string defineParameters
= MingwModuleHandler::GenerateGccDefineParametersFromVector ( data
.defines
);
412 return includeParameters
+ " " + defineParameters
;
416 MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation
,
417 IfableData
& data
) const
422 assignmentOperation
);
426 GenerateIncludesAndDefines ( data
).c_str() );
428 fprintf ( fMakefile
, "\n" );
432 MingwBackend::GenerateGlobalCFlagsAndProperties (
433 const char* assignmentOperation
,
434 IfableData
& data
) const
438 for ( i
= 0; i
< data
.properties
.size(); i
++ )
440 Property
& prop
= *data
.properties
[i
];
441 fprintf ( fMakefile
, "%s := %s\n",
443 prop
.value
.c_str() );
446 if ( data
.includes
.size() || data
.defines
.size() )
448 GenerateProjectCFlagsMacro ( assignmentOperation
,
452 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
454 If
& rIf
= *data
.ifs
[i
];
455 if ( rIf
.data
.defines
.size()
456 || rIf
.data
.includes
.size()
457 || rIf
.data
.ifs
.size() )
461 "ifeq (\"$(%s)\",\"%s\")\n",
462 rIf
.property
.c_str(),
464 GenerateGlobalCFlagsAndProperties (
475 MingwBackend::GenerateProjectGccOptionsMacro ( const char* assignmentOperation
,
476 IfableData
& data
) const
482 "PROJECT_GCCOPTIONS %s",
483 assignmentOperation
);
485 for ( i
= 0; i
< data
.compilerFlags
.size(); i
++ )
490 data
.compilerFlags
[i
]->flag
.c_str() );
493 fprintf ( fMakefile
, "\n" );
497 MingwBackend::GenerateProjectGccOptions (
498 const char* assignmentOperation
,
499 IfableData
& data
) const
503 if ( data
.compilerFlags
.size() )
505 GenerateProjectGccOptionsMacro ( assignmentOperation
,
509 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
511 If
& rIf
= *data
.ifs
[i
];
512 if ( rIf
.data
.compilerFlags
.size()
513 || rIf
.data
.ifs
.size() )
517 "ifeq (\"$(%s)\",\"%s\")\n",
518 rIf
.property
.c_str(),
520 GenerateProjectGccOptions (
531 MingwBackend::GenerateProjectLFLAGS () const
534 for ( size_t i
= 0; i
< ProjectNode
.linkerFlags
.size (); i
++ )
536 LinkerFlag
& linkerFlag
= *ProjectNode
.linkerFlags
[i
];
537 if ( lflags
.length () > 0 )
539 lflags
+= linkerFlag
.flag
;
545 MingwBackend::GenerateGlobalVariables () const
549 compilerPrefix
.c_str () );
552 nasmCommand
.c_str () );
554 GenerateGlobalCFlagsAndProperties ( "=", ProjectNode
.non_if_data
);
555 GenerateProjectGccOptions ( "=", ProjectNode
.non_if_data
);
557 fprintf ( fMakefile
, "PROJECT_RCFLAGS := $(PROJECT_CFLAGS)\n" );
558 fprintf ( fMakefile
, "PROJECT_WIDLFLAGS := $(PROJECT_CFLAGS)\n" );
559 fprintf ( fMakefile
, "PROJECT_LFLAGS := %s\n",
560 GenerateProjectLFLAGS ().c_str () );
561 fprintf ( fMakefile
, "PROJECT_CFLAGS += -Wall\n" );
562 fprintf ( fMakefile
, "PROJECT_CFLAGS += $(PROJECT_GCCOPTIONS)\n" );
563 fprintf ( fMakefile
, "\n" );
567 MingwBackend::IncludeInAllTarget ( const Module
& module
) const
569 if ( MingwModuleHandler::ReferenceObjects ( module
) )
571 if ( module
.type
== BootSector
)
573 if ( module
.type
== Iso
)
575 if ( module
.type
== LiveIso
)
577 if ( module
.type
== Test
)
579 if ( module
.type
== Alias
)
585 MingwBackend::GenerateAllTarget ( const vector
<MingwModuleHandler
*>& handlers
) const
587 fprintf ( fMakefile
, "all:" );
589 size_t iend
= handlers
.size ();
590 for ( size_t i
= 0; i
< iend
; i
++ )
592 const Module
& module
= handlers
[i
]->module
;
593 if ( IncludeInAllTarget ( module
) )
595 if ( wrap_count
++ == 5 )
596 fprintf ( fMakefile
, " \\\n\t\t" ), wrap_count
= 0;
599 GetTargetMacro(module
).c_str () );
602 fprintf ( fMakefile
, "\n\t\n\n" );
606 MingwBackend::GetBuildToolDependencies () const
609 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
611 Module
& module
= *ProjectNode
.modules
[i
];
612 if ( !module
.enabled
)
614 if ( module
.type
== BuildTool
)
616 if ( dependencies
.length () > 0 )
618 dependencies
+= module
.GetDependencyPath ();
625 MingwBackend::GenerateInitTarget () const
629 GetBuildToolDependencies ().c_str () );
630 fprintf ( fMakefile
, "\n" );
634 MingwBackend::GenerateRegTestsRunTarget () const
637 "REGTESTS_RUN_TARGET = regtests.dll\n" );
639 "$(REGTESTS_RUN_TARGET): $(REGTESTS_TARGET)\n" );
641 "\t$(cp) $(REGTESTS_TARGET) $(REGTESTS_RUN_TARGET)\n" );
642 fprintf ( fMakefile
, "\n" );
646 MingwBackend::GenerateXmlBuildFilesMacro() const
649 "XMLBUILDFILES = %s \\\n",
650 ProjectNode
.GetProjectFilename ().c_str () );
651 string xmlbuildFilenames
;
652 int numberOfExistingFiles
= 0;
653 for ( size_t i
= 0; i
< ProjectNode
.xmlbuildfiles
.size (); i
++ )
655 XMLInclude
& xmlbuildfile
= *ProjectNode
.xmlbuildfiles
[i
];
656 if ( !xmlbuildfile
.fileExists
)
658 numberOfExistingFiles
++;
659 if ( xmlbuildFilenames
.length () > 0 )
660 xmlbuildFilenames
+= " ";
661 xmlbuildFilenames
+= NormalizeFilename ( xmlbuildfile
.topIncludeFilename
);
662 if ( numberOfExistingFiles
% 5 == 4 || i
== ProjectNode
.xmlbuildfiles
.size () - 1 )
666 xmlbuildFilenames
.c_str ());
667 if ( i
== ProjectNode
.xmlbuildfiles
.size () - 1 )
669 fprintf ( fMakefile
, "\n" );
676 xmlbuildFilenames
.resize ( 0 );
678 numberOfExistingFiles
++;
680 fprintf ( fMakefile
, "\n" );
684 MingwBackend::GetBin2ResExecutable ()
686 return NormalizeFilename ( Environment::GetOutputPath () + SSEP
+ "tools/bin2res/bin2res" + EXEPOSTFIX
);
690 MingwBackend::UnpackWineResources ()
692 printf ( "Unpacking WINE resources..." );
693 WineResource
wineResource ( ProjectNode
,
694 GetBin2ResExecutable () );
695 wineResource
.UnpackResources ( configuration
.Verbose
);
700 MingwBackend::GenerateTestSupportCode ()
702 printf ( "Generating test support code..." );
703 TestSupportCode
testSupportCode ( ProjectNode
);
704 testSupportCode
.GenerateTestSupportCode ( configuration
.Verbose
);
709 MingwBackend::GetProxyMakefileTree () const
711 if ( configuration
.GenerateProxyMakefilesInSourceTree
)
714 return Environment::GetOutputPath ();
718 MingwBackend::GenerateProxyMakefiles ()
720 printf ( "Generating proxy makefiles..." );
721 ProxyMakefile
proxyMakefile ( ProjectNode
);
722 proxyMakefile
.GenerateProxyMakefiles ( configuration
.Verbose
,
723 GetProxyMakefileTree () );
728 MingwBackend::CheckAutomaticDependencies ()
730 if ( configuration
.AutomaticDependencies
)
732 printf ( "Checking automatic dependencies..." );
733 AutomaticDependency
automaticDependency ( ProjectNode
);
734 automaticDependency
.CheckAutomaticDependencies ( configuration
.Verbose
);
740 MingwBackend::IncludeDirectoryTarget ( const string
& directory
) const
742 if ( directory
== "$(INTERMEDIATE)" SSEP
"tools")
749 MingwBackend::GenerateDirectories ()
751 printf ( "Creating directories..." );
752 intermediateDirectory
->GenerateTree ( "", configuration
.Verbose
);
753 outputDirectory
->GenerateTree ( "", configuration
.Verbose
);
754 if ( !configuration
.MakeHandlesInstallDirectories
)
755 installDirectory
->GenerateTree ( "", configuration
.Verbose
);
760 MingwBackend::TryToDetectThisCompiler ( const string
& compiler
)
762 string command
= ssprintf (
767 int exitcode
= system ( command
.c_str () );
768 return (exitcode
== 0);
772 MingwBackend::DetectCompiler ()
774 printf ( "Detecting compiler..." );
776 bool detectedCompiler
= false;
777 const string
& ROS_PREFIXValue
= Environment::GetVariable ( "ROS_PREFIX" );
778 if ( ROS_PREFIXValue
.length () > 0 )
780 compilerPrefix
= ROS_PREFIXValue
;
781 compilerCommand
= compilerPrefix
+ "-gcc";
782 detectedCompiler
= TryToDetectThisCompiler ( compilerCommand
);
785 if ( !detectedCompiler
)
788 compilerCommand
= "gcc";
789 detectedCompiler
= TryToDetectThisCompiler ( compilerCommand
);
792 if ( !detectedCompiler
)
794 compilerPrefix
= "mingw32";
795 compilerCommand
= compilerPrefix
+ "-gcc";
796 detectedCompiler
= TryToDetectThisCompiler ( compilerCommand
);
798 if ( detectedCompiler
)
799 printf ( "detected (%s)\n", compilerCommand
.c_str () );
801 printf ( "not detected\n" );
805 MingwBackend::TryToDetectThisNetwideAssembler ( const string
& assembler
)
807 string command
= ssprintf (
812 int exitcode
= system ( command
.c_str () );
813 return (exitcode
== 0);
817 MingwBackend::DetectNetwideAssembler ()
819 printf ( "Detecting netwide assembler..." );
821 nasmCommand
= "nasm";
822 bool detectedNasm
= TryToDetectThisNetwideAssembler ( nasmCommand
);
826 nasmCommand
= "nasmw";
827 detectedNasm
= TryToDetectThisNetwideAssembler ( nasmCommand
);
832 nasmCommand
= "yasm";
833 detectedNasm
= TryToDetectThisNetwideAssembler ( nasmCommand
);
836 printf ( "detected (%s)\n", nasmCommand
.c_str () );
838 printf ( "not detected\n" );
842 MingwBackend::DetectPipeSupport ()
844 printf ( "Detecting compiler -pipe support..." );
846 string pipe_detection
= "tools" SSEP
"rbuild" SSEP
"backend" SSEP
"mingw" SSEP
"pipe_detection.c";
847 string pipe_detectionObjectFilename
= ReplaceExtension ( pipe_detection
,
849 string command
= ssprintf (
850 "%s -pipe -c %s -o %s 1>%s 2>%s",
851 compilerCommand
.c_str (),
852 pipe_detection
.c_str (),
853 pipe_detectionObjectFilename
.c_str (),
856 int exitcode
= system ( command
.c_str () );
857 FILE* f
= fopen ( pipe_detectionObjectFilename
.c_str (), "rb" );
860 usePipe
= (exitcode
== 0);
862 unlink ( pipe_detectionObjectFilename
.c_str () );
868 printf ( "detected\n" );
870 printf ( "not detected\n" );
874 MingwBackend::DetectPCHSupport ()
876 printf ( "Detecting compiler pre-compiled header support..." );
878 string path
= "tools" SSEP
"rbuild" SSEP
"backend" SSEP
"mingw" SSEP
"pch_detection.h";
879 string cmd
= ssprintf (
880 "%s -c %s 1>%s 2>%s",
881 compilerCommand
.c_str (),
885 system ( cmd
.c_str () );
888 FILE* f
= fopen ( path
.c_str (), "rb" );
893 unlink ( path
.c_str () );
899 printf ( "detected\n" );
901 printf ( "not detected\n" );
905 MingwBackend::GetNonModuleInstallTargetFiles (
906 vector
<string
>& out
) const
908 for ( size_t i
= 0; i
< ProjectNode
.installfiles
.size (); i
++ )
910 const InstallFile
& installfile
= *ProjectNode
.installfiles
[i
];
911 string targetFilenameNoFixup
= installfile
.base
+ SSEP
+ installfile
.newname
;
912 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
913 NormalizeFilename ( targetFilenameNoFixup
),
915 out
.push_back ( targetFilename
);
920 MingwBackend::GetModuleInstallTargetFiles (
921 vector
<string
>& out
) const
923 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
925 const Module
& module
= *ProjectNode
.modules
[i
];
926 if ( !module
.enabled
)
928 if ( module
.installName
.length () > 0 )
930 string targetFilenameNoFixup
;
931 if ( module
.installBase
.length () > 0 )
932 targetFilenameNoFixup
= module
.installBase
+ SSEP
+ module
.installName
;
934 targetFilenameNoFixup
= module
.installName
;
935 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
936 NormalizeFilename ( targetFilenameNoFixup
),
938 out
.push_back ( targetFilename
);
944 MingwBackend::GetInstallTargetFiles (
945 vector
<string
>& out
) const
947 GetNonModuleInstallTargetFiles ( out
);
948 GetModuleInstallTargetFiles ( out
);
952 MingwBackend::OutputInstallTarget ( const string
& sourceFilename
,
953 const string
& targetFilename
,
954 const string
& targetDirectory
)
956 string fullTargetFilename
;
957 if ( targetDirectory
.length () > 0)
958 fullTargetFilename
= targetDirectory
+ SSEP
+ targetFilename
;
960 fullTargetFilename
= targetFilename
;
961 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
962 NormalizeFilename ( fullTargetFilename
),
964 string normalizedTargetDirectory
= MingwModuleHandler::PassThruCacheDirectory (
965 NormalizeFilename ( targetDirectory
),
969 normalizedTargetFilename
.c_str (),
970 sourceFilename
.c_str (),
971 normalizedTargetDirectory
.c_str () );
975 "\t${cp} %s %s 1>$(NUL)\n",
976 sourceFilename
.c_str (),
977 normalizedTargetFilename
.c_str () );
981 MingwBackend::OutputNonModuleInstallTargets ()
983 for ( size_t i
= 0; i
< ProjectNode
.installfiles
.size (); i
++ )
985 const InstallFile
& installfile
= *ProjectNode
.installfiles
[i
];
986 OutputInstallTarget ( installfile
.GetPath (),
993 MingwBackend::GetAliasedModuleOrModule ( const Module
& module
) const
995 if ( module
.aliasedModuleName
.size () > 0 )
997 const Module
* aliasedModule
= ProjectNode
.LocateModule ( module
.aliasedModuleName
);
998 assert ( aliasedModule
);
999 return *aliasedModule
;
1006 MingwBackend::OutputModuleInstallTargets ()
1008 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
1010 const Module
& module
= *ProjectNode
.modules
[i
];
1011 if ( !module
.enabled
)
1013 if ( module
.installName
.length () > 0 )
1015 const Module
& aliasedModule
= GetAliasedModuleOrModule ( module
);
1016 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
1017 NormalizeFilename ( aliasedModule
.GetPath () ),
1019 OutputInstallTarget ( sourceFilename
,
1021 module
.installBase
);
1027 MingwBackend::GetRegistrySourceFiles ()
1029 return "bootdata" SSEP
"hivecls.inf "
1030 "bootdata" SSEP
"hivedef.inf "
1031 "bootdata" SSEP
"hiveinst.inf "
1032 "bootdata" SSEP
"hivesft.inf "
1033 "bootdata" SSEP
"hivesys.inf";
1037 MingwBackend::GetRegistryTargetFiles ()
1039 string system32ConfigDirectory
= NormalizeFilename (
1040 MingwModuleHandler::PassThruCacheDirectory (
1041 "system32" SSEP
"config" SSEP
,
1042 installDirectory
) );
1043 return system32ConfigDirectory
+ SSEP
"default " +
1044 system32ConfigDirectory
+ SSEP
"sam " +
1045 system32ConfigDirectory
+ SSEP
"security " +
1046 system32ConfigDirectory
+ SSEP
"software " +
1047 system32ConfigDirectory
+ SSEP
"system";
1051 MingwBackend::OutputRegistryInstallTarget ()
1053 string system32ConfigDirectory
= NormalizeFilename (
1054 MingwModuleHandler::PassThruCacheDirectory (
1055 "system32" SSEP
"config" SSEP
,
1056 installDirectory
) );
1058 string registrySourceFiles
= GetRegistrySourceFiles ();
1059 string registryTargetFiles
= GetRegistryTargetFiles ();
1060 fprintf ( fMakefile
,
1061 "install_registry: %s\n",
1062 registryTargetFiles
.c_str () );
1063 fprintf ( fMakefile
,
1064 "%s: %s %s $(MKHIVE_TARGET)\n",
1065 registryTargetFiles
.c_str (),
1066 registrySourceFiles
.c_str (),
1067 system32ConfigDirectory
.c_str () );
1068 fprintf ( fMakefile
,
1069 "\t$(ECHO_MKHIVE)\n" );
1070 fprintf ( fMakefile
,
1071 "\t$(MKHIVE_TARGET) bootdata %s bootdata" SSEP
"hiveinst.inf\n",
1072 system32ConfigDirectory
.c_str () );
1073 fprintf ( fMakefile
,
1078 MingwBackend::GenerateInstallTarget ()
1080 vector
<string
> vInstallTargetFiles
;
1081 GetInstallTargetFiles ( vInstallTargetFiles
);
1082 string installTargetFiles
= v2s ( vInstallTargetFiles
, 5 );
1083 string registryTargetFiles
= GetRegistryTargetFiles ();
1085 fprintf ( fMakefile
,
1087 installTargetFiles
.c_str (),
1088 registryTargetFiles
.c_str () );
1089 OutputNonModuleInstallTargets ();
1090 OutputModuleInstallTargets ();
1091 OutputRegistryInstallTarget ();
1092 fprintf ( fMakefile
,
1097 MingwBackend::GetModuleTestTargets (
1098 vector
<string
>& out
) const
1100 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
1102 const Module
& module
= *ProjectNode
.modules
[i
];
1103 if ( !module
.enabled
)
1105 if ( module
.type
== Test
)
1106 out
.push_back ( module
.name
);
1111 MingwBackend::GenerateTestTarget ()
1113 vector
<string
> vTestTargets
;
1114 GetModuleTestTargets ( vTestTargets
);
1115 string testTargets
= v2s ( vTestTargets
, 5 );
1117 fprintf ( fMakefile
,
1119 testTargets
.c_str () );
1120 fprintf ( fMakefile
,
1125 MingwBackend::GenerateDirectoryTargets ()
1127 intermediateDirectory
->CreateRule ( fMakefile
, "" );
1128 outputDirectory
->CreateRule ( fMakefile
, "" );
1129 installDirectory
->CreateRule ( fMakefile
, "" );