This commit is contained in:
Joshua Granick
2017-06-05 16:06:48 -07:00
parent f31b29fc3c
commit 6ce9d189e3
3 changed files with 49 additions and 41 deletions

View File

@@ -1852,10 +1852,6 @@ class ProjectXMLParser extends HXProject {
case "target-sdk-version":
config.set ("android.target-sdk-version", Std.parseInt (value));
case "build-tools-version":
config.set ("android.build-tools-version", value);
case "install-location":

View File

@@ -71,61 +71,70 @@ class AndroidHelper {
}
public static function getBuildToolsVersion (project:HXProject):String {
var buildToolsPath = project.environment.get ("ANDROID_SDK") + "/build-tools/";
var buildToolsPath = PathHelper.combine (project.environment.get ("ANDROID_SDK"), "build-tools/");
var version = ~/^(\d+)\.(\d+)\.(\d+)$/i;
var current = { major : 0, minor : 0, micro : 0 };
if (!FileSystem.exists (buildToolsPath)) {
LogHelper.error ("Cannot find directory \"" + buildToolsPath + "\"");
}
for (buildTool in FileSystem.readDirectory (buildToolsPath)) {
//gradle only likes simple version numbers (x.y.z)
if (!version.match (buildTool)) {
continue;
}
var newVersion = {
major: Std.parseInt (version.matched (1)),
minor: Std.parseInt (version.matched (2)),
micro: Std.parseInt (version.matched (3))
};
if (newVersion.major != current.major) {
if (newVersion.major > current.major) {
current = newVersion;
}
} else if (newVersion.minor != current.minor) {
if (newVersion.minor > current.minor) {
current = newVersion;
}
} else {
if (newVersion.micro > current.micro) {
current = newVersion;
}
}
}
return '${current.major}.${current.minor}.${current.micro}';
}
public static function getDeviceSDKVersion (deviceID:String):Int {

View File

@@ -321,19 +321,12 @@ class AndroidPlatform extends PlatformTarget {
context.ANDROID_INSTALL_LOCATION = project.config.getString ("android.install-location", "auto");
context.ANDROID_MINIMUM_SDK_VERSION = project.config.getInt ("android.minimum-sdk-version", 9);
context.ANDROID_TARGET_SDK_VERSION = project.config.getInt ("android.target-sdk-version", 19);
context.ANDROID_BUILD_TOOLS_VERSION = project.config.getString ("android.build-tools-version");
context.ANDROID_EXTENSIONS = project.config.getArrayString ("android.extension");
context.ANDROID_PERMISSIONS = project.config.getArrayString ("android.permission", [ "android.permission.WAKE_LOCK", "android.permission.INTERNET", "android.permission.VIBRATE", "android.permission.ACCESS_NETWORK_STATE" ]);
context.ANDROID_GRADLE_VERSION = project.config.getString ("android.gradle-version", "2.10");
context.ANDROID_GRADLE_PLUGIN = project.config.getString ("android.gradle-plugin", "2.1.0");
context.ANDROID_LIBRARY_PROJECTS = [];
if (project.config.exists ("android.gradle-build-directory")) {
context.ANDROID_GRADLE_BUILD_DIRECTORY = project.config.getString ("android.gradle-build-directory");
}
if (!project.environment.exists ("ANDROID_SDK") || !project.environment.exists ("ANDROID_NDK_ROOT")) {
var command = "lime";
@@ -345,11 +338,21 @@ class AndroidPlatform extends PlatformTarget {
Sys.exit (1);
}
if (context.ANDROID_BUILD_TOOLS_VERSION == "") {
if (project.config.exists ("android.gradle-build-directory")) {
context.ANDROID_GRADLE_BUILD_DIRECTORY = project.config.getString ("android.gradle-build-directory");
}
if (project.config.exists ("android.build-tools-version")) {
context.ANDROID_BUILD_TOOLS_VERSION = project.config.getString ("android.build-tools-version");
} else {
context.ANDROID_BUILD_TOOLS_VERSION = AndroidHelper.getBuildToolsVersion (project);
}
var escaped = ~/([ #!=\\:])/g;