Skip to content

Commit 54e4932

Browse files
Add default project 'mobile_app1'
1 parent 03b6cf3 commit 54e4932

File tree

94,816 files changed

+3628992
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94,816 files changed

+3628992
-0
lines changed

README.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
### Intro
2+
3+
This repository is for community collaboration.
4+
5+
It includes Uber-agnostic auto-generated projects (via Android Studio Poet), with comparable complexity to existing Uber Production mobile apps.(*)
6+
7+
These projects are buildable on Buck, Bazel and Gradle, therefore it enables build time benchmarking across different build systems.
8+
9+
Any PR to enable speeding up any of these builds is welcome!
10+
11+
### Project details
12+
13+
Auto-generated project(s) offer similar complexity to existing Uber Production mobile apps in terms of :
14+
15+
- number of modules, classes and (some) resources
16+
- interdependency between modules
17+
- java Vs kotlin code
18+
- dependencies on external libraries
19+
20+
When building these project, we voluntarily disable lint, error prone and annotation processors for each build system for better build time measurement parity.
21+
22+
Also, we're not using build network cache, nor remote build execution (Bazel).
23+
24+
### Pre-requisite to building each project
25+
26+
- Make sure Bazel is installed, and is on the PATH (<https://docs.bazel.build/versions/master/install.html>)
27+
- Disable OkBuck : `export SKIP_OKBUCK=1`. This will prevent OkBuck to regenerate Buck files at the beginning of builds.
28+
- Change directory to mobile app folder.
29+
30+
### How to build a project
31+
32+
- (Gradle) `./gradlew rootModule:assembleDebug`
33+
- (Bazel) `bazel build rootModule`
34+
- (Buck) `./buckw build rootModule:src_release`
35+
36+
### How to run benchmark for a project
37+
38+
- `./benchmark.sh`
39+
40+
Build time report will be generated in the /output/<timestamp> folder.
41+
42+
Note :
43+
44+
- In order to 'clean' builds between runs for Bazel and Buck, we're using a fork for android-profiler that will be installed automatically from <https://github.com/sunyal/gradle-profiler>
45+
46+
### Scenario description
47+
48+
We used special naming for a couple of modules, these can be used to simulate different incremental builds :
49+
50+
- rootModule : the top project module (i.e any module in the project is a transitive dependency on this module)
51+
- leafModule(Min|Avg|Max) : these are modules on which some other modules depend on. Min = only a few modules depends on this module, Max = a lot of modules depends on this module (i.e ABI change of this module will cause a somehow large part of the build graph to be rebuilt)
52+
53+
To simulate incremental builds (ABI and non-ABI changes alike), you can modify manually source files of these modules.
54+
55+
Benchmark scenario are as follow :
56+
57+
- fullLocalCache : clean build of the app (with external artifacts/toolchain already cached locally)
58+
- abiChangeWith(Min|Avg|Max)LeafLocalCache : abi-change incremental build with (large|medium|small) part of the build graph rebuilt
59+
- nonAbiChangeWithMaxLeafLocalCache : non abi-change incremental build
60+
- androidResourceChangeWithRootLocalCache : incremental build with resources changes to root module
61+
- noOpLocalCache : no-op build
62+
63+
### Current results
64+
65+
- Bazel : 3.7.0, persistent workers, sandboxing disabled, JAVA header generation disabled
66+
- Gradle : 6.7, file watcher and configuration cache enabled
67+
- Buck : latest version (as specified by OkBuck)
68+
69+
![apps_presidio_helix_app results](/output/mobile_app1.png)
70+
71+
### License
72+
73+
```
74+
Copyright 2020 Uber Technologies
75+
76+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
77+
in compliance with the License. You may obtain a copy of the License at
78+
79+
http://www.apache.org/licenses/LICENSE-2.0
80+
81+
Unless required by applicable law or agreed to in writing, software distributed under the License
82+
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
83+
or implied. See the License for the specific language governing permissions and limitations under
84+
the License.
85+
```
86+
87+
(*) The generated code is not representative of Uber's existing production mobile apps.

mobile_app1/.bazelrc

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# 12Gb mem heap
2+
startup --host_jvm_args=-Xmx12g
3+
4+
# Disable error prone, for build benchmarking parity
5+
build --javacopt=-XepDisableAllChecks
6+
7+
# Disable generating header file separately, it actually slows down build time in this project
8+
build --nojava_header_compilation
9+
build --nojava_deps
10+
11+
# Disable sandboxing, to get optimal build times. Should be required on CI though.
12+
build --noworker_sandboxing
13+
build --strategy=worker,local
14+
build --spawn_strategy=worker,local
15+
16+
build --strategy=DexBuilder=worker,local
17+
build --strategy=Javac=worker,local
18+
build --strategy=KotlinCompile=worker,local
19+
build --strategy=Desugar=worker,local
20+
build --persistent_android_resource_processor

mobile_app1/.buckconfig

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
[java]
2+
jar_spool_mode = direct_to_jar
3+
suggest_dependencies = false
4+
skip_checking_missing_deps = true
5+
compile_against_abis = true
6+
duplicates_log_level = fine
7+
source_level = 8
8+
target_level = 8
9+
desugar_interface_methods = true
10+
classpath_ordering = reversed
11+
12+
[build]
13+
metadata_storage = sqlite
14+
action_graph_parallelization = enabled
15+
file_hash_cache_mode = limited_prefix_tree
16+
depfiles = cache
17+
18+
[resources]
19+
resource_aware_scheduling_enabled = true
20+
21+
[maven_repositories]
22+
google = https://dl.google.com/dl/android/maven2/
23+
bintrayjcenter = https://jcenter.bintray.com/
24+
maven = https://jitpack.io
25+
26+
[download]
27+
maven_repo = https://repo1.maven.org/maven2
28+
in_build = true
29+
30+
[defs]
31+
disable_errorprone=true
32+
33+
[android]
34+
build_tools_version = 30.0.1
35+
target = android-30
36+
37+
[log]
38+
chrome_trace_generation = true
39+
max_traces = 25

mobile_app1/.buckjavaargs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-Xmx12g
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[android]
2+
build_tools_version = 28.0.2
3+
target = android-28
4+
5+
[kotlin]
6+
kotlin_home = buck-out/gen/.okbuck/workspace/kotlin_home/kotlin_home/kotlin_home
7+
8+
[tools]
9+
proguard = //.okbuck/ext/net/sf/proguard:proguard-base-6.0.3.jar
10+
11+
[maven_repositories]
12+
google = https://dl.google.com/dl/android/maven2/
13+
bintrayjcenter = https://jcenter.bintray.com/
14+
maven = https://jitpack.io
15+
16+
[download]
17+
in_build = true
18+
max_number_of_retries = 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[android]
2+
build_tools_version = 28.0.2
3+
target = android-28
4+
5+
[kotlin]
6+
kotlin_home = //.okbuck/workspace/kotlin_home:kotlin_home
7+
8+
[tools]
9+
proguard = //.okbuck/ext/net/sf/proguard:proguard-base-6.0.3.jar
10+
11+
[maven_repositories]
12+
google = https://dl.google.com/dl/android/maven2/
13+
bintrayjcenter = https://jcenter.bintray.com/
14+
maven = https://jitpack.io
15+
16+
[download]
17+
in_build = true
18+
max_number_of_retries = 3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# @generated
2+
# BUILD FILE SYNTAX: SKYLARK
3+
# Generated by Okbuck, do not modify!
4+
load("//.okbuck/defs:okbuck_targets.bzl", "okbuck_android_library", "okbuck_manifest")
5+
6+
def get_rule_dep(rule_name):
7+
return ":{}".format(rule_name)
8+
9+
def get_exts_aar_deps(src_deps):
10+
return [dep for dep in src_deps if dep.endswith(".aar")]
11+
12+
def src_to_res(str):
13+
return str.replace(":src_", ":res_", 1)
14+
15+
def get_libs_res_deps(src_deps):
16+
mapped_res_deps = []
17+
for dep in src_deps:
18+
if (":src_" in dep and not dep.endswith(":src_main")):
19+
mapped_res_deps.append(src_to_res(dep))
20+
return mapped_res_deps
21+
22+
# Macro that represents a union of all common rules to for an android_library
23+
def okbuck_android_module(
24+
name,
25+
language = None,
26+
## common args
27+
visibility = None,
28+
package = None,
29+
## Manifest related args
30+
manifest_main_manifest = None,
31+
manifest_min_sdk = None,
32+
manifest_target_sdk = None,
33+
manifest_version_code = None,
34+
manifest_version_name = None,
35+
manifest_debuggable = False,
36+
manifest_secondary_manifests = None,
37+
## Resources related args
38+
res_res = None,
39+
res_project_res = None,
40+
res_assets = None,
41+
res_resource_union = None,
42+
res_extra_deps = [],
43+
## Android library related args
44+
deps = [],
45+
exported_deps = [],
46+
**kwargs):
47+
manifest_rule_name = name.replace("src", "manifest_lib", 1)
48+
okbuck_manifest(
49+
name = manifest_rule_name,
50+
main_manifest = manifest_main_manifest,
51+
min_sdk = manifest_min_sdk,
52+
target_sdk = manifest_target_sdk,
53+
package = package,
54+
version_code = manifest_version_code,
55+
version_name = manifest_version_name,
56+
debuggable = manifest_debuggable,
57+
secondary_manifests = manifest_secondary_manifests,
58+
)
59+
60+
res_ext_aar_deps = get_exts_aar_deps(deps)
61+
res_lib_deps = get_libs_res_deps(deps)
62+
res_deps = res_ext_aar_deps + res_lib_deps + res_extra_deps
63+
64+
res_exported_ext_aar_deps = get_exts_aar_deps(exported_deps)
65+
res_exported_lib_deps = get_libs_res_deps(exported_deps)
66+
res_exported_deps = res_exported_ext_aar_deps + res_exported_lib_deps
67+
68+
res_rule_name = name.replace("src", "res", 1)
69+
res_kwargs = dict(
70+
name = res_rule_name,
71+
deps = res_deps if res_deps else None,
72+
res = res_res,
73+
assets = res_assets,
74+
project_res = res_project_res,
75+
package = package,
76+
resource_union = res_resource_union,
77+
visibility = visibility,
78+
)
79+
if res_deps:
80+
res_kwargs.update({"deps": sorted(res_deps)})
81+
if res_exported_deps:
82+
res_kwargs.update({"exported_deps": sorted(res_exported_deps)})
83+
84+
native.android_resource(**res_kwargs)
85+
86+
src_kwargs = dict(
87+
name = name,
88+
visibility = visibility,
89+
manifest = get_rule_dep(manifest_rule_name),
90+
)
91+
src_kwargs.update(kwargs)
92+
93+
src_deps = deps + \
94+
res_lib_deps + \
95+
res_exported_lib_deps + \
96+
[get_rule_dep(res_rule_name), get_rule_dep(manifest_rule_name)]
97+
98+
src_kwargs.update({"deps": sorted(src_deps)})
99+
if exported_deps:
100+
src_kwargs.update({"exported_deps": sorted(exported_deps)})
101+
if language:
102+
src_kwargs.update({"language": language})
103+
104+
okbuck_android_library(**src_kwargs)
105+
106+
def okbuck_kotlin_android_module(
107+
language = "kotlin",
108+
**kwargs):
109+
okbuck_android_module(
110+
language = language,
111+
**kwargs
112+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# @generated
2+
# BUILD FILE SYNTAX: SKYLARK
3+
# Generated by Okbuck, do not modify!
4+
load("//.okbuck/defs:okbuck_targets.bzl", "okbuck_android_prebuilt_aar", "okbuck_prebuilt_jar")
5+
6+
def okbuck_prebuilt(
7+
name,
8+
maven_coords,
9+
sha256,
10+
sources_sha256 = None,
11+
deps = None,
12+
enable_jetifier = False,
13+
first_level = False):
14+
if deps == None:
15+
deps = []
16+
17+
visibility = ["PUBLIC"]
18+
19+
prebuilt_type = maven_coords.split(":")[2]
20+
21+
if sources_sha256 != None:
22+
sources_maven_coords = _get_sources_maven_coords(maven_coords)
23+
else:
24+
sources_maven_coords = None
25+
26+
name_without_type = name
27+
if prebuilt_type in name:
28+
name_without_type = name[:name.index("." + prebuilt_type)]
29+
30+
prebuilt_file_name = name + "__downloaded"
31+
native.http_file(
32+
name = prebuilt_file_name,
33+
urls = ["mvn:" + maven_coords],
34+
out = name,
35+
sha256 = sha256,
36+
)
37+
38+
prebuilt_sources_file_name = None
39+
if sources_maven_coords != None:
40+
prebuilt_sources_file_name = prebuilt_file_name + "_sources"
41+
native.http_file(
42+
name = prebuilt_sources_file_name,
43+
urls = ["mvn:" + sources_maven_coords],
44+
out = name_without_type + "-sources.jar",
45+
sha256 = sources_sha256,
46+
)
47+
48+
if prebuilt_type == "aar":
49+
okbuck_android_prebuilt_aar(
50+
name = name,
51+
aar = ":" + prebuilt_file_name,
52+
source_jar = ":" + prebuilt_sources_file_name if sources_maven_coords != None else None,
53+
maven_coords = maven_coords,
54+
deps = deps,
55+
visibility = visibility,
56+
enable_jetifier = enable_jetifier,
57+
)
58+
elif prebuilt_type == "jar":
59+
okbuck_prebuilt_jar(
60+
name = name,
61+
binary_jar = ":" + prebuilt_file_name,
62+
source_jar = ":" + prebuilt_sources_file_name if sources_maven_coords != None else None,
63+
maven_coords = maven_coords,
64+
deps = deps,
65+
visibility = visibility,
66+
enable_jetifier = enable_jetifier,
67+
)
68+
else:
69+
fail("okbuck_prebuilt not supported for type {}".format(prebuilt_type))
70+
71+
def _get_sources_maven_coords(maven_coords):
72+
parts = maven_coords.split(":")
73+
if len(parts) == 4:
74+
(group, name, _, version) = parts
75+
classifier = "sources"
76+
else:
77+
(group, name, _, classifier, version) = parts
78+
classifier = classifier + "-sources"
79+
80+
return ":".join([group, name, "jar", classifier, version])

0 commit comments

Comments
 (0)