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"
22 #include "modulehandler.h"
29 typedef set
<string
> set_string
;
33 v2s ( const string_list
& v
, int wrap_at
)
39 for ( size_t i
= 0; i
< v
.size(); i
++ )
43 if ( wrap_at
> 0 && wrap_count
++ == wrap_at
)
53 static class MingwFactory
: public Backend::Factory
56 MingwFactory() : Factory ( "mingw" ) {}
57 Backend
* operator() ( Project
& project
,
58 Configuration
& configuration
)
60 return new MingwBackend ( project
,
66 MingwBackend::MingwBackend ( Project
& project
,
67 Configuration
& configuration
)
68 : Backend ( project
, configuration
),
69 intermediateDirectory ( new Directory ("$(INTERMEDIATE)" ) ),
70 outputDirectory ( new Directory ( "$(OUTPUT)" ) ),
71 installDirectory ( new Directory ( "$(INSTALL)" ) )
76 MingwBackend::~MingwBackend()
78 delete intermediateDirectory
;
79 delete outputDirectory
;
80 delete installDirectory
;
84 MingwBackend::AddDirectoryTarget ( const string
& directory
,
85 Directory
* directoryTree
)
87 if ( directory
.length () > 0)
88 directoryTree
->Add ( directory
.c_str() );
89 return directoryTree
->name
;
93 MingwBackend::ProcessModules ()
95 printf ( "Processing modules..." );
97 vector
<MingwModuleHandler
*> v
;
99 for ( i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
101 Module
& module
= *ProjectNode
.modules
[i
];
102 if ( !module
.enabled
)
104 MingwModuleHandler
* h
= MingwModuleHandler::InstanciateHandler (
107 if ( module
.host
== HostDefault
)
109 module
.host
= h
->DefaultHost();
110 assert ( module
.host
!= HostDefault
);
115 size_t iend
= v
.size ();
117 for ( i
= 0; i
< iend
; i
++ )
118 v
[i
]->GenerateObjectMacro();
119 fprintf ( fMakefile
, "\n" );
120 for ( i
= 0; i
< iend
; i
++ )
121 v
[i
]->GenerateTargetMacro();
122 fprintf ( fMakefile
, "\n" );
124 GenerateAllTarget ( v
);
125 GenerateInitTarget ();
126 GenerateRegTestsRunTarget ();
128 for ( i
= 0; i
< iend
; i
++ )
129 v
[i
]->GenerateOtherMacros();
131 for ( i
= 0; i
< iend
; i
++ )
133 MingwModuleHandler
& h
= *v
[i
];
134 h
.GeneratePreconditionDependencies ();
136 h
.GenerateInvocations ();
137 h
.GenerateCleanTarget ();
138 h
.GenerateInstallTarget ();
139 h
.GenerateDependsTarget ();
147 MingwBackend::Process ()
149 if ( configuration
.CheckDependenciesForModuleOnly
)
150 CheckAutomaticDependenciesForModuleOnly ();
156 MingwBackend::CheckAutomaticDependenciesForModuleOnly ()
158 if ( configuration
.AutomaticDependencies
)
160 Module
* module
= ProjectNode
.LocateModule ( configuration
.CheckDependenciesForModuleOnlyModule
);
161 if ( module
== NULL
)
163 printf ( "Module '%s' does not exist\n",
164 configuration
.CheckDependenciesForModuleOnlyModule
.c_str () );
168 printf ( "Checking automatic dependencies for module '%s'...",
169 module
->name
.c_str () );
170 AutomaticDependency
automaticDependency ( ProjectNode
);
171 automaticDependency
.CheckAutomaticDependenciesForModule ( *module
,
172 configuration
.Verbose
);
178 MingwBackend::ProcessNormal ()
182 DetectNetwideAssembler ();
183 DetectPipeSupport ();
187 GenerateGlobalVariables ();
188 GenerateXmlBuildFilesMacro ();
190 GenerateInstallTarget ();
191 GenerateTestTarget ();
192 GenerateDirectoryTargets ();
193 GenerateDirectories ();
194 UnpackWineResources ();
195 GenerateTestSupportCode ();
196 GenerateCompilationUnitSupportCode ();
197 GenerateProxyMakefiles ();
198 CheckAutomaticDependencies ();
203 MingwBackend::CreateMakefile ()
205 fMakefile
= fopen ( ProjectNode
.makefile
.c_str (), "w" );
207 throw AccessDeniedException ( ProjectNode
.makefile
);
208 MingwModuleHandler::SetBackend ( this );
209 MingwModuleHandler::SetMakefile ( fMakefile
);
210 MingwModuleHandler::SetUsePch ( use_pch
);
214 MingwBackend::CloseMakefile () const
217 fclose ( fMakefile
);
221 MingwBackend::GenerateHeader () const
223 fprintf ( fMakefile
, "# THIS FILE IS AUTOMATICALLY GENERATED, EDIT 'ReactOS.xml' INSTEAD\n\n" );
227 MingwBackend::GenerateIncludesAndDefines ( IfableData
& data
) const
229 string includeParameters
= MingwModuleHandler::GenerateGccIncludeParametersFromVector ( data
.includes
);
230 string defineParameters
= MingwModuleHandler::GenerateGccDefineParametersFromVector ( data
.defines
);
231 return includeParameters
+ " " + defineParameters
;
235 MingwBackend::GenerateProjectCFlagsMacro ( const char* assignmentOperation
,
236 IfableData
& data
) const
241 assignmentOperation
);
245 GenerateIncludesAndDefines ( data
).c_str() );
247 fprintf ( fMakefile
, "\n" );
251 MingwBackend::GenerateGlobalCFlagsAndProperties (
252 const char* assignmentOperation
,
253 IfableData
& data
) const
257 for ( i
= 0; i
< data
.properties
.size(); i
++ )
259 Property
& prop
= *data
.properties
[i
];
260 fprintf ( fMakefile
, "%s := %s\n",
262 prop
.value
.c_str() );
265 if ( data
.includes
.size() || data
.defines
.size() )
267 GenerateProjectCFlagsMacro ( assignmentOperation
,
271 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
273 If
& rIf
= *data
.ifs
[i
];
274 if ( rIf
.data
.defines
.size()
275 || rIf
.data
.includes
.size()
276 || rIf
.data
.ifs
.size() )
280 "ifeq (\"$(%s)\",\"%s\")\n",
281 rIf
.property
.c_str(),
283 GenerateGlobalCFlagsAndProperties (
294 MingwBackend::GenerateProjectGccOptionsMacro ( const char* assignmentOperation
,
295 IfableData
& data
) const
301 "PROJECT_GCCOPTIONS %s",
302 assignmentOperation
);
304 for ( i
= 0; i
< data
.compilerFlags
.size(); i
++ )
309 data
.compilerFlags
[i
]->flag
.c_str() );
312 fprintf ( fMakefile
, "\n" );
316 MingwBackend::GenerateProjectGccOptions (
317 const char* assignmentOperation
,
318 IfableData
& data
) const
322 if ( data
.compilerFlags
.size() )
324 GenerateProjectGccOptionsMacro ( assignmentOperation
,
328 for ( i
= 0; i
< data
.ifs
.size(); i
++ )
330 If
& rIf
= *data
.ifs
[i
];
331 if ( rIf
.data
.compilerFlags
.size()
332 || rIf
.data
.ifs
.size() )
336 "ifeq (\"$(%s)\",\"%s\")\n",
337 rIf
.property
.c_str(),
339 GenerateProjectGccOptions (
350 MingwBackend::GenerateProjectLFLAGS () const
353 for ( size_t i
= 0; i
< ProjectNode
.linkerFlags
.size (); i
++ )
355 LinkerFlag
& linkerFlag
= *ProjectNode
.linkerFlags
[i
];
356 if ( lflags
.length () > 0 )
358 lflags
+= linkerFlag
.flag
;
364 MingwBackend::GenerateGlobalVariables () const
368 compilerPrefix
.c_str () );
371 nasmCommand
.c_str () );
373 GenerateGlobalCFlagsAndProperties ( "=", ProjectNode
.non_if_data
);
374 GenerateProjectGccOptions ( "=", ProjectNode
.non_if_data
);
376 fprintf ( fMakefile
, "PROJECT_RCFLAGS := $(PROJECT_CFLAGS)\n" );
377 fprintf ( fMakefile
, "PROJECT_WIDLFLAGS := $(PROJECT_CFLAGS)\n" );
378 fprintf ( fMakefile
, "PROJECT_LFLAGS := %s\n",
379 GenerateProjectLFLAGS ().c_str () );
380 fprintf ( fMakefile
, "PROJECT_CFLAGS += -Wall\n" );
381 fprintf ( fMakefile
, "PROJECT_CFLAGS += $(PROJECT_GCCOPTIONS)\n" );
382 fprintf ( fMakefile
, "\n" );
386 MingwBackend::IncludeInAllTarget ( const Module
& module
) const
388 if ( MingwModuleHandler::ReferenceObjects ( module
) )
390 if ( module
.type
== BootSector
)
392 if ( module
.type
== Iso
)
394 if ( module
.type
== LiveIso
)
396 if ( module
.type
== Test
)
398 if ( module
.type
== Alias
)
404 MingwBackend::GenerateAllTarget ( const vector
<MingwModuleHandler
*>& handlers
) const
406 fprintf ( fMakefile
, "all:" );
408 size_t iend
= handlers
.size ();
409 for ( size_t i
= 0; i
< iend
; i
++ )
411 const Module
& module
= handlers
[i
]->module
;
412 if ( IncludeInAllTarget ( module
) )
414 if ( wrap_count
++ == 5 )
415 fprintf ( fMakefile
, " \\\n\t\t" ), wrap_count
= 0;
418 GetTargetMacro(module
).c_str () );
421 fprintf ( fMakefile
, "\n\t\n\n" );
425 MingwBackend::GetBuildToolDependencies () const
428 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
430 Module
& module
= *ProjectNode
.modules
[i
];
431 if ( !module
.enabled
)
433 if ( module
.type
== BuildTool
)
435 if ( dependencies
.length () > 0 )
437 dependencies
+= module
.GetDependencyPath ();
444 MingwBackend::GenerateInitTarget () const
448 GetBuildToolDependencies ().c_str () );
449 fprintf ( fMakefile
, "\n" );
453 MingwBackend::GenerateRegTestsRunTarget () const
456 "REGTESTS_RUN_TARGET = regtests.dll\n" );
458 "$(REGTESTS_RUN_TARGET): $(REGTESTS_TARGET)\n" );
460 "\t$(cp) $(REGTESTS_TARGET) $(REGTESTS_RUN_TARGET)\n" );
461 fprintf ( fMakefile
, "\n" );
465 MingwBackend::GenerateXmlBuildFilesMacro() const
468 "XMLBUILDFILES = %s \\\n",
469 ProjectNode
.GetProjectFilename ().c_str () );
470 string xmlbuildFilenames
;
471 int numberOfExistingFiles
= 0;
472 for ( size_t i
= 0; i
< ProjectNode
.xmlbuildfiles
.size (); i
++ )
474 XMLInclude
& xmlbuildfile
= *ProjectNode
.xmlbuildfiles
[i
];
475 if ( !xmlbuildfile
.fileExists
)
477 numberOfExistingFiles
++;
478 if ( xmlbuildFilenames
.length () > 0 )
479 xmlbuildFilenames
+= " ";
480 xmlbuildFilenames
+= NormalizeFilename ( xmlbuildfile
.topIncludeFilename
);
481 if ( numberOfExistingFiles
% 5 == 4 || i
== ProjectNode
.xmlbuildfiles
.size () - 1 )
485 xmlbuildFilenames
.c_str ());
486 if ( i
== ProjectNode
.xmlbuildfiles
.size () - 1 )
488 fprintf ( fMakefile
, "\n" );
495 xmlbuildFilenames
.resize ( 0 );
497 numberOfExistingFiles
++;
499 fprintf ( fMakefile
, "\n" );
503 MingwBackend::GetBin2ResExecutable ()
505 return NormalizeFilename ( Environment::GetOutputPath () + sSep
+ "tools/bin2res/bin2res" + ExePostfix
);
509 MingwBackend::UnpackWineResources ()
511 printf ( "Unpacking WINE resources..." );
512 WineResource
wineResource ( ProjectNode
,
513 GetBin2ResExecutable () );
514 wineResource
.UnpackResources ( configuration
.Verbose
);
519 MingwBackend::GenerateTestSupportCode ()
521 printf ( "Generating test support code..." );
522 TestSupportCode
testSupportCode ( ProjectNode
);
523 testSupportCode
.GenerateTestSupportCode ( configuration
.Verbose
);
528 MingwBackend::GenerateCompilationUnitSupportCode ()
530 printf ( "Generating compilation unit support code..." );
531 CompilationUnitSupportCode
compilationUnitSupportCode ( ProjectNode
);
532 compilationUnitSupportCode
.Generate ( configuration
.Verbose
);
537 MingwBackend::GetProxyMakefileTree () const
539 if ( configuration
.GenerateProxyMakefilesInSourceTree
)
542 return Environment::GetOutputPath ();
546 MingwBackend::GenerateProxyMakefiles ()
548 printf ( "Generating proxy makefiles..." );
549 ProxyMakefile
proxyMakefile ( ProjectNode
);
550 proxyMakefile
.GenerateProxyMakefiles ( configuration
.Verbose
,
551 GetProxyMakefileTree () );
556 MingwBackend::CheckAutomaticDependencies ()
558 if ( configuration
.AutomaticDependencies
)
560 printf ( "Checking automatic dependencies..." );
561 AutomaticDependency
automaticDependency ( ProjectNode
);
562 automaticDependency
.CheckAutomaticDependencies ( configuration
.Verbose
);
568 MingwBackend::IncludeDirectoryTarget ( const string
& directory
) const
570 if ( directory
== "$(INTERMEDIATE)" + sSep
+ "tools")
577 MingwBackend::GenerateDirectories ()
579 printf ( "Creating directories..." );
580 intermediateDirectory
->GenerateTree ( "", configuration
.Verbose
);
581 outputDirectory
->GenerateTree ( "", configuration
.Verbose
);
582 if ( !configuration
.MakeHandlesInstallDirectories
)
583 installDirectory
->GenerateTree ( "", configuration
.Verbose
);
588 MingwBackend::TryToDetectThisCompiler ( const string
& compiler
)
590 string command
= ssprintf (
592 FixSeparatorForSystemCommand(compiler
).c_str (),
595 int exitcode
= system ( command
.c_str () );
596 return (exitcode
== 0);
600 MingwBackend::DetectCompiler ()
602 printf ( "Detecting compiler..." );
604 bool detectedCompiler
= false;
605 const string
& ROS_PREFIXValue
= Environment::GetVariable ( "ROS_PREFIX" );
606 if ( ROS_PREFIXValue
.length () > 0 )
608 compilerPrefix
= ROS_PREFIXValue
;
609 compilerCommand
= compilerPrefix
+ "-gcc";
610 detectedCompiler
= TryToDetectThisCompiler ( compilerCommand
);
613 if ( !detectedCompiler
)
616 compilerCommand
= "gcc";
617 detectedCompiler
= TryToDetectThisCompiler ( compilerCommand
);
620 if ( !detectedCompiler
)
622 compilerPrefix
= "mingw32";
623 compilerCommand
= compilerPrefix
+ "-gcc";
624 detectedCompiler
= TryToDetectThisCompiler ( compilerCommand
);
626 if ( detectedCompiler
)
627 printf ( "detected (%s)\n", compilerCommand
.c_str () );
629 printf ( "not detected\n" );
633 MingwBackend::TryToDetectThisNetwideAssembler ( const string
& assembler
)
635 string command
= ssprintf (
637 FixSeparatorForSystemCommand(assembler
).c_str (),
640 int exitcode
= system ( command
.c_str () );
641 return (exitcode
== 0);
645 MingwBackend::TryToDetectThisBinutils ( const string
& binutils
)
647 string command
= ssprintf (
649 FixSeparatorForSystemCommand(binutils
).c_str (),
652 int exitcode
= system ( command
.c_str () );
653 return (exitcode
== 0);
657 MingwBackend::GetBinutilsVersion ( const string
& binutilsCommand
)
663 string versionCommand
= ssprintf ( "%s -v",
664 binutilsCommand
.c_str (),
667 fp
= popen ( versionCommand
.c_str () , "r" );
670 ( feof ( fp
) == 0 &&
671 ( ( ch
= fgetc( fp
) ) != -1 ) );
674 buffer
[i
] = (char) ch
;
679 char separators
[] = " ";
681 char *prevtoken
= NULL
;
683 token
= strtok ( buffer
, separators
);
684 while ( token
!= NULL
)
687 token
= strtok ( NULL
, separators
);
689 string version
= string ( prevtoken
);
690 int lastDigit
= version
.find_last_not_of ( "\t\r\n" );
691 if ( lastDigit
!= -1 )
692 return string ( version
, 0, lastDigit
+1 );
698 MingwBackend::IsSupportedBinutilsVersion ( const string
& binutilsVersion
)
700 if ( ( ( strcmp ( binutilsVersion
.c_str (), "20040902") >= 0 ) &&
701 ( strcmp ( binutilsVersion
.c_str (), "20041008") <= 0 ) ) ||
702 ( strcmp ( binutilsVersion
.c_str (), "20031001") < 0 ) )
709 MingwBackend::DetectBinutils ()
711 printf ( "Detecting binutils..." );
713 bool detectedBinutils
= false;
714 const string
& ROS_PREFIXValue
= Environment::GetVariable ( "ROS_PREFIX" );
715 if ( ROS_PREFIXValue
.length () > 0 )
717 binutilsPrefix
= ROS_PREFIXValue
;
718 binutilsCommand
= binutilsPrefix
+ "-ld";
719 detectedBinutils
= TryToDetectThisBinutils ( binutilsCommand
);
722 if ( !detectedBinutils
)
725 binutilsCommand
= "ld";
726 detectedBinutils
= TryToDetectThisBinutils ( binutilsCommand
);
729 if ( !detectedBinutils
)
731 binutilsPrefix
= "mingw32";
732 binutilsCommand
= binutilsPrefix
+ "-ld";
733 detectedBinutils
= TryToDetectThisBinutils ( binutilsCommand
);
735 if ( detectedBinutils
)
737 string binutilsVersion
= GetBinutilsVersion ( binutilsCommand
);
738 if ( IsSupportedBinutilsVersion ( binutilsVersion
) )
739 printf ( "detected (%s)\n", binutilsCommand
.c_str () );
742 printf ( "detected (%s), but with unsupported version (%s)\n",
743 binutilsCommand
.c_str (),
744 binutilsVersion
.c_str () );
745 throw UnsupportedBuildToolException ( binutilsCommand
, binutilsVersion
);
749 printf ( "not detected\n" );
753 MingwBackend::DetectNetwideAssembler ()
755 printf ( "Detecting netwide assembler..." );
757 nasmCommand
= "nasm";
758 bool detectedNasm
= TryToDetectThisNetwideAssembler ( nasmCommand
);
762 nasmCommand
= "nasmw";
763 detectedNasm
= TryToDetectThisNetwideAssembler ( nasmCommand
);
768 nasmCommand
= "yasm";
769 detectedNasm
= TryToDetectThisNetwideAssembler ( nasmCommand
);
772 printf ( "detected (%s)\n", nasmCommand
.c_str () );
774 printf ( "not detected\n" );
778 MingwBackend::DetectPipeSupport ()
780 printf ( "Detecting compiler -pipe support..." );
782 string pipe_detection
= "tools" + sSep
+ "rbuild" + sSep
+ "backend" + sSep
+ "mingw" + sSep
+ "pipe_detection.c";
783 string pipe_detectionObjectFilename
= ReplaceExtension ( pipe_detection
,
785 string command
= ssprintf (
786 "%s -pipe -c %s -o %s 1>%s 2>%s",
787 FixSeparatorForSystemCommand(compilerCommand
).c_str (),
788 pipe_detection
.c_str (),
789 pipe_detectionObjectFilename
.c_str (),
792 int exitcode
= system ( command
.c_str () );
793 FILE* f
= fopen ( pipe_detectionObjectFilename
.c_str (), "rb" );
796 usePipe
= (exitcode
== 0);
798 unlink ( pipe_detectionObjectFilename
.c_str () );
804 printf ( "detected\n" );
806 printf ( "not detected\n" );
810 MingwBackend::DetectPCHSupport ()
812 printf ( "Detecting compiler pre-compiled header support..." );
814 string path
= "tools" + sSep
+ "rbuild" + sSep
+ "backend" + sSep
+ "mingw" + sSep
+ "pch_detection.h";
815 string cmd
= ssprintf (
816 "%s -c %s 1>%s 2>%s",
817 FixSeparatorForSystemCommand(compilerCommand
).c_str (),
821 system ( cmd
.c_str () );
824 FILE* f
= fopen ( path
.c_str (), "rb" );
829 unlink ( path
.c_str () );
835 printf ( "detected\n" );
837 printf ( "not detected\n" );
841 MingwBackend::GetNonModuleInstallTargetFiles (
842 vector
<string
>& out
) const
844 for ( size_t i
= 0; i
< ProjectNode
.installfiles
.size (); i
++ )
846 const InstallFile
& installfile
= *ProjectNode
.installfiles
[i
];
847 string targetFilenameNoFixup
= installfile
.base
+ sSep
+ installfile
.newname
;
848 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
849 NormalizeFilename ( targetFilenameNoFixup
),
851 out
.push_back ( targetFilename
);
856 MingwBackend::GetModuleInstallTargetFiles (
857 vector
<string
>& out
) const
859 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
861 const Module
& module
= *ProjectNode
.modules
[i
];
862 if ( !module
.enabled
)
864 if ( module
.installName
.length () > 0 )
866 string targetFilenameNoFixup
;
867 if ( module
.installBase
.length () > 0 )
868 targetFilenameNoFixup
= module
.installBase
+ sSep
+ module
.installName
;
870 targetFilenameNoFixup
= module
.installName
;
871 string targetFilename
= MingwModuleHandler::PassThruCacheDirectory (
872 NormalizeFilename ( targetFilenameNoFixup
),
874 out
.push_back ( targetFilename
);
880 MingwBackend::GetInstallTargetFiles (
881 vector
<string
>& out
) const
883 GetNonModuleInstallTargetFiles ( out
);
884 GetModuleInstallTargetFiles ( out
);
888 MingwBackend::OutputInstallTarget ( const string
& sourceFilename
,
889 const string
& targetFilename
,
890 const string
& targetDirectory
)
892 string fullTargetFilename
;
893 if ( targetDirectory
.length () > 0)
894 fullTargetFilename
= targetDirectory
+ sSep
+ targetFilename
;
896 fullTargetFilename
= targetFilename
;
897 string normalizedTargetFilename
= MingwModuleHandler::PassThruCacheDirectory (
898 NormalizeFilename ( fullTargetFilename
),
900 string normalizedTargetDirectory
= MingwModuleHandler::PassThruCacheDirectory (
901 NormalizeFilename ( targetDirectory
),
905 normalizedTargetFilename
.c_str (),
906 sourceFilename
.c_str (),
907 normalizedTargetDirectory
.c_str () );
911 "\t${cp} %s %s 1>$(NUL)\n",
912 sourceFilename
.c_str (),
913 normalizedTargetFilename
.c_str () );
917 MingwBackend::OutputNonModuleInstallTargets ()
919 for ( size_t i
= 0; i
< ProjectNode
.installfiles
.size (); i
++ )
921 const InstallFile
& installfile
= *ProjectNode
.installfiles
[i
];
922 OutputInstallTarget ( installfile
.GetPath (),
929 MingwBackend::GetAliasedModuleOrModule ( const Module
& module
) const
931 if ( module
.aliasedModuleName
.size () > 0 )
933 const Module
* aliasedModule
= ProjectNode
.LocateModule ( module
.aliasedModuleName
);
934 assert ( aliasedModule
);
935 return *aliasedModule
;
942 MingwBackend::OutputModuleInstallTargets ()
944 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
946 const Module
& module
= *ProjectNode
.modules
[i
];
947 if ( !module
.enabled
)
949 if ( module
.installName
.length () > 0 )
951 const Module
& aliasedModule
= GetAliasedModuleOrModule ( module
);
952 string sourceFilename
= MingwModuleHandler::PassThruCacheDirectory (
953 NormalizeFilename ( aliasedModule
.GetPath () ),
955 OutputInstallTarget ( sourceFilename
,
957 module
.installBase
);
963 MingwBackend::GetRegistrySourceFiles ()
965 return "bootdata" + sSep
+ "hivecls.inf "
966 "bootdata" + sSep
+ "hivedef.inf "
967 "bootdata" + sSep
+ "hiveinst.inf "
968 "bootdata" + sSep
+ "hivesft.inf "
969 "bootdata" + sSep
+ "hivesys.inf";
973 MingwBackend::GetRegistryTargetFiles ()
975 string system32ConfigDirectory
= NormalizeFilename (
976 MingwModuleHandler::PassThruCacheDirectory (
977 "system32" + sSep
+ "config" + sSep
,
978 installDirectory
) );
979 return system32ConfigDirectory
+ sSep
+ "default " +
980 system32ConfigDirectory
+ sSep
+ "sam " +
981 system32ConfigDirectory
+ sSep
+ "security " +
982 system32ConfigDirectory
+ sSep
+ "software " +
983 system32ConfigDirectory
+ sSep
+ "system";
987 MingwBackend::OutputRegistryInstallTarget ()
989 string system32ConfigDirectory
= NormalizeFilename (
990 MingwModuleHandler::PassThruCacheDirectory (
991 "system32" + sSep
+ "config" + sSep
,
992 installDirectory
) );
994 string registrySourceFiles
= GetRegistrySourceFiles ();
995 string registryTargetFiles
= GetRegistryTargetFiles ();
997 "install_registry: %s\n",
998 registryTargetFiles
.c_str () );
1000 "%s: %s %s $(MKHIVE_TARGET)\n",
1001 registryTargetFiles
.c_str (),
1002 registrySourceFiles
.c_str (),
1003 system32ConfigDirectory
.c_str () );
1004 fprintf ( fMakefile
,
1005 "\t$(ECHO_MKHIVE)\n" );
1006 fprintf ( fMakefile
,
1007 "\t$(MKHIVE_TARGET) bootdata %s bootdata%chiveinst.inf\n",
1008 system32ConfigDirectory
.c_str (),
1010 fprintf ( fMakefile
,
1015 MingwBackend::GenerateInstallTarget ()
1017 vector
<string
> vInstallTargetFiles
;
1018 GetInstallTargetFiles ( vInstallTargetFiles
);
1019 string installTargetFiles
= v2s ( vInstallTargetFiles
, 5 );
1020 string registryTargetFiles
= GetRegistryTargetFiles ();
1022 fprintf ( fMakefile
,
1024 installTargetFiles
.c_str (),
1025 registryTargetFiles
.c_str () );
1026 OutputNonModuleInstallTargets ();
1027 OutputModuleInstallTargets ();
1028 OutputRegistryInstallTarget ();
1029 fprintf ( fMakefile
,
1034 MingwBackend::GetModuleTestTargets (
1035 vector
<string
>& out
) const
1037 for ( size_t i
= 0; i
< ProjectNode
.modules
.size (); i
++ )
1039 const Module
& module
= *ProjectNode
.modules
[i
];
1040 if ( !module
.enabled
)
1042 if ( module
.type
== Test
)
1043 out
.push_back ( module
.name
);
1048 MingwBackend::GenerateTestTarget ()
1050 vector
<string
> vTestTargets
;
1051 GetModuleTestTargets ( vTestTargets
);
1052 string testTargets
= v2s ( vTestTargets
, 5 );
1054 fprintf ( fMakefile
,
1056 testTargets
.c_str () );
1057 fprintf ( fMakefile
,
1062 MingwBackend::GenerateDirectoryTargets ()
1064 intermediateDirectory
->CreateRule ( fMakefile
, "" );
1065 outputDirectory
->CreateRule ( fMakefile
, "" );
1066 installDirectory
->CreateRule ( fMakefile
, "" );