Bazel for Apple Weekly

Subscribe
Archives
August 26, 2020

Bazel for Apple Weekly Issue #1

Welcome to the first issue of Bazel for Apple Weekly, a weekly newsletter covering news and developments in Bazel for Apple platforms, and related projects. Bazel for Apple Weekly is brought to you by Thi Doãn. Subscribe to future issues at bazelappleweekly.email and pass it on to anyone else you think may be interested. Please send any tips or feedback to bazelappleweekly@thi.im, or @bazelapplewkly or @thi_dt on Twitter.

Starting out, this is going to be mostly just a collection of commits. In this first issue, I have collected the news and developments related to Apple rules in the last two weeks.

News

Apple related rules have been moved to be community-maintained.

Google has decided the cost of maintaining both the internal and external versions of the Apple related bazel rules has become unwieldy given their current resources and prioritization. Because of this the community will need to step in and take over some portion of the maintenance.

Jerry Marino wrote an introduction document to Bazel for iOS developers.

This document is an introduction to Bazel for iOS developers. While there's been many docs written about Bazel, the existing material can be overwhelming for a line engineer looking to get started. This document is geared towards an iOS developer coming from Xcode and intends to be a lightweight and therefore incomplete introduction to Bazel.

Bazel

Michael Eisel and Thi Doãn merged a commit that supports deterministic mode when using a version of libtool that supports it.

Xcode 10.2 adds a new flag -D to libtool that sets archive contents' user ids, group ids, dates, and file modes to reasonable defaults. This patch adds this new flag to all libtool actions to when they're built with a version of libtool that supports this mode, to ensure hemertic results for linking actions. Note that this new flag covers the functionality of the ZERO_AR_DATE environment variable, but this variable is still being left in the libtool wrapper for backward-compatibility with older versions.

Michael Eisel merged a commit that makes libtool running without symlinking if possible.

tools/objc/libtool.shincreases the incremental build time for a single-target app with 700 implementation files by ~3 seconds. It appears that /usr/bin/libtool takes only a fraction of a second, but the work being done beforehand with symlinks and hashing takes longer. This work is to prevent giving libtool object files with the same basename.

If there are no duplicate .o basenames, then libtool can be invoked directly without symlinking.

Walter Lee merged a commit that turned on parse_headers for objc_library.

Benjamin Barenblat merged a commit that adds support for controlling apple_binary linkstamping by flag.

A previous change made apple_binary support the stamp attribute in the same way as cc_binary does, but we defaulted it to OFF rather than cc_binary’s AUTO to avoid behavioral changes. Switch it now to AUTO, bringing apple_binary in line with cc_binary.

Apple rules

Thi Doãn merged a commit that adds support for processing Metal files in resource bundles.

This adds support for processing Metal files when they're included in a apple_resource_bundle target. This currently does not support specifying the output filename of the compiled .metallib -- the Metal files are always compiled to a single default.metallib now.

Brentley Jones merged a commit that allows App Extensions to be bundle loaders.

This is needed when using SwiftUI Previews with a WidgetKit extension.

Swift rules

Tony Allevato merged a commit that adds various changes related to explicit module compilation:

  • Add a feature to support compiling system modules with reduced diagnostic output.
  • Support system modules passed as path names (strings) instead of File artifacts.
  • Add the necessary tool config to support compiling explicit modules with Xcode 12 and higher (when the features are also enabled).
  • When compiling explicit modules, generate module maps for objc_library targets in the Swift rules instead of using the one propagated by ObjcProvider to ensure that use declarations for dependencies unknown to the native Bazel module map generation code are present.

In the Uber's fork of rules_swift, Kanglei Fang added an emit_bc feature that

If enabled, Swift compilation will produce LLVM bitcode instead of object file the output will share the same name as the object file (file.o).


That's it for this week. Til next time!

Don't miss what's next. Subscribe to Bazel for Apple Weekly:
Powered by Buttondown, the easiest way to start and grow your newsletter.