Modified: trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
Modified: trunk/reactos/tools/rbuild/doc/rbuild.txt
Added: trunk/reactos/tools/rbuild/linkerscript.cpp
Modified: trunk/reactos/tools/rbuild/module.cpp
Modified: trunk/reactos/tools/rbuild/rbuild.h
Modified: trunk/reactos/tools/rbuild/rbuild.mak
--- trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-10-24 18:47:33 UTC (rev 18757)
+++ trunk/reactos/tools/rbuild/backend/mingw/modulehandler.cpp 2005-10-24 19:38:58 UTC (rev 18758)
@@ -1417,12 +1417,18 @@
{
string target ( GetTargetMacro ( module ) );
string target_folder ( GetDirectory ( GetTargetFilename ( module, NULL ) ) );
- string def_file = GetDefinitionFilename ();
+ string definitionFilename = GetDefinitionFilename ();
+ string linkerScriptArgument;
+ if ( module.linkerScript != NULL )
+ linkerScriptArgument = ssprintf ( "-Wl,-T,%s", module.linkerScript->directory.c_str () );
+ else
+ linkerScriptArgument = "";
+
fprintf ( fMakefile,
"%s: %s %s $(RSYM_TARGET) $(PEFIXUP_TARGET) | %s\n",
target.c_str (),
- def_file.c_str (),
+ definitionFilename.c_str (),
dependencies.c_str (),
target_folder.c_str () );
fprintf ( fMakefile, "\t$(ECHO_LD)\n" );
@@ -1432,19 +1438,20 @@
{
string temp_exp = ros_temp + module.name + ".temp.exp";
CLEAN_FILE ( temp_exp );
-
+
string killAt = module.mangledSymbols ? "" : "--kill-at";
fprintf ( fMakefile,
"\t${dlltool} --dllname %s --def %s --output-exp %s %s\n",
targetName.c_str (),
- def_file.c_str (),
+ definitionFilename.c_str (),
temp_exp.c_str (),
killAt.c_str () );
fprintf ( fMakefile,
- "\t%s %s %s -o %s %s %s %s\n",
+ "\t%s %s %s -o %s %s %s %s %s\n",
linker.c_str (),
linkerParameters.c_str (),
+ linkerScriptArgument.c_str (),
temp_exp.c_str (),
target.c_str (),
objectsMacro.c_str (),
@@ -1463,9 +1470,10 @@
else
{
fprintf ( fMakefile,
- "\t%s %s -o %s %s %s %s\n",
+ "\t%s %s -o %s %s %s %s %s\n",
linker.c_str (),
linkerParameters.c_str (),
+ linkerScriptArgument.c_str (),
target.c_str (),
objectsMacro.c_str (),
libsMacro.c_str (),
--- trunk/reactos/tools/rbuild/doc/rbuild.txt 2005-10-24 18:47:33 UTC (rev 18757)
+++ trunk/reactos/tools/rbuild/doc/rbuild.txt 2005-10-24 19:38:58 UTC (rev 18758)
@@ -129,7 +129,7 @@
None.
Elements:
- bootstrap, component, define, dependency, directory, file, if, importlibrary, include, invoke, library, property.
+ bootstrap, component, define, dependency, directory, file, if, importlibrary, include, invoke, library, linkerscript, property.
Module types
@@ -466,6 +466,23 @@
None.
+Linkerscript
+------------
+A linkerscript element specifies the filename of a binutils linker script.
+
+Syntax:
+ <linkerscript base="mymodule">MyLinkerScript</linkerscript>
+
+Attributes:
+ base - Module which the value of this element is relative to. This attribute is optional. If left out, the linker script is relative to the position of the top-level xml build file.
+
+Value:
+ Relative linker script filename.
+
+Elements:
+ None.
+
+
Property
--------
A property element specifies the name and value of a property that can be used for conditional processing of the xml build file.
--- trunk/reactos/tools/rbuild/linkerscript.cpp 2005-10-24 18:47:33 UTC (rev 18757)
+++ trunk/reactos/tools/rbuild/linkerscript.cpp 2005-10-24 19:38:58 UTC (rev 18758)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2005 Casper S. Hornstrup
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+#include "pch.h"
+#include <assert.h>
+
+#include "rbuild.h"
+
+using std::string;
+using std::vector;
+
+LinkerScript::LinkerScript ( const Project& project,
+ const Module* module,
+ const XMLElement& node )
+ : project ( project ),
+ module ( module ),
+ node ( node ),
+ baseModule ( NULL )
+{
+}
+
+LinkerScript::~LinkerScript ()
+{
+}
+
+void
+LinkerScript::ProcessXML()
+{
+ const XMLAttribute* att;
+ att = node.GetAttribute ( "base",
+ false );
+ if ( att )
+ {
+ bool referenceResolved = false;
+ if ( att->value == project.name )
+ {
+ basePath = ".";
+ referenceResolved = true;
+ }
+ else
+ {
+ const Module* base = project.LocateModule ( att->value );
+ if ( base != NULL )
+ {
+ baseModule = base;
+ basePath = base->GetBasePath ();
+ referenceResolved = true;
+ }
+ }
+ if ( !referenceResolved )
+ throw InvalidBuildFileException (
+ node.location,
+ "<linkerscript> attribute 'base' references non-existant project or module '%s'",
+ att->value.c_str() );
+ directory = NormalizeFilename ( basePath + SSEP + node.value );
+ }
+ else
+ directory = NormalizeFilename ( node.value );
+}
Property changes on: trunk/reactos/tools/rbuild/linkerscript.cpp
___________________________________________________________________
Name: svn:eol-style
+ native
--- trunk/reactos/tools/rbuild/module.cpp 2005-10-24 18:47:33 UTC (rev 18757)
+++ trunk/reactos/tools/rbuild/module.cpp 2005-10-24 19:38:58 UTC (rev 18758)
@@ -211,6 +211,7 @@
node (moduleNode),
importLibrary (NULL),
bootstrap (NULL),
+ linkerScript (NULL),
pch (NULL),
cplusplus (false),
host (HostDefault)
@@ -372,6 +373,8 @@
delete linkerFlags[i];
for ( i = 0; i < stubbedComponents.size(); i++ )
delete stubbedComponents[i];
+ if ( linkerScript )
+ delete linkerScript;
if ( pch )
delete pch;
}
@@ -409,6 +412,8 @@
for ( i = 0; i < stubbedComponents.size(); i++ )
stubbedComponents[i]->ProcessXML();
non_if_data.ProcessXML();
+ if ( linkerScript )
+ linkerScript->ProcessXML();
if ( pch )
pch->ProcessXML();
}
@@ -556,6 +561,15 @@
linkerFlags.push_back ( new LinkerFlag ( project, this, e ) );
subs_invalid = true;
}
+ else if ( e.name == "linkerscript" )
+ {
+ if ( linkerScript )
+ throw InvalidBuildFileException (
+ e.location,
+ "Only one <linkerscript> is valid per module" );
+ linkerScript = new LinkerScript ( project, this, e );
+ subs_invalid = true;
+ }
else if ( e.name == "component" )
{
stubbedComponents.push_back ( new StubbedComponent ( this, e ) );
--- trunk/reactos/tools/rbuild/rbuild.h 2005-10-24 18:47:33 UTC (rev 18757)
+++ trunk/reactos/tools/rbuild/rbuild.h 2005-10-24 19:38:58 UTC (rev 18758)
@@ -73,6 +73,7 @@
class If;
class CompilerFlag;
class LinkerFlag;
+class LinkerScript;
class Property;
class TestSupportCode;
class WineResource;
@@ -230,6 +231,7 @@
std::vector<CompilerFlag*> compilerFlags;
std::vector<LinkerFlag*> linkerFlags;
std::vector<StubbedComponent*> stubbedComponents;
+ LinkerScript* linkerScript;
PchFile* pch;
bool cplusplus;
std::string prefix;
@@ -476,6 +478,24 @@
};
+class LinkerScript
+{
+public:
+ const Project& project;
+ const Module* module;
+ const XMLElement& node;
+ const Module* baseModule;
+ std::string directory;
+ std::string basePath;
+
+ LinkerScript ( const Project& project,
+ const Module* module,
+ const XMLElement& node );
+ ~LinkerScript ();
+ void ProcessXML();
+};
+
+
class Property
{
public:
--- trunk/reactos/tools/rbuild/rbuild.mak 2005-10-24 18:47:33 UTC (rev 18757)
+++ trunk/reactos/tools/rbuild/rbuild.mak 2005-10-24 19:38:58 UTC (rev 18758)
@@ -163,6 +163,7 @@
include.cpp \
installfile.cpp \
linkerflag.cpp \
+ linkerscript.cpp \
module.cpp \
project.cpp \
ssprintf.cpp \
@@ -299,6 +300,10 @@
$(ECHO_CC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+$(RBUILD_INT_)linkerscript.o: $(RBUILD_BASE_)linkerscript.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
+ $(ECHO_CC)
+ ${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@
+
$(RBUILD_INT_)module.o: $(RBUILD_BASE_)module.cpp $(RBUILD_HEADERS) | $(RBUILD_INT)
$(ECHO_CC)
${host_gpp} $(RBUILD_HOST_CXXFLAGS) -c $< -o $@