Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 import("config.gni") | |
|
brettw
2014/07/02 00:23:28
Need copyright.
Also, can you use the full path f
cjhopman
2014/07/02 02:36:49
Done.
| |
| 2 | |
| 3 template("write_build_config") { | |
|
brettw
2014/07/02 00:23:28
Can you write a comment about what this is for?
cjhopman
2014/07/02 02:36:49
Done.
| |
| 4 assert(defined(invoker.type)) | |
| 5 assert(defined(invoker.base_path)) | |
| 6 | |
| 7 base_path = invoker.base_path | |
| 8 type = invoker.type | |
| 9 build_config = base_path + ".build_config" | |
| 10 | |
| 11 assert(type == "android_library" || type == "android_binary") | |
| 12 | |
| 13 action(target_name) { | |
| 14 script = "//build/android/gyp/write_build_config.py" | |
| 15 depfile = "$target_gen_dir/$target_name.d" | |
| 16 | |
| 17 deps = [] | |
| 18 if (defined(invoker.deps)) { | |
| 19 deps += invoker.deps | |
| 20 } | |
| 21 | |
| 22 outputs = [depfile, build_config] | |
| 23 | |
| 24 possible_deps_configs = [] | |
| 25 foreach(d, deps) { | |
| 26 possible_deps_configs += [get_label_info(d, "target_gen_dir") + "/" + get_ label_info(d, "name") + ".build_config"] | |
| 27 } | |
| 28 rebase_possible_deps_configs = rebase_path(possible_deps_configs) | |
| 29 args = [ | |
| 30 "--type", type, | |
| 31 "--depfile", rebase_path(depfile, root_build_dir), | |
| 32 "--possible-deps-configs=$rebase_possible_deps_configs", | |
| 33 "--build-config", rebase_path(build_config, root_build_dir), | |
| 34 ] | |
| 35 | |
| 36 if (type == "android_library") { | |
| 37 jar_path = base_path + ".jar" | |
| 38 args += [ | |
| 39 "--jar-path", rebase_path(jar_path, root_build_dir), | |
| 40 ] | |
| 41 } | |
| 42 } | |
| 43 } | |
| 1 | 44 |
| 2 # Creates a zip archive of the inputs. | 45 # Creates a zip archive of the inputs. |
| 3 # If base_dir is provided, the archive paths will be relative to it. | 46 # If base_dir is provided, the archive paths will be relative to it. |
| 4 template("zip") { | 47 template("zip") { |
| 5 assert(defined(invoker.inputs)) | 48 assert(defined(invoker.inputs)) |
| 6 assert(defined(invoker.output)) | 49 assert(defined(invoker.output)) |
| 7 | 50 |
| 8 rebase_inputs = rebase_path(invoker.inputs) | 51 rebase_inputs = rebase_path(invoker.inputs, root_build_dir) |
| 9 rebase_output = rebase_path(invoker.output) | 52 rebase_output = rebase_path(invoker.output, root_build_dir) |
| 10 action(target_name) { | 53 action(target_name) { |
| 11 script = "//build/android/gn/zip.py" | 54 script = "//build/android/gn/zip.py" |
| 12 depfile = "$target_gen_dir/$target_name.d" | 55 depfile = "$target_gen_dir/$target_name.d" |
| 13 source_prereqs = invoker.inputs | 56 source_prereqs = invoker.inputs |
| 14 outputs = [depfile, invoker.output] | 57 outputs = [depfile, invoker.output] |
| 15 args = [ | 58 args = [ |
| 16 "--depfile", rebase_path(depfile, root_build_dir), | 59 "--depfile", rebase_path(depfile, root_build_dir), |
| 17 "--inputs=$rebase_inputs", | 60 "--inputs=$rebase_inputs", |
| 18 "--output=$rebase_output", | 61 "--output=$rebase_output", |
| 19 ] | 62 ] |
| 20 if (defined(invoker.base_dir)) { | 63 if (defined(invoker.base_dir)) { |
| 21 args += [ | 64 args += [ |
| 22 "--base-dir", rebase_path(invoker.base_dir) | 65 "--base-dir", rebase_path(invoker.base_dir, root_build_dir) |
| 23 ] | 66 ] |
| 24 } | 67 } |
| 25 } | 68 } |
| 26 } | 69 } |
| 27 | 70 |
| 71 # Compiles and jars a set of java_files. | |
| 72 # | |
| 73 # Outputs: | |
| 74 # $jar_path.jar | |
| 75 # $jar_path.jar.TOC | |
| 76 # | |
| 77 # Variables | |
| 78 # java_files: List of .java files to compile. | |
| 79 # java_deps: List of java dependencies. These should all have a .jar output | |
| 80 # at "${target_gen_dir}/${target_name}.jar. | |
| 81 # chromium_code: If 1, enable extra warnings. | |
| 82 # srcjar_deps: List of srcjar dependencies. The .java files contained in the | |
| 83 # dependencies srcjar outputs will be compiled and added to the output jar. | |
| 84 # jar_path: Use this to explicitly set the output jar path. Defaults to | |
| 85 # "${target_gen_dir}/${target_name}.jar. | |
| 86 template("java_library") { | |
| 87 assert(defined(invoker.java_files)) | |
| 88 assert(defined(invoker.build_config)) | |
| 89 assert(defined(invoker.jar_path)) | |
| 90 | |
| 91 java_files = invoker.java_files | |
| 92 jar_path = invoker.jar_path | |
| 93 jar_toc_path = jar_path + ".TOC" | |
| 94 | |
| 95 build_config = invoker.build_config | |
| 96 | |
| 97 jar_excluded_patterns = [] | |
| 98 if (defined(invoker.jar_excluded_patterns)) { | |
| 99 jar_excluded_patterns += invoker.jar_excluded_patterns | |
| 100 } | |
| 101 | |
| 102 chromium_code = false | |
| 103 if (defined(invoker.chromium_code)) { | |
| 104 chromium_code = chromium_code || invoker.chromium_code | |
| 105 } | |
| 106 | |
| 107 srcjar_deps = [] | |
| 108 if (defined(invoker.srcjar_deps)) { | |
| 109 srcjar_deps += invoker.srcjar_deps | |
| 110 } | |
| 111 | |
| 112 java_srcjars = [] | |
| 113 foreach(dep, srcjar_deps) { | |
| 114 java_srcjars += [get_label_info(dep, "target_gen_dir") + "/" + get_label_inf o(dep, "name") + ".srcjar"] | |
|
brettw
2014/07/02 00:23:28
Wrap, also spaces inside []
cjhopman
2014/07/02 02:36:49
Done.
| |
| 115 } | |
| 116 | |
| 117 # Mark srcjar_deps as used. | |
| 118 assert(srcjar_deps == [] || srcjar_deps != []) | |
| 119 | |
| 120 | |
| 121 rebase_jar_path = rebase_path(jar_path, root_build_dir) | |
| 122 | |
| 123 system_jars = ["${android_sdk}/android.jar"] | |
| 124 action("${target_name}__javac") { | |
| 125 script = "//build/android/gyp/javac.py" | |
| 126 depfile = "$target_gen_dir/$target_name.d" | |
| 127 outputs = [ | |
| 128 depfile, | |
| 129 jar_path, | |
| 130 jar_path + ".md5.stamp" | |
| 131 ] | |
| 132 sources = java_files + java_srcjars | |
| 133 source_prereqs = system_jars + [build_config] | |
|
brettw
2014/07/02 00:23:28
spaces inside [], same in a few places below.
cjhopman
2014/07/02 02:36:49
Done.
| |
| 134 | |
| 135 rebase_system_jars = rebase_path(system_jars, root_build_dir) | |
| 136 rebase_java_srcjars = rebase_path(java_srcjars, root_build_dir) | |
| 137 rebase_build_config = rebase_path(build_config, root_build_dir) | |
| 138 rebase_depfile = rebase_path(depfile, root_build_dir) | |
| 139 args = [ | |
| 140 "--depfile=$rebase_depfile", | |
| 141 "--classpath=$rebase_system_jars", | |
| 142 "--classpath=@($rebase_build_config:javac:classpath)", | |
| 143 "--jar-path=$rebase_jar_path", | |
| 144 "--java-srcjars=$rebase_java_srcjars", | |
| 145 "--jar-excluded-classes=$jar_excluded_patterns", | |
| 146 ] | |
| 147 if (chromium_code) { | |
| 148 args += ["--chromium-code"] | |
| 149 } | |
| 150 | |
| 151 args += rebase_path(java_files, root_build_dir) | |
| 152 } | |
| 153 | |
| 154 # TODO(cjhopman): proguard | |
| 155 | |
| 156 rebase_jar_toc_path = rebase_path(jar_toc_path, root_build_dir) | |
| 157 action("${target_name}__jar_toc") { | |
| 158 script = "//build/android/gyp/jar_toc.py" | |
| 159 depfile = "$target_gen_dir/$target_name.d" | |
| 160 outputs = [depfile, jar_toc_path, jar_toc_path + ".md5.stamp"] | |
| 161 source_prereqs = [jar_path] | |
| 162 args = [ | |
| 163 "--depfile", rebase_path(depfile, root_build_dir), | |
| 164 "--jar-path=${rebase_jar_path}", | |
| 165 "--toc-path=${rebase_jar_toc_path}", | |
| 166 ] | |
| 167 } | |
| 168 | |
| 169 group(target_name) { | |
| 170 deps = [ | |
| 171 ":${target_name}__javac", | |
| 172 ":${target_name}__jar_toc", | |
| 173 ] | |
| 174 } | |
| 175 } | |
| 176 | |
| 177 # This adds Android-specific parts to the java_library template. | |
| 178 # | |
| 179 # Runs Android lint against the compiled java files. | |
| 180 # Dexes the output jar for inclusion in an APK. | |
| 181 template("android_java_library") { | |
| 182 assert(defined(invoker.java_files)) | |
| 183 | |
| 184 assert(defined(invoker.build_config)) | |
| 185 assert(defined(invoker.jar_path)) | |
| 186 | |
| 187 java_library("${target_name}__java_library") { | |
| 188 if (defined(invoker.jar_excluded_patterns)) { | |
| 189 jar_excluded_patterns = invoker.jar_excluded_patterns | |
| 190 } | |
| 191 build_config = invoker.build_config | |
| 192 java_files = invoker.java_files | |
| 193 jar_path = invoker.jar_path | |
| 194 | |
| 195 if (defined(invoker.srcjar_deps)) { | |
| 196 srcjar_deps = invoker.srcjar_deps | |
| 197 } | |
| 198 } | |
| 199 | |
| 200 # TODO(cjhopman): lint | |
| 201 # TODO(cjhopman): dex | |
| 202 | |
| 203 group(target_name) { | |
| 204 deps = [ | |
| 205 ":${target_name}__java_library" | |
| 206 ] | |
| 207 } | |
| 208 } | |
| OLD | NEW |