use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.
the class CompilationSupport method frameworkNames.
/**
* Returns all framework names to pass to the linker using {@code -framework} flags. For a
* framework in the directory foo/bar.framework, the name is "bar". Each framework is found
* without using the full path by means of the framework search paths. Search paths are added by
* {@link#commonLinkAndCompileFlagsForClang(ObjcProvider, ObjcConfiguration, AppleConfiguration)})
*
* <p>It's awful that we can't pass the full path to the framework and avoid framework search
* paths, but this is imposed on us by clang. clang does not support passing the full path to the
* framework, so Bazel cannot do it either.
*/
protected Set<String> frameworkNames(ObjcProvider provider) {
Set<String> names = new LinkedHashSet<>();
Iterables.addAll(names, SdkFramework.names(provider.get(SDK_FRAMEWORK)));
for (PathFragment frameworkDir : Iterables.concat(provider.get(STATIC_FRAMEWORK_DIR), provider.get(DYNAMIC_FRAMEWORK_DIR))) {
String segment = frameworkDir.getBaseName();
Preconditions.checkState(segment.endsWith(FRAMEWORK_SUFFIX), "expect %s to end with %s, but it does not", segment, FRAMEWORK_SUFFIX);
names.add(segment.substring(0, segment.length() - FRAMEWORK_SUFFIX.length()));
}
return names;
}
use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.
the class CompilationSupport method validateAttributes.
/**
* Validates compilation-related attributes on this rule.
*
* @return this compilation support
* @throws RuleErrorException if there are attribute errors
*/
CompilationSupport validateAttributes() throws RuleErrorException {
for (PathFragment absoluteInclude : Iterables.filter(attributes.includes(), PathFragment.IS_ABSOLUTE)) {
ruleContext.attributeError("includes", String.format(ABSOLUTE_INCLUDES_PATH_FORMAT, absoluteInclude));
}
if (ruleContext.attributes().has("srcs", BuildType.LABEL_LIST)) {
ImmutableSet<Artifact> hdrsSet = ImmutableSet.copyOf(attributes.hdrs());
ImmutableSet<Artifact> srcsSet = ImmutableSet.copyOf(ruleContext.getPrerequisiteArtifacts("srcs", Mode.TARGET).list());
// Check for overlap between srcs and hdrs.
for (Artifact header : Sets.intersection(hdrsSet, srcsSet)) {
String path = header.getRootRelativePath().toString();
ruleContext.attributeWarning("srcs", String.format(FILE_IN_SRCS_AND_HDRS_WARNING_FORMAT, path));
}
// Check for overlap between srcs and non_arc_srcs.
ImmutableSet<Artifact> nonArcSrcsSet = ImmutableSet.copyOf(ruleContext.getPrerequisiteArtifacts("non_arc_srcs", Mode.TARGET).list());
for (Artifact conflict : Sets.intersection(nonArcSrcsSet, srcsSet)) {
String path = conflict.getRootRelativePath().toString();
ruleContext.attributeError("srcs", String.format(FILE_IN_SRCS_AND_NON_ARC_SRCS_ERROR_FORMAT, path));
}
}
ruleContext.assertNoErrors();
return this;
}
use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.
the class IntermediateArtifacts method inUniqueObjsDir.
private Artifact inUniqueObjsDir(Artifact source, String extension) {
PathFragment uniqueDir = new PathFragment("_objs").getRelative(ruleContext.getLabel().getName());
PathFragment sourceFile = uniqueDir.getRelative(source.getRootRelativePath());
PathFragment scopeRelativePath = FileSystemUtils.replaceExtension(sourceFile, extension);
return scopedArtifact(scopeRelativePath);
}
use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.
the class IosFramework method getExtraArtifacts.
/**
* Returns a map of original {@code Artifact} to symlinked {@code Artifact} inside framework
* bundle.
*/
private ImmutableMap<Artifact, Artifact> getExtraArtifacts(RuleContext ruleContext) {
IntermediateArtifacts intermediateArtifacts = ObjcRuleClasses.intermediateArtifacts(ruleContext);
ImmutableList<Pair<Artifact, Label>> headers = ImmutableList.copyOf(CcCommon.getHeaders(ruleContext));
ImmutableMap.Builder<Artifact, Artifact> builder = new ImmutableMap.Builder<>();
// Create framework binary
Artifact frameworkBinary = outputArtifact(ruleContext, new PathFragment(bundleName(ruleContext)));
builder.put(intermediateArtifacts.combinedArchitectureBinary(), frameworkBinary);
// Create framework headers
for (Pair<Artifact, Label> header : headers) {
Artifact frameworkHeader = outputArtifact(ruleContext, new PathFragment("Headers/" + header.first.getFilename()));
builder.put(header.first, frameworkHeader);
}
return builder.build();
}
use of com.google.devtools.build.lib.vfs.PathFragment in project bazel by bazelbuild.
the class BundleSupport method registerConvertStringsActions.
private void registerConvertStringsActions(ObjcProvider objcProvider) {
for (Artifact strings : objcProvider.get(ObjcProvider.STRINGS)) {
Artifact bundled = bundling.getIntermediateArtifacts().convertedStringsFile(strings);
ruleContext.registerAction(ObjcRuleClasses.spawnAppleEnvActionBuilder(appleConfiguration, platform).setMnemonic("ConvertStringsPlist").setExecutable(new PathFragment("/usr/bin/plutil")).setCommandLine(CustomCommandLine.builder().add("-convert").add("binary1").addExecPath("-o", bundled).add("--").addPath(strings.getExecPath()).build()).addInput(strings).addInput(CompilationSupport.xcrunwrapper(ruleContext).getExecutable()).addOutput(bundled).build(ruleContext));
}
}
Aggregations