Skip to content

Commit

Permalink
[FIXED JENKINS-14740] Include ABI in generated AVD name.
Browse files Browse the repository at this point in the history
Also expand variables in the 'Target ABI' field at runtime.
  • Loading branch information
orrc committed Sep 23, 2012
1 parent 6e28da5 commit 0c1f816
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
14 changes: 11 additions & 3 deletions src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java
Expand Up @@ -150,8 +150,10 @@ public String getConfigHash(Node node, Combination combination) {
String screenDensity = Utils.expandVariables(envVars, combination, this.screenDensity);
String screenResolution = Utils.expandVariables(envVars, combination, this.screenResolution);
String deviceLocale = Utils.expandVariables(envVars, combination, this.deviceLocale);
String targetAbi = Utils.expandVariables(envVars, combination, this.targetAbi);

return EmulatorConfig.getAvdName(avdName, osVersion, screenDensity, screenResolution, deviceLocale);
return EmulatorConfig.getAvdName(avdName, osVersion, screenDensity, screenResolution,
deviceLocale, targetAbi);
}

@Override
Expand All @@ -174,6 +176,7 @@ public Environment setUp(AbstractBuild build, final Launcher launcher, BuildList
String screenResolution = Utils.expandVariables(envVars, buildVars, this.screenResolution);
String deviceLocale = Utils.expandVariables(envVars, buildVars, this.deviceLocale);
String sdCardSize = Utils.expandVariables(envVars, buildVars, this.sdCardSize);
String targetAbi = Utils.expandVariables(envVars, buildVars, this.targetAbi);

// Expand macros within hardware property values
final int propCount = hardwareProperties == null ? 0 : hardwareProperties.length;
Expand Down Expand Up @@ -984,13 +987,18 @@ private ValidationResult doCheckDeviceLocale(String locale, boolean allowVariabl
}

public FormValidation doCheckTargetAbi(@QueryParameter String value) {
return checkTargetAbi(value).getFormValidation();
return checkTargetAbi(value, true).getFormValidation();
}

private ValidationResult checkTargetAbi(String value) {
private ValidationResult checkTargetAbi(String value, boolean allowVariables) {
if (value == null || "".equals(value.trim())) {
return ValidationResult.ok();
}

if (allowVariables && value.matches(Constants.REGEX_VARIABLE)) {
return ValidationResult.ok();
}

for (String s : Constants.TARGET_ABIS) {
if (s.equals(value)) {
return ValidationResult.ok();
Expand Down
Expand Up @@ -123,10 +123,10 @@ public static final EmulatorConfig create(String avdName, String osVersion, Stri
}

public static final String getAvdName(String avdName, String osVersion, String screenDensity,
String screenResolution, String deviceLocale) {
String screenResolution, String deviceLocale, String targetAbi) {
try {
return create(avdName, osVersion, screenDensity, screenResolution, deviceLocale, null,
false, false, false, null, null, null).getAvdName();
false, false, false, null, targetAbi, null).getAvdName();
} catch (IllegalArgumentException e) {}
return null;
}
Expand All @@ -148,7 +148,11 @@ private String getGeneratedAvdName() {
String density = screenDensity.toString();
String resolution = screenResolution.toString();
String platform = osVersion.getTargetName().replace(':', '_').replace(' ', '_');
return String.format("hudson_%s_%s_%s_%s", locale, density, resolution, platform);
String abi = "";
if (Util.fixEmptyAndTrim(targetAbi) != null) {
abi = "_" + targetAbi.replace(' ', '-');
}
return String.format("hudson_%s_%s_%s_%s%s", locale, density, resolution, platform, abi);
}

public AndroidPlatform getOsVersion() {
Expand Down
Expand Up @@ -20,7 +20,7 @@ SUSPECT_RESOLUTION_ANDROID_4=That doesn''t look right for Android {0}. Did you m
DEFAULT_LOCALE_WARNING=Locale will default to ''{0}'' if not specified
LOCALE_FORMAT_WARNING=Locale should have format: ab_XY
INVALID_SD_CARD_SIZE=SD card size should be numeric with suffix, e.g. 32M
INVALID_TARGET_ABI=Invalid target abi
INVALID_TARGET_ABI=Unrecognised target ABI
SD_CARD_SIZE_TOO_SMALL=SD card size must be at least 9 megabytes
EMULATOR_CONFIGURATION_BAD=Unrecognised Android emulator configuration: ''{0}''

Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/help-targetAbi.html
@@ -1,3 +1,3 @@
Should be the name of the abi / system image to be used, e.g "<code>armeabi</code>" or "<code>x86</code>".<br/>
If empty the default abi for the select platform will be used. You only need to define this field if you have
more than one system image per Android platform installed.
Should be the name of the ABI / system image to be used, e.g "<code>armeabi</code>" or "<code>x86</code>".<br/>
If empty the default ABI for the select platform will be used. You only need to define this field if you have
more than one system image per Android platform installed.

0 comments on commit 0c1f816

Please sign in to comment.