Home | History | Annotate | Download | only in gcc
      1 #
      2 #  Copyright (C) 2015 Google, Inc.
      3 #
      4 #  Licensed under the Apache License, Version 2.0 (the "License");
      5 #  you may not use this file except in compliance with the License.
      6 #  You may obtain a copy of the License at:
      7 #
      8 #  http://www.apache.org/licenses/LICENSE-2.0
      9 #
     10 #  Unless required by applicable law or agreed to in writing, software
     11 #  distributed under the License is distributed on an "AS IS" BASIS,
     12 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13 #  See the License for the specific language governing permissions and
     14 #  limitations under the License.
     15 #
     16 cc = "gcc"
     17 cxx = "g++"
     18 
     19 toolchain("gcc") {
     20   tool("cc") {
     21     depfile = "{{output}}.d"
     22     command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
     23     depsformat = "gcc"
     24     description = "CC {{output}}"
     25     outputs = [
     26       "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
     27     ]
     28   }
     29 
     30   tool("cxx") {
     31     depfile = "{{output}}.d"
     32     command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
     33     depsformat = "gcc"
     34     description = "CXX {{output}}"
     35     outputs = [
     36       "{{source_out_dir}}/{{target_output_name}}.{{source_name_part}}.o",
     37     ]
     38   }
     39 
     40   tool("alink") {
     41     rspfile = "{{output}}.rsp"
     42     command = "rm -f {{output}} && ar rcs {{output}} @$rspfile"
     43     description = "AR {{target_output_name}}{{output_extension}}"
     44     rspfile_content = "{{inputs}}"
     45     outputs = [
     46       "{{target_out_dir}}/{{target_output_name}}{{output_extension}}",
     47     ]
     48     default_output_extension = ".a"
     49 
     50     output_prefix = "lib"
     51   }
     52 
     53   tool("solink") {
     54     soname = "{{target_output_name}}{{output_extension}}"  # e.g. "libfoo.so".
     55     rspfile = soname + ".rsp"
     56 
     57     command =
     58         "$cxx -shared {{ldflags}} -o $soname -Wl,-soname=$soname @$rspfile"
     59     rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"
     60 
     61     description = "SOLINK $soname"
     62 
     63     # Use this for {{output_extension}} expansions unless a target manually
     64     # overrides it (in which case {{output_extension}} will be what the target
     65     # specifies).
     66     default_output_extension = ".so"
     67 
     68     outputs = [
     69       soname,
     70     ]
     71     link_output = soname
     72     depend_output = soname
     73 
     74     output_prefix = "lib"
     75   }
     76 
     77   tool("link") {
     78     outfile = "{{target_output_name}}{{output_extension}}"
     79     rspfile = "$outfile.rsp"
     80     command = "$cxx {{ldflags}} -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}"
     81     description = "LINK $outfile"
     82     rspfile_content = "{{inputs}}"
     83     outputs = [
     84       outfile,
     85     ]
     86   }
     87 
     88   tool("stamp") {
     89     command = "touch {{output}}"
     90     description = "STAMP {{output}}"
     91   }
     92 
     93   tool("copy") {
     94     command = "cp -af {{source}} {{output}}"
     95     description = "COPY {{source}} {{output}}"
     96   }
     97 }
     98