From 41ac47d732eed8392d60d0f6773e5a279d49b999 Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 12 Dec 2013 13:36:50 +0100 Subject: initial commit of Enea Linux 3.1 Migrated from the internal git server on the dora-enea branch Signed-off-by: Adrian Dudau --- .../natures/YoctoSDKAutotoolsProjectNature.java | 79 +++++++++++++++++++ .../ide/natures/YoctoSDKCMakeProjectNature.java | 92 ++++++++++++++++++++++ .../ide/natures/YoctoSDKEmptyProjectNature.java | 8 ++ .../yocto/sdk/ide/natures/YoctoSDKNatureUtils.java | 39 +++++++++ .../sdk/ide/natures/YoctoSDKProjectNature.java | 36 +++++++++ 5 files changed, 254 insertions(+) create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java create mode 100644 plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures') diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java new file mode 100644 index 0000000..ce80d77 --- /dev/null +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2010 Intel Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel - initial API and implementation + *******************************************************************************/ +package org.yocto.sdk.ide.natures; + +import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager; +import org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration; +import org.eclipse.cdt.managedbuilder.core.IConfiguration; +import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; +import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; +import org.eclipse.core.resources.IProject; +import org.yocto.sdk.ide.YoctoSDKPlugin; +import org.yocto.sdk.ide.YoctoUIElement; +import org.yocto.sdk.ide.utils.ProjectPreferenceUtils; +import org.yocto.sdk.ide.utils.YoctoSDKUtils; + +public class YoctoSDKAutotoolsProjectNature extends YoctoSDKProjectNature { + public static final String YoctoSDK_AUTOTOOLS_NATURE_ID = YoctoSDKPlugin.getUniqueIdentifier() + ".YoctoSDKAutotoolsNature"; + + private static final String DEFAULT_HOST_STR = "host"; + private static final String DEFAULT_TARGET_STR = "target"; + private static final String DEFAULT_BUILD_STR = "build"; + private static final String DEFAULT_AUTOGEN_OPT_STR = "autogenOpts"; + + private static final String DEFAULT_CONFIGURE_STR = "configure"; + private static final String DEFAULT_AUTOGEN_STR = "autogen"; + private static final String DEFAULT_LIBTOOL_SYSROOT_PREFIX = " --with-libtool-sysroot="; + + public static void configureAutotoolsOptions(IProject project) { + IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); + IConfiguration icfg = info.getDefaultConfiguration(); + YoctoUIElement elem = ProjectPreferenceUtils.getElemFromProjectEnv(project); + String sysroot_str = elem.getStrSysrootLoc(); + String id = icfg.getId(); + String CFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CFLAGS"); + String CXXFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CXXFLAGS"); + String CPPFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CPPFLAGS"); + String LDFLAGS_str = YoctoSDKUtils.getEnvValue(project, "LDFLAGS"); + + String command_prefix = "CFLAGS=\" -g -O0 " + CFLAGS_str + "\" CXXFLAGS=\" -g -O0 " + + CXXFLAGS_str + "\" LDFLAGS=\"" + LDFLAGS_str + "\" CPPFLAGS=\"" + CPPFLAGS_str + "\""; + String autogen_setting = command_prefix+" autogen.sh" + DEFAULT_LIBTOOL_SYSROOT_PREFIX + sysroot_str; + String configure_setting = command_prefix + " configure" + DEFAULT_LIBTOOL_SYSROOT_PREFIX + sysroot_str; + IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, id); + String strConfigure = YoctoSDKUtils.getEnvValue(project, "CONFIGURE_FLAGS"); + + cfg.setOption(DEFAULT_CONFIGURE_STR, configure_setting); + cfg.setOption(DEFAULT_BUILD_STR, splitString(strConfigure, "--build=")); + cfg.setOption(DEFAULT_HOST_STR, splitString(strConfigure, "--host=")); + cfg.setOption(DEFAULT_TARGET_STR, splitString(strConfigure, "--target=")); + cfg.setOption(DEFAULT_AUTOGEN_STR, autogen_setting); + cfg.setOption(DEFAULT_AUTOGEN_OPT_STR, strConfigure); + + AutotoolsConfigurationManager.getInstance().addConfiguration(project, cfg); + AutotoolsConfigurationManager.getInstance().saveConfigs(project); + } + + private static String splitString(String strValue, String strDelim) { + int iBeginIndex = strValue.indexOf(strDelim); + + if (iBeginIndex < 0) { + return ""; + } + int iEndIndex = strValue.indexOf(' ', iBeginIndex + 1); + + if (iEndIndex < 0) { + return strValue.substring(iBeginIndex + strDelim.length()); + } else { + return strValue.substring(iBeginIndex + strDelim.length(), iEndIndex); + } + } +} diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java new file mode 100644 index 0000000..b3d0f2c --- /dev/null +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKCMakeProjectNature.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2013 BMW Car IT GmbH. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * BMW Car IT - initial API and implementation + *******************************************************************************/ +package org.yocto.sdk.ide.natures; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.envvar.IContributedEnvironment; +import org.eclipse.cdt.core.envvar.IEnvironmentVariable; +import org.eclipse.cdt.core.envvar.IEnvironmentVariableManager; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.yocto.sdk.ide.YoctoSDKPlugin; +import org.yocto.sdk.ide.utils.YoctoSDKUtils; + +public class YoctoSDKCMakeProjectNature extends YoctoSDKProjectNature { + public static final String YoctoSDK_CMAKE_NATURE_ID = YoctoSDKPlugin.getUniqueIdentifier() + ".YoctoSDKCMakeNature"; + + // Considered poky's cmake.bbclass for this method + public static void extendProjectEnvironmentForCMake(IProject project) { + ICProjectDescription cpdesc = CoreModel.getDefault().getProjectDescription(project, true); + ICConfigurationDescription ccdesc = cpdesc.getActiveConfiguration(); + IEnvironmentVariableManager manager = CCorePlugin.getDefault().getBuildEnvironmentManager(); + IContributedEnvironment env = manager.getContributedEnvironment(); + String delimiter = manager.getDefaultDelimiter(); + + env.addVariable("CCACHE", "", IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + + env.addVariable("OECMAKE_SOURCEPATH", "..", + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + + String oecmakeBuildPathString = ""; + env.addVariable("OECMAKE_BUILDPATH", oecmakeBuildPathString, + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + env.addVariable("EXTRA_OEMAKE", "-C " + oecmakeBuildPathString, + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + + String ccString = YoctoSDKUtils.getEnvValue(project, "CC"); + + if (!ccString.equals("") && !ccString.equals(" ")) { + ccString.trim(); + ccString = ccString.split(" ")[0]; + } + + env.addVariable("OECMAKE_C_COMPILER", ccString, + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + String cxxString = YoctoSDKUtils.getEnvValue(project, "CXX"); + + if (!cxxString.equals("") && !cxxString.equals(" ")) { + cxxString.trim(); + cxxString = cxxString.split(" ")[0]; + } + + env.addVariable("OECMAKE_CXX_COMPILER", cxxString, + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + + String hostCCArchString = YoctoSDKUtils.getEnvValue(project, "HOST_CC_ARCH"); + String toolchainOptionsString = YoctoSDKUtils.getEnvValue(project, "TOOLCHAIN_OPTIONS"); + String cppFlagsString = YoctoSDKUtils.getEnvValue(project, "CPPFLAGS"); + String cxxFlagsString = YoctoSDKUtils.getEnvValue(project, "CXXFLAGS"); + String selectedOptimizationString = YoctoSDKUtils.getEnvValue(project, "SELECTED_OPTIMIZATION"); + env.addVariable("OECMAKE_C_FLAGS", hostCCArchString + " " + toolchainOptionsString + " " + cppFlagsString, + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + env.addVariable("OECMAKE_CXX_FLAGS", hostCCArchString + " " + toolchainOptionsString + " " + cxxFlagsString + + " -fpermissive", + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + env.addVariable("OECMAKE_C_FLAGS_RELEASE", selectedOptimizationString + " " + cppFlagsString + " -DNDEBUG", + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + env.addVariable("OECMAKE_CXX_FLAGS_RELEASE", selectedOptimizationString + " " + cxxFlagsString + " -DNDEBUG", + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + + env.addVariable("OECMAKE_RPATH", "", + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + env.addVariable("OECMAKE_PERLNATIVE_DIR", "", + IEnvironmentVariable.ENVVAR_REPLACE, delimiter, ccdesc); + + try { + CoreModel.getDefault().setProjectDescription(project, cpdesc); + } catch (CoreException e) { + e.printStackTrace(); + } + } +} diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java new file mode 100644 index 0000000..e1b847a --- /dev/null +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKEmptyProjectNature.java @@ -0,0 +1,8 @@ +package org.yocto.sdk.ide.natures; + +import org.yocto.sdk.ide.YoctoSDKPlugin; + +public class YoctoSDKEmptyProjectNature extends YoctoSDKProjectNature { + + public static final String YoctoSDK_EMPTY_NATURE_ID = YoctoSDKPlugin.getUniqueIdentifier() + ".YoctoSDKEmptyNature"; +} diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java new file mode 100644 index 0000000..5a2a6b1 --- /dev/null +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKNatureUtils.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2010 Intel Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel - initial API and implementation + * BMW Car IT - extracted in an own class + *******************************************************************************/ +package org.yocto.sdk.ide.natures; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +public class YoctoSDKNatureUtils { + + public static void addNature(IProject project, String natureId, IProgressMonitor monitor) throws CoreException + { + IProjectDescription description = project.getDescription(); + String[] natures = description.getNatureIds(); + + for (int i = 0; i < natures.length; ++i) { + if (natureId.equals(natures[i])) + return; + } + + String[] newNatures = new String[natures.length + 1]; + System.arraycopy(natures, 0, newNatures, 0, natures.length); + newNatures[natures.length] = natureId; + description.setNatureIds(newNatures); + project.setDescription(description, monitor); + + } + +} diff --git a/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java new file mode 100644 index 0000000..e3f6a35 --- /dev/null +++ b/plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKProjectNature.java @@ -0,0 +1,36 @@ +/******************************************************************************* + * Copyright (c) 2010 Intel Corporation. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel - initial API and implementation + *******************************************************************************/ +package org.yocto.sdk.ide.natures; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; +import org.yocto.sdk.ide.YoctoSDKPlugin; + +public class YoctoSDKProjectNature implements IProjectNature { + public static final String YoctoSDK_NATURE_ID = YoctoSDKPlugin.getUniqueIdentifier() + ".YoctoSDKNature"; + + private IProject proj; + + public void configure() throws CoreException { + } + + public void deconfigure() throws CoreException { + } + + public IProject getProject() { + return proj; + } + + public void setProject(IProject project) { + this.proj = project; + } +} -- cgit v1.2.3-54-g00ecf