mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
Android builder from now can handle native activity
git-svn-id: svn://ultimatepp.org/upp/trunk@8675 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1ff95c3ac7
commit
8b8f539bb9
8 changed files with 74 additions and 24 deletions
|
|
@ -55,6 +55,7 @@ public:
|
|||
void AddCppFlag(const String& name, const String& value = "");
|
||||
void AddLdLibrary(const String& ldLibrary);
|
||||
void AddStaticLibrary(const String& staticLibrary);
|
||||
void AddStaticModuleLibrary(const String& staticModuleLibrary);
|
||||
void AddSharedLibrary(const String& sharedLibrary);
|
||||
|
||||
String GetName() const { return this->name; }
|
||||
|
|
@ -67,6 +68,7 @@ protected:
|
|||
void AppendLdLibraries(String& makeFile) const;
|
||||
void AppendStaticLibraries(String& makeFile) const;
|
||||
void AppendSharedLibraries(String& makeFile) const;
|
||||
void AppendModules(String& makeFile) const;
|
||||
|
||||
private:
|
||||
String name;
|
||||
|
|
@ -74,6 +76,7 @@ private:
|
|||
VectorMap<String, String> cppFlags;
|
||||
Vector<String> ldLibraries;
|
||||
Vector<String> staticLibraries;
|
||||
Vector<String> staticModuleLibraries;
|
||||
Vector<String> sharedLibraries;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void AndroidApplicationMakeFile::SetPlatform(const String& platform)
|
|||
|
||||
void AndroidApplicationMakeFile::SetArchitectures(const Vector<String>& architectures)
|
||||
{
|
||||
this->architectures = clone(architectures);
|
||||
this->architectures = architectures;
|
||||
}
|
||||
|
||||
void AndroidApplicationMakeFile::AddArchitecture(const String& architecture)
|
||||
|
|
|
|||
|
|
@ -201,10 +201,17 @@ bool AndroidBuilder::BuildPackage(const String& package, Vector<String>& linkfil
|
|||
// TODO: improve sieve mechanisme
|
||||
for(int i = 0; i < nativeSourceFilesInPackage.GetCount(); i++)
|
||||
pkgMakeFile.AddSourceFile(nativeSourceFilesInPackage[i]);
|
||||
|
||||
for(int i = 0; i < pkg.flag.GetCount(); i++)
|
||||
pkgMakeFile.AddCppFlag(pkg.flag[i].text);
|
||||
|
||||
for(int i = 0; i < pkg.library.GetCount(); i++)
|
||||
pkgMakeFile.AddLdLibrary(pkg.library[i].text);
|
||||
|
||||
Vector<String> staticLibs = Split(Gather(pkg.static_library, config.GetKeys()), ' ');
|
||||
for(int i = 0; i < staticLibs.GetCount(); i++)
|
||||
pkgMakeFile.AddStaticModuleLibrary(staticLibs[i]);
|
||||
|
||||
for(int i = 0; i < pkg.uses.GetCount(); i++)
|
||||
pkgMakeFile.AddSharedLibrary(pkg.uses[i].text);
|
||||
|
||||
|
|
@ -228,17 +235,20 @@ bool AndroidBuilder::Link(const Vector<String>& linkfile, const String& linkopti
|
|||
|
||||
// We need to compile java packages in this place, because we need to generate "R.java" file before...
|
||||
// We don't know which packages contain resources.
|
||||
PutConsole("-----");
|
||||
PutConsole("Compiling java sources...");
|
||||
bool error = false;
|
||||
int time = GetTickCount();
|
||||
for(int i = 0; i < linkfile.GetCount(); i++) {
|
||||
if(Execute(linkfile[i], ss) != 0) {
|
||||
PutConsole(ss.GetResult());
|
||||
return false;
|
||||
int time;
|
||||
if(linkfile.GetCount()) {
|
||||
PutConsole("-----");
|
||||
PutConsole("Compiling java sources...");
|
||||
bool error = false;
|
||||
time = GetTickCount();
|
||||
for(int i = 0; i < linkfile.GetCount(); i++) {
|
||||
if(Execute(linkfile[i], ss) != 0) {
|
||||
PutConsole(ss.GetResult());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PutConsole("Java sources compiled in " + GetPrintTime(time) + ".");
|
||||
}
|
||||
PutConsole("Java sources compiled in " + GetPrintTime(time) + ".");
|
||||
|
||||
// Now, we are going to start compiling c/c++ sources
|
||||
if(DirectoryExists(GetAndroidProjectJniSourcesDir())) {
|
||||
|
|
@ -264,18 +274,21 @@ bool AndroidBuilder::Link(const Vector<String>& linkfile, const String& linkopti
|
|||
PutConsole("Native sources compiled in " + GetPrintTime(time) + ".");
|
||||
}
|
||||
|
||||
PutConsole("-----");
|
||||
PutConsole("Creating dex file...");
|
||||
RealizeDirectory(GetAndroidProjectBinDir());
|
||||
String dxCmd;
|
||||
dxCmd << NormalizeExePath(androidSDK.DxPath());
|
||||
dxCmd << " --dex ";
|
||||
dxCmd << "--output=" << GetAndroidProjectBinDir() << DIR_SEPS << "classes.dex ";
|
||||
dxCmd << GetAndroidProjectClassesDir();
|
||||
// PutConsole(dxCmd);
|
||||
if(Execute(dxCmd, ss) != 0) {
|
||||
PutConsole(ss.GetResult());
|
||||
return false;
|
||||
String classesDir = GetAndroidProjectClassesDir();
|
||||
if(DirectoryExists(classesDir)) {
|
||||
PutConsole("-----");
|
||||
PutConsole("Creating dex file...");
|
||||
RealizeDirectory(GetAndroidProjectBinDir());
|
||||
String dxCmd;
|
||||
dxCmd << NormalizeExePath(androidSDK.DxPath());
|
||||
dxCmd << " --dex ";
|
||||
dxCmd << "--output=" << GetAndroidProjectBinDir() << DIR_SEPS << "classes.dex ";
|
||||
dxCmd << classesDir;
|
||||
// PutConsole(dxCmd);
|
||||
if(Execute(dxCmd, ss) != 0) {
|
||||
PutConsole(ss.GetResult());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
PutConsole("Creating apk file...");
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ String AndroidModuleMakeFile::ToString() const
|
|||
AppendStaticLibraries(makeFile);
|
||||
AppendSharedLibraries(makeFile);
|
||||
makeFile << "include $(BUILD_SHARED_LIBRARY)\n";
|
||||
AppendModules(makeFile);
|
||||
|
||||
return makeFile;
|
||||
}
|
||||
|
|
@ -63,6 +64,11 @@ void AndroidModuleMakeFile::AddStaticLibrary(const String& staticLibrary)
|
|||
staticLibraries.Add(staticLibrary);
|
||||
}
|
||||
|
||||
void AndroidModuleMakeFile::AddStaticModuleLibrary(const String& staticModuleLibrary)
|
||||
{
|
||||
staticModuleLibraries.Add(staticModuleLibrary);
|
||||
}
|
||||
|
||||
void AndroidModuleMakeFile::AddSharedLibrary(const String& sharedLibrary)
|
||||
{
|
||||
sharedLibraries.Add(sharedLibrary);
|
||||
|
|
@ -101,7 +107,11 @@ void AndroidModuleMakeFile::AppendLdLibraries(String& makeFile) const
|
|||
|
||||
void AndroidModuleMakeFile::AppendStaticLibraries(String& makeFile) const
|
||||
{
|
||||
AndroidMakeFile::AppendStringVector(makeFile, staticLibraries, "LOCAL_STATIC_LIBRARIES");
|
||||
Vector<String> allLibs;
|
||||
allLibs.Append(staticLibraries);
|
||||
allLibs.Append(staticModuleLibraries);
|
||||
|
||||
AndroidMakeFile::AppendStringVector(makeFile, allLibs, "LOCAL_STATIC_LIBRARIES");
|
||||
}
|
||||
|
||||
void AndroidModuleMakeFile::AppendSharedLibraries(String& makeFile) const
|
||||
|
|
@ -109,4 +119,23 @@ void AndroidModuleMakeFile::AppendSharedLibraries(String& makeFile) const
|
|||
AndroidMakeFile::AppendStringVector(makeFile, sharedLibraries, "LOCAL_SHARED_LIBRARIES");
|
||||
}
|
||||
|
||||
void AndroidModuleMakeFile::AppendModules(String& makeFile) const
|
||||
{
|
||||
if(staticModuleLibraries.GetCount()) {
|
||||
for(int i = 0; i < staticModuleLibraries.GetCount(); i++) {
|
||||
if(i == 0)
|
||||
makeFile << "\n";
|
||||
|
||||
const String androidPrefix = "android_";
|
||||
|
||||
String module = staticModuleLibraries[i];
|
||||
if(module.StartsWith(androidPrefix))
|
||||
module.Remove(0, androidPrefix.GetCount());
|
||||
module = "android/" + module;
|
||||
|
||||
makeFile << "$(call import-module, " << module << ")\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END_UPP_NAMESPACE
|
||||
|
|
|
|||
|
|
@ -315,6 +315,7 @@ public:
|
|||
Array<OptItem> uses;
|
||||
Array<OptItem> target;
|
||||
Array<OptItem> library;
|
||||
Array<OptItem> static_library;
|
||||
Array<OptItem> link;
|
||||
Array<OptItem> option;
|
||||
Array<OptItem> include;
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ bool Package::Load(const char *path)
|
|||
for(;;) {
|
||||
Reset();
|
||||
library.Clear();
|
||||
static_library.Clear();
|
||||
target.Clear();
|
||||
flag.Clear();
|
||||
option.Clear();
|
||||
|
|
@ -227,6 +228,7 @@ bool Package::Load(const char *path)
|
|||
if(!LoadOpt(p, "options", option) &&
|
||||
!LoadOpt(p, "link", link) &&
|
||||
!LoadOpt(p, "library", library) &&
|
||||
!LoadOpt(p, "static_library", static_library) &&
|
||||
!LoadOpt(p, "flags", flag) &&
|
||||
!LoadOpt(p, "target", target) &&
|
||||
!LoadOpt(p, "uses", uses) &&
|
||||
|
|
@ -436,6 +438,7 @@ bool Package::Save(const char *path) const {
|
|||
putopt(out, "uses", uses);
|
||||
putopt(out, "target", target);
|
||||
putopt(out, "library", library);
|
||||
putopt(out, "static_library", static_library);
|
||||
putopt(out, "options", option);
|
||||
putopt(out, "link", link);
|
||||
putopt(out, "include", include);
|
||||
|
|
|
|||
|
|
@ -609,6 +609,7 @@ PackageEditor::PackageEditor()
|
|||
Add("Uses", actual.uses);
|
||||
Add("Targets", actual.target);
|
||||
Add("Libraries", actual.library);
|
||||
Add("Static libraries", actual.static_library);
|
||||
Add("Link options", actual.link);
|
||||
Add("Compiler options", actual.option);
|
||||
Add("Internal includes", actual.include);
|
||||
|
|
|
|||
|
|
@ -397,7 +397,7 @@ struct PackageEditor : WorkspaceWork, WithUppLayout<TopWindow> {
|
|||
virtual void PackageCursor();
|
||||
|
||||
enum OptionType {
|
||||
FLAG = 0, USES, TARGET, LIBRARY, LINK, COMPILER, INCLUDE,
|
||||
FLAG = 0, USES, TARGET, LIBRARY, STATIC_LIBRARY, LINK, COMPILER, INCLUDE,
|
||||
FILEOPTION, FILEDEPENDS
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue