| Index: third_party/cython/rules.gni
|
| diff --git a/third_party/cython/rules.gni b/third_party/cython/rules.gni
|
| index efd9ca3e5eb1d7f3d32cf15b6a908a19f7ecd75e..cea1e363cbd95137b698e0ee923af97002e4a2f8 100644
|
| --- a/third_party/cython/rules.gni
|
| +++ b/third_party/cython/rules.gni
|
| @@ -2,31 +2,19 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| -template("python_binary_module") {
|
| +template("python_binary_module_sources") {
|
| # Only available on linux for now.
|
| assert(is_linux)
|
| assert(defined(invoker.sources))
|
| - assert(defined(invoker.python_base_module))
|
|
|
| cython_root = "//third_party/cython"
|
| cython_script = "$cython_root/src/cython.py"
|
| cython_output = "${target_out_dir}/${target_name}.cc"
|
|
|
| generator_target_name = target_name + "_cython_compiler"
|
| - shared_library_name = target_name + "_shared_library"
|
| config_name = target_name + "_python_config"
|
|
|
| - if (is_linux) {
|
| - shared_library_prefix = "lib"
|
| - shared_library_suffix = ".so"
|
| - python_module_suffix = ".so"
|
| - }
|
| -
|
| - target_visibility = [
|
| - ":$generator_target_name",
|
| - ":$shared_library_name",
|
| - ":$target_name",
|
| - ]
|
| + target_visibility = [ ":$target_name" ]
|
|
|
| action(generator_target_name) {
|
| visibility = target_visibility
|
| @@ -34,48 +22,89 @@ template("python_binary_module") {
|
| sources = invoker.sources
|
| outputs = [ cython_output ]
|
| args = [
|
| - "--cplus",
|
| - "-I", rebase_path("//", root_build_dir),
|
| - "-o", rebase_path(cython_output, root_build_dir),
|
| - ] + rebase_path(sources, root_build_dir)
|
| + "--cplus",
|
| + "-I",
|
| + rebase_path("//", root_build_dir),
|
| + "-o",
|
| + rebase_path(cython_output, root_build_dir),
|
| + ] + rebase_path(sources, root_build_dir)
|
| }
|
|
|
| config(config_name) {
|
| visibility = target_visibility
|
| python_flags = "//third_party/cython/python_flags.py"
|
| - include_dirs = exec_script(python_flags,
|
| - [ "--gn", "--includes" ],
|
| - "list lines")
|
| - libs = exec_script(python_flags,
|
| - [ "--gn", "--libraries" ],
|
| - "list lines")
|
| - lib_dirs = exec_script(python_flags,
|
| - [ "--gn", "--library_dirs" ],
|
| - "list lines")
|
| + include_dirs = exec_script(python_flags, [ "--includes" ], "list lines")
|
| + libs = exec_script(python_flags, [ "--libraries" ], "list lines")
|
| + lib_dirs = exec_script(python_flags, [ "--library_dirs" ], "list lines")
|
| if (!is_win) {
|
| # Generated code includes static utility functions that often go unused.
|
| - cflags = [
|
| - "-Wno-unused-function",
|
| - ]
|
| + cflags = [ "-Wno-unused-function" ]
|
| }
|
| }
|
|
|
| - shared_library(shared_library_name) {
|
| - visibility = target_visibility
|
| + source_set(target_name) {
|
| deps = [
|
| ":$generator_target_name",
|
| ]
|
| + if (defined(invoker.visibility)) {
|
| + visibility = invoker.visibility
|
| + }
|
| if (defined(invoker.deps)) {
|
| deps += invoker.deps
|
| }
|
| if (defined(invoker.datadeps)) {
|
| datadeps = invoker.datadeps
|
| }
|
| - sources = [ cython_output ]
|
| + sources = [
|
| + cython_output,
|
| + ]
|
| if (defined(invoker.additional_sources)) {
|
| sources += invoker.additional_sources
|
| }
|
| - configs += [ ":$config_name" ]
|
| + all_dependent_configs = [ ":$config_name" ]
|
| + }
|
| +}
|
| +
|
| +template("python_binary_module") {
|
| + # Only available on linux for now.
|
| + assert(is_linux)
|
| + assert(defined(invoker.sources))
|
| + assert(defined(invoker.python_base_module))
|
| +
|
| + sources_target_name = target_name + "_cython_sources"
|
| + shared_library_name = target_name + "_shared_library"
|
| +
|
| + if (is_linux) {
|
| + shared_library_prefix = "lib"
|
| + shared_library_suffix = ".so"
|
| + python_module_suffix = ".so"
|
| + }
|
| +
|
| + target_visibility = [
|
| + ":$sources_target_name",
|
| + ":$shared_library_name",
|
| + ":$target_name",
|
| + ]
|
| +
|
| + python_binary_module_sources(sources_target_name) {
|
| + visibility = target_visibility
|
| + sources = invoker.sources
|
| + }
|
| +
|
| + shared_library(shared_library_name) {
|
| + visibility = target_visibility
|
| + deps = [
|
| + ":$sources_target_name",
|
| + ]
|
| + if (defined(invoker.deps)) {
|
| + deps += invoker.deps
|
| + }
|
| + if (defined(invoker.datadeps)) {
|
| + datadeps = invoker.datadeps
|
| + }
|
| + if (defined(invoker.additional_sources)) {
|
| + sources = invoker.additional_sources
|
| + }
|
| if (defined(invoker.configs)) {
|
| configs += invoker.configs
|
| }
|
| @@ -84,13 +113,12 @@ template("python_binary_module") {
|
| copy(target_name) {
|
| python_base_module = invoker.python_base_module
|
| sources = [
|
| - "$root_out_dir/${shared_library_prefix}${shared_library_name}${shared_library_suffix}"
|
| - ]
|
| - outputs = [
|
| - "$root_out_dir/python/$python_base_module/${target_name}${python_module_suffix}"
|
| + "$root_out_dir/${shared_library_prefix}${shared_library_name}${shared_library_suffix}",
|
| ]
|
| + outputs =
|
| + [ "$root_out_dir/python/$python_base_module/${target_name}${python_module_suffix}" ]
|
| deps = [
|
| - ":$shared_library_name"
|
| + ":$shared_library_name",
|
| ]
|
| }
|
| }
|
|
|