• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5toolchain("gcc") {
6  tool("cc") {
7    depfile = "{{output}}.d"
8    command = "gcc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
9    depsformat = "gcc"
10    description = "CC {{output}}"
11    outputs =
12        [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
13  }
14
15  tool("cxx") {
16    depfile = "{{output}}.d"
17    command = "g++ -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
18    depsformat = "gcc"
19    description = "CXX {{output}}"
20    outputs =
21        [ "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o" ]
22  }
23
24  tool("alink") {
25    command = "rm -f {{output}} && ar rcs {{output}} {{inputs}}"
26    description = "AR {{target_output_name}}{{output_extension}}"
27
28    outputs =
29        [ "{{target_out_dir}}/{{target_output_name}}{{output_extension}}" ]
30    default_output_extension = ".a"
31    output_prefix = "lib"
32  }
33
34  tool("solink") {
35    soname = "{{target_output_name}}{{output_extension}}"  # e.g. "libfoo.so".
36    sofile = "{{output_dir}}/$soname"
37    rspfile = soname + ".rsp"
38    if (is_mac) {
39      os_specific_option = "-install_name @executable_path/$sofile"
40      rspfile_content = "{{inputs}} {{solibs}} {{libs}}"
41    } else {
42      os_specific_option = "-Wl,-soname=$soname"
43      rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"
44    }
45
46    command = "g++ -shared {{ldflags}} -o $sofile $os_specific_option @$rspfile"
47
48    description = "SOLINK $soname"
49
50    # Use this for {{output_extension}} expansions unless a target manually
51    # overrides it (in which case {{output_extension}} will be what the target
52    # specifies).
53    default_output_extension = ".so"
54
55    # Use this for {{output_dir}} expansions unless a target manually overrides
56    # it (in which case {{output_dir}} will be what the target specifies).
57    default_output_dir = "{{root_out_dir}}"
58
59    outputs = [ sofile ]
60    link_output = sofile
61    depend_output = sofile
62    output_prefix = "lib"
63  }
64
65  tool("link") {
66    outfile = "{{target_output_name}}{{output_extension}}"
67    rspfile = "$outfile.rsp"
68    if (is_mac) {
69      command = "g++ {{ldflags}} -o $outfile @$rspfile {{solibs}} {{libs}}"
70    } else {
71      command = "g++ {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}"
72    }
73    description = "LINK $outfile"
74    default_output_dir = "{{root_out_dir}}"
75    rspfile_content = "{{inputs}}"
76    outputs = [ outfile ]
77  }
78
79  tool("stamp") {
80    command = "touch {{output}}"
81    description = "STAMP {{output}}"
82  }
83
84  tool("copy") {
85    command = "cp -af {{source}} {{output}}"
86    description = "COPY {{source}} {{output}}"
87  }
88}
89