| # Copyright 2023 The Fuchsia Authors. All rights reserved. | |
| # Use of this source code is governed by a BSD-style license that can be | |
| # found in the LICENSE file. | |
| # Defines a python C extension shared library. | |
| # | |
| # This is not directly importable into a Python `.pyz`. | |
| # This builds a .so file that can be loaded into python if its parent directory | |
| # is included in the PYTHONPATH environment variable. | |
| template("python_c_extension_shared_lib") { | |
| assert(defined(invoker.sources), "sources is required") | |
| assert(is_host, "python C extensions can only be built on host") | |
| shared_library(target_name) { | |
| output_prefix_override = true | |
| output_extension = "so" | |
| forward_variables_from(invoker, | |
| [ | |
| "assert_no_deps", | |
| "public_configs", | |
| "testonly", | |
| "sources", | |
| "deps", | |
| "visibility", | |
| ]) | |
| if (defined(invoker.configs)) { | |
| configs += invoker.configs | |
| } | |
| configs += [ "//build/config/python:python_c_extension_shared_lib_config" ] | |
| if (!defined(invoker.deps)) { | |
| deps = [] | |
| } | |
| deps += [ "//build/config/python:generate_python_api_symbols" ] | |
| } | |
| } |