diff options
Diffstat (limited to 'plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java')
-rw-r--r-- | plugins/org.yocto.sdk.ide/src/org/yocto/sdk/ide/natures/YoctoSDKAutotoolsProjectNature.java | 79 |
1 files changed, 79 insertions, 0 deletions
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 @@ | |||
1 | /******************************************************************************* | ||
2 | * Copyright (c) 2010 Intel Corporation. | ||
3 | * All rights reserved. This program and the accompanying materials | ||
4 | * are made available under the terms of the Eclipse Public License v1.0 | ||
5 | * which accompanies this distribution, and is available at | ||
6 | * http://www.eclipse.org/legal/epl-v10.html | ||
7 | * | ||
8 | * Contributors: | ||
9 | * Intel - initial API and implementation | ||
10 | *******************************************************************************/ | ||
11 | package org.yocto.sdk.ide.natures; | ||
12 | |||
13 | import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager; | ||
14 | import org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration; | ||
15 | import org.eclipse.cdt.managedbuilder.core.IConfiguration; | ||
16 | import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; | ||
17 | import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; | ||
18 | import org.eclipse.core.resources.IProject; | ||
19 | import org.yocto.sdk.ide.YoctoSDKPlugin; | ||
20 | import org.yocto.sdk.ide.YoctoUIElement; | ||
21 | import org.yocto.sdk.ide.utils.ProjectPreferenceUtils; | ||
22 | import org.yocto.sdk.ide.utils.YoctoSDKUtils; | ||
23 | |||
24 | public class YoctoSDKAutotoolsProjectNature extends YoctoSDKProjectNature { | ||
25 | public static final String YoctoSDK_AUTOTOOLS_NATURE_ID = YoctoSDKPlugin.getUniqueIdentifier() + ".YoctoSDKAutotoolsNature"; | ||
26 | |||
27 | private static final String DEFAULT_HOST_STR = "host"; | ||
28 | private static final String DEFAULT_TARGET_STR = "target"; | ||
29 | private static final String DEFAULT_BUILD_STR = "build"; | ||
30 | private static final String DEFAULT_AUTOGEN_OPT_STR = "autogenOpts"; | ||
31 | |||
32 | private static final String DEFAULT_CONFIGURE_STR = "configure"; | ||
33 | private static final String DEFAULT_AUTOGEN_STR = "autogen"; | ||
34 | private static final String DEFAULT_LIBTOOL_SYSROOT_PREFIX = " --with-libtool-sysroot="; | ||
35 | |||
36 | public static void configureAutotoolsOptions(IProject project) { | ||
37 | IManagedBuildInfo info = ManagedBuildManager.getBuildInfo(project); | ||
38 | IConfiguration icfg = info.getDefaultConfiguration(); | ||
39 | YoctoUIElement elem = ProjectPreferenceUtils.getElemFromProjectEnv(project); | ||
40 | String sysroot_str = elem.getStrSysrootLoc(); | ||
41 | String id = icfg.getId(); | ||
42 | String CFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CFLAGS"); | ||
43 | String CXXFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CXXFLAGS"); | ||
44 | String CPPFLAGS_str = YoctoSDKUtils.getEnvValue(project, "CPPFLAGS"); | ||
45 | String LDFLAGS_str = YoctoSDKUtils.getEnvValue(project, "LDFLAGS"); | ||
46 | |||
47 | String command_prefix = "CFLAGS=\" -g -O0 " + CFLAGS_str + "\" CXXFLAGS=\" -g -O0 " | ||
48 | + CXXFLAGS_str + "\" LDFLAGS=\"" + LDFLAGS_str + "\" CPPFLAGS=\"" + CPPFLAGS_str + "\""; | ||
49 | String autogen_setting = command_prefix+" autogen.sh" + DEFAULT_LIBTOOL_SYSROOT_PREFIX + sysroot_str; | ||
50 | String configure_setting = command_prefix + " configure" + DEFAULT_LIBTOOL_SYSROOT_PREFIX + sysroot_str; | ||
51 | IAConfiguration cfg = AutotoolsConfigurationManager.getInstance().getConfiguration(project, id); | ||
52 | String strConfigure = YoctoSDKUtils.getEnvValue(project, "CONFIGURE_FLAGS"); | ||
53 | |||
54 | cfg.setOption(DEFAULT_CONFIGURE_STR, configure_setting); | ||
55 | cfg.setOption(DEFAULT_BUILD_STR, splitString(strConfigure, "--build=")); | ||
56 | cfg.setOption(DEFAULT_HOST_STR, splitString(strConfigure, "--host=")); | ||
57 | cfg.setOption(DEFAULT_TARGET_STR, splitString(strConfigure, "--target=")); | ||
58 | cfg.setOption(DEFAULT_AUTOGEN_STR, autogen_setting); | ||
59 | cfg.setOption(DEFAULT_AUTOGEN_OPT_STR, strConfigure); | ||
60 | |||
61 | AutotoolsConfigurationManager.getInstance().addConfiguration(project, cfg); | ||
62 | AutotoolsConfigurationManager.getInstance().saveConfigs(project); | ||
63 | } | ||
64 | |||
65 | private static String splitString(String strValue, String strDelim) { | ||
66 | int iBeginIndex = strValue.indexOf(strDelim); | ||
67 | |||
68 | if (iBeginIndex < 0) { | ||
69 | return ""; | ||
70 | } | ||
71 | int iEndIndex = strValue.indexOf(' ', iBeginIndex + 1); | ||
72 | |||
73 | if (iEndIndex < 0) { | ||
74 | return strValue.substring(iBeginIndex + strDelim.length()); | ||
75 | } else { | ||
76 | return strValue.substring(iBeginIndex + strDelim.length(), iEndIndex); | ||
77 | } | ||
78 | } | ||
79 | } | ||