project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/scripting/ImportBldInfWrapper.java
changeset 544 6911e366cafa
equal deleted inserted replaced
541:37c8331f98f7 544:6911e366cafa
       
     1 /*
       
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 package com.nokia.carbide.cpp.internal.scripting;
       
    18 
       
    19 import java.util.ArrayList;
       
    20 import java.util.HashMap;
       
    21 import java.util.List;
       
    22 import java.util.Map;
       
    23 
       
    24 import org.eclipse.core.resources.IProject;
       
    25 
       
    26 import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContext;
       
    27 import com.nokia.carbide.cpp.sdk.core.ISDKManager;
       
    28 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext;
       
    29 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
       
    30 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
       
    31 
       
    32 
       
    33 public class ImportBldInfWrapper {
       
    34 	
       
    35 	private static final String KEY_SDKID = "KEY_SDKID";
       
    36 	private static final String KEY_PLATFORM = "KEY_PLATFORM";
       
    37 	private static final String KEY_TARGET = "KEY_TARGET";
       
    38 	
       
    39 	static public String importBldInf(String projectName, String rootDirectory,
       
    40 		String bldInfFile, String[] buildComponents,
       
    41 		Map<String, String>[] buildContextMap) {
       
    42 
       
    43 		List<ISymbianBuildContext> contexts = new ArrayList<ISymbianBuildContext>();
       
    44 		ISDKManager sdkMgr = SDKCorePlugin.getSDKManager();
       
    45 		for (Map<String, String> currMap : buildContextMap) {
       
    46 			ISymbianSDK sdk = sdkMgr.getSDK(currMap.get(KEY_SDKID), false);
       
    47 			if (sdk != null) {
       
    48 				if (!ImporterScritpingUtils.checkProjectIsOnSDKDrive(
       
    49 						rootDirectory, sdk)) {
       
    50 					// AssertTestCase.fail("!" + projectPath +
       
    51 					// " is not on the same drive as SDK: " + sdkName
       
    52 					// + " and could not import: " + projectName);
       
    53 				}
       
    54 				contexts.add(new SymbianBuildContext(sdk, currMap
       
    55 						.get(KEY_PLATFORM), currMap.get(KEY_TARGET)));
       
    56 			}
       
    57 		}
       
    58 
       
    59 		IProject project = ImporterScritpingUtils.importINF(projectName,
       
    60 				bldInfFile, contexts, 0, false);
       
    61 
       
    62 		if (project == null)
       
    63 			return null;
       
    64 		else
       
    65 			return projectName;
       
    66 	}
       
    67 	
       
    68 	static public Map<String, String> createSymbianBuildContext(String sdkID, String platform, String target){
       
    69 		Map<String,String> mp = new HashMap<String, String>();
       
    70 
       
    71 		mp.put(KEY_SDKID, sdkID);
       
    72 		mp.put(KEY_PLATFORM, platform);
       
    73 		mp.put(KEY_TARGET, target);
       
    74 		
       
    75 		return mp;
       
    76 	}
       
    77 	
       
    78 	static public boolean buildProject(String projectName){
       
    79 		// TODO:
       
    80 		return false;
       
    81 	}
       
    82 	
       
    83 	static public boolean cleanProject(int cleanLevel){
       
    84 		// TODO:
       
    85 		return false;
       
    86 	}
       
    87 	
       
    88 	static public boolean changeBuildConfiguration(Map<String, String> buildContextMap){
       
    89 		// TODO:
       
    90 		return false;
       
    91 	}
       
    92 	
       
    93 }