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.
4toolchain("gcc") {
5  tool("cc") {
6    depfile = "{{output}}.d"
7    command = "gcc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
8    depsformat = "gcc"
9    description = "CC {{output}}"
10    outputs = [
11      "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
12    ]
13  }
14  tool("cxx") {
15    depfile = "{{output}}.d"
16    command = "g++ -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
17    depsformat = "gcc"
18    description = "CXX {{output}}"
19    outputs = [
20      "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
21    ]
22  }
23  tool("alink") {
24    rspfile = "{{output}}.rsp"
25    command = "rm -f {{output}} && ar rcs {{output}} @$rspfile"
26    description = "AR {{target_output_name}}{{output_extension}}"
27    rspfile_content = "{{inputs}}"
28    outputs = [
29      "{{target_out_dir}}/{{target_output_name}}{{output_extension}}",
30    ]
31    default_output_extension = ".a"
32    output_prefix = "lib"
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    command = "g++ -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile"
39    rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"
40    description = "SOLINK $soname"
41    # Use this for {{output_extension}} expansions unless a target manually
42    # overrides it (in which case {{output_extension}} will be what the target
43    # specifies).
44    default_output_extension = ".so"
45    # Use this for {{output_dir}} expansions unless a target manually overrides
46    # it (in which case {{output_dir}} will be what the target specifies).
47    default_output_dir = "{{root_out_dir}}"
48    outputs = [
49      sofile,
50    ]
51    link_output = sofile
52    depend_output = sofile
53    output_prefix = "lib"
54  }
55  tool("link") {
56    outfile = "{{target_output_name}}{{output_extension}}"
57    rspfile = "$outfile.rsp"
58    command = "g++ {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}"
59    description = "LINK $outfile"
60    default_output_dir = "{{root_out_dir}}"
61    rspfile_content = "{{inputs}}"
62    outputs = [
63      outfile,
64    ]
65  }
66  tool("stamp") {
67    command = "touch {{output}}"
68    description = "STAMP {{output}}"
69  }
70  tool("copy") {
71    command = "cp -af {{source}} {{output}}"
72    description = "COPY {{source}} {{output}}"
73  }
74}
75