Merge changes Iac724187,I60dc7a01,Ia40c8e4a
* changes:
gn2bp: Support //tools/grit:grit_sources
gn2bp: Support write_native_libraries_java.py
gn2bp: Support //build/android:build_config_gen
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 72674bd..ad075f3 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -2055,20 +2055,28 @@
// GN: //build/android:build_config_gen
genrule {
name: "cronet_aml_build_android_build_config_gen",
- cmd: "$(location build/android/gyp/gcc_preprocess.py) --include-dirs " +
- "[\"../../\", \"gen\"] " +
- "--output " +
- "gen/build/android/build_config_gen.srcjar " +
- "--define " +
- "_ENABLE_ASSERTS " +
- "../../build/android/java/templates/BuildConfig.template",
+ tools: [
+ "soong_zip",
+ ],
+ cmd: "echo " +
+ "\"package org.chromium.build;\n " +
+ "public class BuildConfig {\n " +
+ "public static boolean IS_MULTIDEX_ENABLED ;\n " +
+ "public static boolean ENABLE_ASSERTS = true;\n " +
+ "public static boolean IS_UBSAN ;\n " +
+ "public static boolean IS_CHROME_BRANDED ;\n " +
+ "public static int R_STRING_PRODUCT_VERSION ;\n " +
+ "public static int MIN_SDK_VERSION = 1;\n " +
+ "public static boolean BUNDLES_SUPPORTED ;\n " +
+ "public static boolean IS_INCREMENTAL_INSTALL ;\n " +
+ "public static boolean ISOLATED_SPLITS_ENABLED ;\n " +
+ "public static boolean IS_FOR_TEST ;\n " +
+ "}\n\" " +
+ "> $(genDir)/BuildConfig.java && " +
+ "$(location soong_zip) -o $(out) -srcjar -f $(genDir)/BuildConfig.java",
out: [
"build/android/build_config_gen.srcjar",
],
- tool_files: [
- "build/android/gyp/gcc_preprocess.py",
- "build/android/java/templates/BuildConfig.template",
- ],
}
// GN: //build/android:build_java__build_config_crbug_908819
@@ -2858,7 +2866,7 @@
genrule {
name: "cronet_aml_build_android_native_libraries_gen",
cmd: "$(location build/android/gyp/write_native_libraries_java.py) --output " +
- "gen/build/android/native_libraries_gen.srcjar " +
+ "$(out) " +
"--cpu-family " +
"CPU_FAMILY_X86",
out: [
@@ -10084,11 +10092,11 @@
// GN: //tools/grit:grit_sources
genrule {
name: "cronet_aml_tools_grit_grit_sources",
- cmd: "$(location tools/grit/stamp_grit_sources.py) ../../tools/grit " +
- "obj/tools/grit/grit_sources.script.stamp " +
- "obj/tools/grit/grit_sources.d",
+ cmd: "python $(location tools/grit/stamp_grit_sources.py) `dirname $(location tools/grit/grit.py)` " +
+ "$(out) " +
+ "$(genDir)/grit_sources.d",
out: [
- "//out/test/obj/tools/grit/grit_sources.script.stamp",
+ "out/test/obj/tools/grit/grit_sources.script.stamp",
],
tool_files: [
"tools/grit/grit.py",
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 97eeb4d..f0eb1d8 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -667,6 +667,37 @@
blueprint.add_module(module)
+# HACK: Need to support build_cofig_gen flexibly instead of hardcoding
+# build_config_gen generates srcjar by executing gcc via gcc_preprocess.py but gcc is not
+# available in genrule sandbox. Also gcc path is not configurable.
+# Under the //net:net, gcc_preprocess.py is only used for build_config_gen.
+# So, for now, hardcoding BuildConfig.java and generates srcjar by soong_zip.
+def override_build_config_gen(module):
+ module.tool_files.clear()
+ module.tools.add("soong_zip")
+ cmd = [
+ "echo",
+ "\\\"package org.chromium.build;\\n",
+ "public class BuildConfig {\\n",
+ "public static boolean IS_MULTIDEX_ENABLED ;\\n",
+ "public static boolean ENABLE_ASSERTS = true;\\n",
+ "public static boolean IS_UBSAN ;\\n",
+ "public static boolean IS_CHROME_BRANDED ;\\n",
+ "public static int R_STRING_PRODUCT_VERSION ;\\n",
+ "public static int MIN_SDK_VERSION = 1;\\n",
+ "public static boolean BUNDLES_SUPPORTED ;\\n",
+ "public static boolean IS_INCREMENTAL_INSTALL ;\\n",
+ "public static boolean ISOLATED_SPLITS_ENABLED ;\\n",
+ "public static boolean IS_FOR_TEST ;\\n",
+ "}\\n\\\"",
+ "> $(genDir)/BuildConfig.java &&",
+ "$(location soong_zip) -o $(out) -srcjar -f $(genDir)/BuildConfig.java"
+ ]
+ NEWLINE = ' " +\n "'
+ module.cmd = NEWLINE.join(cmd)
+ return module
+
+
def create_action_module(blueprint, target):
bp_module_name = label_to_module_name(target.name)
module = Module('genrule', bp_module_name, target.name)
@@ -777,6 +808,20 @@
# wrap filename in \"$(location filename)\"
args = ['$(location %s)' % arg for arg in args]
target.args[i + 1] = '[%s]' % ', '.join(args)
+ elif target.script == "//build/android/gyp/write_native_libraries_java.py":
+ for i, val in enumerate(target.args):
+ if val == '--output':
+ target.args[i + 1] = '$(out)'
+ elif target.script == "//tools/grit/stamp_grit_sources.py":
+ target.outputs = [re.sub('^\/\/', '', out) for out in target.outputs]
+ # Directory that contains grit scripts
+ target.args[0] = '`dirname $(location tools/grit/grit.py)`'
+ # Path to the stamp file
+ target.args[1] = '$(out)'
+ # Script tries to create args[2] file but this is not in the output.
+ # Specifying file under $(genDir) so that parent directory exists.
+ # If this file is used by other module, we may need to add this file to the outputs.
+ target.args[2] = '$(genDir)/' + target.args[2].split('/')[-1]
script = gn_utils.label_to_path(target.script)
module.tool_files.add(script)
@@ -822,6 +867,13 @@
module.srcs.remove(script)
module.out.update(target.outputs)
+
+ if target.name == "//build/android:build_config_gen":
+ module = override_build_config_gen(module)
+ elif target.script == "//tools/grit/stamp_grit_sources.py":
+ # stamp_grit_sources.py is not executable
+ module.cmd = "python " + module.cmd
+
blueprint.add_module(module)
return module