buildframework/helium/sf/java/legacy/src/com/nokia/tools/cone/CONETool.java
author wbernard
Fri, 13 Aug 2010 14:59:05 +0300
changeset 628 7c4a911dc066
parent 587 85df38eb4012
permissions -rw-r--r--
helium_11.0.0-e00f171ca185
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
     1
/*
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
     2
 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
     3
 * All rights reserved.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
     4
 * This component and the accompanying materials are made available
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
     5
 * under the terms of the License "Eclipse Public License v1.0"
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
     6
 * which accompanies this distribution, and is available
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
     8
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
     9
 * Initial Contributors:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    10
 * Nokia Corporation - initial contribution.
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    11
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    12
 * Contributors:
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    13
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    14
 * Description: 
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    15
 *
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    16
 */
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    17
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    18
package com.nokia.tools.cone;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    19
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    20
import java.io.File;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    21
import java.util.HashMap;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    22
import java.util.Map;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    23
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    24
import org.apache.tools.ant.Project;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    25
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    26
import com.nokia.helium.core.ant.types.VariableSet;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    27
import com.nokia.tools.Tool;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    28
import com.nokia.tools.ToolsProcessException;
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    29
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    30
/**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    31
 * To generate the cenrep files using ConE tool.
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    32
 */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    33
public class CONETool implements Tool {
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    34
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    35
    private Map<String, String> varMapping = new HashMap<String, String>();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    36
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    37
    public void execute(VariableSet varSet, Project prj) throws ToolsProcessException {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    38
    }
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    39
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    40
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    41
     * Run the cone command with arguments from hashmap.
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    42
     * 
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    43
     * @param prj
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    44
     * @throws ToolsProcessException
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    45
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    46
    public void execute(Project prj) throws ToolsProcessException {
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    47
        String command = null;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    48
        String osType = System.getProperty("os.name");
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    49
        org.apache.tools.ant.taskdefs.ExecTask task = new org.apache.tools.ant.taskdefs.ExecTask();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    50
        task.setTaskName("ConE");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    51
        task.setDir(new java.io.File(varMapping.get("path")));
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    52
        task.setExecutable("cmd.exe");
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    53
        command = "cmd.exe";
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    54
        task.setOutput(new File(varMapping.get("output")));
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    55
        task.createArg().setValue("/c");
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    56
        task.setAppend(true);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    57
        task.createArg().setValue("cone.cmd");
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    58
        task.createArg().setValue(varMapping.get("command"));
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    59
        command += " /c cone.cmd " + varMapping.get("command");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    60
        for (Map.Entry<String, String> varEntry : varMapping.entrySet()) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    61
            if (!varEntry.getKey().equals("path") && !varEntry.getKey().equals("output")) {
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    62
                task.createArg().setValue(varEntry.getKey());
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    63
                command += " " + varEntry.getKey();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    64
                task.createArg().setValue(varEntry.getValue());
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    65
                command += " " + varEntry.getValue();
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    66
            }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    67
        }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    68
        if (!osType.toLowerCase().startsWith("win")) {
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    69
            task.log("ConE tool runs only on windows platforms.");
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    70
            return;
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    71
        }
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    72
        task.log("Running ConE command \"" + command + "\"");
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    73
        task.execute();
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    74
    }
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    75
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    76
    /**
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    77
     * To Store the variable and it value into hashmap to read them later.
628
7c4a911dc066 helium_11.0.0-e00f171ca185
wbernard
parents: 587
diff changeset
    78
     * 
587
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    79
     * @param name
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    80
     * @param value
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    81
     */
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    82
    public void storeVariables(String name, String value) {
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    83
        varMapping.put(name, value);
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    84
    }
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    85
85df38eb4012 helium_9.0-a7879c935424
wbernard
parents:
diff changeset
    86
}