mirror of
https://github.com/reactos/reactos.git
synced 2025-07-15 18:44:22 +00:00
Autodetect nasm
svn path=/trunk/; revision=15656
This commit is contained in:
parent
66500a1428
commit
750ce3d65a
3 changed files with 46 additions and 4 deletions
|
@ -301,6 +301,7 @@ void
|
||||||
MingwBackend::Process ()
|
MingwBackend::Process ()
|
||||||
{
|
{
|
||||||
DetectCompiler ();
|
DetectCompiler ();
|
||||||
|
DetectNetwideAssembler ();
|
||||||
DetectPipeSupport ();
|
DetectPipeSupport ();
|
||||||
DetectPCHSupport ();
|
DetectPCHSupport ();
|
||||||
CreateMakefile ();
|
CreateMakefile ();
|
||||||
|
@ -486,6 +487,9 @@ MingwBackend::GenerateGlobalVariables () const
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"PREFIX := %s\n",
|
"PREFIX := %s\n",
|
||||||
compilerPrefix.c_str () );
|
compilerPrefix.c_str () );
|
||||||
|
fprintf ( fMakefile,
|
||||||
|
"nasm := %s\n",
|
||||||
|
nasmCommand.c_str () );
|
||||||
|
|
||||||
GenerateGlobalCFlagsAndProperties ( "=", ProjectNode.non_if_data );
|
GenerateGlobalCFlagsAndProperties ( "=", ProjectNode.non_if_data );
|
||||||
GenerateProjectGccOptions ( "=", ProjectNode.non_if_data );
|
GenerateProjectGccOptions ( "=", ProjectNode.non_if_data );
|
||||||
|
@ -683,8 +687,9 @@ bool
|
||||||
MingwBackend::TryToDetectThisCompiler ( const string& compiler )
|
MingwBackend::TryToDetectThisCompiler ( const string& compiler )
|
||||||
{
|
{
|
||||||
string command = ssprintf (
|
string command = ssprintf (
|
||||||
"%s -v 2>%s",
|
"%s -v 1>%s 2>%s",
|
||||||
compiler.c_str (),
|
compiler.c_str (),
|
||||||
|
NUL,
|
||||||
NUL );
|
NUL );
|
||||||
int exitcode = system ( command.c_str () );
|
int exitcode = system ( command.c_str () );
|
||||||
return (exitcode == 0);
|
return (exitcode == 0);
|
||||||
|
@ -723,6 +728,38 @@ MingwBackend::DetectCompiler ()
|
||||||
printf ( "not detected\n" );
|
printf ( "not detected\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
MingwBackend::TryToDetectThisNetwideAssembler ( const string& assembler )
|
||||||
|
{
|
||||||
|
string command = ssprintf (
|
||||||
|
"%s -h 1>%s 2>%s",
|
||||||
|
assembler.c_str (),
|
||||||
|
NUL,
|
||||||
|
NUL );
|
||||||
|
int exitcode = system ( command.c_str () );
|
||||||
|
return (exitcode == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
MingwBackend::DetectNetwideAssembler ()
|
||||||
|
{
|
||||||
|
printf ( "Detecting netwide assembler..." );
|
||||||
|
|
||||||
|
nasmCommand = "nasm";
|
||||||
|
bool detectedNasm = TryToDetectThisNetwideAssembler ( nasmCommand );
|
||||||
|
#if defined(WIN32)
|
||||||
|
if ( !detectedNasm )
|
||||||
|
{
|
||||||
|
nasmCommand = "nasmw";
|
||||||
|
detectedNasm = TryToDetectThisNetwideAssembler ( nasmCommand );
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if ( detectedNasm )
|
||||||
|
printf ( "detected (%s)\n", nasmCommand.c_str () );
|
||||||
|
else
|
||||||
|
printf ( "not detected\n" );
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MingwBackend::DetectPipeSupport ()
|
MingwBackend::DetectPipeSupport ()
|
||||||
{
|
{
|
||||||
|
@ -732,10 +769,11 @@ MingwBackend::DetectPipeSupport ()
|
||||||
string pipe_detectionObjectFilename = ReplaceExtension ( pipe_detection,
|
string pipe_detectionObjectFilename = ReplaceExtension ( pipe_detection,
|
||||||
".o" );
|
".o" );
|
||||||
string command = ssprintf (
|
string command = ssprintf (
|
||||||
"%s -pipe -c %s -o %s 2>%s",
|
"%s -pipe -c %s -o %s 1>%s 2>%s",
|
||||||
compilerCommand.c_str (),
|
compilerCommand.c_str (),
|
||||||
pipe_detection.c_str (),
|
pipe_detection.c_str (),
|
||||||
pipe_detectionObjectFilename.c_str (),
|
pipe_detectionObjectFilename.c_str (),
|
||||||
|
NUL,
|
||||||
NUL );
|
NUL );
|
||||||
int exitcode = system ( command.c_str () );
|
int exitcode = system ( command.c_str () );
|
||||||
FILE* f = fopen ( pipe_detectionObjectFilename.c_str (), "rb" );
|
FILE* f = fopen ( pipe_detectionObjectFilename.c_str (), "rb" );
|
||||||
|
@ -761,9 +799,10 @@ MingwBackend::DetectPCHSupport ()
|
||||||
|
|
||||||
string path = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pch_detection.h";
|
string path = "tools" SSEP "rbuild" SSEP "backend" SSEP "mingw" SSEP "pch_detection.h";
|
||||||
string cmd = ssprintf (
|
string cmd = ssprintf (
|
||||||
"%s -c %s 2>%s",
|
"%s -c %s 1>%s 2>%s",
|
||||||
compilerCommand.c_str (),
|
compilerCommand.c_str (),
|
||||||
path.c_str (),
|
path.c_str (),
|
||||||
|
NUL,
|
||||||
NUL );
|
NUL );
|
||||||
system ( cmd.c_str () );
|
system ( cmd.c_str () );
|
||||||
path += ".gch";
|
path += ".gch";
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
Directory* directoryTree );
|
Directory* directoryTree );
|
||||||
std::string compilerPrefix;
|
std::string compilerPrefix;
|
||||||
std::string compilerCommand;
|
std::string compilerCommand;
|
||||||
|
std::string nasmCommand;
|
||||||
bool usePipe;
|
bool usePipe;
|
||||||
Directory* intermediateDirectory;
|
Directory* intermediateDirectory;
|
||||||
Directory* outputDirectory;
|
Directory* outputDirectory;
|
||||||
|
@ -87,6 +88,8 @@ private:
|
||||||
bool IncludeDirectoryTarget ( const std::string& directory ) const;
|
bool IncludeDirectoryTarget ( const std::string& directory ) const;
|
||||||
bool TryToDetectThisCompiler ( const std::string& compiler );
|
bool TryToDetectThisCompiler ( const std::string& compiler );
|
||||||
void DetectCompiler ();
|
void DetectCompiler ();
|
||||||
|
bool TryToDetectThisNetwideAssembler ( const std::string& assembler );
|
||||||
|
void DetectNetwideAssembler ();
|
||||||
void DetectPipeSupport ();
|
void DetectPipeSupport ();
|
||||||
void DetectPCHSupport ();
|
void DetectPCHSupport ();
|
||||||
void ProcessModules ();
|
void ProcessModules ();
|
||||||
|
|
|
@ -899,7 +899,7 @@ MingwModuleHandler::GenerateNasmCommand (
|
||||||
fprintf ( fMakefile, "\t$(ECHO_NASM)\n" );
|
fprintf ( fMakefile, "\t$(ECHO_NASM)\n" );
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t%s -f win32 $< -o $@ %s\n",
|
"\t%s -f win32 $< -o $@ %s\n",
|
||||||
"$(Q)nasm",
|
"$(Q)${nasm}",
|
||||||
nasmflagsMacro.c_str () );
|
nasmflagsMacro.c_str () );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue