| # Copyright 2024 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. |
| |
| assert( |
| is_host && is_linux, |
| "Fuchsia's Python C extension configuration is only compatible with Linux hosts") |
| |
| action("generate_python_api_symbols") { |
| script = "${root_out_dir}/generate_python_api_symbols" |
| deps = [ "//build/config/python/generate_python_api_symbols" ] |
| sources = [ |
| "//prebuilt/third_party/clang/${host_platform}/bin/llvm-readelf", |
| "//prebuilt/third_party/jq/${host_platform}/bin/jq", |
| ] |
| outputs = [ "${target_gen_dir}/python_api_symbols.lds" ] |
| args = [ |
| "--python-exe=" + rebase_path(python_exe_src, root_build_dir), |
| "--llvm-readelf-exe=" + rebase_path( |
| "//prebuilt/third_party/clang/${host_platform}/bin/llvm-readelf", |
| root_build_dir), |
| "--output=" + rebase_path(outputs[0], root_build_dir), |
| ] |
| } |
| |
| # Targets that add this config MUST add generate_python_api_symbols as a dependency. |
| config("python_c_extension_shared_lib_config") { |
| cflags = [ "-I" + rebase_path("${python_include_dir}/python${python_version}", |
| root_build_dir) ] |
| |
| python_api_symbols_linker_script = |
| get_target_outputs(":generate_python_api_symbols") |
| python_api_symbols_linker_script = |
| rebase_path(python_api_symbols_linker_script[0], root_build_dir) |
| ldflags = [ "-Wl,-T," + python_api_symbols_linker_script ] |
| } |