* Nasm support

* Hal, rosrtl, pseh, string modules
* Build ntoskrnl


svn path=/branches/xmlbuildsystem/; revision=12913
This commit is contained in:
Casper Hornstrup 2005-01-09 21:26:16 +00:00
parent e5130a546a
commit b663342f01
15 changed files with 320 additions and 16 deletions

View file

@ -12,6 +12,9 @@
<directory name="tools">
<xi:include href="tools/tools.xml" />
</directory>
<directory name="hal">
<xi:include href="hal/directory.xml" />
</directory>
<directory name="iface">
<directory name="native">
<xi:include href="iface/native/module.xml" />

View file

@ -0,0 +1,3 @@
<directory name="hal">
<xi:include href="hal/hal.xml" />
</directory>

3
reactos/hal/hal/hal.xml Normal file
View file

@ -0,0 +1,3 @@
<module name="hal" type="kernelmodedll">
<importlibrary basename="hal" definition="hal.def" />
</module>

View file

@ -1,3 +1,15 @@
<directory name="kjs">
<xi:include href="kjs/module.xml" />
<xi:include href="kjs/kjs.xml" />
</directory>
<directory name="pseh">
<xi:include href="pseh/pseh.xml" />
</directory>
<directory name="rosrtl">
<xi:include href="rosrtl/rosrtl.xml" />
</directory>
<directory name="rtl">
<xi:include href="rtl/rtl.xml" />
</directory>
<directory name="string">
<xi:include href="string/string.xml" />
</directory>

View file

@ -0,0 +1,8 @@
<module name="pseh" type="staticlibrary">
<define name="__USE_W32API" />
<directory name="i386">
<file>framebased.asm</file>
<file>setjmp.asm</file>
</directory>
<file>framebased.c</file>
</module>

View file

@ -0,0 +1,33 @@
<module name="rosrtl" type="staticlibrary">
<define name="__USE_W32API" />
<directory name="file">
<file>sparse.c</file>
</directory>
<directory name="misc">
<file>devmode.c</file>
<file>intrlck.c</file>
<file>logfont.c</file>
<file>qsort.c</file>
</directory>
<directory name="recmutex">
<file>recmutex.c</file>
</directory>
<directory name="registry">
<file>registry.c</file>
</directory>
<directory name="string">
<file>append.c</file>
<file>resstr.c</file>
</directory>
<directory name="thread">
<directory name="i386">
<file>context.c</file>
<file>stackexit.S</file>
</directory>
<file>create.c</file>
<file>exit.c</file>
<file>linearstack.c</file>
<file>priv.c</file>
<file>stack.c</file>
</directory>
</module>

34
reactos/lib/rtl/rtl.xml Normal file
View file

@ -0,0 +1,34 @@
<module name="rtl" type="staticlibrary">
<directory name="i386">
<file>except.s</file>
<file>exception.c</file>
</directory>
<file>acl.c</file>
<file>bit.c</file>
<file>bitmap.c</file>
<file>bootdata.c</file>
<file>compress.c</file>
<file>dos8dot3.c</file>
<file>encode.c</file>
<file>env.c</file>
<file>error.c</file>
<file>exception.c</file>
<file>generictable.c</file>
<file>heap.c</file>
<file>image.c</file>
<file>largeint.c</file>
<file>luid.c</file>
<file>mem.c</file>
<file>network.c</file>
<file>nls.c</file>
<file>random.c</file>
<file>sd.c</file>
<file>security.c</file>
<file>sid.c</file>
<file>splaytree.c</file>
<file>time.c</file>
<file>timezone.c</file>
<file>unicode.c</file>
<file>unicodeprefix.c</file>
<file>version.c</file>
</module>

View file

@ -0,0 +1,30 @@
<module name="string" type="staticlibrary">
<file>memccpy.c</file>
<file>memchr.c</file>
<file>memcmp.c</file>
<file>memcpy.c</file>
<file>memmove.c</file>
<file>memset.c</file>
<file>strcat.c</file>
<file>strchr.c</file>
<file>strcmp.c</file>
<file>strcpy.c</file>
<file>strcspn.c</file>
<file>strlen.c</file>
<file>strncat.c</file>
<file>strncmp.c</file>
<file>strncpy.c</file>
<file>strnlen.c</file>
<file>strrchr.c</file>
<file>strspn.c</file>
<file>wcscat.c</file>
<file>wcschr.c</file>
<file>wcscmp.c</file>
<file>wcscpy.c</file>
<file>wcslen.c</file>
<file>wcsncat.c</file>
<file>wcsncmp.c</file>
<file>wcsncpy.c</file>
<file>wcsnlen.c</file>
<file>wcsrchr.c</file>
</module>

View file

@ -1,4 +1,4 @@
<module name="ntoskrnl" type="kernelmodedll" extension=".exe">
<module name="ntoskrnl" type="kernel">
<dependency>buildno</dependency>
<dependency>genntdll</dependency>
<dependency>wmc</dependency>
@ -9,7 +9,12 @@
<define name="__ELF_WORD_SIZE">32</define>
<include base="kjs">include</include>
<include base="ntoskrnl">include</include>
<library>hal</library>
<library>kjs</library>
<library>pseh</library>
<library>rosrtl</library>
<library>rtl</library>
<library>string</library>
<invoke module="wmc">
<input>
<inputfile>ntoskrnl.mc</inputfile>
@ -83,13 +88,11 @@
<file>user.c</file>
</directory>
<directory name="ex">
<!--
<if property="arch" value="i386">
<directory name="i386">
<file>interlck.c</file>
</directory>
</if>
-->
<file>btree.c</file>
<file>callback.c</file>
<file>fmutex.c</file>
@ -315,6 +318,7 @@
<file>plugplay.c</file>
<file>profile.c</file>
<file>vdm.c</file>
<file>zw.c</file>
</directory>
<directory name="ob">
<file>dirobj.c</file>

View file

@ -65,7 +65,7 @@ MingwBackend::GenerateGlobalVariables ()
fprintf ( fMakefile, "host_gcc = gcc\n" );
fprintf ( fMakefile, "host_ar = ar\n" );
fprintf ( fMakefile, "host_ld = ld\n" );
fprintf ( fMakefile, "rm = del /y\n" );
fprintf ( fMakefile, "rm = del /f /q\n" );
fprintf ( fMakefile, "gcc = gcc\n" );
fprintf ( fMakefile, "ld = ld\n" );
fprintf ( fMakefile, "ar = ar\n" );
@ -82,7 +82,7 @@ MingwBackend::GenerateAllTarget ()
Module& module = *ProjectNode.modules[i];
fprintf ( fMakefile,
" %s",
FixupTargetFilename(module.GetPath ()).c_str () );
FixupTargetFilename( module.GetPath () ).c_str () );
}
fprintf ( fMakefile, "\n\t\n\n" );
}

View file

@ -100,7 +100,7 @@ MingwModuleHandler::GetImportLibraryDependencies ( const Module& module ) const
dependencies += " ";
const Module* importedModule = module.project.LocateModule ( module.libraries[i]->name );
assert ( importedModule != NULL );
dependencies += FixupTargetFilename ( importedModule->GetPath () ).c_str ();
dependencies += FixupTargetFilename ( importedModule->GetDependencyPath () ).c_str ();
}
return dependencies;
}
@ -261,10 +261,16 @@ string
MingwModuleHandler::GenerateGccParameters ( const Module& module ) const
{
string parameters = GenerateGccDefineParameters ( module );
parameters += ssprintf(" $(%s_INCLUDES)",module.name.c_str());
parameters += ssprintf(" $(%s_INCLUDES)", module.name.c_str());
return parameters;
}
string
MingwModuleHandler::GenerateNasmParameters ( const Module& module ) const
{
return "";
}
string
MingwModuleHandler::GenerateGccCommand ( const Module& module,
const string& sourceFilename,
@ -291,6 +297,18 @@ MingwModuleHandler::GenerateGccAssemblerCommand ( const Module& module,
GenerateGccParameters ( module ).c_str () );
}
string
MingwModuleHandler::GenerateNasmCommand ( const Module& module,
const string& sourceFilename ) const
{
string objectFilename = GetObjectFilename ( sourceFilename );
return ssprintf ( "%s -f win32 %s -o %s %s\n",
"nasm",
sourceFilename.c_str (),
objectFilename.c_str (),
GenerateNasmParameters ( module ).c_str () );
}
string
MingwModuleHandler::GenerateCommand ( const Module& module,
const string& sourceFilename,
@ -305,6 +323,9 @@ MingwModuleHandler::GenerateCommand ( const Module& module,
return GenerateGccAssemblerCommand ( module,
sourceFilename,
cc );
else if ( extension == ".asm" || extension == ".ASM" )
return GenerateNasmCommand ( module,
sourceFilename );
throw InvalidOperationException ( __FILE__,
__LINE__,
@ -506,6 +527,7 @@ MingwModuleHandler::GeneratePreconditionDependencies ( const Module& module ) co
preconditionDependenciesName.c_str () );
}
static MingwBuildToolModuleHandler buildtool_handler;
MingwBuildToolModuleHandler::MingwBuildToolModuleHandler()
@ -540,7 +562,7 @@ MingwBuildToolModuleHandler::GenerateBuildToolModuleTarget ( const Module& modul
static MingwKernelModuleHandler kernelmodule_handler;
MingwKernelModuleHandler::MingwKernelModuleHandler ()
: MingwModuleHandler ( KernelModeDLL )
: MingwModuleHandler ( Kernel )
{
}
@ -564,13 +586,15 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
string base_tmp = ros_junk + module.name + ".base.tmp";
string junk_tmp = ros_junk + module.name + ".junk.tmp";
string temp_exp = ros_junk + module.name + ".temp.exp";
string gccOptions = ssprintf ("-Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--entry,_NtProcessStartup -Wl,--image-base,0xC0000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll",
module.GetBasePath ().c_str () );
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
fprintf ( fMakefile,
"\t${gcc} -Wl,--entry,_NtProcessStartup -Wl,-T,%s" SSEP "ntoskrnl.lnk -Wl,--subsystem,native -Wl,--image-base,0xC0000000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -Wl,--base-file,%s -nostartfiles -o %s %s %s\n",
module.GetBasePath ().c_str (),
"\t${gcc} %s -Wl,--base-file,%s -o %s %s %s\n",
gccOptions.c_str (),
base_tmp.c_str (),
junk_tmp.c_str (),
archiveFilename.c_str (),
@ -587,7 +611,8 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
"\t${rm} %s\n",
base_tmp.c_str () );
fprintf ( fMakefile,
"\t${ld} -Wl,%s -o %s %s %s\n",
"\t${gcc} %s -Wl,%s -o %s %s %s\n",
gccOptions.c_str (),
temp_exp.c_str (),
target.c_str (),
archiveFilename.c_str (),
@ -600,6 +625,7 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( const Module& module )
GenerateObjectFileTargetsTarget ( module );
}
static MingwStaticLibraryModuleHandler staticlibrary_handler;
MingwStaticLibraryModuleHandler::MingwStaticLibraryModuleHandler ()
@ -621,3 +647,65 @@ MingwStaticLibraryModuleHandler::GenerateStaticLibraryModuleTarget ( const Modul
GenerateArchiveTargetTarget ( module );
GenerateObjectFileTargetsTarget ( module );
}
static MingwKernelModeDLLModuleHandler kernelmodedll_handler;
MingwKernelModeDLLModuleHandler::MingwKernelModeDLLModuleHandler ()
: MingwModuleHandler ( KernelModeDLL )
{
}
void
MingwKernelModeDLLModuleHandler::Process ( const Module& module )
{
GeneratePreconditionDependencies ( module );
GenerateKernelModeDLLModuleTarget ( module );
GenerateInvocations ( module );
}
void
MingwKernelModeDLLModuleHandler::GenerateKernelModeDLLModuleTarget ( const Module& module )
{
static string ros_junk ( "$(ROS_TEMPORARY)" );
string target ( FixupTargetFilename ( module.GetPath () ) );
string workingDirectory = GetWorkingDirectory ( );
string archiveFilename = GetModuleArchiveFilename ( module );
string importLibraryDependencies = GetImportLibraryDependencies ( module );
if (module.importLibrary != NULL)
{
fprintf ( fMakefile, "%s:\n",
module.GetDependencyPath ().c_str () );
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-lib %s --kill-at\n\n",
module.GetTargetName ().c_str (),
FixupTargetFilename ( module.GetBasePath () + SSEP + module.importLibrary->definition ).c_str (),
FixupTargetFilename ( module.GetDependencyPath () ).c_str () );
}
if (module.files.size () > 0)
{
fprintf ( fMakefile, "%s: %s %s\n",
target.c_str (),
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
fprintf ( fMakefile,
"\t${gcc} -Wl,--subsystem,native -Wl,--entry,_DriverEntry@8 -Wl,--image-base,0x10000 -Wl,--file-alignment,0x1000 -Wl,--section-alignment,0x1000 -nostartfiles -mdll -o %s %s %s\n",
target.c_str (),
archiveFilename.c_str (),
importLibraryDependencies.c_str () );
GenerateArchiveTargetTarget ( module );
GenerateObjectFileTargetsTarget ( module );
}
else
{
fprintf ( fMakefile, "%s:\n\n",
target.c_str ());
fprintf ( fMakefile, ".PHONY: %s\n\n",
target.c_str ());
}
}

View file

@ -48,12 +48,15 @@ private:
void GenerateGccModuleIncludeVariable ( const Module& module ) const;
std::string GenerateGccIncludeParameters ( const Module& module ) const;
std::string GenerateGccParameters ( const Module& module ) const;
std::string GenerateNasmParameters ( const Module& module ) const;
std::string GenerateGccCommand ( const Module& module,
const std::string& sourceFilename,
const std::string& cc ) const;
std::string GenerateGccAssemblerCommand ( const Module& module,
const std::string& sourceFilename,
const std::string& cc ) const;
std::string GenerateNasmCommand ( const Module& module,
const std::string& sourceFilename ) const;
std::string GenerateCommand ( const Module& module,
const std::string& sourceFilename,
const std::string& cc ) const;
@ -94,4 +97,14 @@ private:
void GenerateStaticLibraryModuleTarget ( const Module& module );
};
class MingwKernelModeDLLModuleHandler : public MingwModuleHandler
{
public:
MingwKernelModeDLLModuleHandler ();
virtual void Process ( const Module& module );
private:
void GenerateKernelModeDLLModuleTarget ( const Module& module );
};
#endif /* MINGW_MODULEHANDLER_H */

View file

@ -24,8 +24,9 @@ FixSeparator ( const string& s )
Module::Module ( const Project& project,
const XMLElement& moduleNode,
const string& modulePath )
: project(project),
node(moduleNode)
: project (project),
node (moduleNode),
importLibrary (NULL)
{
if ( node.name != "module" )
throw Exception ( "internal tool error: Module created with non-<module> node" );
@ -126,6 +127,11 @@ Module::ProcessXMLSubElement ( const XMLElement& e,
dependencies.push_back ( new Dependency ( e, *this ) );
subs_invalid = true;
}
else if ( e.name == "importlibrary" )
{
importLibrary = new ImportLibrary ( e, *this );
subs_invalid = true;
}
if ( subs_invalid && e.subElements.size() > 0 )
throw InvalidBuildFileException (
e.location,
@ -142,6 +148,8 @@ Module::GetModuleType ( const string& location, const XMLAttribute& attribute )
return BuildTool;
if ( attribute.value == "staticlibrary" )
return StaticLibrary;
if ( attribute.value == "kernel" )
return Kernel;
if ( attribute.value == "kernelmodedll" )
return KernelModeDLL;
throw InvalidAttributeValueException ( location,
@ -158,6 +166,8 @@ Module::GetDefaultModuleExtension () const
return EXEPOSTFIX;
case StaticLibrary:
return ".a";
case Kernel:
return ".exe";
case KernelModeDLL:
return ".dll";
}
@ -166,7 +176,26 @@ Module::GetDefaultModuleExtension () const
}
string
Module::GetBasePath() const
Module::GetTargetName () const
{
return name + extension;
}
string
Module::GetDependencyPath () const
{
if ( type == KernelModeDLL )
return ssprintf ( "dk%snkm%slib%slib%s.a",
SSEP,
SSEP,
SSEP,
name.c_str () );
else
return GetPath ();
}
string
Module::GetBasePath () const
{
return path;
}
@ -174,7 +203,13 @@ Module::GetBasePath() const
string
Module::GetPath () const
{
return path + CSEP + name + extension;
return path + CSEP + GetTargetName ();
}
string
Module::GetPathWithPrefix ( const string& prefix ) const
{
return path + CSEP + prefix + GetTargetName ();
}
string
@ -371,3 +406,20 @@ Dependency::ProcessXML()
module.name.c_str(),
node.value.c_str() );
}
ImportLibrary::ImportLibrary ( const XMLElement& _node,
const Module& _module )
: node (_node),
module (_module)
{
const XMLAttribute* att = _node.GetAttribute ( "basename", false );
if (att != NULL)
basename = att->value;
else
basename = module.name;
att = _node.GetAttribute ( "definition", true );
assert (att);
definition = att->value;
}

View file

@ -30,6 +30,7 @@ class Library;
class Invoke;
class InvokeFile;
class Dependency;
class ImportLibrary;
class Project
{
@ -63,6 +64,7 @@ enum ModuleType
{
BuildTool,
StaticLibrary,
Kernel,
KernelModeDLL
};
@ -76,6 +78,7 @@ public:
std::string extension;
std::string path;
ModuleType type;
ImportLibrary* importLibrary;
std::vector<File*> files;
std::vector<Library*> libraries;
std::vector<Include*> includes;
@ -89,8 +92,11 @@ public:
~Module ();
ModuleType GetModuleType ( const std::string& location,
const XMLAttribute& attribute );
std::string GetTargetName () const;
std::string GetDependencyPath () const;
std::string GetBasePath() const;
std::string GetPath () const;
std::string GetPathWithPrefix ( const std::string& prefix ) const;
std::string GetTargets () const;
std::string GetInvocationTarget ( const int index ) const;
void ProcessXML();
@ -217,6 +223,21 @@ public:
void ProcessXML();
};
class ImportLibrary
{
public:
const XMLElement& node;
const Module& module;
std::string basename;
std::string definition;
ImportLibrary ( const XMLElement& _node,
const Module& module );
void ProcessXML ();
};
extern std::string
FixSeparator ( const std::string& s );