How to detect Xcode version in "select" with Bazel

Can Xcode version value be used in select

or an equivalent dynamic engine?

The motivation is that we have to support many Xcode changes in our pipeline and on our developer desktops. When supporting multiple versions of Xcode with the same build infrastructure, it is advisable to programmatically change the command line arguments used for CFLAGS, such as specifying different optimization, debug and warning flags. For example, we would like to specify certain flags only for Xcode 8.3 or higher.

I see there are config snippets for xcode_toolchain

and xcode_version

, but I don't think I can select them. We would rather not tell bazel which version of Xcode it is using (for CFLAGS purposes) either with command line configuration configuration or by generating files BUILD

dynamically if at all possible, especially since Bazel should already know which version it is using.

Is there a better recommended approach for this scenario?

+3


source to share


2 answers


I see there are config snippets for xcode_toolchain

and xcode_version

, but I don't think I can select them.

What are the latest challenges you face?

If you set the config setting using xcode_version like:



config_setting(
  name = "xcode_7_1" + vers,
  values = {"xcode_version": "7.1"},
)

      

You should be able to choose this.

+1


source


You can use repositories for local autodetect similar to bazel autodetects C ++ toolchain . The resulting CROSSTOOL must be accurately baked for the current host and no samples will be needed in the BUILD files. If you need specific command line flags for a subset of the rules, you can use "functions" to do so. Features can be enabled / disabled for each rule:

cc_library(
  name = "foo",
  features = [ "foo_flags", "-bar_flags" ]
)

      



You can find about the CROSSTOOL wiki page . And for more examples on how to write functions and action_configs have a look at CppActionConfigs.java

0


source







All Articles