# HG changeset patch # User timkelly # Date 1256306195 18000 # Node ID 6911e366cafa11bf870739cbfb4997c998e121b9 # Parent 37c8331f98f7ed6f296be470027ea1e7a2fcc7fc initial implementation of scripting extension & Symbian SDK list retrieval and basic bld.inf project import. diff -r 37c8331f98f7 -r 6911e366cafa core/com.nokia.carbide.cpp.sdk.core/.project --- a/core/com.nokia.carbide.cpp.sdk.core/.project Wed Oct 21 14:28:08 2009 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/.project Fri Oct 23 08:56:35 2009 -0500 @@ -6,6 +6,11 @@ + org.python.pydev.PyDevBuilder + + + + org.eclipse.jdt.core.javabuilder @@ -30,5 +35,6 @@ org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature org.eclipse.pde.api.tools.apiAnalysisNature + org.python.pydev.pythonNature diff -r 37c8331f98f7 -r 6911e366cafa core/com.nokia.carbide.cpp.sdk.core/plugin.xml --- a/core/com.nokia.carbide.cpp.sdk.core/plugin.xml Wed Oct 21 14:28:08 2009 -0500 +++ b/core/com.nokia.carbide.cpp.sdk.core/plugin.xml Fri Oct 23 08:56:35 2009 -0500 @@ -22,5 +22,13 @@ class="com.nokia.carbide.cpp.internal.sdk.core.gen.Devices.util.DevicesResourceFactoryImpl" /> + + + + + diff -r 37c8331f98f7 -r 6911e366cafa core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/scripting/SDKScriptManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/com.nokia.carbide.cpp.sdk.core/src/com/nokia/carbide/cpp/internal/sdk/core/scripting/SDKScriptManager.java Fri Oct 23 08:56:35 2009 -0500 @@ -0,0 +1,53 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.carbide.cpp.internal.sdk.core.scripting; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import com.nokia.carbide.cpp.sdk.core.ISDKManager; +import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; +import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; + +public class SDKScriptManager { + + private static final String KEY_SDK_ID = "KEY_SDK_ID"; + private static final String KEY_SDK_EPOCROOT = "KEY_SDK_EPOCROOT"; + private static final String KEY_SDK_NAME = "KEY_SDK_NAME"; + + static private ISDKManager getSDKManager(){ + return SDKCorePlugin.getSDKManager(); + } + + static public Map[] getSDKMapList(){ + ArrayList> sdkMapArray = new ArrayList>(); + List sdkList = getSDKManager().getSDKList(); + for (ISymbianSDK sdk : sdkList){ + Map mp = new HashMap(); + mp.put(KEY_SDK_ID, sdk.getUniqueId()); + mp.put(KEY_SDK_NAME, sdk.getName()); + mp.put(KEY_SDK_EPOCROOT, sdk.getEPOCROOT()); + sdkMapArray.add(mp); + } + + + return sdkMapArray.toArray(new HashMap[sdkMapArray.size()]); + } + +} diff -r 37c8331f98f7 -r 6911e366cafa project/com.nokia.carbide.cpp.project.ui/plugin.xml --- a/project/com.nokia.carbide.cpp.project.ui/plugin.xml Wed Oct 21 14:28:08 2009 -0500 +++ b/project/com.nokia.carbide.cpp.project.ui/plugin.xml Fri Oct 23 08:56:35 2009 -0500 @@ -534,4 +534,12 @@ + + + + + diff -r 37c8331f98f7 -r 6911e366cafa project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/scripting/ImportBldInfWrapper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/scripting/ImportBldInfWrapper.java Fri Oct 23 08:56:35 2009 -0500 @@ -0,0 +1,93 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of the License "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ +package com.nokia.carbide.cpp.internal.scripting; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IProject; + +import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContext; +import com.nokia.carbide.cpp.sdk.core.ISDKManager; +import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; +import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; +import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; + + +public class ImportBldInfWrapper { + + private static final String KEY_SDKID = "KEY_SDKID"; + private static final String KEY_PLATFORM = "KEY_PLATFORM"; + private static final String KEY_TARGET = "KEY_TARGET"; + + static public String importBldInf(String projectName, String rootDirectory, + String bldInfFile, String[] buildComponents, + Map[] buildContextMap) { + + List contexts = new ArrayList(); + ISDKManager sdkMgr = SDKCorePlugin.getSDKManager(); + for (Map currMap : buildContextMap) { + ISymbianSDK sdk = sdkMgr.getSDK(currMap.get(KEY_SDKID), false); + if (sdk != null) { + if (!ImporterScritpingUtils.checkProjectIsOnSDKDrive( + rootDirectory, sdk)) { + // AssertTestCase.fail("!" + projectPath + + // " is not on the same drive as SDK: " + sdkName + // + " and could not import: " + projectName); + } + contexts.add(new SymbianBuildContext(sdk, currMap + .get(KEY_PLATFORM), currMap.get(KEY_TARGET))); + } + } + + IProject project = ImporterScritpingUtils.importINF(projectName, + bldInfFile, contexts, 0, false); + + if (project == null) + return null; + else + return projectName; + } + + static public Map createSymbianBuildContext(String sdkID, String platform, String target){ + Map mp = new HashMap(); + + mp.put(KEY_SDKID, sdkID); + mp.put(KEY_PLATFORM, platform); + mp.put(KEY_TARGET, target); + + return mp; + } + + static public boolean buildProject(String projectName){ + // TODO: + return false; + } + + static public boolean cleanProject(int cleanLevel){ + // TODO: + return false; + } + + static public boolean changeBuildConfiguration(Map buildContextMap){ + // TODO: + return false; + } + +} diff -r 37c8331f98f7 -r 6911e366cafa project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/scripting/ImporterScritpingUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/scripting/ImporterScritpingUtils.java Fri Oct 23 08:56:35 2009 -0500 @@ -0,0 +1,129 @@ +package com.nokia.carbide.cpp.internal.scripting; + +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; + +import com.nokia.carbide.cdt.builder.EpocEngineHelper; +import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContext; +import com.nokia.carbide.cpp.internal.project.utils.BldInfImportWrapper; +import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; +import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; +import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin; + +public class ImporterScritpingUtils { + + /** + * Import a project from bld.inf + * + * @param sdkName - The SDK to use. + * @param projectName - The project to import. + * @param projectPath - The path of the project to import. + * @changelog + * ARH 04/03/2009 Added an assert to reject a project path that is too long. + */ + public static IProject importINF(String projectName, String projectPath, + List buildContexts, int rootPathIndex, + boolean isSBSv2) { + + IProject project = null; + + IPath bldInf = new Path(projectPath); + + // AssertTestCase.assertFalse("The project: " + projectName + + // " could not be imported from " + + // projectPath + " because the path is " + + // ProjectUtils.getProjectPathOverflowLength(bldInf) + + // " too many character long.", + // ProjectUtils.isProjectPathToLong(bldInf)); + + List projectRoots = EpocEngineHelper.getProjectRoots(bldInf, + buildContexts, new NullProgressMonitor()); + IPath rootDirectoryPath = projectRoots.get(rootPathIndex); + + final List components = new ArrayList(); // should be + // empty + // list, + // same as + // all MMP + // components + // checked + final List refs = new ArrayList(); // refs should be + // empty, we'll + // build from + // bld.inf + BldInfImportWrapper infWrapper = new BldInfImportWrapper(projectName, + rootDirectoryPath, bldInf, components, refs, buildContexts); + + infWrapper.createProjectFromBldInf(isSBSv2); + + project = infWrapper.getProject(); + + return project; + } + + /** + * Validate that the project and SDK are compatible. If the SDK and project are not on the + * same drive, then return false. If they are on the same drive, then return true + * @param projectPath the path to the project to check + * @param sdk the SDK to check against the project + * @return true if projectPath is on the same drive as sdkName + */ + public static boolean checkProjectIsOnSDKDrive(String projectPath, ISymbianSDK sdk) { + // The drive letter of the SDK + String expectedDrive = sdk.getEPOCROOT().substring( 0, 1 ); + + // The drive letter of the project + String actualDrive = projectPath.substring( 0, 1 ); + + // Check if drive letters are different of the SDK versus the project to import + if ( expectedDrive.equalsIgnoreCase( actualDrive ) ) { + return true; + } + + return false; + } + + /** + * Given an sdk and a comma deliminated list of build targets, return a List of ISymbianBuildContext + * An example build target string would be "WINSCW UDEB,GCCE UREL" and would return + * @param sdk + * @param buildTargets + * @return + */ + public static List getSymbianBuildContextsFromString(ISymbianSDK sdk, String buildTargets) { + List selectedConfigs; + + // Create a selectConfigs list with all elements contained in buildTargets string + if (buildTargets != null && buildTargets.length() > 0) { + selectedConfigs = new ArrayList(); + StringTokenizer targetT = new StringTokenizer(buildTargets, ","); + String buildTarget; + String buildContext; + while(targetT.hasMoreElements()) { + // Get the element, separated by a comma, e.g. "GCCE UDEB". Needs to be split further + buildTarget = targetT.nextToken(); + // Within the element, get the context, which should be either "UDEB" or "UREL" + buildContext = buildTarget.substring(buildTarget.indexOf(" ")+1); + // Backfill with buildTarget with just the target + buildTarget = buildTarget.substring(0, buildTarget.indexOf(" ")); + + // Validate target and context strings against ISymbianBuildContext +// AssertTestCase.assertTrue("!Invalid build target, should be ARMV5, GCCE, WINSCW, etc.. but was: " + buildTarget, validateBuildTarget(buildTarget)); +// AssertTestCase.assertTrue("!Invalid build context, should be UREL or UDEB, but was: " + buildContext, validateBuildContext(buildContext)); + ISymbianBuildContext context = new SymbianBuildContext(sdk, buildTarget, buildContext); + selectedConfigs.add(context); + } + } + else { + selectedConfigs = sdk.getFilteredBuildConfigurations(); + } + return selectedConfigs; + } + +}