Skip to content
Permalink
Browse files
allow users to specifiy additional arguments to candle and light. PR …
…46968

git-svn-id: https://svn.apache.org/repos/asf/ant/antlibs/dotnet/trunk@763647 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
bodewig committed Apr 9, 2009
1 parent b443383 commit ced10d8eea422bb62381789d56fe29a182df02ed
Showing 3 changed files with 84 additions and 10 deletions.
@@ -38,6 +38,10 @@
</properties>

<release version="SVN trunk" date="unpublished">
<action type="update" issue="46968">
The wix task has new nested elements that allow users to send
addtional command line arguments to candle and light.
</action>
<action type="fix">
The include and exclude arguments to NUnit were broken (they
had a leading ",").
@@ -8,7 +8,7 @@
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -101,13 +101,36 @@ <h4>moresources</h4>
are newer than the expected target, the task won't do
anything.</p>

<h4>candleParameters</h4>
<h4>candleParameter</h4>

<p>Specifies preprocessor parameters for candle</p>

<p><code>candleParameters</code> has two required attributes.
<p><code>candleParameter</code> has two required attributes.
name and value that specify name and value of a parameter.</p>

<h4>candleArg</h4>

<p>Specifies additional arguments for candle</p>

<p><code>candleArg</code> is
a <a href="http://ant.apache.org/manual/using.html#arg">command
line argument</a>.</p>

<h4>lightParameter</h4>

<p>Specifies parameters for light</p>

<p><code>lightParameter</code> has two required attributes.
name and value that specify name and value of a parameter.</p>

<h4>lightArg</h4>

<p>Specifies additional arguments for light</p>

<p><code>lightArg</code> is
a <a href="http://ant.apache.org/manual/using.html#arg">command
line argument</a>.</p>

<h3>Examples</h3>

<p>Create <code>product.wixobj</code> from <code>product.wxs</code>:</p>
@@ -212,4 +235,4 @@ <h3>Examples</h3>
<code>product.msi</code> is newer than all files, the task won't
do anything.</p>
</body>
</html>
</html>
@@ -23,6 +23,7 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.EnumeratedAttribute;
import org.apache.tools.ant.types.FileSet;

@@ -83,10 +84,25 @@ public class WixTask extends Task {
*/
private File wixobjDestDir = null;

/**
* addtional command line arguments for candle.
*/
private Commandline candleCmdl = new Commandline();

/**
* list of parameters for the preprocessor.
*/
private ArrayList parameters = new ArrayList();
private ArrayList candleParameters = new ArrayList();

/**
* addtional command line arguments for light.
*/
private Commandline lightCmdl = new Commandline();

/**
* list of parameters for the "compiler".
*/
private ArrayList lightParameters = new ArrayList();

public WixTask() {
super();
@@ -172,7 +188,32 @@ public void setWixobjDestDir(File f) {
* A parameter to pass to candle.exe.
*/
public final void addCandleParameter(AbstractBuildTask.Property t) {
parameters.add(t);
candleParameters.add(t);
}

/**
* A parameter to pass to light.exe.
*/
public final void addLightParameter(AbstractBuildTask.Property t) {
lightParameters.add(t);
}

/**
* Adds a command-line argument for light.exe.
*
* @return new command line argument created.
*/
public Commandline.Argument createLightArg() {
return lightCmdl.createArgument();
}

/**
* Adds a command-line argument for candle.exe.
*
* @return new command line argument created.
*/
public Commandline.Argument createCandleArg() {
return candleCmdl.createArgument();
}

public void execute() {
@@ -270,14 +311,16 @@ private void doLight(Collection lightSources,
* Run candle passing all files of the collection on the command line.
*/
private void runCandle(Collection s) {
run(wixExecutable("candle.exe"), s, null, wixobjDestDir, parameters);
run(wixExecutable("candle.exe"), s, null, wixobjDestDir,
candleParameters, candleCmdl);
}

/**
* Run light passing all files of the collection on the command line.
*/
private void runLight(Collection s) {
run(wixExecutable("light.exe"), s, target, null, Collections.EMPTY_LIST);
run(wixExecutable("light.exe"), s, target, null,
lightParameters, lightCmdl);
}

/**
@@ -294,7 +337,7 @@ private String wixExecutable(String name) {
* on the command line - potentially adding an /out parameter.
*/
private void run(String executable, Collection s, File target,
File runInDir, Collection params) {
File runInDir, Collection params, Commandline cmdl) {
DotNetExecTask exec = DotNetExecTask.getTask(this, vm,
executable, null);
if (runInDir != null) {
@@ -315,13 +358,17 @@ private void run(String executable, Collection s, File target,
exec.createArg().setValue("/out");
exec.createArg().setValue(target.getAbsolutePath());
}

iter = params.iterator();
while (iter.hasNext()) {
AbstractBuildTask.Property p =
(AbstractBuildTask.Property) iter.next();
exec.createArg().setValue("-d" + p.getName() + "=" + p.getValue());
}
String[] extraArgs = cmdl.getArguments();
for (int i = 0; i < extraArgs.length; i++) {
exec.createArg().setValue(extraArgs[i]);
}

exec.execute();
}

0 comments on commit ced10d8

Please sign in to comment.