Merge changes I1b2e50f1,I78926bf7
* changes: gn2bp: Split `gcc_preprocess` actions into genrules gn2bp: Add compile_multilib attribute
This commit is contained in:
@@ -5671,24 +5671,45 @@ cc_genrule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GN: //build/android:build_config_gen
|
// GN: //build/android:build_config_gen
|
||||||
java_genrule {
|
genrule {
|
||||||
name: "cronet_aml_build_android_build_config_gen",
|
name: "cronet_aml_build_android_build_config_gen",
|
||||||
cmd: "$(location build/android/gyp/gcc_preprocess.py) --include-dirs " +
|
srcs: [
|
||||||
"[\"../../\", \"gen\"] " +
|
":cronet_aml_build_android_build_config_gen_preprocess",
|
||||||
"--output " +
|
|
||||||
"gen/build/android/build_config_gen.srcjar " +
|
|
||||||
"--define " +
|
|
||||||
"_ENABLE_ASSERTS " +
|
|
||||||
"../../build/android/java/templates/BuildConfig.template",
|
|
||||||
out: [
|
|
||||||
"build/android/build_config_gen.srcjar",
|
|
||||||
],
|
],
|
||||||
tool_files: [
|
tools: [
|
||||||
"build/android/gyp/gcc_preprocess.py",
|
"soong_zip",
|
||||||
"build/android/gyp/util/__init__.py",
|
],
|
||||||
"build/android/gyp/util/build_utils.py",
|
cmd: "cp $(in) $(genDir)/BuildConfig.java && " +
|
||||||
|
"$(location soong_zip) -o $(out) -srcjar -f $(genDir)/BuildConfig.java",
|
||||||
|
out: [
|
||||||
|
"BuildConfig.srcjar",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
// GN: //build/android:build_config_gen
|
||||||
|
cc_object {
|
||||||
|
name: "cronet_aml_build_android_build_config_gen_preprocess",
|
||||||
|
srcs: [
|
||||||
|
":cronet_aml_build_android_build_config_gen_rename",
|
||||||
|
],
|
||||||
|
cflags: [
|
||||||
|
"-DANDROID",
|
||||||
|
"-D_ENABLE_ASSERTS",
|
||||||
|
"-E",
|
||||||
|
"-P",
|
||||||
|
],
|
||||||
|
compile_multilib: "32",
|
||||||
|
}
|
||||||
|
|
||||||
|
// GN: //build/android:build_config_gen
|
||||||
|
genrule {
|
||||||
|
name: "cronet_aml_build_android_build_config_gen_rename",
|
||||||
|
srcs: [
|
||||||
"build/android/java/templates/BuildConfig.template",
|
"build/android/java/templates/BuildConfig.template",
|
||||||
"build/gn_helpers.py",
|
],
|
||||||
|
cmd: "cp $(in) $(out)",
|
||||||
|
out: [
|
||||||
|
"BuildConfig.cc",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7852,23 +7873,45 @@ java_genrule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GN: //components/cronet/android:integrated_mode_state
|
// GN: //components/cronet/android:integrated_mode_state
|
||||||
java_genrule {
|
genrule {
|
||||||
name: "cronet_aml_components_cronet_android_integrated_mode_state",
|
name: "cronet_aml_components_cronet_android_integrated_mode_state",
|
||||||
cmd: "$(location build/android/gyp/gcc_preprocess.py) --include-dirs " +
|
srcs: [
|
||||||
"[\"../../\", \"gen\"] " +
|
":cronet_aml_components_cronet_android_integrated_mode_state_preprocess",
|
||||||
"--output " +
|
|
||||||
"gen/components/cronet/android/integrated_mode_state.srcjar " +
|
|
||||||
"../../components/cronet/android/java/src/org/chromium/net/impl/IntegratedModeState.template",
|
|
||||||
out: [
|
|
||||||
"components/cronet/android/integrated_mode_state.srcjar",
|
|
||||||
],
|
],
|
||||||
tool_files: [
|
tools: [
|
||||||
"build/android/gyp/gcc_preprocess.py",
|
"soong_zip",
|
||||||
"build/android/gyp/util/__init__.py",
|
],
|
||||||
"build/android/gyp/util/build_utils.py",
|
cmd: "cp $(in) $(genDir)/IntegratedModeState.java && " +
|
||||||
"build/gn_helpers.py",
|
"$(location soong_zip) -o $(out) -srcjar -f $(genDir)/IntegratedModeState.java",
|
||||||
|
out: [
|
||||||
|
"IntegratedModeState.srcjar",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
// GN: //components/cronet/android:integrated_mode_state
|
||||||
|
cc_object {
|
||||||
|
name: "cronet_aml_components_cronet_android_integrated_mode_state_preprocess",
|
||||||
|
srcs: [
|
||||||
|
":cronet_aml_components_cronet_android_integrated_mode_state_rename",
|
||||||
|
],
|
||||||
|
cflags: [
|
||||||
|
"-DANDROID",
|
||||||
|
"-E",
|
||||||
|
"-P",
|
||||||
|
],
|
||||||
|
compile_multilib: "32",
|
||||||
|
}
|
||||||
|
|
||||||
|
// GN: //components/cronet/android:integrated_mode_state
|
||||||
|
genrule {
|
||||||
|
name: "cronet_aml_components_cronet_android_integrated_mode_state_rename",
|
||||||
|
srcs: [
|
||||||
"components/cronet/android/java/src/org/chromium/net/impl/IntegratedModeState.template",
|
"components/cronet/android/java/src/org/chromium/net/impl/IntegratedModeState.template",
|
||||||
],
|
],
|
||||||
|
cmd: "cp $(in) $(out)",
|
||||||
|
out: [
|
||||||
|
"IntegratedModeState.cc",
|
||||||
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
// GN: //components/cronet/android:interface_api_version
|
// GN: //components/cronet/android:interface_api_version
|
||||||
@@ -7896,23 +7939,44 @@ java_genrule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GN: //components/cronet/android:load_states_list
|
// GN: //components/cronet/android:load_states_list
|
||||||
java_genrule {
|
genrule {
|
||||||
name: "cronet_aml_components_cronet_android_load_states_list",
|
name: "cronet_aml_components_cronet_android_load_states_list",
|
||||||
cmd: "$(location build/android/gyp/gcc_preprocess.py) --include-dirs " +
|
srcs: [
|
||||||
"[\"../../\", \"gen\"] " +
|
":cronet_aml_components_cronet_android_load_states_list_preprocess",
|
||||||
"--output " +
|
|
||||||
"gen/components/cronet/android/load_states_list.srcjar " +
|
|
||||||
"../../components/cronet/android/java/src/org/chromium/net/impl/LoadState.template",
|
|
||||||
out: [
|
|
||||||
"components/cronet/android/load_states_list.srcjar",
|
|
||||||
],
|
],
|
||||||
tool_files: [
|
tools: [
|
||||||
"build/android/gyp/gcc_preprocess.py",
|
"soong_zip",
|
||||||
"build/android/gyp/util/__init__.py",
|
],
|
||||||
"build/android/gyp/util/build_utils.py",
|
cmd: "cp $(in) $(genDir)/LoadState.java && " +
|
||||||
"build/gn_helpers.py",
|
"$(location soong_zip) -o $(out) -srcjar -f $(genDir)/LoadState.java",
|
||||||
|
out: [
|
||||||
|
"LoadState.srcjar",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
// GN: //components/cronet/android:load_states_list
|
||||||
|
cc_object {
|
||||||
|
name: "cronet_aml_components_cronet_android_load_states_list_preprocess",
|
||||||
|
srcs: [
|
||||||
|
":cronet_aml_components_cronet_android_load_states_list_rename",
|
||||||
|
],
|
||||||
|
cflags: [
|
||||||
|
"-DANDROID",
|
||||||
|
"-E",
|
||||||
|
"-P",
|
||||||
|
],
|
||||||
|
compile_multilib: "32",
|
||||||
|
}
|
||||||
|
|
||||||
|
// GN: //components/cronet/android:load_states_list
|
||||||
|
genrule {
|
||||||
|
name: "cronet_aml_components_cronet_android_load_states_list_rename",
|
||||||
|
srcs: [
|
||||||
"components/cronet/android/java/src/org/chromium/net/impl/LoadState.template",
|
"components/cronet/android/java/src/org/chromium/net/impl/LoadState.template",
|
||||||
"net/base/load_states_list.h",
|
],
|
||||||
|
cmd: "cp $(in) $(out)",
|
||||||
|
out: [
|
||||||
|
"LoadState.cc",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9488,6 +9552,25 @@ cc_object {
|
|||||||
java_library {
|
java_library {
|
||||||
name: "cronet_aml_java",
|
name: "cronet_aml_java",
|
||||||
srcs: [
|
srcs: [
|
||||||
|
":cronet_aml_base_base_android_java_enums_srcjar",
|
||||||
|
":cronet_aml_base_java_features_srcjar",
|
||||||
|
":cronet_aml_base_java_switches_srcjar",
|
||||||
|
":cronet_aml_build_android_build_config_gen",
|
||||||
|
":cronet_aml_build_android_native_libraries_gen",
|
||||||
|
":cronet_aml_components_cronet_android_cronet_jni_registration__java",
|
||||||
|
":cronet_aml_components_cronet_android_http_cache_type_java",
|
||||||
|
":cronet_aml_components_cronet_android_implementation_api_version",
|
||||||
|
":cronet_aml_components_cronet_android_integrated_mode_state",
|
||||||
|
":cronet_aml_components_cronet_android_interface_api_version",
|
||||||
|
":cronet_aml_components_cronet_android_load_states_list",
|
||||||
|
":cronet_aml_components_cronet_android_net_idempotency_java",
|
||||||
|
":cronet_aml_components_cronet_android_net_request_priority_java",
|
||||||
|
":cronet_aml_components_cronet_android_network_quality_observation_source_java",
|
||||||
|
":cronet_aml_components_cronet_android_rtt_throughput_values_java",
|
||||||
|
":cronet_aml_components_cronet_android_url_request_error_java",
|
||||||
|
":cronet_aml_net_android_net_android_java_enums_srcjar",
|
||||||
|
":cronet_aml_net_android_net_errors_java",
|
||||||
|
":cronet_aml_net_effective_connection_type_java",
|
||||||
"base/android/java/src/org/chromium/base/ActivityState.java",
|
"base/android/java/src/org/chromium/base/ActivityState.java",
|
||||||
"base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java",
|
"base/android/java/src/org/chromium/base/ApiCompatibilityUtils.java",
|
||||||
"base/android/java/src/org/chromium/base/ApkAssets.java",
|
"base/android/java/src/org/chromium/base/ApkAssets.java",
|
||||||
@@ -9799,23 +9882,44 @@ java_genrule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GN: //net/android:net_errors_java
|
// GN: //net/android:net_errors_java
|
||||||
java_genrule {
|
genrule {
|
||||||
name: "cronet_aml_net_android_net_errors_java",
|
name: "cronet_aml_net_android_net_errors_java",
|
||||||
cmd: "$(location build/android/gyp/gcc_preprocess.py) --include-dirs " +
|
srcs: [
|
||||||
"[\"../../\", \"gen\"] " +
|
":cronet_aml_net_android_net_errors_java_preprocess",
|
||||||
"--output " +
|
|
||||||
"gen/net/android/net_errors_java.srcjar " +
|
|
||||||
"../../net/android/java/NetError.template",
|
|
||||||
out: [
|
|
||||||
"net/android/net_errors_java.srcjar",
|
|
||||||
],
|
],
|
||||||
tool_files: [
|
tools: [
|
||||||
"build/android/gyp/gcc_preprocess.py",
|
"soong_zip",
|
||||||
"build/android/gyp/util/__init__.py",
|
],
|
||||||
"build/android/gyp/util/build_utils.py",
|
cmd: "cp $(in) $(genDir)/NetError.java && " +
|
||||||
"build/gn_helpers.py",
|
"$(location soong_zip) -o $(out) -srcjar -f $(genDir)/NetError.java",
|
||||||
|
out: [
|
||||||
|
"NetError.srcjar",
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
// GN: //net/android:net_errors_java
|
||||||
|
cc_object {
|
||||||
|
name: "cronet_aml_net_android_net_errors_java_preprocess",
|
||||||
|
srcs: [
|
||||||
|
":cronet_aml_net_android_net_errors_java_rename",
|
||||||
|
],
|
||||||
|
cflags: [
|
||||||
|
"-DANDROID",
|
||||||
|
"-E",
|
||||||
|
"-P",
|
||||||
|
],
|
||||||
|
compile_multilib: "32",
|
||||||
|
}
|
||||||
|
|
||||||
|
// GN: //net/android:net_errors_java
|
||||||
|
genrule {
|
||||||
|
name: "cronet_aml_net_android_net_errors_java_rename",
|
||||||
|
srcs: [
|
||||||
"net/android/java/NetError.template",
|
"net/android/java/NetError.template",
|
||||||
"net/base/net_error_list.h",
|
],
|
||||||
|
cmd: "cp $(in) $(out)",
|
||||||
|
out: [
|
||||||
|
"NetError.cc",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ import os
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import copy
|
import copy
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import gn_utils
|
import gn_utils
|
||||||
|
|
||||||
@@ -314,6 +315,7 @@ class Module(object):
|
|||||||
self.rtti = False
|
self.rtti = False
|
||||||
# Name of the output. Used for setting .so file name for libcronet
|
# Name of the output. Used for setting .so file name for libcronet
|
||||||
self.stem = None
|
self.stem = None
|
||||||
|
self.compile_multilib = None
|
||||||
|
|
||||||
def to_string(self, output):
|
def to_string(self, output):
|
||||||
if self.comment:
|
if self.comment:
|
||||||
@@ -361,6 +363,7 @@ class Module(object):
|
|||||||
self._output_field(output, 'linker_scripts')
|
self._output_field(output, 'linker_scripts')
|
||||||
self._output_field(output, 'cppflags')
|
self._output_field(output, 'cppflags')
|
||||||
self._output_field(output, 'stem')
|
self._output_field(output, 'stem')
|
||||||
|
self._output_field(output, 'compile_multilib')
|
||||||
if self.rtti:
|
if self.rtti:
|
||||||
self._output_field(output, 'rtti')
|
self._output_field(output, 'rtti')
|
||||||
|
|
||||||
@@ -618,6 +621,53 @@ def create_proto_group_modules(blueprint, gn, module_name, target_names):
|
|||||||
|
|
||||||
blueprint.add_module(module)
|
blueprint.add_module(module)
|
||||||
|
|
||||||
|
def create_gcc_preprocess_modules(blueprint, target):
|
||||||
|
# gcc_preprocess.py internally execute host gcc which is not allowed in genrule.
|
||||||
|
# So, this function create multiple modules and realize equivalent processing
|
||||||
|
# TODO: Consider to support gcc_preprocess.py in different way
|
||||||
|
# It's not great to have genrule and cc_object in the dependency from java_library
|
||||||
|
assert (len(target.sources) == 1)
|
||||||
|
source = list(target.sources)[0]
|
||||||
|
assert (Path(source).suffix == '.template')
|
||||||
|
stem = Path(source).stem
|
||||||
|
|
||||||
|
bp_module_name = label_to_module_name(target.name)
|
||||||
|
|
||||||
|
# Rename .template to .cc since cc_object does not accept .template file as srcs
|
||||||
|
rename_module = Module('genrule', bp_module_name + '_rename', target.name)
|
||||||
|
rename_module.srcs.add(gn_utils.label_to_path(source))
|
||||||
|
rename_module.out.add(stem + '.cc')
|
||||||
|
rename_module.cmd = 'cp $(in) $(out)'
|
||||||
|
blueprint.add_module(rename_module)
|
||||||
|
|
||||||
|
# Preprocess template file and generates java file
|
||||||
|
preprocess_module = Module('cc_object', bp_module_name + '_preprocess', target.name)
|
||||||
|
# -E: stop after preprocessing.
|
||||||
|
# -P: disable line markers, i.e. '#line 309'
|
||||||
|
preprocess_module.cflags.update(['-E', '-P', '-DANDROID'])
|
||||||
|
preprocess_module.srcs.add(':' + rename_module.name)
|
||||||
|
defines = ['-D' + target.args[i+1] for i, arg in enumerate(target.args) if arg == '--define']
|
||||||
|
preprocess_module.cflags.update(defines)
|
||||||
|
# HACK: Specifying compile_multilib to build cc_object only once.
|
||||||
|
# Without this, soong complain to genrule that depends on cc_object when built for 64bit target.
|
||||||
|
# It seems this is because cc object is a module with per-architecture variants and genrule is a
|
||||||
|
# module with default variant. For 64bit target, cc_object is built multiple times for 32/64bit
|
||||||
|
# modes and genrule doesn't know which one to depend on.
|
||||||
|
preprocess_module.compile_multilib = 32
|
||||||
|
blueprint.add_module(preprocess_module)
|
||||||
|
|
||||||
|
# Generates srcjar using soong_zip
|
||||||
|
module = Module('genrule', bp_module_name, target.name)
|
||||||
|
module.srcs.add(':' + preprocess_module.name)
|
||||||
|
module.out.add(stem + '.srcjar')
|
||||||
|
module.cmd = NEWLINE.join([
|
||||||
|
f'cp $(in) $(genDir)/{stem}.java &&',
|
||||||
|
f'$(location soong_zip) -o $(out) -srcjar -f $(genDir)/{stem}.java'
|
||||||
|
])
|
||||||
|
module.tools.add('soong_zip')
|
||||||
|
blueprint.add_module(module)
|
||||||
|
return module
|
||||||
|
|
||||||
|
|
||||||
class BaseActionSanitizer():
|
class BaseActionSanitizer():
|
||||||
def __init__(self, target):
|
def __init__(self, target):
|
||||||
@@ -1253,7 +1303,11 @@ def create_java_module(blueprint, gn):
|
|||||||
module = Module('java_library', bp_module_name, '//gn:java')
|
module = Module('java_library', bp_module_name, '//gn:java')
|
||||||
module.srcs.update([gn_utils.label_to_path(source) for source in gn.java_sources])
|
module.srcs.update([gn_utils.label_to_path(source) for source in gn.java_sources])
|
||||||
for dep in gn.java_actions:
|
for dep in gn.java_actions:
|
||||||
dep_module = create_action_module(blueprint, gn.get_target(dep), 'java_genrule')
|
target = gn.get_target(dep)
|
||||||
|
if target.script == '//build/android/gyp/gcc_preprocess.py':
|
||||||
|
module.srcs.add(':' + create_gcc_preprocess_modules(blueprint, target).name)
|
||||||
|
else:
|
||||||
|
module.srcs.add(':' + create_action_module(blueprint, target, 'java_genrule').name)
|
||||||
blueprint.add_module(module)
|
blueprint.add_module(module)
|
||||||
|
|
||||||
def update_jni_registration_module(module, gn):
|
def update_jni_registration_module(module, gn):
|
||||||
|
|||||||
Reference in New Issue
Block a user