Search in sources :

Example 41 with NSDictionary

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

the class WatchExtensionSupport method registerWatchExtensionAutomaticPlistAction.

/**
   * Registers an action to generate a plist containing entries required for watch extension that
   * should be added to the merged plist.
   */
private void registerWatchExtensionAutomaticPlistAction() {
    List<String> uiRequiredDeviceCapabilities = ImmutableList.of("watch-companion");
    NSDictionary watchExtensionAutomaticEntries = new NSDictionary();
    watchExtensionAutomaticEntries.put("UIRequiredDeviceCapabilities", NSObject.wrap(uiRequiredDeviceCapabilities.toArray()));
    ruleContext.registerAction(FileWriteAction.create(ruleContext, watchExtensionAutomaticPlist(), watchExtensionAutomaticEntries.toGnuStepASCIIPropertyList(), /*makeExecutable=*/
    false));
}
Also used : NSDictionary(com.dd.plist.NSDictionary)

Example 42 with NSDictionary

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

the class ReleaseBundlingSupport method registerLaunchStoryboardPlistAction.

private void registerLaunchStoryboardPlistAction() {
    String launchStoryboard = releaseBundling.getLaunchStoryboard().getFilename();
    String launchStoryboardName = launchStoryboard.substring(0, launchStoryboard.lastIndexOf('.'));
    NSDictionary result = new NSDictionary();
    result.put("UILaunchStoryboardName", launchStoryboardName);
    String contents = result.toGnuStepASCIIPropertyList();
    ruleContext.registerAction(FileWriteAction.create(ruleContext, getLaunchStoryboardPlist(), contents, false));
}
Also used : NSDictionary(com.dd.plist.NSDictionary)

Example 43 with NSDictionary

use of com.dd.plist.NSDictionary in project buck by facebook.

the class ProjectGeneratorTest method cxxFlagsPropagatedToConfig.

@Test
public void cxxFlagsPropagatedToConfig() throws IOException {
    BuildTarget buildTarget = BuildTarget.builder(rootPath, "//foo", "lib").build();
    TargetNode<?, ?> node = AppleLibraryBuilder.createBuilder(buildTarget).setLangPreprocessorFlags(ImmutableMap.of(CxxSource.Type.C, ImmutableList.of("-std=gnu11"), CxxSource.Type.OBJC, ImmutableList.of("-std=gnu11", "-fobjc-arc"), CxxSource.Type.CXX, ImmutableList.of("-std=c++11", "-stdlib=libc++"), CxxSource.Type.OBJCXX, ImmutableList.of("-std=c++11", "-stdlib=libc++", "-fobjc-arc"))).setConfigs(ImmutableSortedMap.of("Debug", ImmutableMap.of())).setSrcs(ImmutableSortedSet.of(SourceWithFlags.of(new FakeSourcePath("foo1.m")), SourceWithFlags.of(new FakeSourcePath("foo2.mm")), SourceWithFlags.of(new FakeSourcePath("foo3.c")), SourceWithFlags.of(new FakeSourcePath("foo4.cc")))).build();
    ProjectGenerator projectGenerator = createProjectGeneratorForCombinedProject(ImmutableSet.of(node));
    projectGenerator.createXcodeProjects();
    PBXTarget target = assertTargetExistsAndReturnTarget(projectGenerator.getGeneratedProject(), "//foo:lib");
    PBXSourcesBuildPhase sourcesBuildPhase = ProjectGeneratorTestUtils.getSingletonPhaseByType(target, PBXSourcesBuildPhase.class);
    ImmutableMap<String, String> expected = ImmutableMap.of("foo1.m", "-std=gnu11 -fobjc-arc", "foo2.mm", "-std=c++11 -stdlib=libc++ -fobjc-arc", "foo3.c", "-std=gnu11", "foo4.cc", "-std=c++11 -stdlib=libc++");
    for (PBXBuildFile file : sourcesBuildPhase.getFiles()) {
        String fileName = file.getFileRef().getName();
        NSDictionary buildFileSettings = file.getSettings().get();
        NSString compilerFlags = (NSString) buildFileSettings.get("COMPILER_FLAGS");
        assertNotNull("Build file settings should have COMPILER_FLAGS entry", compilerFlags);
        assertEquals(compilerFlags.toString(), expected.get(fileName));
    }
}
Also used : FakeSourcePath(com.facebook.buck.rules.FakeSourcePath) PBXTarget(com.facebook.buck.apple.xcode.xcodeproj.PBXTarget) BuildTarget(com.facebook.buck.model.BuildTarget) NSDictionary(com.dd.plist.NSDictionary) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) NSString(com.dd.plist.NSString) NSString(com.dd.plist.NSString) PBXSourcesBuildPhase(com.facebook.buck.apple.xcode.xcodeproj.PBXSourcesBuildPhase) Test(org.junit.Test)

Example 44 with NSDictionary

use of com.dd.plist.NSDictionary in project buck by facebook.

the class ProjectWorkspace method assertFilesEqual.

public void assertFilesEqual(Path expected, Path actual) throws IOException {
    if (!expected.isAbsolute()) {
        expected = templatePath.resolve(expected);
    }
    if (!actual.isAbsolute()) {
        actual = destPath.resolve(actual);
    }
    if (!Files.isRegularFile(actual)) {
        fail("Expected file " + actual + " could not be found.");
    }
    String extension = MorePaths.getFileExtension(actual);
    String cleanPathToObservedFile = MoreStrings.withoutSuffix(templatePath.relativize(expected).toString(), EXPECTED_SUFFIX);
    switch(extension) {
        //    Otherwise, fall back to exact string match.
        case "plist":
        case "stringsdict":
            NSObject expectedObject;
            try {
                expectedObject = BinaryPropertyListParser.parse(expected.toFile());
            } catch (Exception e) {
                // Not binary format.
                expectedObject = null;
            }
            NSObject observedObject;
            try {
                observedObject = BinaryPropertyListParser.parse(actual.toFile());
            } catch (Exception e) {
                // Not binary format.
                observedObject = null;
            }
            assertTrue(String.format("In %s, expected plist to be of %s type.", cleanPathToObservedFile, (expectedObject != null) ? "binary" : "XML"), (expectedObject != null) == (observedObject != null));
            if (expectedObject != null) {
                // These keys depend on the locally installed version of Xcode, so ignore them
                // in comparisons.
                String[] ignoredKeys = { "DTSDKName", "DTPlatformName", "DTPlatformVersion", "MinimumOSVersion", "DTSDKBuild", "DTPlatformBuild", "DTXcode", "DTXcodeBuild" };
                if (observedObject instanceof NSDictionary && expectedObject instanceof NSDictionary) {
                    for (String key : ignoredKeys) {
                        ((NSDictionary) observedObject).remove(key);
                        ((NSDictionary) expectedObject).remove(key);
                    }
                }
                assertEquals(String.format("In %s, expected binary plist contents to match.", cleanPathToObservedFile), expectedObject, observedObject);
                break;
            } else {
                assertFileContentsEqual(expected, actual);
            }
            break;
        default:
            assertFileContentsEqual(expected, actual);
    }
}
Also used : NSObject(com.dd.plist.NSObject) NSDictionary(com.dd.plist.NSDictionary) NoSuchFileException(java.nio.file.NoSuchFileException) InvalidPathException(java.nio.file.InvalidPathException) IOException(java.io.IOException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 45 with NSDictionary

use of com.dd.plist.NSDictionary in project buck by facebook.

the class NewNativeTargetProjectMutator method addSourcePathToSourcesBuildPhase.

private void addSourcePathToSourcesBuildPhase(SourceWithFlags sourceWithFlags, PBXGroup sourcesGroup, PBXSourcesBuildPhase sourcesBuildPhase) {
    SourceTreePath sourceTreePath = new SourceTreePath(PBXReference.SourceTree.SOURCE_ROOT, pathRelativizer.outputDirToRootRelative(sourcePathResolver.apply(sourceWithFlags.getSourcePath())), Optional.empty());
    PBXFileReference fileReference = sourcesGroup.getOrCreateFileReferenceBySourceTreePath(sourceTreePath);
    PBXBuildFile buildFile = new PBXBuildFile(fileReference);
    sourcesBuildPhase.getFiles().add(buildFile);
    ImmutableList<String> customLangPreprocessorFlags = ImmutableList.of();
    Optional<CxxSource.Type> sourceType = CxxSource.Type.fromExtension(Files.getFileExtension(sourceTreePath.toString()));
    if (sourceType.isPresent() && langPreprocessorFlags.containsKey(sourceType.get())) {
        customLangPreprocessorFlags = langPreprocessorFlags.get(sourceType.get());
    }
    ImmutableList<String> customFlags = ImmutableList.copyOf(Iterables.concat(customLangPreprocessorFlags, sourceWithFlags.getFlags()));
    if (!customFlags.isEmpty()) {
        NSDictionary settings = new NSDictionary();
        settings.put("COMPILER_FLAGS", Joiner.on(' ').join(customFlags));
        buildFile.setSettings(Optional.of(settings));
    }
    LOG.verbose("Added source path %s to group %s, flags %s, PBXFileReference %s", sourceWithFlags, sourcesGroup.getName(), customFlags, fileReference);
}
Also used : SourceTreePath(com.facebook.buck.apple.xcode.xcodeproj.SourceTreePath) ProductType(com.facebook.buck.apple.xcode.xcodeproj.ProductType) NSDictionary(com.dd.plist.NSDictionary) PBXBuildFile(com.facebook.buck.apple.xcode.xcodeproj.PBXBuildFile) 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