forked from timniederhausen/gn-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiler_version.gni
71 lines (63 loc) · 2.29 KB
/
compiler_version.gni
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# Copyright 2015 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/toolchain/toolchain.gni")
# Bring all the windows toolchain definitions in.
# Officially msc_ver etc. live here, but they're actually defined
# in win/settings.gni.
if (is_win) {
import("//build/toolchain/win/settings.gni")
}
# Defines compiler versions for compilers used by multiple toolchains.
# TODO(tim): Disable gcc_version on Windows?
declare_args() {
# Version of the GCC compiler.
# Auto-detection is toolchain-specific and happens only if GCC is the active
# compiler.
# Format: MAJOR * 10000 + MINOR * 100 + PATCHLEVEL
gcc_version = 0
# Version of the Clang compiler.
# Auto-detection is toolchain-specific and happens only if Clang is the
# active compiler.
# Format: MAJOR * 10000 + MINOR * 100 + PATCHLEVEL
clang_version = 0
}
# If the user didn't specify the compiler version, attempt to autodetect it.
if (gcc_version == 0 && !is_clang && !is_win) {
if (is_android) {
# sync with //build/toolchain/android/BUILD.gn
import("//build/toolchain/android/settings.gni")
_exe = "${android_tool_prefix}gcc"
} else if (is_posix) {
import("//build/toolchain/posix/settings.gni")
_exe = gcc_cc
} else {
assert(false, "GCC isn't supported on this platform")
}
gcc_version = exec_script("posix/toolchain.py",
[
"get_gcc_version",
_exe,
],
"trim value")
}
if (clang_version == 0 && is_clang && !is_win) {
if (is_android) {
# sync with //build/toolchain/android/BUILD.gn
import("//build/toolchain/clang.gni")
_exe = "$clang_base_path/bin/clang"
} else if (is_posix) {
import("//build/toolchain/posix/settings.gni")
_exe = clang_cc
} else {
assert(false, "GCC isn't supported on this platform")
}
clang_version = exec_script("posix/toolchain.py",
[
"get_clang_version",
_exe,
],
"trim value")
} else if (clang_version == 0 && is_clang) {
clang_version = win_clang_version
}