[yocto] [eclipse][PATCH 1/2] plugins/cmake: Refactor creation of CMAKE_FIND_ROOT_PATH
Timo Mueller
mail at timomueller.eu
Thu May 22 03:04:43 PDT 2014
From: Timo Mueller <timo.mueller at bmw-carit.de>
Adding new environment variables to the list of variables that
contribute to the the CMAKE_FIND_ROOT_PATH involved manually appending
to the value string and also adding a whitespace to separate values.
The construction of the CMAKE_FIND_ROOT_PATH value is extracted to a
separate method, which expects a list of environment variables. Adding
or removing environment variables that contribute to the path is now
achieved by modifying the entries of the list.
Signed-off-by: Timo Mueller <timo.mueller at bmw-carit.de>
---
.../YoctoCMakeMakefileGenerator.java | 35 ++++++++++++++--------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMakefileGenerator.java b/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMakefileGenerator.java
index b77ae9e..4119aaf 100644
--- a/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMakefileGenerator.java
+++ b/plugins/org.yocto.cmake.managedbuilder/src/org/yocto/cmake/managedbuilder/YoctoCMakeMakefileGenerator.java
@@ -12,6 +12,8 @@ package org.yocto.cmake.managedbuilder;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.util.Arrays;
+import java.util.List;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
@@ -226,18 +228,13 @@ public class YoctoCMakeMakefileGenerator implements IManagedBuilderMakefileGener
toolchainCMakeFileContentAsString += "# only search in the paths provided so cmake doesnt pick\n"; //$NON-NLS-1$
toolchainCMakeFileContentAsString += "# up libraries and tools from the native build machine\n"; //$NON-NLS-1$
- String findRootPathValue = YoctoSDKUtils.getEnvValue(project, "STAGING_DIR_HOST"); //$NON-NLS-1$
- findRootPathValue += " "; //$NON-NLS-1$
- findRootPathValue += YoctoSDKUtils.getEnvValue(project, "STAGING_DIR_NATIVE"); //$NON-NLS-1$
- findRootPathValue += " "; //$NON-NLS-1$
- findRootPathValue += YoctoSDKUtils.getEnvValue(project, "CROSS_DIR"); //$NON-NLS-1$
- findRootPathValue += " "; //$NON-NLS-1$
- findRootPathValue += YoctoSDKUtils.getEnvValue(project, "OECMAKE_PERLNATIVE_DIR"); //$NON-NLS-1$
- findRootPathValue += " "; //$NON-NLS-1$
- findRootPathValue += YoctoSDKUtils.getEnvValue(project, "OECMAKE_EXTRA_ROOT_PATH"); //$NON-NLS-1$
- findRootPathValue += " "; //$NON-NLS-1$
- findRootPathValue += YoctoSDKUtils.getEnvValue(project, "EXTERNAL_TOOLCHAIN"); //$NON-NLS-1$
- toolchainCMakeFileContentAsString += createCMakeSetStatement("CMAKE_FIND_ROOT_PATH", findRootPathValue, null); //$NON-NLS-1$
+ List<String> findRootPathValues = Arrays.asList("STAGING_DIR_HOST", //$NON-NLS-1$
+ "STAGING_DIR_NATIVE", //$NON-NLS-1$
+ "CROSS_DIR", //$NON-NLS-1$
+ "OECMAKE_PERLNATIVE_DIR", //$NON-NLS-1$
+ "OECMAKE_EXTRA_ROOT_PATH", //$NON-NLS-1$
+ "EXTERNAL_TOOLCHAIN"); //$NON-NLS-1$
+ toolchainCMakeFileContentAsString += createCMakeSetStatement("CMAKE_FIND_ROOT_PATH", getFindRootPath(findRootPathValues), null); //$NON-NLS-1$
toolchainCMakeFileContentAsString += createCMakeSetStatement("CMAKE_FIND_ROOT_PATH_MODE_PROGRAM", "ONLY", null); //$NON-NLS-1$ //$NON-NLS-2$
toolchainCMakeFileContentAsString += createCMakeSetStatement("CMAKE_FIND_ROOT_PATH_MODE_LIBRARY", "ONLY", null); //$NON-NLS-1$ //$NON-NLS-2$
@@ -278,4 +275,18 @@ public class YoctoCMakeMakefileGenerator implements IManagedBuilderMakefileGener
e.printStackTrace();
}
}
+
+ private String getFindRootPath(List<String> values) {
+ String findRootPath = "";
+
+ for (String value : values) {
+ String pathValue = YoctoSDKUtils.getEnvValue(project, value);
+
+ if (pathValue.length() > 0) {
+ findRootPath += pathValue + " ";
+ }
+ }
+
+ return findRootPath;
+ }
}
--
1.9.0
More information about the yocto
mailing list