Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2015 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 # Rules to generate python packaged applications for Mojo | |
| 6 | |
| 7 import("../mojo_sdk.gni") | |
| 8 | |
| 9 template("python_package") { | |
| 10 action(target_name) { | |
| 11 script = rebase_path("mojo/public/tools/gn/zip.py", ".", mojo_root) | |
| 12 | |
| 13 inputs = invoker.sources | |
| 14 | |
| 15 deps = [] | |
| 16 zip_inputs = [] | |
| 17 | |
| 18 if (defined(invoker.mojom_deps)) { | |
| 19 foreach(d, invoker.mojom_deps) { | |
| 20 # Resolve the name, so that a target //mojo/something becomes | |
| 21 # //mojo/something:something and we can append "_python" to get the | |
| 22 # python dependency name. | |
| 23 full_name = get_label_info(d, "label_no_toolchain") | |
| 24 dep_name = get_label_info(d, "name") | |
| 25 dep_target_out_dir = get_label_info(d, "target_out_dir") | |
| 26 deps += [ "${full_name}_python" ] | |
| 27 zip_inputs += [ "$dep_target_out_dir/$dep_name.pyzip" ] | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 if (defined(invoker.deps)) { | |
| 32 deps += invoker.deps | |
| 33 foreach(d, invoker.deps) { | |
| 34 dep_name = get_label_info(d, "name") | |
| 35 dep_target_out_dir = get_label_info(d, "target_out_dir") | |
| 36 zip_inputs += [ "$dep_target_out_dir/$dep_name.zip" ] | |
|
qsr
2015/01/07 15:14:45
Please use pyzip for all the python zipped package
etiennej
2015/01/08 11:23:12
Done.
| |
| 37 } | |
| 38 } | |
| 39 | |
| 40 if (defined(invoker.datadeps)) { | |
| 41 datadeps = invoker.datadeps | |
| 42 } | |
| 43 | |
| 44 output = "$target_out_dir/$target_name.zip" | |
| 45 outputs = [ | |
| 46 output, | |
| 47 ] | |
| 48 | |
| 49 rebase_base_dir = | |
| 50 rebase_path(get_label_info(":$target_name", "dir"), root_build_dir) | |
| 51 rebase_inputs = rebase_path(inputs, root_build_dir) | |
| 52 rebase_zip_inputs = rebase_path(zip_inputs, root_build_dir) | |
| 53 rebase_output = rebase_path(output, root_build_dir) | |
| 54 args = [ | |
| 55 "--base-dir=$rebase_base_dir", | |
| 56 "--inputs=$rebase_inputs", | |
| 57 "--zip-inputs=$rebase_zip_inputs", | |
| 58 "--output=$rebase_output", | |
| 59 ] | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 # Use this template to generate a .mojo python application. One of the source | |
| 64 # files should be named __mojo__.py and contain a MojoMain function as the | |
| 65 # entry point. Dependencies of python_packaged_application targets should be | |
| 66 # either mojom targets (and specified using the mojom_deps variable) or | |
| 67 # python_package targets. | |
| 68 template("python_packaged_application") { | |
| 69 package_name = "${target_name}_package" | |
| 70 package_output = "$target_out_dir/$package_name.zip" | |
|
qsr
2015/01/07 15:14:45
Same thing, please use pyzip.
etiennej
2015/01/08 11:23:12
Done.
| |
| 71 | |
| 72 if (defined(invoker.output_name)) { | |
| 73 mojo_output = "$root_out_dir/" + invoker.output_name + ".mojo" | |
| 74 } else { | |
| 75 mojo_output = "$root_out_dir/" + target_name + ".mojo" | |
| 76 } | |
| 77 | |
| 78 python_package(package_name) { | |
| 79 sources = invoker.sources | |
| 80 if (defined(invoker.deps)) { | |
| 81 deps = invoker.deps | |
| 82 } | |
| 83 if (defined(invoker.mojom_deps)) { | |
| 84 mojom_deps = invoker.mojom_deps | |
| 85 } | |
| 86 if (defined(invoker.datadeps)) { | |
| 87 datadeps = invoker.datadeps | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 action(target_name) { | |
| 92 script = rebase_path("mojo/public/tools/prepend.py", ".", mojo_root) | |
| 93 | |
| 94 input = package_output | |
| 95 inputs = [ | |
| 96 input, | |
| 97 ] | |
| 98 | |
| 99 output = mojo_output | |
| 100 outputs = [ | |
| 101 output, | |
| 102 ] | |
| 103 | |
| 104 deps = [ | |
| 105 ":$package_name", | |
| 106 ] | |
| 107 if (defined(invoker.deps)) { | |
| 108 deps += invoker.deps | |
| 109 } | |
| 110 if (defined(invoker.mojom_deps)) { | |
| 111 deps += invoker.mojom_deps | |
| 112 } | |
| 113 if (defined(invoker.datadeps)) { | |
| 114 datadeps = invoker.datadeps | |
| 115 } | |
| 116 | |
| 117 rebase_input = rebase_path(input, root_build_dir) | |
| 118 rebase_output = rebase_path(output, root_build_dir) | |
| 119 args = [ | |
| 120 "--input=$rebase_input", | |
| 121 "--output=$rebase_output", | |
| 122 "--line=#!mojo:py_content_handler", | |
| 123 ] | |
| 124 } | |
| 125 } | |
| OLD | NEW |