| # Copyright 2019 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| declare_args() { |
| # If $clang_tool_dir is "", then this controls how the Clang toolchain |
| # binaries are found. If true, then the standard prebuilt is used. |
| # Otherwise the tools are just expected to be found by the shell via `PATH`. |
| use_prebuilt_clang = true |
| |
| # Directory where the Clang toolchain binaries ("clang", "llvm-nm", etc.) are |
| # found. If this is "", then the behavior depends on $use_prebuilt_clang. |
| # This toolchain is expected to support both Fuchsia targets and the host. |
| clang_tool_dir = "" |
| } |
| |
| # This is a string identifying the particular toolchain version in use. Its |
| # only purpose is to be unique enough that it changes when switching to a new |
| # toolchain, so that recompilations with the new compiler can be triggered. |
| # |
| # When using the prebuilt, the CIPD instance ID of the prebuilt is perfect. |
| # When not using the prebuilt, there isn't a quick way to extract the compiler |
| # version. But at least changing the setting to a different compiler will |
| # change the string. |
| clang_version_string = clang_tool_dir |
| if (clang_tool_dir == "" && use_prebuilt_clang) { |
| _prebuilt_dir = "$zx/prebuilt/downloads/clang" |
| clang_tool_dir = "$_prebuilt_dir/bin" |
| _prebuilt_cipd_version = |
| read_file("$_prebuilt_dir/.versions/clang.cipd_version", "json") |
| clang_version_string = _prebuilt_cipd_version.instance_id |
| } |