mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 20:32:18 +00:00
parse, but ignore, <? ?> tags - eliminated duplicate code ala FixSeparator() - fix path separator issues
svn path=/branches/xmlbuildsystem/; revision=12868
This commit is contained in:
parent
f7257ee1be
commit
4e235dbcc9
8 changed files with 53 additions and 45 deletions
|
@ -251,6 +251,14 @@ XMLFile::get_token(string& token)
|
||||||
else
|
else
|
||||||
tokend += 3;
|
tokend += 3;
|
||||||
}
|
}
|
||||||
|
else if ( !strncmp ( _p, "<?", 2 ) )
|
||||||
|
{
|
||||||
|
tokend = strstr ( _p, "?>" );
|
||||||
|
if ( !tokend )
|
||||||
|
tokend = _end;
|
||||||
|
else
|
||||||
|
tokend += 2;
|
||||||
|
}
|
||||||
else if ( *_p == '<' )
|
else if ( *_p == '<' )
|
||||||
{
|
{
|
||||||
tokend = strchr ( _p, '>' );
|
tokend = strchr ( _p, '>' );
|
||||||
|
@ -456,7 +464,9 @@ XMLParse(XMLFile& f,
|
||||||
return NULL;
|
return NULL;
|
||||||
bool end_tag;
|
bool end_tag;
|
||||||
|
|
||||||
while ( token[0] != '<' || !strncmp ( token.c_str(), "<!--", 4 ) )
|
while ( token[0] != '<'
|
||||||
|
|| !strncmp ( token.c_str(), "<!--", 4 )
|
||||||
|
|| !strncmp ( token.c_str(), "<?", 2 ) )
|
||||||
{
|
{
|
||||||
if ( token[0] != '<' )
|
if ( token[0] != '<' )
|
||||||
throw XMLSyntaxErrorException ( f.Location(),
|
throw XMLSyntaxErrorException ( f.Location(),
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
#include "../../pch.h"
|
#include "../../pch.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "../../rbuild.h"
|
#include "../../rbuild.h"
|
||||||
#include "mingw.h"
|
#include "mingw.h"
|
||||||
|
@ -162,30 +163,30 @@ MingwKernelModuleHandler::GenerateKernelModuleTarget ( Module& module )
|
||||||
archiveFilename.c_str (),
|
archiveFilename.c_str (),
|
||||||
importLibraryDependencies.c_str () );
|
importLibraryDependencies.c_str () );
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t${gcc} -Wl,--base-file,%s/base.tmp -o %s/junk.tmp %s %s\n",
|
"\t${gcc} -Wl,--base-file,%s" SSEP "base.tmp -o %s" SSEP "junk.tmp %s %s\n",
|
||||||
workingDirectory.c_str (),
|
workingDirectory.c_str (),
|
||||||
workingDirectory.c_str (),
|
workingDirectory.c_str (),
|
||||||
archiveFilename.c_str (),
|
archiveFilename.c_str (),
|
||||||
importLibraryDependencies.c_str () );
|
importLibraryDependencies.c_str () );
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t${rm} %s/junk.tmp\n",
|
"\t${rm} %s" SSEP "junk.tmp\n",
|
||||||
workingDirectory.c_str () );
|
workingDirectory.c_str () );
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t${dlltool} --dllname %s --base-file %s/base.tmp --output-exp %s/temp.exp --kill-at\n",
|
"\t${dlltool} --dllname %s --base-file %s" SSEP "base.tmp --output-exp %s" SSEP "temp.exp --kill-at\n",
|
||||||
module.GetPath ().c_str (),
|
module.GetPath ().c_str (),
|
||||||
workingDirectory.c_str (),
|
workingDirectory.c_str (),
|
||||||
workingDirectory.c_str ());
|
workingDirectory.c_str ());
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t${rm} %s/base.tmp\n",
|
"\t${rm} %s" SSEP "base.tmp\n",
|
||||||
workingDirectory.c_str () );
|
workingDirectory.c_str () );
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t${ld} -Wl,%s/temp.exp -o %s %s %s\n",
|
"\t${ld} -Wl,%s" SSEP "temp.exp -o %s %s %s\n",
|
||||||
workingDirectory.c_str (),
|
workingDirectory.c_str (),
|
||||||
module.GetPath ().c_str (),
|
module.GetPath ().c_str (),
|
||||||
archiveFilename.c_str (),
|
archiveFilename.c_str (),
|
||||||
importLibraryDependencies.c_str () );
|
importLibraryDependencies.c_str () );
|
||||||
fprintf ( fMakefile,
|
fprintf ( fMakefile,
|
||||||
"\t${rm} %s/temp.exp\n",
|
"\t${rm} %s" SSEP "temp.exp\n",
|
||||||
workingDirectory.c_str () );
|
workingDirectory.c_str () );
|
||||||
|
|
||||||
GenerateArchiveTarget ( module );
|
GenerateArchiveTarget ( module );
|
||||||
|
|
|
@ -8,37 +8,18 @@
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#define EXEPOSTFIX ".exe"
|
|
||||||
#define SEP "\\"
|
|
||||||
string
|
string
|
||||||
FixSeparator ( const string& s )
|
FixSeparator ( const string& s )
|
||||||
{
|
{
|
||||||
string s2(s);
|
string s2(s);
|
||||||
char* p = strchr ( &s2[0], '/' );
|
char* p = strchr ( &s2[0], CBAD_SEP );
|
||||||
while ( p )
|
while ( p )
|
||||||
{
|
{
|
||||||
*p++ = '\\';
|
*p++ = CSEP;
|
||||||
p = strchr ( p, '/' );
|
p = strchr ( p, CBAD_SEP );
|
||||||
}
|
}
|
||||||
return s2;
|
return s2;
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define EXEPOSTFIX
|
|
||||||
#define SEP "/"
|
|
||||||
string
|
|
||||||
FixSeparator ( const string& s )
|
|
||||||
{
|
|
||||||
string s2(s);
|
|
||||||
char* p = strchr ( &s2[0], '\\' );
|
|
||||||
while ( p )
|
|
||||||
{
|
|
||||||
*p++ = '/';
|
|
||||||
p = strchr ( p, '\\' );
|
|
||||||
}
|
|
||||||
return s2;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Module::Module ( Project* project,
|
Module::Module ( Project* project,
|
||||||
const XMLElement& moduleNode,
|
const XMLElement& moduleNode,
|
||||||
|
@ -68,7 +49,7 @@ Module::ProcessXML ( const XMLElement& e,
|
||||||
string subpath ( path );
|
string subpath ( path );
|
||||||
if ( e.name == "file" && e.value.size () )
|
if ( e.name == "file" && e.value.size () )
|
||||||
{
|
{
|
||||||
files.push_back ( new File ( path + "/" + e.value ) );
|
files.push_back ( new File ( path + CSEP + e.value ) );
|
||||||
}
|
}
|
||||||
else if ( e.name == "library" && e.value.size () )
|
else if ( e.name == "library" && e.value.size () )
|
||||||
{
|
{
|
||||||
|
@ -78,7 +59,7 @@ Module::ProcessXML ( const XMLElement& e,
|
||||||
{
|
{
|
||||||
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
||||||
assert(att);
|
assert(att);
|
||||||
subpath = path + "/" + att->value;
|
subpath = path + CSEP + att->value;
|
||||||
}
|
}
|
||||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||||
ProcessXML ( *e.subElements[i], subpath );
|
ProcessXML ( *e.subElements[i], subpath );
|
||||||
|
@ -100,7 +81,7 @@ Module::GetModuleType ( const XMLAttribute& attribute )
|
||||||
string
|
string
|
||||||
Module::GetPath ()
|
Module::GetPath ()
|
||||||
{
|
{
|
||||||
return FixSeparator (path) + SEP + name + EXEPOSTFIX;
|
return FixSeparator (path) + CSEP + name + EXEPOSTFIX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,12 @@ Project::ReadXml ()
|
||||||
{
|
{
|
||||||
Path path;
|
Path path;
|
||||||
|
|
||||||
head = XMLParse ( xmlfile, path );
|
do
|
||||||
if ( !head )
|
|
||||||
throw InvalidBuildFileException ( "Document contains no 'project' tag." );
|
|
||||||
|
|
||||||
if ( head->name != "project" )
|
|
||||||
{
|
{
|
||||||
throw InvalidBuildFileException ( "Expected 'project', got '%s'.",
|
head = XMLParse ( xmlfile, path );
|
||||||
head->name.c_str());
|
if ( !head )
|
||||||
}
|
throw InvalidBuildFileException ( "Document contains no 'project' tag." );
|
||||||
|
} while ( head->name != "project" );
|
||||||
|
|
||||||
this->ProcessXML ( *head, "." );
|
this->ProcessXML ( *head, "." );
|
||||||
}
|
}
|
||||||
|
@ -73,7 +70,7 @@ Project::ProcessXML ( const XMLElement& e, const string& path )
|
||||||
{
|
{
|
||||||
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
const XMLAttribute* att = e.GetAttribute ( "name", true );
|
||||||
assert(att);
|
assert(att);
|
||||||
subpath = path + "/" + att->value;
|
subpath = path + CSEP + att->value;
|
||||||
}
|
}
|
||||||
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
for ( size_t i = 0; i < e.subElements.size (); i++ )
|
||||||
ProcessXML ( *e.subElements[i], subpath );
|
ProcessXML ( *e.subElements[i], subpath );
|
||||||
|
|
|
@ -7,6 +7,20 @@
|
||||||
#include "exception.h"
|
#include "exception.h"
|
||||||
#include "XML.h"
|
#include "XML.h"
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define EXEPOSTFIX ".exe"
|
||||||
|
#define CSEP '\\'
|
||||||
|
#define CBAD_SEP '/'
|
||||||
|
#define SSEP "\\"
|
||||||
|
#define SBAD_SEP "/"
|
||||||
|
#else
|
||||||
|
#define EXEPOSTFIX
|
||||||
|
#define CSEP '/'
|
||||||
|
#define CBAD_SEP '\\'
|
||||||
|
#define SSEP "/"
|
||||||
|
#define SBAD_SEP "\\"
|
||||||
|
#endif
|
||||||
|
|
||||||
class Project;
|
class Project;
|
||||||
class Module;
|
class Module;
|
||||||
class File;
|
class File;
|
||||||
|
@ -78,4 +92,7 @@ public:
|
||||||
Library ( const std::string& _name );
|
Library ( const std::string& _name );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern std::string
|
||||||
|
FixSeparator ( const std::string& s );
|
||||||
|
|
||||||
#endif /* __RBUILD_H */
|
#endif /* __RBUILD_H */
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<?xml version="1.0" ?>
|
||||||
<project name="Project" makefile="Makefile">
|
<project name="Project" makefile="Makefile">
|
||||||
<directory name="dir1">
|
<directory name="dir1">
|
||||||
<module name="module1" type="buildtool">
|
<module name="module1" type="buildtool">
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
<?xml version="1.0" ?>
|
||||||
<project name="Project" makefile="Makefile">
|
<project name="Project" makefile="Makefile">
|
||||||
<directory name="dir1">
|
<directory name="dir1">
|
||||||
<module name="module1" type="buildtool">
|
<module name="module1" type="buildtool">
|
||||||
|
|
|
@ -11,16 +11,16 @@ void ModuleTest::Run()
|
||||||
Module& module1 = *project.modules[0];
|
Module& module1 = *project.modules[0];
|
||||||
IS_TRUE(module1.type == BuildTool);
|
IS_TRUE(module1.type == BuildTool);
|
||||||
ARE_EQUAL(2, module1.files.size());
|
ARE_EQUAL(2, module1.files.size());
|
||||||
ARE_EQUAL("./dir1/file1.c", module1.files[0]->name);
|
ARE_EQUAL("." SSEP "dir1" SSEP "file1.c", module1.files[0]->name);
|
||||||
ARE_EQUAL("./dir1/file2.c", module1.files[1]->name);
|
ARE_EQUAL("." SSEP "dir1" SSEP "file2.c", module1.files[1]->name);
|
||||||
|
|
||||||
ARE_EQUAL(0, module1.libraries.size());
|
ARE_EQUAL(0, module1.libraries.size());
|
||||||
|
|
||||||
Module& module2 = *project.modules[1];
|
Module& module2 = *project.modules[1];
|
||||||
IS_TRUE(module2.type == KernelModeDLL);
|
IS_TRUE(module2.type == KernelModeDLL);
|
||||||
ARE_EQUAL(2, module2.files.size());
|
ARE_EQUAL(2, module2.files.size());
|
||||||
ARE_EQUAL("./dir2/file3.c", module2.files[0]->name);
|
ARE_EQUAL("." SSEP "dir2" SSEP "file3.c", module2.files[0]->name);
|
||||||
ARE_EQUAL("./dir2/file4.c", module2.files[1]->name);
|
ARE_EQUAL("." SSEP "dir2" SSEP "file4.c", module2.files[1]->name);
|
||||||
|
|
||||||
ARE_EQUAL(1, module2.libraries.size());
|
ARE_EQUAL(1, module2.libraries.size());
|
||||||
Library& library1 = *module2.libraries[0];
|
Library& library1 = *module2.libraries[0];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue