mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 09:12:56 +00:00
* Generate kernel
* Add static library module type * Add build script for kjs svn path=/branches/xmlbuildsystem/; revision=12856
This commit is contained in:
parent
b1ec82cd59
commit
f7257ee1be
9 changed files with 121 additions and 12 deletions
|
@ -4,6 +4,9 @@
|
|||
<file>depends.c</file>
|
||||
</module>
|
||||
</directory>
|
||||
<directory name="lib">
|
||||
<xi:include href="lib/directory.xml" />
|
||||
</directory>
|
||||
<directory name="ntoskrnl">
|
||||
<xi:include href="ntoskrnl/module.xml" />
|
||||
</directory>
|
||||
|
|
3
reactos/lib/directory.xml
Normal file
3
reactos/lib/directory.xml
Normal file
|
@ -0,0 +1,3 @@
|
|||
<directory name="kjs">
|
||||
<xi:include href="kjs/module.xml" />
|
||||
</directory>
|
42
reactos/lib/kjs/module.xml
Normal file
42
reactos/lib/kjs/module.xml
Normal file
|
@ -0,0 +1,42 @@
|
|||
<module name="kjs" type="staticlibrary">
|
||||
<include>.</include>
|
||||
<include>./src</include>
|
||||
<include>./include</include>
|
||||
<directory name="ksrc">
|
||||
<file>setjmp.S</file>
|
||||
<file>longjmp.S</file>
|
||||
<file>alloc.c</file>
|
||||
<file>bc.c</file>
|
||||
<file>b_core.c</file>
|
||||
<file>b_file.c</file>
|
||||
<file>b_func.c</file>
|
||||
<file>b_regexp.c</file>
|
||||
<file>b_system.c</file>
|
||||
<file>compat.c</file>
|
||||
<file>debug.c</file>
|
||||
<file>iostream.c</file>
|
||||
<file>js.c</file>
|
||||
<file>kjs.c</file>
|
||||
<file>mrgsort.c</file>
|
||||
<file>object.c</file>
|
||||
<file>regex.c</file>
|
||||
<file>vm.c</file>
|
||||
<file>vmjumps.c</file>
|
||||
<file>vmswitch.c</file>
|
||||
<file>vmswt0.c</file>
|
||||
<file>longjmp.c</file>
|
||||
</directory>
|
||||
<directory name="src">
|
||||
<file>b_array.c</file>
|
||||
<file>b_bool.c</file>
|
||||
<file>b_object.c</file>
|
||||
<file>b_number.c</file>
|
||||
<file>b_string.c</file>
|
||||
<file>b_vm.c</file>
|
||||
<file>compiler.c</file>
|
||||
<file>crc32.c</file>
|
||||
<file>dl_dummy.c</file>
|
||||
<file>heap.c</file>
|
||||
<file>utils.c</file>
|
||||
</directory>
|
||||
</module>
|
|
@ -61,9 +61,11 @@ MingwBackend::GenerateHeader ()
|
|||
void
|
||||
MingwBackend::GenerateGlobalVariables ()
|
||||
{
|
||||
fprintf ( fMakefile, "rm = del /y\n" );
|
||||
fprintf ( fMakefile, "gcc = gcc\n" );
|
||||
fprintf ( fMakefile, "ld = ld\n" );
|
||||
fprintf ( fMakefile, "ar = ar\n" );
|
||||
fprintf ( fMakefile, "dlltool = dlltool\n" );
|
||||
fprintf ( fMakefile, "\n" );
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,12 @@ MingwModuleHandler::MingwModuleHandler ( FILE* fMakefile )
|
|||
{
|
||||
}
|
||||
|
||||
string
|
||||
MingwModuleHandler::GetWorkingDirectory ()
|
||||
{
|
||||
return ".";
|
||||
}
|
||||
|
||||
string
|
||||
MingwModuleHandler::ReplaceExtension ( string filename,
|
||||
string newExtension )
|
||||
|
@ -30,7 +36,7 @@ MingwModuleHandler::GetModuleArchiveFilename ( Module& module )
|
|||
}
|
||||
|
||||
string
|
||||
MingwModuleHandler::GetModuleLibraryDependencies ( Module& module )
|
||||
MingwModuleHandler::GetImportLibraryDependencies ( Module& module )
|
||||
{
|
||||
if ( module.libraries.size () == 0 )
|
||||
return "";
|
||||
|
@ -40,7 +46,9 @@ MingwModuleHandler::GetModuleLibraryDependencies ( Module& module )
|
|||
{
|
||||
if ( dependencies.size () > 0 )
|
||||
dependencies += " ";
|
||||
dependencies += module.libraries[i]->name;
|
||||
Module* importedModule = module.project->LocateModule ( module.libraries[i]->name );
|
||||
assert ( importedModule != NULL );
|
||||
dependencies += importedModule->GetPath ().c_str ();
|
||||
}
|
||||
return dependencies;
|
||||
}
|
||||
|
@ -96,8 +104,8 @@ MingwModuleHandler::GenerateObjectFileTargets ( Module& module )
|
|||
string objectFilename = GetObjectFilename ( sourceFilename );
|
||||
fprintf ( fMakefile,
|
||||
"%s: %s\n",
|
||||
sourceFilename.c_str (),
|
||||
objectFilename.c_str() );
|
||||
objectFilename.c_str (),
|
||||
sourceFilename.c_str() );
|
||||
fprintf ( fMakefile,
|
||||
"\t${gcc} -c %s -o %s\n",
|
||||
sourceFilename.c_str (),
|
||||
|
@ -146,10 +154,40 @@ MingwKernelModuleHandler::Process ( Module& module )
|
|||
void
|
||||
MingwKernelModuleHandler::GenerateKernelModuleTarget ( Module& module )
|
||||
{
|
||||
fprintf ( fMakefile, "%s: %s\n",
|
||||
string workingDirectory = GetWorkingDirectory ( );
|
||||
string archiveFilename = GetModuleArchiveFilename ( module );
|
||||
string importLibraryDependencies = GetImportLibraryDependencies ( module );
|
||||
fprintf ( fMakefile, "%s: %s %s\n",
|
||||
module.GetPath ().c_str (),
|
||||
GetModuleLibraryDependencies ( module ).c_str () );
|
||||
fprintf ( fMakefile, "\t\n\n" );
|
||||
archiveFilename.c_str (),
|
||||
importLibraryDependencies.c_str () );
|
||||
fprintf ( fMakefile,
|
||||
"\t${gcc} -Wl,--base-file,%s/base.tmp -o %s/junk.tmp %s %s\n",
|
||||
workingDirectory.c_str (),
|
||||
workingDirectory.c_str (),
|
||||
archiveFilename.c_str (),
|
||||
importLibraryDependencies.c_str () );
|
||||
fprintf ( fMakefile,
|
||||
"\t${rm} %s/junk.tmp\n",
|
||||
workingDirectory.c_str () );
|
||||
fprintf ( fMakefile,
|
||||
"\t${dlltool} --dllname %s --base-file %s/base.tmp --output-exp %s/temp.exp --kill-at\n",
|
||||
module.GetPath ().c_str (),
|
||||
workingDirectory.c_str (),
|
||||
workingDirectory.c_str ());
|
||||
fprintf ( fMakefile,
|
||||
"\t${rm} %s/base.tmp\n",
|
||||
workingDirectory.c_str () );
|
||||
fprintf ( fMakefile,
|
||||
"\t${ld} -Wl,%s/temp.exp -o %s %s %s\n",
|
||||
workingDirectory.c_str (),
|
||||
module.GetPath ().c_str (),
|
||||
archiveFilename.c_str (),
|
||||
importLibraryDependencies.c_str () );
|
||||
fprintf ( fMakefile,
|
||||
"\t${rm} %s/temp.exp\n",
|
||||
workingDirectory.c_str () );
|
||||
|
||||
GenerateArchiveTarget ( module );
|
||||
GenerateObjectFileTargets ( module );
|
||||
}
|
||||
|
|
|
@ -10,10 +10,11 @@ public:
|
|||
virtual bool CanHandleModule ( Module& module ) = 0;
|
||||
virtual void Process ( Module& module ) = 0;
|
||||
protected:
|
||||
std::string MingwModuleHandler::GetWorkingDirectory ();
|
||||
std::string ReplaceExtension ( std::string filename,
|
||||
std::string newExtension );
|
||||
std::string GetModuleArchiveFilename ( Module& module );
|
||||
std::string GetModuleLibraryDependencies ( Module& module );
|
||||
std::string GetImportLibraryDependencies ( Module& module );
|
||||
std::string GetSourceFilenames ( Module& module );
|
||||
std::string GetObjectFilename ( std::string sourceFilename );
|
||||
std::string GetObjectFilenames ( Module& module );
|
||||
|
|
|
@ -40,10 +40,12 @@ FixSeparator ( const string& s )
|
|||
}
|
||||
#endif
|
||||
|
||||
Module::Module ( const XMLElement& moduleNode,
|
||||
Module::Module ( Project* project,
|
||||
const XMLElement& moduleNode,
|
||||
const string& moduleName,
|
||||
const string& modulePath )
|
||||
: node(moduleNode),
|
||||
: project(project),
|
||||
node(moduleNode),
|
||||
name(moduleName),
|
||||
path(modulePath)
|
||||
{
|
||||
|
@ -87,6 +89,8 @@ Module::GetModuleType ( const XMLAttribute& attribute )
|
|||
{
|
||||
if ( attribute.value == "buildtool" )
|
||||
return BuildTool;
|
||||
if ( attribute.value == "staticlibrary" )
|
||||
return StaticLibrary;
|
||||
if ( attribute.value == "kernelmodedll" )
|
||||
return KernelModeDLL;
|
||||
throw InvalidAttributeValueException ( attribute.name,
|
||||
|
|
|
@ -64,7 +64,7 @@ Project::ProcessXML ( const XMLElement& e, const string& path )
|
|||
{
|
||||
att = e.GetAttribute ( "name", true );
|
||||
assert(att);
|
||||
Module* module = new Module ( e, att->value, path );
|
||||
Module* module = new Module ( this, e, att->value, path );
|
||||
modules.push_back ( module );
|
||||
module->ProcessXML ( e, path );
|
||||
return;
|
||||
|
@ -78,3 +78,15 @@ Project::ProcessXML ( const XMLElement& e, const string& path )
|
|||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||
ProcessXML ( *e.subElements[i], subpath );
|
||||
}
|
||||
|
||||
Module*
|
||||
Project::LocateModule ( string name )
|
||||
{
|
||||
for ( size_t i = 0; i < modules.size (); i++ )
|
||||
{
|
||||
if (modules[i]->name == name)
|
||||
return modules[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ public:
|
|||
~Project ();
|
||||
void ProcessXML ( const XMLElement& e,
|
||||
const std::string& path );
|
||||
Module* LocateModule ( std::string name );
|
||||
private:
|
||||
void ReadXml ();
|
||||
XMLFile xmlfile;
|
||||
|
@ -34,12 +35,14 @@ private:
|
|||
enum ModuleType
|
||||
{
|
||||
BuildTool,
|
||||
StaticLibrary,
|
||||
KernelModeDLL
|
||||
};
|
||||
|
||||
class Module
|
||||
{
|
||||
public:
|
||||
Project* project;
|
||||
const XMLElement& node;
|
||||
std::string name;
|
||||
std::string path;
|
||||
|
@ -47,7 +50,8 @@ public:
|
|||
std::vector<File*> files;
|
||||
std::vector<Library*> libraries;
|
||||
|
||||
Module ( const XMLElement& moduleNode,
|
||||
Module ( Project* project,
|
||||
const XMLElement& moduleNode,
|
||||
const std::string& moduleName,
|
||||
const std::string& modulePath );
|
||||
~Module();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue