mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-30 23:02:39 -06:00
Added minimal support for new cpp parser when AndroidBuilder is active
git-svn-id: svn://ultimatepp.org/upp/trunk@8759 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
060d1c488c
commit
4eff8fd81e
6 changed files with 131 additions and 3 deletions
|
|
@ -20,4 +20,75 @@ String Android::GetCmdExt()
|
|||
#endif
|
||||
}
|
||||
|
||||
void Android::NormalizeVersions(Vector<String>& versions)
|
||||
{
|
||||
String prefix = FindVersionsPrefix(versions);
|
||||
String longestVersion = FindLongestVersion(versions);
|
||||
|
||||
int longestVersionCount = longestVersion.GetCount();
|
||||
for(int i = 0; i < versions.GetCount(); i++) {
|
||||
int diff = longestVersionCount - versions[i].GetCount();
|
||||
if(diff <= 0)
|
||||
continue;
|
||||
|
||||
String version = versions[i];
|
||||
if(!prefix.IsEmpty())
|
||||
version.Replace(prefix, "");
|
||||
for(int j = 0; j < diff; j++)
|
||||
version = "0" + version;
|
||||
versions[i] = prefix + version;
|
||||
}
|
||||
}
|
||||
|
||||
void Android::RemoveVersionsNormalization(Vector<String>& versions)
|
||||
{
|
||||
String prefix = FindVersionsPrefix(versions);
|
||||
for(int i = 0; i < versions.GetCount(); i++) {
|
||||
String version = versions[i];
|
||||
if(!prefix.IsEmpty())
|
||||
version.Replace(prefix, "");
|
||||
for(;;) {
|
||||
if(!version.StartsWith("0"))
|
||||
break;
|
||||
version.Remove(0);
|
||||
}
|
||||
versions[i] = prefix + version;
|
||||
}
|
||||
}
|
||||
|
||||
String Android::FindVersionsPrefix(const Vector<String>& versions)
|
||||
{
|
||||
String prefix;
|
||||
for(int i = 0; i < versions.GetCount(); i++) {
|
||||
String currentPrefix;
|
||||
String version = versions[i];
|
||||
for(int j = 0; j < 10; j++) {
|
||||
int idx = version.Find(IntStr(j));
|
||||
if(idx < 0)
|
||||
continue;
|
||||
String left = version.Left(idx);
|
||||
if(currentPrefix.IsEmpty() || left.GetCount() < currentPrefix.GetCount())
|
||||
currentPrefix = left;
|
||||
}
|
||||
if(i == 0)
|
||||
prefix = currentPrefix;
|
||||
else
|
||||
if(i > 0 && currentPrefix != prefix)
|
||||
return "";
|
||||
}
|
||||
|
||||
return prefix;
|
||||
}
|
||||
|
||||
String Android::FindLongestVersion(const Vector<String>& versions)
|
||||
{
|
||||
String longest;
|
||||
for(int i = 0; i < versions.GetCount(); i++) {
|
||||
String current = versions[i];
|
||||
if(current.GetCount() > longest.GetCount())
|
||||
longest = current;
|
||||
}
|
||||
return longest;
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -14,6 +14,13 @@ public:
|
|||
static String GetScriptExt();
|
||||
static String GetCmdExt();
|
||||
|
||||
static void NormalizeVersions(Vector<String>& versions);
|
||||
static void RemoveVersionsNormalization(Vector<String>& versions);
|
||||
|
||||
private:
|
||||
static String FindVersionsPrefix(const Vector<String>& versions);
|
||||
static String FindLongestVersion(const Vector<String>& versions);
|
||||
|
||||
private:
|
||||
Android();
|
||||
Android(const Android&);
|
||||
|
|
@ -95,16 +102,22 @@ public:
|
|||
|
||||
bool Validate() const;
|
||||
|
||||
String FindDefaultPlatform() const;
|
||||
String FindDefaultToolchain() const;
|
||||
String FindDefaultCppRuntime() const;
|
||||
|
||||
Vector<String> FindPlatforms() const;
|
||||
Vector<String> FindToolchains() const;
|
||||
Vector<String> FindCppRuntimes() const;
|
||||
|
||||
public:
|
||||
String GetIncludeDir() const;
|
||||
|
||||
String GetPlatformsDir() const { return path + DIR_SEPS + "platforms"; }
|
||||
String GetToolchainsDir() const { return path + DIR_SEPS + "toolchains"; }
|
||||
|
||||
String GetNdkBuildPath() const { return path + DIR_SEPS + "ndk-build" + Android::GetCmdExt(); }
|
||||
String GetGdbPath() const { return path + DIR_SEPS + "ndk-gdb"; }
|
||||
String GetToolchainsDir() const { return path + DIR_SEPS + "toolchains"; }
|
||||
|
||||
public:
|
||||
String GetPath() const { return this->path; }
|
||||
|
|
|
|||
|
|
@ -30,12 +30,24 @@ bool AndroidNDK::Validate() const
|
|||
return true;
|
||||
}
|
||||
|
||||
String AndroidNDK::FindDefaultPlatform() const
|
||||
{
|
||||
Vector<String> platforms = FindPlatforms();
|
||||
|
||||
Android::NormalizeVersions(platforms);
|
||||
Sort(platforms, StdGreater<String>());
|
||||
Android::RemoveVersionsNormalization(platforms);
|
||||
|
||||
return !platforms.IsEmpty() ? platforms[0] : "";
|
||||
}
|
||||
|
||||
String AndroidNDK::FindDefaultToolchain() const
|
||||
{
|
||||
Vector<String> toolchains = FindToolchains();
|
||||
Sort(toolchains, StdGreater<String>());
|
||||
|
||||
return toolchains.GetCount() ? toolchains[toolchains.GetCount() - 1] : "";
|
||||
int count = toolchains.GetCount();
|
||||
return count ? toolchains[count - 1] : "";
|
||||
}
|
||||
|
||||
String AndroidNDK::FindDefaultCppRuntime() const
|
||||
|
|
@ -43,6 +55,18 @@ String AndroidNDK::FindDefaultCppRuntime() const
|
|||
return "gnustl_shared";
|
||||
}
|
||||
|
||||
Vector<String> AndroidNDK::FindPlatforms() const
|
||||
{
|
||||
Vector<String> platforms;
|
||||
|
||||
for(FindFile ff(AppendFileName(GetPlatformsDir(), "*")); ff; ff.Next()) {
|
||||
if(!ff.IsHidden() && ff.IsFolder())
|
||||
platforms.Add(ff.GetName());
|
||||
}
|
||||
|
||||
return platforms;
|
||||
}
|
||||
|
||||
Vector<String> AndroidNDK::FindToolchains() const
|
||||
{
|
||||
Vector<String> toolchains;
|
||||
|
|
@ -83,4 +107,15 @@ Vector<String> AndroidNDK::FindCppRuntimes() const
|
|||
return runtimes;
|
||||
}
|
||||
|
||||
String AndroidNDK::GetIncludeDir() const
|
||||
{
|
||||
String dir;
|
||||
dir << GetPlatformsDir() << DIR_SEPS << FindDefaultPlatform() << DIR_SEPS;
|
||||
// TODO: decide how to implement architecture selection.
|
||||
dir << "arch-arm" << DIR_SEPS;
|
||||
dir << "usr" << DIR_SEPS << "include";
|
||||
|
||||
return DirectoryExists(dir) ? dir : "";
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -173,7 +173,10 @@ String AndroidSDK::FindDefaultPlatform() const
|
|||
{
|
||||
Vector<String> platforms = FindPlatforms();
|
||||
if(platforms.GetCount()) {
|
||||
Android::NormalizeVersions(platforms);
|
||||
Sort(platforms, StdGreater<String>());
|
||||
Android::RemoveVersionsNormalization(platforms);
|
||||
|
||||
int idx = 0;
|
||||
for(int i = 0; i < platforms.GetCount(); i++) {
|
||||
if(RegExp("^android-[0-9]*$").Match(platforms[i])) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public:
|
|||
|
||||
public:
|
||||
String GetBinDir() const { return path + DIR_SEPS + "bin"; }
|
||||
String GetIncludeDir() const { return path + DIR_SEPS + "include"; }
|
||||
|
||||
String GetJarPath() const { return GetBinDir() + DIR_SEPS + "jar" + GetExeExt(); }
|
||||
String GetJavacPath() const { return GetBinDir() + DIR_SEPS + "javac" + GetExeExt(); }
|
||||
|
|
|
|||
|
|
@ -832,7 +832,12 @@ String Ide::GetIncludePath()
|
|||
}
|
||||
MergeWith(include, ";", mingw_include[q]);
|
||||
#endif
|
||||
|
||||
if(findarg(bm.Get("BUILDER"), "ANDROID") >= 0) {
|
||||
AndroidNDK ndk(bm.Get("NDK_PATH"));
|
||||
if(ndk.Validate())
|
||||
MergeWith(include, ";", ndk.GetIncludeDir());
|
||||
}
|
||||
|
||||
const Workspace& wspc = GetIdeWorkspace();
|
||||
for(int i = 0; i < wspc.GetCount(); i++) {
|
||||
const Package& pkg = wspc.GetPackage(i);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue