buildframework/helium/sf/java/sbs/src/com/nokia/helium/sbs/ant/taskdefs/CTCTask.java
author wbernard
Thu, 22 Jul 2010 17:08:43 +0300
branchhelium-9.0
changeset 618 df88fead2976
parent 587 85df38eb4012
permissions -rw-r--r--
helium_9.0.5-4399343f4f50
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     2
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     3
* All rights reserved.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     4
* This component and the accompanying materials are made available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     6
* which accompanies this distribution, and is available
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     8
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     9
* Initial Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    11
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    12
* Contributors:
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    13
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    14
* Description:  
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    15
*
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    16
*/
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
package com.nokia.helium.sbs.ant.taskdefs;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
618
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    19
import java.util.Vector;
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    20
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    21
import org.apache.tools.ant.BuildException;
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    22
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    23
import com.nokia.helium.core.ant.types.Variable;
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    24
import com.nokia.helium.core.ant.types.VariableSet;
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    25
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
/**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
 * This task is to execute the CTCWrap command with the list of sbs parameters
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
 * using sbsinput type. Based on the raptor input list of additional log file path
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
 * used needs to be set, so that the scanlog, additional log files are generated 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
 * properly.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
 * 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
 * <pre>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
 * &lt;ctctask sbsinput=&quot;sbs.input&quot; sysdefFile=&quot;system.def.file&quot;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    34
 *      workingDir=&quot;build.drive&quot; failOnError=&quot;false&quot; 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
 *      cleanLog=&quot;sbs.log.file.clean.log&quot; 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
 *      failOnError=&quot;false&quot; 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    37
 *      errorfile=&quot;path to error file&quot;/&gt;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    38
 * </pre>
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
 * 
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
 * @ant.task name="ctctask" category="SBS"
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    42
public class CTCTask extends SBSTask {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
    
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
    private String instrumentType = "m";
618
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    45
    private Vector<VariableSet> ctcOptions = new Vector<VariableSet>();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
    
618
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    47
    /**
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    48
     * Constructing the task, overriding default executable to be 
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    49
     * ctcwrap.
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    50
     */
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
    public CTCTask() {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        super();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    53
        getSbsCmd().setExecutable("ctcwrap");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
    
618
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    56
    /**
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    57
     * Defined the instrumentation type.
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    58
     * @param instrumentType the instrumentation type.
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    59
     * @ant.not-required Default is 'm'
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    60
     */
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    61
    public void setInstrumentType(String instrumentType)
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
    {
618
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    63
        this.instrumentType = instrumentType;
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    65
    
618
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    66
    /**
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    67
     * Override the command line construction.
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    68
     */
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    69
    protected String getSBSCmdLine() {
618
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    70
        String ctcConfig = "";
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    71
        for (VariableSet ctcOption : ctcOptions) {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    72
            ctcConfig += " "; // needed for forward compatibility
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    73
            if (ctcOption.isReference()) {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    74
                Object refObject = ctcOption.getRefid().getReferencedObject();
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    75
                if (refObject instanceof VariableSet) {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    76
                    ctcOption = (VariableSet)refObject;
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    77
                } else {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    78
                    throw new BuildException(ctcOption.getRefid().getRefId() + " is not referencing a VariableSet.");
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    79
                }
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    80
            }
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    81
            for (VariableSet vset : ctcOption.getVariableSets()) {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    82
                if (vset.isReference()) {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    83
                    Object refObject = vset.getRefid().getReferencedObject();
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    84
                    if (refObject instanceof VariableSet) {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    85
                        vset = (VariableSet)refObject;
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    86
                    } else {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    87
                        throw new BuildException(vset.getRefid().getRefId() + " is not referencing a VariableSet.");
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    88
                    }
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    89
                }
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    90
                for (Variable var : vset.getVariablesList()) {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    91
                    ctcConfig += " " + var.getParameter();
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    92
                }
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    93
            }
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    94
        }
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    95
        return "-i " + instrumentType  + ctcConfig + " sbs" + super.getSBSCmdLine();
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    96
    }
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    97
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    98
    /**
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
    99
     * To read the ctc arguments for ctcwrap command.
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
   100
     * 
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
   101
     * @param ctcArg
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
   102
     */
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
   103
    public void addCTCOptions(VariableSet ctcArg) {
df88fead2976 helium_9.0.5-4399343f4f50
wbernard
parents: 587
diff changeset
   104
        ctcOptions.add(ctcArg);
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   105
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   106
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
   107
}