OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 template("python_binary_module_sources") { | 5 template("python_binary_module_sources") { |
6 # Only available on linux for now. | 6 # Only available on linux for now. |
7 assert(is_linux) | 7 assert(is_linux) |
8 assert(defined(invoker.sources)) | 8 assert(defined(invoker.sources)) |
9 | 9 |
10 cython_root = "//third_party/cython" | 10 cython_root = "//third_party/cython" |
11 cython_script = "$cython_root/src/cython.py" | 11 cython_script = "$cython_root/src/cython.py" |
12 cython_output = "${target_out_dir}/${target_name}.cc" | 12 cython_output = "${target_out_dir}/${target_name}.cc" |
13 | 13 |
14 generator_target_name = target_name + "_cython_compiler" | 14 generator_target_name = target_name + "_cython_compiler" |
15 config_name = target_name + "_python_config" | 15 config_name = target_name + "_python_config" |
16 | 16 |
17 target_visibility = [ ":$target_name" ] | 17 target_visibility = [ ":$target_name" ] |
18 | 18 |
19 action(generator_target_name) { | 19 action(generator_target_name) { |
20 visibility = target_visibility | 20 visibility = target_visibility |
21 script = cython_script | 21 script = cython_script |
22 sources = invoker.sources | 22 sources = invoker.sources |
23 outputs = [ cython_output ] | 23 outputs = [ cython_output ] |
24 args = [ | 24 args = [ |
25 "--cplus", | 25 "--cplus", |
26 "-I", | 26 "-I", |
27 rebase_path("//", root_build_dir), | 27 rebase_path("//", root_build_dir), |
28 "-o", | 28 "-o", |
29 rebase_path(cython_output, root_build_dir), | 29 rebase_path(cython_output, root_build_dir), |
30 ] + rebase_path(sources, root_build_dir) | 30 ] + rebase_path(sources, root_build_dir) |
31 } | 31 } |
32 | 32 |
33 config(config_name) { | 33 config(config_name) { |
34 visibility = target_visibility | 34 visibility = target_visibility |
35 python_flags = "//third_party/cython/python_flags.py" | 35 python_flags = "//third_party/cython/python_flags.py" |
36 include_dirs = exec_script(python_flags, | 36 include_dirs = exec_script(python_flags, [ "--includes" ], "list lines") |
37 [ "--includes" ], | 37 libs = exec_script(python_flags, [ "--libraries" ], "list lines") |
38 "list lines") | 38 lib_dirs = exec_script(python_flags, [ "--library_dirs" ], "list lines") |
39 libs = exec_script(python_flags, | |
40 [ "--libraries" ], | |
41 "list lines") | |
42 lib_dirs = exec_script(python_flags, | |
43 [ "--library_dirs" ], | |
44 "list lines") | |
45 if (!is_win) { | 39 if (!is_win) { |
46 # Generated code includes static utility functions that often go unused. | 40 # Generated code includes static utility functions that often go unused. |
47 cflags = [ "-Wno-unused-function" ] | 41 cflags = [ "-Wno-unused-function" ] |
48 } | 42 } |
49 } | 43 } |
50 | 44 |
51 source_set(target_name) { | 45 source_set(target_name) { |
52 deps = [ ":$generator_target_name" ] | 46 deps = [ |
| 47 ":$generator_target_name", |
| 48 ] |
53 if (defined(invoker.visibility)) { | 49 if (defined(invoker.visibility)) { |
54 visibility = invoker.visibility | 50 visibility = invoker.visibility |
55 } | 51 } |
56 if (defined(invoker.deps)) { | 52 if (defined(invoker.deps)) { |
57 deps += invoker.deps | 53 deps += invoker.deps |
58 } | 54 } |
59 if (defined(invoker.datadeps)) { | 55 if (defined(invoker.datadeps)) { |
60 datadeps = invoker.datadeps | 56 datadeps = invoker.datadeps |
61 } | 57 } |
62 sources = [ cython_output ] | 58 sources = [ |
| 59 cython_output, |
| 60 ] |
63 if (defined(invoker.additional_sources)) { | 61 if (defined(invoker.additional_sources)) { |
64 sources += invoker.additional_sources | 62 sources += invoker.additional_sources |
65 } | 63 } |
66 all_dependent_configs = [ ":$config_name" ] | 64 all_dependent_configs = [ ":$config_name" ] |
67 } | 65 } |
68 } | 66 } |
69 | 67 |
70 template("python_binary_module") { | 68 template("python_binary_module") { |
71 # Only available on linux for now. | 69 # Only available on linux for now. |
72 assert(is_linux) | 70 assert(is_linux) |
(...skipping 15 matching lines...) Expand all Loading... |
88 ":$target_name", | 86 ":$target_name", |
89 ] | 87 ] |
90 | 88 |
91 python_binary_module_sources(sources_target_name) { | 89 python_binary_module_sources(sources_target_name) { |
92 visibility = target_visibility | 90 visibility = target_visibility |
93 sources = invoker.sources | 91 sources = invoker.sources |
94 } | 92 } |
95 | 93 |
96 shared_library(shared_library_name) { | 94 shared_library(shared_library_name) { |
97 visibility = target_visibility | 95 visibility = target_visibility |
98 deps = [ ":$sources_target_name" ] | 96 deps = [ |
| 97 ":$sources_target_name", |
| 98 ] |
99 if (defined(invoker.deps)) { | 99 if (defined(invoker.deps)) { |
100 deps += invoker.deps | 100 deps += invoker.deps |
101 } | 101 } |
102 if (defined(invoker.datadeps)) { | 102 if (defined(invoker.datadeps)) { |
103 datadeps = invoker.datadeps | 103 datadeps = invoker.datadeps |
104 } | 104 } |
105 if (defined(invoker.additional_sources)) { | 105 if (defined(invoker.additional_sources)) { |
106 sources = invoker.additional_sources | 106 sources = invoker.additional_sources |
107 } | 107 } |
108 if (defined(invoker.configs)) { | 108 if (defined(invoker.configs)) { |
109 configs += invoker.configs | 109 configs += invoker.configs |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 copy(target_name) { | 113 copy(target_name) { |
114 python_base_module = invoker.python_base_module | 114 python_base_module = invoker.python_base_module |
115 sources = [ | 115 sources = [ |
116 "$root_out_dir/${shared_library_prefix}${shared_library_name}${shared_libr
ary_suffix}" | 116 "$root_out_dir/${shared_library_prefix}${shared_library_name}${shared_libr
ary_suffix}", |
117 ] | 117 ] |
118 outputs = [ | 118 outputs = |
119 "$root_out_dir/python/$python_base_module/${target_name}${python_module_su
ffix}" | 119 [ "$root_out_dir/python/$python_base_module/${target_name}${python_modul
e_suffix}" ] |
| 120 deps = [ |
| 121 ":$shared_library_name", |
120 ] | 122 ] |
121 deps = [ ":$shared_library_name" ] | |
122 } | 123 } |
123 } | 124 } |
OLD | NEW |