import("//build/ohos.gni") template("python3_action") { action(target_name) { # Forward all variables. Ensure that testonly and visibility are forwarded # explicitly, since this performs recursive scope lookups, which is # required to ensure their definition from scopes above the caller are # properly handled. All other variables are forwarded with "*", which # doesn't perform recursive lookups at all. See https://crbug.com/862232 forward_variables_from(invoker, [ "testonly", "visibility", ]) forward_variables_from(invoker, "*", [ "testonly", "visibility", ]) script = "//third_party/wayland_standard/python3_action.py" _rebased_script = rebase_path(invoker.script, root_build_dir) inputs = [] inputs = [ invoker.script ] if (defined(invoker.inputs)) { inputs += invoker.inputs } args = [] args = [ _rebased_script ] if (defined(invoker.args)) { args += invoker.args } } } template("wayland_protocol") { assert(defined(invoker.sources), "Need sources for wayland_protocol template") # Calculate the output paths. protocol_outputs = [] output_dirs = [] foreach(protocol, invoker.sources) { dir = "$root_gen_dir/" + rebase_path(get_path_info(protocol, "dir"), "//") name = get_path_info(protocol, "name") protocol_outputs += [ "${dir}/${name}-protocol.c", "${dir}/${name}-client-protocol.h", "${dir}/${name}-server-protocol.h", ] output_dirs += [ dir ] } action_name = "${target_name}_gen" config_name = "${target_name}_config" source_set_name = "${target_name}" # Action which runs wayland-scanner to generate the code. # TODO(crbug.com/1112471): Get this to run cleanly under Python 3. python3_action(action_name) { visibility = [ ":$source_set_name" ] script = "//third_party/wayland_standard/wayland_scanner_wrapper.py" sources = invoker.sources outputs = protocol_outputs # Paths in invoker.sources are relative to the invoker. # Make it relative to the src root. args = rebase_path(invoker.sources, "//") args += [ "--src-root", rebase_path("//", root_build_dir), ] args += [ "--root-gen-dir", rebase_path(root_gen_dir, root_build_dir), ] wayland_scanner_label = "//third_party/wayland_standard:wayland_scanner($host_toolchain)" deps = [ wayland_scanner_label ] args += [ "--cmd", "./" + rebase_path(get_label_info(wayland_scanner_label, "root_out_dir"), root_build_dir) + "/graphic/graphic_standard/wayland_scanner", ] } # Config to include the generated headers only with the file names. # e.g. #include config(config_name) { include_dirs = output_dirs } # Source set which consists of the generated code. source_set(source_set_name) { sources = get_target_outputs(":$action_name") public_deps = [ ":$action_name", "//third_party/wayland_standard:wayland_util", ] public_configs = [ ":$config_name" ] } }