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));
}
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));
}
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));
}
}
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);
}
}
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);
}
Aggregations