Commit Graph

54 Commits

Author SHA1 Message Date
Motomu Utsumi
ee47af6e0c gn2bp: Set the output name for libcronet.so
.so file name needs to match with CronetLibraryLoader.java
(e.g. libcronet.109.0.5386.0.so)

Test: m, atest CtsCronetTestCases
Change-Id: I82285c32e82fc27ba5233e1bef7195ec57c35bea
2022-11-30 16:41:15 +09:00
Mohannad Farrag
f2391cc1e7 gn2bp: Refactor and code clean up
Test: m cronet_aml_components_cronet_android_cronet
Change-Id: I20b9d12c0a66555914760a766995629399c76a1c
2022-11-29 17:18:41 +00:00
Mohannad Farrag
1de6cb10d3 gn2bp: Convert genrules to cc_genrules
* This change doesn't effectively use the `CC_ARCH` environment variable. Just a change of variable name.
* cc_genrules are compiled so they need host_supported/device_supported tags.

Test: m cronet_aml_components_cronet_android_cronet
Change-Id: Ie55e5e0fb60b444817bc13c967e89f35c4e8badf
2022-11-28 17:18:22 +00:00
Mohannad Farrag
7f29d836a7 gn2bp: Convert source_set to cc_object
* Convert every source_set into a cc_object.

Test: m cronet_aml_components_cronet_android_cronet
Change-Id: Iaa123d1b348e8809fbfa4acc1d888bb6d0d0989c
2022-11-25 13:54:05 +00:00
Mohannad Farrag
a0db68bc8d gn2bp: Add _is_java_source method
Test: m cronet_aml_components_cronet_android_cronet
Change-Id: I2c28c794ba2b39e2a3baec0cce83a5e1d7770381
2022-11-24 12:28:09 +00:00
Mohannad Farrag
a23114ad94 gn2bp: Add cronet_package to update_results.sh
* This will include all of the java files needed to build cronet java.

Test: m cronet_aml_components_cronet_android_cronet
Change-Id: Idc0f61a5f290eca1a03253b622c416c65eba04c9
2022-11-22 17:47:51 +00:00
Mohannad Farrag
4bea14a4e0 gn2bp: Fix parsing java sources for multi-arch
Test: m cronet_aml_components_cronet_android_cronet
Change-Id: I678779c296753c07ada321225cb48ee10357657e
2022-11-22 15:38:30 +00:00
Mohannad Farrag
baf0d57a74 gn2bp: Convert source_set with rtti to static_libraries
* `source_set` were converted to cc_defaults and this would pose a huge problem if those cc_defaults had rtti on since it affected all of the dependencies of the source target.
* The solution here would be to compile the `source_set` independently as a static/shared library with rtti on then link it.

Test: m cronet_aml_components_cronet_android_cronet
Change-Id: I28bbe0947d0dc87c2d602514a2759a3171b68aa2
2022-11-22 12:52:39 +00:00
Mohannad Farrag
d7efd7b9c5 gn2bp: Generate per-architecture genrule for action_foreach
Test: m cronet_aml_base_base
Change-Id: I90b6f7f105e870aac24f829358cc78b927e8eb7a
2022-11-21 16:15:16 +00:00
Patrick Rohr
98600687ec gn2bp: create one action per arch
Action modules can have different args depending on target_cpu
(specifically, the buildflags action). Therefore, we create one action
per target os & arch.

Test: //components/cronet/android:cronet
Change-Id: I6025abba8eb9f1974ef0fa6b62f79998305374a3
2022-11-18 19:29:18 -08:00
Motomu Utsumi
5539463ed1 gn2bp: Skip extracting common part for source_set
Test: ./update_results.sh
Change-Id: I429cef85ffbb47df0e44970732f223d81e2867c8
2022-11-18 20:00:04 +09:00
Patrick Rohr
297f979e8f gn2bp: collect linker unit deps per target
Both transitive static libraries and LINKER_UNIT_TYPES dependencies need
to be stored separately for every target as they could differ. In
reality, only static deps differ right now.

I am not a big fan of how transitive_static_libs_deps are handled in
this CL; maybe we can come up with a more readable solution.

Test: //components/cronet/android:cronet
Change-Id: Ia4ad8e264b1243b7dd5d58a26543ee78206f9c79
2022-11-17 07:05:47 -08:00
Patrick Rohr
f1004372e6 gn2bp: remove is_third_party_dep
This is not used anymore.

Test: //components/cronet/android:cronet
Change-Id: Ie6d21f93e44348b51732b6030de315e8c67db52a
2022-11-17 07:03:09 -08:00
Motomu Utsumi
f0f4768b5d gn2bp: Add flags and include_dirs to target
Test: ./update_results.sh
Change-Id: Iac05e49a7f195afec72e229f667a402bae8a1742
2022-11-17 22:45:34 +09:00
Motomu Utsumi
778f830dd1 gn2bp: Add indlue_dirs to arch
Test: ./update_results.sh
Change-Id: I4d7477869bbf0c121e2c0249d031a57b82e11e6f
2022-11-17 22:45:33 +09:00
Motomu Utsumi
80e044716b gn2bp: Add defines to arch
Test: ./update_results.sh
Change-Id: Ia167511becaa4c1ddb3ed40e2b78732fc291cb8e
2022-11-17 22:45:33 +09:00
Motomu Utsumi
1c64e448dc gn2bp: Add cflags to arch
Test: m cronet_aml_third_party_protobuf_protoc
Change-Id: Iea847d205fd258ae00ba1ff03e382798deb2f0a8
2022-11-17 22:45:25 +09:00
Patrick Rohr
9006b3695a gn2bp: using dep.name when adding dependency is more correct
This is pretty much a noop, but if we ever decided to change the
target.name or similar, the code would still work.

Test: //components/cronet/android:cronet
Change-Id: I37ad0250ec1b25f03f8942e34fddc57186340276
2022-11-16 21:50:44 -08:00
Patrick Rohr
ad7a29c86e gn2bp: properly add proto_deps
Test: //components/cronet/android:cronet
Change-Id: I1583db83d3cd51d734c9d7252f0c5ff6194f9131
2022-11-16 21:48:09 -08:00
Motomu Utsumi
6ccc9d8b1c gn2bp: Fix to bubble up proto static_lib deps
Test: ./update_results.sh
Change-Id: I98d484b3d6c467248f7a05cb25576d48a75ce228
2022-11-16 20:06:03 +09:00
Motomu Utsumi
dee9ce06d8 gn2bp: create modules for protoc
Test: ./update_results.sh
Change-Id: I04a0eee68316acd13be67d8dd516eff7c50142d0
2022-11-16 20:06:03 +09:00
Patrick Rohr
04f194e075 gn2bp: remove unused toolchain property
This has been replaced by target.arch.

Test: //components/cronet/android:cronet
Change-Id: If0193d549fbe50ab9b5197e186e41ffff3ca6e09
2022-11-15 22:50:22 -08:00
Patrick Rohr
c8f41cd4eb gn2bp: fix host and device support properties
With proper arch support, we now have all the information to do this
properly.

Test: //components/cronet/android:cronet
Change-Id: Iab86261a6a4d775ba5f3b12b2487b7c27096580d
2022-11-15 22:49:29 -08:00
Patrick Rohr
4eff210a9f gn2bp: use proper target annotation
Test: //components/cronet/android:cronet
Change-Id: I72bbbec7d49c82d1581769a4968764dd3234ceda
2022-11-15 22:21:52 -08:00
Patrick Rohr
d938d53f01 gn2bp: toolchain propery is always present
No need to default to anything.

Test: //components/cronet/android:cronet
Change-Id: I93ea5173c4d9059c4c824347a380542eeda97292
2022-11-15 22:17:08 -08:00
Patrick Rohr
53dcd10ef0 gn2bp: collect sources for each architecture
Test: //components/cronet/android:cronet
Change-Id: I980677f326e82b2f164908611b95db3350d040a1
2022-11-15 21:58:24 -08:00
Patrick Rohr
70913563ee gn2bp: add code that collects common sources
Once sources will be added to a Target.Arch, common sources need to be
collected from the arch-dependent object. This is done via finalize()
method, which is called once on every Target. Finalize collects the
intersection of all sources and subtracts it from the arch dependent
sources.

Test: //components/cronet/android:cronet
Change-Id: If2d0d04ff6c8df0efb541a322bcf2febcf79bb55
2022-11-15 21:49:28 -08:00
Patrick Rohr
81a4ac30db gn2bp: get arch from toolchain
Default all non-android toolchains to the host toolchain. Some limited
host support may be required. Let's see.

Test: //components/cronet/android:cronet
Change-Id: I3bc7a0d5da0c9558bda83583a0a7f90b1a5a2597
2022-11-15 14:43:21 -08:00
Patrick Rohr
7f4631e236 gn2bp: remove toolchain label from dependencies
This probably won't have any effect, but just in case.

Test: //components/cronet/android:cronet
Change-Id: I1e956ab5add346764f4f479d7ef7da85e3f560c4
2022-11-15 14:35:03 -08:00
Patrick Rohr
02ad51f54a gn2bp: add arch to Target
arch set will consist of Arch object that contain arch-dependent
properties (sources, flags, etc.).

Test: //components/cronet/android:cronet
Change-Id: Ic5b62063d3c5ea07435c676eb11923defdf4e577
2022-11-15 14:33:36 -08:00
Patrick Rohr
7705bdb443 gn2bp: use name without toolchain for Targets
This change does affect the Android.bp.swp for targets that currently
exist in multiple toolchain variations. Only the first one is parsed.

Test: //components/cronet/android:cronet
Change-Id: I77501b1b195a91a61e29566d540ecc7dfadeea75
2022-11-15 13:26:30 -08:00
Patrick Rohr
770cf68919 gn2bp: remove unused third_party deps handling
This was not useful for the cronet build, as we have not remapped
third_party deps into //gn (unlike perfetto).

We probably do want something similar for builtin_deps (like pass
builtin_deps into the GnParser constructor) to prevent static_library
dependencies to circumvent replaced dependencies via builtin_deps.

Test: //components/cronet/android:cronet
Change-Id: I77ed99eb14618a478281b9be025cf9d384066ddb
2022-11-15 13:18:20 -08:00
Patrick Rohr
0d40da3955 gn2bp: pass gn_target_name into get_proto_target_type
This is to get ready for removing the toolchain from Target names.

Test: //components/cronet/android:cronet
Change-Id: I0d7d6ae286c2e5c493e7bb565a4943be6f4c5b98
2022-11-15 13:08:12 -08:00
Patrick Rohr
564d6be8db gn2bp: pass gn_desc to parse_gn_desc
Eventually, this will lead to support for passing in different gn desc
files.

Test: //components/cronet/android:cronet
Change-Id: I6e1f7ee51f9819969b0bef8da7a1a21abbccabc8
2022-11-15 12:57:57 -08:00
Patrick Rohr
d0077b7e5e gn2bp: separate parsing gn desc from retrieving Target object
To support parsing multiple gn desc files for different architectures,
the process of parsing and retrieving Targets needs to be split in two.

Test: //components/cronet/android:cronet
Change-Id: Ib94cbc18b9b73b17942a71289ef86f69d4e36c5f
2022-11-15 12:54:29 -08:00
Patrick Rohr
a9c1dda118 gn2bp: fix collecting static libs dependencies
There were some flaws in the previous logic. Dependencies need to be
bubbled up for all targets, but only static_libs should be added to
them.

Test: update_results.sh
Change-Id: I98025a8a0720d34bc47a820bf45118c06acd64a0
2022-11-14 19:02:40 -08:00
Patrick Rohr
5de9f2e266 gn2bp: propagate static libs up the tree
Soong explicitly requires to list all static libraries, including static
libraries that are linked by a dependency.

What is interesting is that this change seemed to have introduced new
targets?! Will have to check if that's correct, but at first glance it
seems to make sense.

Test: //components/cronet/android:cronet
Change-Id: I0e6e9a760dd0a4ebc5ce50f5dabc02458ff488a8
2022-11-11 15:36:39 -08:00
Patrick Rohr
67f5312922 gn2bp: move target.type check into _is_java_target
Cleanup -- makes the code more readable.

Test: //components/cronet/android:cronet
Change-Id: I4bb68137ac21f6204143c4fb9c74e57e9db8c5d7
2022-11-09 10:57:40 -08:00
Motomu Utsumi
d7e0e42941 gn2bp: Update --proto_path and --cpp_out arg
--proto_path specify the directory in which to search for imports.
net_quic_proto and metrics_proto have files that import other files.
Get proper --proto_path from the args in the desc.
Also, update --cpp_out to follow --proto_path change.

There are 6 targets which use protoc_wrapper.py in the dependency
from cronet_package_android.
It is confirmed that they could build with this commit.

Test: m cronet_aml_net_isolation_info_proto_gen
      (//net:isolation_info_proto)
Test: m cronet_aml_net_net_nqe_proto_gen
      (//net:net_nqe_proto)
Test: m cronet_aml_net_third_party_quiche_net_quic_test_tools_proto_gen
      (//net/third_party/quiche:net_quic_test_tools_proto)
Test: m cronet_aml_net_cert_root_store_proto_full_gen
      (//net/cert:root_store_proto_full)
Test: m cronet_aml_net_third_party_quiche_net_quic_proto_gen
      (//net/third_party/quiche:net_quic_proto)
Test: m cronet_aml_third_party_metrics_proto_metrics_proto_gen
      (//third_party/metrics_proto:metrics_proto)
Change-Id: Id19e956eb0eb3fb402f8aaa9eb94734b731c74fd
2022-11-08 19:58:49 +09:00
Patrick Rohr
c5980783c6 gn2bp: fix proto parsing
GnUtils and gen_android_bp already have support for proto targets.
It looks pretty generic and quite a bit more evolved than what we have
done so far.

Test: //net:net
Change-Id: I1ca0d004650b4dc5e09fae4a0f4159699b4de96b
2022-11-07 19:10:53 -08:00
Patrick Rohr
b27587ec54 gn2bp: collect java sources
The current plan is to write a lightweight wrapper around Cronet that
serves as the Android API surface. If that holds true, we might get away
with putting all .java sources in a single jar. Otherwise, the API will
have to be put in a separate source jar.

Test: //net:net
Change-Id: I2bef893ebdf0a4390dfb634e715c60ccd94dc1fb
2022-11-04 14:57:24 -07:00
Patrick Rohr
3624f95078 gn2bp: be explicit about dropping java_group dependencies
This is a no-op that makes the code more readable.

Test: //net:net
Change-Id: I8c026cd2f7cd3d676223d4c05a49376140791e21
2022-11-04 14:30:18 -07:00
Patrick Rohr
af92fa6088 gn2bp: mark java targets as java_group
According to the docs, java target names are (somewhat) guaranteed to end in
_java. There are some other variations that are allowlisted, though it
is currently unclear if those need to be supported for our purposes.

Test: //net:net
Change-Id: I0647dac6a078790e23509d437628aed0d8d62f77
2022-11-04 14:29:48 -07:00
Motomu Utsumi
b42a71c549 gn2bp: Removed meaningless lines
Test: ./update_result.sh
Change-Id: I12a07ba3593929a1d7666a3230b62bb8a5aeff53
2022-10-31 16:51:15 +09:00
Patrick Rohr
c20887d2db gn2bp: fix response_file_contents parsing
Test: //base:base
Change-Id: I6a90f684d31a83323580001822b0cc3745497baa
2022-10-28 13:04:11 -07:00
Patrick Rohr
7aa98f9cdb gn2bp: gn_utils should not touch action args
gn_utils does not have enough information to fix the args, so it should
not touch them.

Test: //base:base
Change-Id: Id813a255fcf3694448eae2bb51637b10fc8a0297
2022-10-28 11:18:04 -07:00
Patrick Rohr
09716f5c7e gn2bp: store response_file_contents for action targets
These will be piped into a script, so it is important that both single
and double quotes are properly escaped.

Test: //base:base
Change-Id: I0123e09a698418f222f51b0326608d4e97374928
2022-10-27 14:45:54 -07:00
Patrick Rohr
da778a00ca gn2bp: add basic parser support for copy and action_foreach rules
*Very* basic GnParser support for copy and action_foreach targets.
Copy rules are not very common, for cronet package only two are invoked:

- //components/cronet/android:cronet_package_copy_native_lib
- //third_party/icu:icudata

(I am using a heavily pruned version of cronet_package, it is possible
that the upstreamed version includes more such rules).

Test: parse //components/cronet:cronet_package
Change-Id: I47cd077b7f6261085d8006596df165f27a83a1d8
2022-10-26 11:53:44 -07:00
Patrick Rohr
26af1e76b2 gn2bp: allow targets to depend on chromium's libc++ and libunwind
We need to determine if this should be replaced by Android's version of
those libraries.

This can be done via "stl" property on dependent targets (we would
additionally have to configure the version).

Test: n/a
Change-Id: Ibd54cc0b58086ec77d5eee40708f28b237d70c3f
2022-10-26 11:52:44 -07:00
Motomu Utsumi
b26c337590 gn2bp: Remove unuded code
Test: ./gen_android_bp --desc gn.json --output Android.bp \
'//third_party/zlib:zlib'

Change-Id: Icd3891c605e6b519b4eb7ca9a14563c825c5750d
2022-10-26 19:59:02 +09:00