Add support for building Android app on Linux or Mac
This commit is contained in:
@@ -304,10 +304,13 @@ bool AndroidPlatformTools::OnPostProcess(CookingData& data)
|
|||||||
const Char* gradlew = TEXT("gradlew.bat");
|
const Char* gradlew = TEXT("gradlew.bat");
|
||||||
#else
|
#else
|
||||||
const Char* gradlew = TEXT("gradlew");
|
const Char* gradlew = TEXT("gradlew");
|
||||||
|
#endif
|
||||||
|
#if PLATFORM_LINUX
|
||||||
|
Platform::RunProcess(String::Format(TEXT("chmod +x \"{0}/gradlew\""), data.OriginalOutputPath), data.OriginalOutputPath, Dictionary<String, String>(), true);
|
||||||
#endif
|
#endif
|
||||||
const bool distributionPackage = buildSettings->ForDistribution;
|
const bool distributionPackage = buildSettings->ForDistribution;
|
||||||
const String gradleCommand = String::Format(TEXT("\"{0}\" {1}"), data.OriginalOutputPath / gradlew, distributionPackage ? TEXT("assemble") : TEXT("assembleDebug"));
|
const String gradleCommand = String::Format(TEXT("\"{0}\" {1}"), data.OriginalOutputPath / gradlew, distributionPackage ? TEXT("assemble") : TEXT("assembleDebug"));
|
||||||
const int32 result = Platform::RunProcess(gradleCommand, data.OriginalOutputPath, envVars, true);
|
const int32 result = Platform::RunProcess(gradleCommand, data.OriginalOutputPath, Dictionary<String, String>(), true);
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
data.Error(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result);
|
data.Error(TEXT("Failed to build Gradle project into package (result code: {0}). See log for more info."), result);
|
||||||
|
|||||||
@@ -66,10 +66,12 @@ public class Editor : EditorModule
|
|||||||
else if (options.Platform.Target == TargetPlatform.Linux)
|
else if (options.Platform.Target == TargetPlatform.Linux)
|
||||||
{
|
{
|
||||||
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Linux", "PLATFORM_TOOLS_LINUX");
|
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Linux", "PLATFORM_TOOLS_LINUX");
|
||||||
|
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Android", "PLATFORM_TOOLS_ANDROID");
|
||||||
}
|
}
|
||||||
else if (options.Platform.Target == TargetPlatform.Mac)
|
else if (options.Platform.Target == TargetPlatform.Mac)
|
||||||
{
|
{
|
||||||
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Mac", "PLATFORM_TOOLS_MAC");
|
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Mac", "PLATFORM_TOOLS_MAC");
|
||||||
|
AddPlatformTools(options, platformToolsRoot, platformToolsRootExternal, "Android", "PLATFORM_TOOLS_ANDROID");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visual Studio integration
|
// Visual Studio integration
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ namespace FlaxEditor.Windows
|
|||||||
switch (BuildPlatform)
|
switch (BuildPlatform)
|
||||||
{
|
{
|
||||||
case BuildPlatform.LinuxX64:
|
case BuildPlatform.LinuxX64:
|
||||||
|
case BuildPlatform.AndroidARM64:
|
||||||
IsSupported = true;
|
IsSupported = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -129,6 +130,7 @@ namespace FlaxEditor.Windows
|
|||||||
switch (BuildPlatform)
|
switch (BuildPlatform)
|
||||||
{
|
{
|
||||||
case BuildPlatform.MacOSx64:
|
case BuildPlatform.MacOSx64:
|
||||||
|
case BuildPlatform.AndroidARM64:
|
||||||
IsSupported = true;
|
IsSupported = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -2755,6 +2755,30 @@ Window* LinuxPlatform::CreateWindow(const CreateWindowSettings& settings)
|
|||||||
return New<LinuxWindow>(settings);
|
return New<LinuxWindow>(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern char **environ;
|
||||||
|
|
||||||
|
void LinuxPlatform::GetEnvironmentVariables(Dictionary<String, String, HeapAllocation>& result)
|
||||||
|
{
|
||||||
|
char **s = environ;
|
||||||
|
for (; *s; s++)
|
||||||
|
{
|
||||||
|
char* var = *s;
|
||||||
|
int32 split = -1;
|
||||||
|
for (int32 i = 0; var[i]; i++)
|
||||||
|
{
|
||||||
|
if (var[i] == '=')
|
||||||
|
{
|
||||||
|
split = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (split == -1)
|
||||||
|
result[String(var)] = String::Empty;
|
||||||
|
else
|
||||||
|
result[String(var, split)] = String(var + split + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool LinuxPlatform::GetEnvironmentVariable(const String& name, String& value)
|
bool LinuxPlatform::GetEnvironmentVariable(const String& name, String& value)
|
||||||
{
|
{
|
||||||
char* env = getenv(StringAsANSI<>(*name).Get());
|
char* env = getenv(StringAsANSI<>(*name).Get());
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ public:
|
|||||||
static String GetWorkingDirectory();
|
static String GetWorkingDirectory();
|
||||||
static bool SetWorkingDirectory(const String& path);
|
static bool SetWorkingDirectory(const String& path);
|
||||||
static Window* CreateWindow(const CreateWindowSettings& settings);
|
static Window* CreateWindow(const CreateWindowSettings& settings);
|
||||||
|
static void GetEnvironmentVariables(Dictionary<String, String, HeapAllocation>& result);
|
||||||
static bool GetEnvironmentVariable(const String& name, String& value);
|
static bool GetEnvironmentVariable(const String& name, String& value);
|
||||||
static bool SetEnvironmentVariable(const String& name, const String& value);
|
static bool SetEnvironmentVariable(const String& name, const String& value);
|
||||||
static int32 StartProcess(const StringView& filename, const StringView& args, const StringView& workingDir, bool hiddenWindow = false, bool waitForEnd = false);
|
static int32 StartProcess(const StringView& filename, const StringView& args, const StringView& workingDir, bool hiddenWindow = false, bool waitForEnd = false);
|
||||||
|
|||||||
Reference in New Issue
Block a user