Skip to content

Commit

Permalink
Refactored info plist handling, added missing license headers and usi…
Browse files Browse the repository at this point in the history
…ng correct min os version for actool.
  • Loading branch information
BlueRiverInteractive committed Feb 18, 2015
1 parent 6fa6b27 commit f2a1a97
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 32 deletions.
17 changes: 11 additions & 6 deletions compiler/src/main/java/org/robovm/compiler/config/Config.java
Expand Up @@ -69,6 +69,7 @@
import org.robovm.compiler.target.ConsoleTarget;
import org.robovm.compiler.target.Target;
import org.robovm.compiler.target.ios.IOSTarget;
import org.robovm.compiler.target.ios.InfoPList;
import org.robovm.compiler.target.ios.ProvisioningProfile;
import org.robovm.compiler.target.ios.SigningIdentity;
import org.simpleframework.xml.Element;
Expand Down Expand Up @@ -139,19 +140,20 @@ public enum TargetType { console, ios };

@Element(required = false)
private String iosSdkVersion;
@Element(required = false)
private File iosInfoPList = null;
@Element(required = false, name = "iosInfoPList")
private File iosInfoPListFile = null;
@Element(required = false)
private File iosResourceRulesPList;
@Element(required = false)
private File iosEntitlementsPList;

@Element(required = false)
private Tools tools = new Tools();
private Tools tools;

private SigningIdentity iosSignIdentity;
private ProvisioningProfile iosProvisioningProfile;
private String iosDeviceType;
private InfoPList iosInfoPList;

private boolean iosSkipSigning = false;

Expand Down Expand Up @@ -434,10 +436,13 @@ public String getIosDeviceType() {
return iosDeviceType;
}

public File getIosInfoPList() {
public InfoPList getIosInfoPList() {
if (iosInfoPList == null && iosInfoPListFile != null) {
iosInfoPList = new InfoPList(iosInfoPListFile);
}
return iosInfoPList;
}

public File getIosResourceRulesPList() {
return iosResourceRulesPList;
}
Expand Down Expand Up @@ -1251,7 +1256,7 @@ public Builder iosDeviceType(String deviceType) {
}

public Builder iosInfoPList(File infoPList) {
config.iosInfoPList = infoPList;
config.iosInfoPListFile = infoPList;
return this;
}

Expand Down
@@ -1,3 +1,18 @@
/*
* Copyright (C) 2013-2015 Trillian Mobile AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.robovm.compiler.config.tools;

import org.simpleframework.xml.Element;
Expand Down
15 changes: 15 additions & 0 deletions compiler/src/main/java/org/robovm/compiler/config/tools/Tools.java
@@ -1,3 +1,18 @@
/*
* Copyright (C) 2013-2015 Trillian Mobile AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.robovm.compiler.config.tools;

import org.simpleframework.xml.Element;
Expand Down
Expand Up @@ -74,8 +74,6 @@ public class IOSTarget extends AbstractTarget {

private Arch arch;
private SDK sdk;
private File infoPList = null;
private NSDictionary infoPListDict = null;
private File resourceRulesPList;
private File entitlementsPList;
private SigningIdentity signIdentity;
Expand Down Expand Up @@ -268,10 +266,8 @@ protected void doBuild(File outFile, List<String> ccArgs,
libArgs.add("UIKit");
}

String minVersion = config.getOs().getMinVersion();
if (infoPListDict != null && infoPListDict.objectForKey("MinimumOSVersion") != null) {
minVersion = infoPListDict.objectForKey("MinimumOSVersion").toString();
}
String minVersion = getMinimumOSVersion();

int majorVersionNumber = -1;
try {
majorVersionNumber = Integer.parseInt(minVersion.substring(0, minVersion.indexOf('.')));
Expand Down Expand Up @@ -520,25 +516,35 @@ protected File getAppDir() {
}

protected String getExecutable() {
if (infoPListDict != null) {
NSObject bundleExecutable = infoPListDict.objectForKey("CFBundleExecutable");
if (config.getIosInfoPList() != null) {
String bundleExecutable = config.getIosInfoPList().getBundleExecutable();
if (bundleExecutable != null) {
return bundleExecutable.toString();
return bundleExecutable;
}
}
return config.getExecutableName();
}

protected String getBundleId() {
if (infoPListDict != null) {
NSObject bundleIdentifier = infoPListDict.objectForKey("CFBundleIdentifier");
if (config.getIosInfoPList() != null) {
String bundleIdentifier = config.getIosInfoPList().getBundleIdentifier();
if (bundleIdentifier != null) {
return bundleIdentifier.toString();
return bundleIdentifier;
}
}
return config.getMainClass() != null ? config.getMainClass() : config.getExecutableName();
}

protected String getMinimumOSVersion() {
if (config.getIosInfoPList() != null) {
String minVersion = config.getIosInfoPList().getMinimumOSVersion();
if (minVersion != null) {
return minVersion;
}
}
return config.getOs().getMinVersion();
}

private void putIfAbsent(NSDictionary dict, String key, String value) {
if (dict.objectForKey(key) == null) {
dict.put(key, value);
Expand Down Expand Up @@ -583,7 +589,8 @@ protected void customizeInfoPList(NSDictionary dict) {

protected void createInfoPList(File dir) throws IOException {
NSDictionary dict = new NSDictionary();
if (infoPListDict != null) {
if (config.getIosInfoPList() != null && config.getIosInfoPList().getDictionary() != null) {
NSDictionary infoPListDict = config.getIosInfoPList().getDictionary();
for (String key : infoPListDict.allKeys()) {
dict.put(key, infoPListDict.objectForKey(key));
}
Expand Down Expand Up @@ -669,24 +676,19 @@ public void init(Config config) {
}
}

infoPList = config.getIosInfoPList();
if (infoPList != null) {
try {
infoPListDict = (NSDictionary) parsePropertyList(infoPList, config.getProperties());
} catch (Throwable t) {
throw new IllegalArgumentException("Failed to parse Info.plist XML file: " + infoPList, t);
}
if (config.getIosInfoPList() != null) {
config.getIosInfoPList().parse(config.getProperties());
}

if (isDeviceArch(arch)) {
if (!config.isIosSkipSigning()) {
provisioningProfile = config.getIosProvisioningProfile();
if (provisioningProfile == null) {
NSString bundleId = infoPListDict != null ? (NSString) infoPListDict.objectForKey("CFBundleIdentifier") : null;
String bundleId = config.getIosInfoPList().getBundleIdentifier();
if (bundleId == null) {
bundleId = new NSString("*");
bundleId = "*";
}
provisioningProfile = ProvisioningProfile.find(ProvisioningProfile.list(), signIdentity, bundleId.toString());
provisioningProfile = ProvisioningProfile.find(ProvisioningProfile.list(), signIdentity, bundleId);
}
}
}
Expand Down
@@ -0,0 +1,77 @@
/*
* Copyright (C) 2013-2015 Trillian Mobile AB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.robovm.compiler.target.ios;

import java.io.File;
import java.util.Properties;

import com.dd.plist.NSDictionary;
import com.dd.plist.NSObject;

public class InfoPList {
private File file;
private NSDictionary dictionary;

public InfoPList(File file) {
this.file = file;
}

public void parse(Properties props) {
try {
this.dictionary = (NSDictionary) IOSTarget.parsePropertyList(file, props);
} catch (Throwable t) {
throw new IllegalArgumentException("Failed to parse Info.plist XML file: " + file, t);
}
}

public String getBundleIdentifier() {
if (dictionary != null) {
NSObject object = dictionary.objectForKey("CFBundleIdentifier");
if (object != null) {
return object.toString();
}
}
return null;
}

public String getBundleExecutable() {
if (dictionary != null) {
NSObject object = dictionary.objectForKey("CFBundleExecutable");
if (object != null) {
return object.toString();
}
}
return null;
}

public String getMinimumOSVersion() {
if (dictionary != null) {
NSObject object = dictionary.objectForKey("MinimumOSVersion");
if (object != null) {
return object.toString();
}
}
return null;
}

public File getFile() {
return file;
}

public NSDictionary getDictionary() {
return dictionary;
}
}
14 changes: 11 additions & 3 deletions compiler/src/main/java/org/robovm/compiler/util/ToolchainUtil.java
Expand Up @@ -153,11 +153,11 @@ public static void pngcrush(Config config, File inFile, File outFile) throws IOE

public static void textureatlas(Config config, File inDir, File outDir) throws IOException {
List<String> opts = new ArrayList<String>();
TextureAtlas atlasConfig = config.getTools().getTextureAtlas();
int outputFormat = 1;
int maxTextureDimension = 1;

if (atlasConfig != null) {
if (config.getTools() != null && config.getTools().getTextureAtlas() != null) {
TextureAtlas atlasConfig = config.getTools().getTextureAtlas();
outputFormat = 1 + atlasConfig.getOutputFormat().ordinal();
maxTextureDimension = 1 + atlasConfig.getMaximumTextureDimension().ordinal();

Expand Down Expand Up @@ -210,9 +210,17 @@ public static void actool(Config config, File inDir, File outDir) throws IOExcep
opts.add("iphonesimulator");
}

String minOSVersion = config.getOs().getMinVersion();
if (config.getIosInfoPList() != null) {
String v = config.getIosInfoPList().getMinimumOSVersion();
if (v != null) {
minOSVersion = v;
}
}

new Executor(config.getLogger(), getACTool())
.args(inDir, opts, "--output-format", "human-readable-text",
"--minimum-deployment-target", "6.0", "--compile", outDir).exec();
"--minimum-deployment-target", minOSVersion, "--compile", outDir).exec();
}

public static void compileStrings(Config config, File inFile, File outFile) throws IOException {
Expand Down

0 comments on commit f2a1a97

Please sign in to comment.