|
4 | 4 |
|
5 | 5 | # The actual configurations are put inside a template in unofficial.gni to |
6 | 6 | # prevent accidental edits from contributors. |
7 | | -template("cares_gn_build") { |
8 | | - config("cares_config") { |
9 | | - include_dirs = [ "include" ] |
10 | | - if (!is_component_build) { |
11 | | - defines = [ "CARES_STATICLIB" ] |
12 | | - } |
13 | | - } |
14 | | - |
15 | | - gypi_values = exec_script("../../tools/gypi_to_gn.py", |
16 | | - [ rebase_path("cares.gyp") ], |
17 | | - "scope", |
18 | | - [ "cares.gyp" ]) |
| 7 | +import("../../node.gni") |
19 | 8 |
|
20 | | - component(target_name) { |
21 | | - forward_variables_from(invoker, "*") |
22 | | - public_configs = [ ":cares_config" ] |
23 | | - if (is_component_build) { |
24 | | - defines = [ "CARES_BUILDING_LIBRARY" ] |
25 | | - } else { |
26 | | - defines = [] |
| 9 | +template("cares_gn_build") { |
| 10 | + if (node_shared_cares) { |
| 11 | + import("//build/config/linux/pkg_config.gni") |
| 12 | + pkg_config("cares_config") { |
| 13 | + packages = [ "libcares" ] |
27 | 14 | } |
28 | | - if (is_win) { |
29 | | - defines += [ "CARES_PULL_WS2TCPIP_H=1" ] |
| 15 | + group(target_name) { |
| 16 | + forward_variables_from(invoker, "*") |
| 17 | + public_configs = [ ":cares_config" ] |
30 | 18 | } |
31 | | - if (is_posix) { |
32 | | - defines += [ |
33 | | - "_DARWIN_USE_64_BIT_INODE=1", |
34 | | - "_LARGEFILE_SOURCE", |
35 | | - "_FILE_OFFSET_BITS=64", |
36 | | - "_GNU_SOURCE", |
37 | | - "HAVE_CONFIG_H", |
38 | | - ] |
| 19 | + } else { |
| 20 | + config("cares_config") { |
| 21 | + include_dirs = [ "include" ] |
| 22 | + if (!is_component_build) { |
| 23 | + defines = [ "CARES_STATICLIB" ] |
| 24 | + } |
39 | 25 | } |
40 | 26 |
|
41 | | - include_dirs = [ |
42 | | - "src/lib", |
43 | | - "src/lib/include", |
44 | | - ] |
45 | | - if (is_win) { |
46 | | - include_dirs += [ "config/win32" ] |
47 | | - } else if (is_linux) { |
48 | | - include_dirs += [ "config/linux" ] |
49 | | - } else if (is_mac) { |
50 | | - include_dirs += [ "config/darwin" ] |
51 | | - } |
| 27 | + gypi_values = exec_script("../../tools/gypi_to_gn.py", |
| 28 | + [ rebase_path("cares.gyp") ], |
| 29 | + "scope", |
| 30 | + [ "cares.gyp" ]) |
52 | 31 |
|
53 | | - if (is_win) { |
54 | | - libs = [ |
55 | | - "ws2_32.lib", |
56 | | - "iphlpapi.lib", |
57 | | - ] |
58 | | - } |
| 32 | + component(target_name) { |
| 33 | + forward_variables_from(invoker, "*") |
| 34 | + public_configs = [ ":cares_config" ] |
| 35 | + if (is_component_build) { |
| 36 | + defines = [ "CARES_BUILDING_LIBRARY" ] |
| 37 | + } else { |
| 38 | + defines = [] |
| 39 | + } |
| 40 | + if (is_win) { |
| 41 | + defines += [ "CARES_PULL_WS2TCPIP_H=1" ] |
| 42 | + } |
| 43 | + if (is_posix) { |
| 44 | + defines += [ |
| 45 | + "_DARWIN_USE_64_BIT_INODE=1", |
| 46 | + "_LARGEFILE_SOURCE", |
| 47 | + "_FILE_OFFSET_BITS=64", |
| 48 | + "_GNU_SOURCE", |
| 49 | + "HAVE_CONFIG_H", |
| 50 | + ] |
| 51 | + } |
59 | 52 |
|
60 | | - sources = gypi_values.cares_sources_common |
61 | | - if (is_linux) { |
62 | | - sources += [ "config/linux/ares_config.h" ] |
63 | | - } |
64 | | - if (is_mac) { |
65 | | - sources += gypi_values.cares_sources_mac |
66 | | - } |
| 53 | + include_dirs = [ |
| 54 | + "src/lib", |
| 55 | + "src/lib/include", |
| 56 | + ] |
| 57 | + if (is_win) { |
| 58 | + include_dirs += [ "config/win32" ] |
| 59 | + } else if (is_linux) { |
| 60 | + include_dirs += [ "config/linux" ] |
| 61 | + } else if (is_mac) { |
| 62 | + include_dirs += [ "config/darwin" ] |
| 63 | + } |
67 | 64 |
|
68 | | - if (is_clang) { |
69 | 65 | if (is_win) { |
70 | | - cflags_c = [ |
71 | | - "-Wno-macro-redefined", |
72 | | - ] |
73 | | - } else { |
74 | | - cflags_c = [ |
75 | | - "-Wno-implicit-fallthrough", |
76 | | - "-Wno-unreachable-code", |
| 66 | + libs = [ |
| 67 | + "ws2_32.lib", |
| 68 | + "iphlpapi.lib", |
77 | 69 | ] |
78 | 70 | } |
| 71 | + |
| 72 | + sources = gypi_values.cares_sources_common |
| 73 | + if (is_linux) { |
| 74 | + sources += [ "config/linux/ares_config.h" ] |
| 75 | + } |
| 76 | + if (is_mac) { |
| 77 | + sources += gypi_values.cares_sources_mac |
| 78 | + } |
| 79 | + |
| 80 | + if (is_clang) { |
| 81 | + if (is_win) { |
| 82 | + cflags_c = [ |
| 83 | + "-Wno-macro-redefined", |
| 84 | + ] |
| 85 | + } else { |
| 86 | + cflags_c = [ |
| 87 | + "-Wno-implicit-fallthrough", |
| 88 | + "-Wno-unreachable-code", |
| 89 | + ] |
| 90 | + } |
| 91 | + } |
79 | 92 | } |
80 | 93 | } |
81 | 94 | } |
0 commit comments