|
Re: problem when using filter for linking [message #664171 is a reply to message #664142] |
Thu, 07 April 2011 17:38   |
Sasha Slijepcevic Messages: 115 Registered: July 2009 |
Senior Member |
|
|
Patrick,
any target can return more than one command line from link(), and many targets have 'rm' command is a part of the return value.
I solved the similar problem by looking for a string that shows up in the linker command line:
var rescmd = "";
for (var i = 0; i < result.cmds.length; i++) {
if (result.cmds[i].match('lnk')) {
rescmd = rescmd + "date " + result.cmds[i] + "\n";
}
else {
rescmd = rescmd + result.cmds[i] + "\n";
}
}
return (rescmd);
In your case, 'lnk' could be some other string ('gcc').
[Updated on: Thu, 07 April 2011 17:39] Report message to a moderator
|
|
|
Re: problem when using filter for linking [message #666418 is a reply to message #664171] |
Wed, 20 April 2011 11:50  |
Patrick Geremia Messages: 79 Registered: July 2009 |
Member |
|
|
ok. Thanks. I got it to work.
The filter is desired to wotk with Parasoft insure++.
Here is my final version in case someone is interested.
============================================================ ============
function compile(container, target, goal, compArgs, result)
{
/*
print("compile filter ...");
print(" container: " + container);
print(" target : " + target.name);
print(" goal : " + goal);
print(" source : " + compArgs.srcPrefix + compArgs.base +
compArgs.srcSuffix);
*/
/* pre-pend a pre-processing step to each compile */
result.cmds = "insure " + result.cmds;
}
function link(container, cfgBase, prog, objList, linkArgs, result)
{
/*
print("link filter ...");
print(" container: " + container);
print(" cfg : " + cfgBase);
print(" prog : " + prog.name);
print(" objs : " + objList);
print(" linkArgs : " + linkArgs.files);
*/
var xdlFile;
var files=linkArgs.files.split(" ");
for (var i=0; i<files.length; i++)
{
if (files[i].match(".xdl"))
/* found xdl file */
{
xdlFile=files[i];
}
}
var cmdLines=result.cmds.split("\n");
var resLines = [];
for (var i = 0; i < cmdLines.length; i++)
{
print("old line = " + cmdLines[i]);
if (cmdLines[i].match("gcc"))
/* found gcc command line */
{
var cmds=cmdLines[i].split(" ");
var newCmd="";
for (var j = 0; j < cmds.length; j++)
{
if (cmds[j].match(xdlFile))
{
newCmd = newCmd + " -Xlinker " + cmds[j] ;
}
else
{
newCmd = newCmd + " " + cmds[j] ;
}
}
resLines[i]="insure " + newCmd;
}
else
{
resLines[i] = cmdLines[i] ;
}
print("new line = " + resLines[i]);
}
result.cmds=resLines.join("\n");
}
============================================================ ============
-------- Original Message --------
Subject: Re: problem when using filter for linking
From: Sasha Slijepcevic <sascha@ti.com>
To:
Date: Thu Apr 07 2011 19:38:54 GMT+0200 (CET)
> Patrick,
> any target can return more than one command line from link(), and many
> targets have 'rm' command is a part of the return value.
>
> I solved the similar problem by looking for a string that shows up in
> the linker command line:
>
> var rescmd = "";
> for (var i = 0; i < result.cmds.length; i++) {
> if (result.cmds[i].match('lnk')) {
> rescmd = rescmd + "date " + result.cmds[i] + "\n";
> }
> else {
> rescmd = rescmd + result.cmds[i] + "\n";
> }
> }
> return (rescmd);
>
> In your case, 'lnk' could be some other string.
|
|
|
Powered by
FUDForum. Page generated in 0.01708 seconds