BUILD.gn 2.9 KB

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