Search in sources :

Example 36 with NSDictionary

use of com.dd.plist.NSDictionary in project bazel by bazelbuild.

the class XcodeprojGeneration method nonArcCompileSettings.

private static NSDictionary nonArcCompileSettings() {
    NSDictionary result = new NSDictionary();
    result.put("COMPILER_FLAGS", "-fno-objc-arc");
    return result;
}
Also used : NSDictionary(com.dd.plist.NSDictionary)

Example 37 with NSDictionary

use of com.dd.plist.NSDictionary in project bazel by bazelbuild.

the class XcodeprojSerializer method serializeObject.

/**
   * Serialize a {@link PBXObject} and its recursive descendants into the object dictionary.
   *
   * @return the GID of the serialized object
   *
   * @see PBXObject#serializeInto
   */
private String serializeObject(PBXObject obj) {
    if (obj.getGlobalID() == null) {
        obj.setGlobalID(obj.generateGid(gidGenerator));
        LOG.verbose("Set new object GID: %s", obj);
    } else {
        // Check that the object has already been serialized.
        NSObject object = objects.get(obj.getGlobalID());
        if (object != null) {
            LOG.verbose("Object %s found, returning existing object %s", obj, object);
            return obj.getGlobalID();
        } else {
            LOG.verbose("Object already had GID set: %s", obj);
        }
    }
    // Save the existing object being deserialized.
    NSDictionary stack = currentObject;
    currentObject = new NSDictionary();
    currentObject.put("isa", obj.isa());
    obj.serializeInto(this);
    objects.put(obj.getGlobalID(), currentObject);
    // Restore the existing object being deserialized.
    currentObject = stack;
    return obj.getGlobalID();
}
Also used : NSObject(com.dd.plist.NSObject) NSDictionary(com.dd.plist.NSDictionary)

Example 38 with NSDictionary

use of com.dd.plist.NSDictionary in project bazel by bazelbuild.

the class PBXProject method serializeInto.

@Override
public void serializeInto(XcodeprojSerializer s) {
    super.serializeInto(s);
    s.addField("mainGroup", mainGroup);
    Collections.sort(targets, Ordering.natural().onResultOf(new Function<PBXTarget, String>() {

        @Override
        public String apply(PBXTarget input) {
            return input.getName();
        }
    }));
    s.addField("targets", targets);
    s.addField("buildConfigurationList", buildConfigurationList);
    s.addField("compatibilityVersion", compatibilityVersion);
    NSDictionary d = new NSDictionary();
    d.put("LastUpgradeCheck", "0610");
    s.addField("attributes", d);
}
Also used : Function(com.google.common.base.Function) NSDictionary(com.dd.plist.NSDictionary)

Example 39 with NSDictionary

use of com.dd.plist.NSDictionary in project bazel by bazelbuild.

the class PlistMerging method from.

/**
   * Generates a Plistmerging combining values from sourceFiles and immutableSourceFiles, and
   * modifying them based on subsitutions and keysToRemoveIfEmptyString.
   */
public static PlistMerging from(List<Path> sourceFiles, List<Path> immutableSourceFiles, Map<String, String> substitutions, KeysToRemoveIfEmptyString keysToRemoveIfEmptyString, String executableName) throws IOException {
    NSDictionary merged = PlistMerging.merge(sourceFiles);
    NSDictionary immutableEntries = PlistMerging.merge(immutableSourceFiles);
    Set<String> conflictingEntries = Sets.intersection(immutableEntries.keySet(), merged.keySet());
    Preconditions.checkArgument(conflictingEntries.isEmpty(), "The following plist entries may not be overridden, but are present in more than one " + "of the input lists: %s", conflictingEntries);
    merged.putAll(immutableEntries);
    for (Map.Entry<String, NSObject> entry : merged.entrySet()) {
        if (entry.getValue().toJavaObject() instanceof String) {
            String newValue = substituteEnvironmentVariable(substitutions, (String) entry.getValue().toJavaObject());
            merged.put(entry.getKey(), newValue);
        }
    }
    for (String key : keysToRemoveIfEmptyString) {
        if (Equaling.of(Mapping.of(merged, key), Optional.<NSObject>of(new NSString("")))) {
            merged.remove(key);
        }
    }
    // TODO(bazel-team): warn user if we replace their values.
    if (!immutableEntries.isEmpty()) {
        Pattern versionPattern = Pattern.compile("[^0-9.]");
        if (!merged.containsKey(BUNDLE_VERSION_PLIST_KEY)) {
            merged.put(BUNDLE_VERSION_PLIST_KEY, BUNDLE_VERSION_DEFAULT);
        } else {
            NSObject nsVersion = merged.get(BUNDLE_VERSION_PLIST_KEY);
            String version = (String) nsVersion.toJavaObject();
            if (version.length() > 18 || versionPattern.matcher(version).find()) {
                merged.put(BUNDLE_VERSION_PLIST_KEY, BUNDLE_VERSION_DEFAULT);
            }
        }
        if (!merged.containsKey(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY)) {
            merged.put(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY, BUNDLE_SHORT_VERSION_STRING_DEFAULT);
        } else {
            NSObject nsVersion = merged.get(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY);
            String version = (String) nsVersion.toJavaObject();
            if (version.length() > 18 || versionPattern.matcher(version).find()) {
                merged.put(BUNDLE_SHORT_VERSION_STRING_PLIST_KEY, BUNDLE_SHORT_VERSION_STRING_DEFAULT);
            }
        }
    }
    PlistMerging result = new PlistMerging(merged);
    if (executableName != null) {
        result.setExecutableName(executableName);
    }
    return result;
}
Also used : Pattern(java.util.regex.Pattern) NSObject(com.dd.plist.NSObject) NSDictionary(com.dd.plist.NSDictionary) NSString(com.dd.plist.NSString) Map(java.util.Map) NSString(com.dd.plist.NSString)

Example 40 with NSDictionary

use of com.dd.plist.NSDictionary in project bazel by bazelbuild.

the class CurrentVersionSetter method trySetCurrentVersion.

private void trySetCurrentVersion(XCVersionGroup group) {
    if (group.getSourceTree() != SourceTree.GROUP) {
        return;
    }
    Path groupPath = workspaceRoot.resolve(group.getPath());
    Path currentVersionPlist = groupPath.resolve(".xccurrentversion");
    if (!Files.isReadable(currentVersionPlist)) {
        return;
    }
    NSDictionary plist;
    try {
        plist = PlistMerging.readPlistFile(currentVersionPlist);
    } catch (IOException e) {
        return;
    }
    NSString currentVersion = (NSString) plist.get("_XCCurrentVersionName");
    if (currentVersion == null) {
        return;
    }
    for (PBXFileReference child : group.getChildren()) {
        child.setExplicitFileType(Optional.of("wrapper.xcdatamodel"));
        if (child.getName().equals(currentVersion.getContent())) {
            group.setCurrentVersion(Optional.of(child));
        }
    }
}
Also used : Path(java.nio.file.Path) NSDictionary(com.dd.plist.NSDictionary) IOException(java.io.IOException) NSString(com.dd.plist.NSString) PBXFileReference(com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)

Aggregations

NSDictionary (com.dd.plist.NSDictionary)70 NSString (com.dd.plist.NSString)33 NSObject (com.dd.plist.NSObject)22 IOException (java.io.IOException)16 Test (org.junit.Test)15 File (java.io.File)13 NSArray (com.dd.plist.NSArray)12 Path (java.nio.file.Path)11 InputStream (java.io.InputStream)8 NSNumber (com.dd.plist.NSNumber)7 PBXBuildFile (com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile)6 PBXFileReference (com.facebook.buck.apple.xcode.xcodeproj.PBXFileReference)6 ImmutableMap (com.google.common.collect.ImmutableMap)6 BufferedInputStream (java.io.BufferedInputStream)6 SourceTreePath (com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath)4 NoSuchFileException (java.nio.file.NoSuchFileException)4 PropertyListFormatException (com.dd.plist.PropertyListFormatException)3 ExecutionContext (com.facebook.buck.step.ExecutionContext)3 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)3 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)3