mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-09 03:24:59 -06:00
Improve AndroidBuilder ndk build method configuration, Adb implement GetPid method
git-svn-id: svn://ultimatepp.org/upp/trunk@8726 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
00357b76fb
commit
19b13dbb1a
9 changed files with 126 additions and 22 deletions
|
|
@ -12,6 +12,25 @@ Adb::~Adb()
|
|||
|
||||
}
|
||||
|
||||
int Adb::GetPid(const String& packageName) const
|
||||
{
|
||||
int pid = -1;
|
||||
|
||||
String out;
|
||||
if(Sys(MakeGetAllProcessesCmd(), out) == 0) {
|
||||
Vector<String> lines = Split(out, "\n");
|
||||
for(int i = 0; i < lines.GetCount(); i++) {
|
||||
if(lines[i].Find(packageName) >= 0) {
|
||||
Vector<String> parts = Split(lines[i], " ");
|
||||
if(parts.GetCount() >= 2)
|
||||
pid = StrInt(parts[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pid;
|
||||
}
|
||||
|
||||
String Adb::MakeCmd() const
|
||||
{
|
||||
String cmd = NormalizeExePath(path);
|
||||
|
|
@ -23,7 +42,7 @@ String Adb::MakeCmd() const
|
|||
|
||||
String Adb::MakeInstallCmd(const String& apkPath) const
|
||||
{
|
||||
return NormalizeExePath(path) + " -s " + serial + " install -r " + apkPath;
|
||||
return MakeCmd() + " install -r " + apkPath;
|
||||
}
|
||||
|
||||
String Adb::MakeInstallOnDefaultDeviceCmd(const String& apkPath) const
|
||||
|
|
@ -45,4 +64,9 @@ String Adb::MakeLaunchOnDeviceCmd(const String& packageName, const String& activ
|
|||
return cmd;
|
||||
}
|
||||
|
||||
String Adb::MakeGetAllProcessesCmd() const
|
||||
{
|
||||
return MakeCmd() + " shell ps";
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ public:
|
|||
virtual ~Apk();
|
||||
|
||||
String FindPackageName() const;
|
||||
String FindLauchableActivity() const;
|
||||
String FindLaunchableActivity() const;
|
||||
|
||||
private:
|
||||
String FindValueInAndroidManifest(const String& badge, const String& tag) const;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ String Apk::FindPackageName() const
|
|||
return FindValueInAndroidManifest("package", "name");
|
||||
}
|
||||
|
||||
String Apk::FindLauchableActivity() const
|
||||
String Apk::FindLaunchableActivity() const
|
||||
{
|
||||
return FindValueInAndroidManifest("launchable-activity", "name");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ public:
|
|||
void SetPath(const String& path) { this->path = path; }
|
||||
void SetSerial(const String& serial) { this->serial = serial; }
|
||||
|
||||
public:
|
||||
int GetPid(const String& packageName) const;
|
||||
|
||||
public:
|
||||
String MakeListDevicesCmd() const;
|
||||
|
||||
|
|
@ -32,6 +35,8 @@ public:
|
|||
|
||||
String MakeLaunchOnDeviceCmd(const String& packageName, const String& activityName) const;
|
||||
|
||||
String MakeGetAllProcessesCmd() const;
|
||||
|
||||
private:
|
||||
String path;
|
||||
String serial;
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ void Ide::ExecuteApk()
|
|||
One<Host> host = CreateHost(false);
|
||||
Apk apk(target, sdk);
|
||||
String packageName = apk.FindPackageName();
|
||||
String activityName = apk.FindLauchableActivity();
|
||||
String activityName = apk.FindLaunchableActivity();
|
||||
|
||||
Adb adb = sdk.MakeAdb();
|
||||
adb.SetSerial(select.GetSelectedSerial());
|
||||
|
|
@ -213,6 +213,8 @@ void Ide::ExecuteApk()
|
|||
|
||||
if(!packageName.IsEmpty() && !activityName.IsEmpty())
|
||||
host->Execute(adb.MakeLaunchOnDeviceCmd(packageName, activityName));
|
||||
|
||||
Cout() << "PID: " << adb.GetPid(packageName) << "\n";
|
||||
}
|
||||
|
||||
void Ide::BuildAndDebug0(const String& srcfile)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef JAVA_H
|
||||
#define JAVA_H
|
||||
#ifndef _Java_Java_h_
|
||||
#define _Java_Java_h_
|
||||
|
||||
#include <Core/Core.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -94,6 +94,8 @@ AndroidBuilderSetup::AndroidBuilderSetup()
|
|||
|
||||
ndk_path <<= THISBACK(OnNdkPathChange);
|
||||
|
||||
GroupNdkCtrls();
|
||||
|
||||
ndkDownload.SetImage(IdeImg::DownloadBlack());
|
||||
ndkDownload.Tip("Download");
|
||||
ndkDownload <<= callback1(LaunchWebBrowser, AndroidNDK::GetDownloadUrl());
|
||||
|
|
@ -143,19 +145,15 @@ AndroidBuilderSetup::~AndroidBuilderSetup()
|
|||
void AndroidBuilderSetup::New(const String& builder)
|
||||
{
|
||||
OnLoad();
|
||||
|
||||
ndk_arch_armeabi.Set(1);
|
||||
ndk_arch_armeabi_v7a.Set(1);
|
||||
ndk_arch_arm64_v8a.Set(1);
|
||||
ndk_common_cpp_options.SetData("-fexceptions -frtti");
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::OnLoad()
|
||||
{
|
||||
String sdkPath = GetAndroidSDKPath();
|
||||
|
||||
sdk_path.SetData(sdkPath);
|
||||
OnSdkPathChange(sdkPath);
|
||||
|
||||
OnNdkPathChange();
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::OnCtrlLoad(const String& ctrlKey, const String& value)
|
||||
|
|
@ -172,9 +170,16 @@ void AndroidBuilderSetup::OnCtrlLoad(const String& ctrlKey, const String& value)
|
|||
|
||||
void AndroidBuilderSetup::OnShow()
|
||||
{
|
||||
OnSdkShow();
|
||||
OnNdkShow();
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::OnSdkShow()
|
||||
{
|
||||
AndroidSDK sdk(GetAndroidSDKPath(), true);
|
||||
if(!sdk.Validate())
|
||||
if(!sdk.Validate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(((String)sdk_platform_version.GetValue()).IsEmpty())
|
||||
sdk_platform_version.SetData(sdk.FindDefaultPlatform());
|
||||
|
|
@ -191,27 +196,50 @@ void AndroidBuilderSetup::OnSdkPathChange(const String& sdkPath)
|
|||
}
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::OnNdkShow()
|
||||
{
|
||||
AndroidNDK ndk(ndk_path.GetData());
|
||||
if(ndk.Validate()) {
|
||||
LoadToolchains(ndk);
|
||||
LoadCppRuntimes(ndk);
|
||||
|
||||
EnableCtrls(ndkCtrls);
|
||||
}
|
||||
else {
|
||||
// TODO: waiting for DisableCtrls method in CtrlCore :)
|
||||
for(int i = 0; i < ndkCtrls.GetCount(); i++)
|
||||
ndkCtrls[i]->Disable();
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::OnNdkPathInsert()
|
||||
{
|
||||
String currentPath = ndk_path.GetData();
|
||||
|
||||
InsertPath(&ndk_path);
|
||||
if(currentPath != ndk_path.GetData())
|
||||
|
||||
String newPath = ndk_path.GetData();
|
||||
if(currentPath != newPath)
|
||||
OnNdkPathChange();
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::OnNdkPathChange()
|
||||
{
|
||||
OnNdkPathChange0(ndk_path.GetData());
|
||||
OnNdkShow();
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::OnNdkPathChange0(const String& ndkPath)
|
||||
{
|
||||
AndroidNDK ndk(ndkPath);
|
||||
if(ndk.Validate()) {
|
||||
LoadToolchains(ndk);
|
||||
LoadCppRuntimes(ndk);
|
||||
ndk_arch_armeabi.Set(1);
|
||||
ndk_arch_armeabi_v7a.Set(1);
|
||||
ndk_arch_arm64_v8a.Set(1);
|
||||
ndk_common_cpp_options.SetData("-fexceptions -frtti");
|
||||
}
|
||||
else
|
||||
ClearNdkCtrls();
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::LoadPlatforms(const AndroidSDK& sdk)
|
||||
|
|
@ -265,6 +293,41 @@ void AndroidBuilderSetup::LoadDropList(DropList& dropList,
|
|||
}
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::GroupNdkCtrls()
|
||||
{
|
||||
if(!ndkCtrls.IsEmpty())
|
||||
ndkCtrls.Clear();
|
||||
|
||||
ndkCtrls.Add(&ndk_blitz);
|
||||
ndkCtrls.Add(&ndk_arch_armeabi);
|
||||
ndkCtrls.Add(&ndk_arch_armeabi_v7a);
|
||||
ndkCtrls.Add(&ndk_arch_arm64_v8a);
|
||||
ndkCtrls.Add(&ndk_arch_x86);
|
||||
ndkCtrls.Add(&ndk_arch_x86_64);
|
||||
ndkCtrls.Add(&ndk_arch_mips);
|
||||
ndkCtrls.Add(&ndk_arch_mips64);
|
||||
ndkCtrls.Add(&ndk_toolchain);
|
||||
ndkCtrls.Add(&ndk_cpp_runtime);
|
||||
ndkCtrls.Add(&ndk_common_cpp_options);
|
||||
ndkCtrls.Add(&ndk_common_c_options);
|
||||
}
|
||||
|
||||
void AndroidBuilderSetup::ClearNdkCtrls()
|
||||
{
|
||||
ndk_blitz.Set(0);
|
||||
ndk_arch_armeabi.Set(0);
|
||||
ndk_arch_armeabi_v7a.Set(0);
|
||||
ndk_arch_arm64_v8a.Set(0);
|
||||
ndk_arch_x86.Set(0);
|
||||
ndk_arch_x86_64.Set(0);
|
||||
ndk_arch_mips.Set(0);
|
||||
ndk_arch_mips64.Set(0);
|
||||
ndk_toolchain.Clear();
|
||||
ndk_cpp_runtime.Clear();
|
||||
ndk_common_cpp_options.Clear();
|
||||
ndk_common_c_options.Clear();
|
||||
}
|
||||
|
||||
DefaultBuilderSetup::DefaultBuilderSetup()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
|
|
|
|||
|
|
@ -78,7 +78,9 @@ public:
|
|||
virtual void InitSetupCtrlsMap(VectorMap<Id, Ctrl*>& map);
|
||||
|
||||
private:
|
||||
void OnSdkShow();
|
||||
void OnSdkPathChange(const String& sdkPath);
|
||||
void OnNdkShow();
|
||||
void OnNdkPathInsert();
|
||||
void OnNdkPathChange();
|
||||
void OnNdkPathChange0(const String& ndkPath);
|
||||
|
|
@ -89,6 +91,13 @@ private:
|
|||
void LoadToolchains(const AndroidNDK& ndk);
|
||||
void LoadCppRuntimes(const AndroidNDK& ndk);
|
||||
void LoadDropList(DropList& dropList, const Vector<String>& values, const String& defaultKey = "");
|
||||
|
||||
private:
|
||||
void GroupNdkCtrls();
|
||||
void ClearNdkCtrls();
|
||||
|
||||
private:
|
||||
Vector<Ptr<Ctrl> > ndkCtrls;
|
||||
};
|
||||
|
||||
class BuilderSetup {
|
||||
|
|
|
|||
|
|
@ -208,8 +208,9 @@ LAYOUT(BuildMethodsAndroidBuilderSetupLayout, 648, 500)
|
|||
ITEM(StaticText, dv___11, SetText(t_("Build tools version:")).LeftPosZ(236, 100).TopPosZ(148, 19))
|
||||
ITEM(DropList, sdk_build_tools_release, LeftPosZ(340, 100).TopPosZ(148, 19))
|
||||
ITEM(LabelBox, dv___13, SetLabel(t_("Android NDK setting")).HSizePosZ(0, 0).TopPosZ(188, 164))
|
||||
ITEM(TextOption, ndk_blitz, SetLabel(t_("&Use BLITZ")).LeftPosZ(8, 112).TopPosZ(204, 16))
|
||||
ITEM(StaticText, dv___15, SetText(t_("Target architectures:")).LeftPosZ(8, 116).TopPosZ(228, 19))
|
||||
ITEM(StaticText, dv___14, SetText(t_("BLITZ:")).LeftPosZ(8, 116).TopPosZ(204, 19))
|
||||
ITEM(TextOption, ndk_blitz, SetLabel(t_("&Use BLITZ")).LeftPosZ(128, 112).TopPosZ(204, 20))
|
||||
ITEM(StaticText, dv___16, SetText(t_("Target architectures:")).LeftPosZ(8, 116).TopPosZ(228, 19))
|
||||
ITEM(TextOption, ndk_arch_armeabi, SetLabel(t_("armeabi")).LeftPosZ(128, 68).TopPosZ(228, 20))
|
||||
ITEM(TextOption, ndk_arch_armeabi_v7a, SetLabel(t_("armeabi-v7a")).LeftPosZ(204, 84).TopPosZ(228, 20))
|
||||
ITEM(TextOption, ndk_arch_arm64_v8a, SetLabel(t_("arm64-v8a")).LeftPosZ(296, 76).TopPosZ(228, 20))
|
||||
|
|
@ -217,13 +218,13 @@ LAYOUT(BuildMethodsAndroidBuilderSetupLayout, 648, 500)
|
|||
ITEM(TextOption, ndk_arch_x86_64, SetLabel(t_("x86-64")).LeftPosZ(432, 56).TopPosZ(228, 20))
|
||||
ITEM(TextOption, ndk_arch_mips, SetLabel(t_("mips")).LeftPosZ(492, 56).TopPosZ(228, 20))
|
||||
ITEM(TextOption, ndk_arch_mips64, SetLabel(t_("mips64")).LeftPosZ(552, 56).TopPosZ(228, 20))
|
||||
ITEM(StaticText, dv___23, SetText(t_("Toolchain:")).LeftPosZ(8, 116).TopPosZ(252, 19))
|
||||
ITEM(StaticText, dv___24, SetText(t_("Toolchain:")).LeftPosZ(8, 116).TopPosZ(252, 19))
|
||||
ITEM(DropList, ndk_toolchain, LeftPosZ(128, 136).TopPosZ(252, 19))
|
||||
ITEM(StaticText, dv___25, SetText(t_("C++ runtime:")).LeftPosZ(8, 116).TopPosZ(276, 19))
|
||||
ITEM(StaticText, dv___26, SetText(t_("C++ runtime:")).LeftPosZ(8, 116).TopPosZ(276, 19))
|
||||
ITEM(DropList, ndk_cpp_runtime, LeftPosZ(128, 136).TopPosZ(276, 19))
|
||||
ITEM(StaticText, dv___27, SetText(t_("Common C++ options:")).LeftPosZ(8, 116).TopPosZ(300, 19))
|
||||
ITEM(StaticText, dv___28, SetText(t_("Common C++ options:")).LeftPosZ(8, 116).TopPosZ(300, 19))
|
||||
ITEM(EditString, ndk_common_cpp_options, HSizePosZ(128, 8).TopPosZ(300, 19))
|
||||
ITEM(StaticText, dv___29, SetText(t_("Common C options:")).LeftPosZ(8, 116).TopPosZ(324, 19))
|
||||
ITEM(StaticText, dv___30, SetText(t_("Common C options:")).LeftPosZ(8, 116).TopPosZ(324, 19))
|
||||
ITEM(EditString, ndk_common_c_options, HSizePosZ(128, 8).TopPosZ(324, 19))
|
||||
END_LAYOUT
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue