| OLD | NEW |
| (Empty) |
| 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 | |
| 5 template("python_binary_module") { | |
| 6 # Only available on linux for now. | |
| 7 assert(is_linux) | |
| 8 assert(defined(invoker.sources)) | |
| 9 assert(defined(invoker.python_base_module)) | |
| 10 | |
| 11 cython_root = "//third_party/cython" | |
| 12 cython_script = "$cython_root/src/cython.py" | |
| 13 cython_output = "${target_out_dir}/${target_name}.cc" | |
| 14 | |
| 15 generator_target_name = target_name + "_cython_compiler" | |
| 16 shared_library_name = target_name + "_shared_library" | |
| 17 config_name = target_name + "_python_config" | |
| 18 | |
| 19 if (is_linux) { | |
| 20 shared_library_prefix = "lib" | |
| 21 shared_library_suffix = ".so" | |
| 22 python_module_suffix = ".so" | |
| 23 } | |
| 24 | |
| 25 target_visibility = [ | |
| 26 ":$generator_target_name", | |
| 27 ":$shared_library_name", | |
| 28 ":$target_name", | |
| 29 ] | |
| 30 | |
| 31 action(generator_target_name) { | |
| 32 visibility = target_visibility | |
| 33 script = cython_script | |
| 34 sources = invoker.sources | |
| 35 outputs = [ cython_output ] | |
| 36 args = [ | |
| 37 "--cplus", | |
| 38 "-I", rebase_path("//", root_build_dir), | |
| 39 "-o", rebase_path(cython_output, root_build_dir), | |
| 40 ] + rebase_path(sources, root_build_dir) | |
| 41 } | |
| 42 | |
| 43 config(config_name) { | |
| 44 visibility = target_visibility | |
| 45 python_flags = "//third_party/cython/python_flags.py" | |
| 46 include_dirs = exec_script(python_flags, | |
| 47 [ "--gn", "--includes" ], | |
| 48 "list lines") | |
| 49 libs = exec_script(python_flags, | |
| 50 [ "--gn", "--libraries" ], | |
| 51 "list lines") | |
| 52 lib_dirs = exec_script(python_flags, | |
| 53 [ "--gn", "--library_dirs" ], | |
| 54 "list lines") | |
| 55 } | |
| 56 | |
| 57 shared_library(shared_library_name) { | |
| 58 visibility = target_visibility | |
| 59 deps = [ | |
| 60 ":$generator_target_name", | |
| 61 ] | |
| 62 if (defined(invoker.deps)) { | |
| 63 deps += invoker.deps | |
| 64 } | |
| 65 if (defined(invoker.datadeps)) { | |
| 66 datadeps = invoker.datadeps | |
| 67 } | |
| 68 sources = [ cython_output ] | |
| 69 configs += [ ":$config_name" ] | |
| 70 } | |
| 71 | |
| 72 copy(target_name) { | |
| 73 python_base_module = invoker.python_base_module | |
| 74 sources = [ | |
| 75 "$root_out_dir/${shared_library_prefix}${shared_library_name}${shared_libr
ary_suffix}" | |
| 76 ] | |
| 77 outputs = [ | |
| 78 "$root_out_dir/python/$python_base_module/${target_name}${python_module_su
ffix}" | |
| 79 ] | |
| 80 deps = [ | |
| 81 ":$shared_library_name" | |
| 82 ] | |
| 83 } | |
| 84 } | |
| OLD | NEW |