Skip to content

Commit

Permalink
GN: Some small changes to support chrome android internal stuff
Browse files Browse the repository at this point in the history
This actually hooks up (i.e. passes from invoker) several variables
controlling apk creation (version name, version code,
use_relocation_packer, use_chromium_linker, unzip_libraries_from_apk).

Adds support for overriding some configuration in the private repo.

Adds support for public_configs in grit_rule.gni.

Adds some junit targets (these are built as android libraries currently
instead of host libraries, but that just means we do a bit extra work
that we don't really need).

BUG=359249

Review URL: https://codereview.chromium.org/659703002

Cr-Commit-Position: refs/heads/master@{#301039}
  • Loading branch information
cjhopman authored and Commit bot committed Oct 24, 2014
1 parent 7ec86e8 commit ca675d3
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 88 deletions.
9 changes: 9 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
# file to your new one or GN won't know about it.

import("//build/config/ui.gni")
if (is_android) {
import("//build/config/android/config.gni")
}

declare_args() {
# A list of extra dependencies to add to the root target. This allows a
Expand Down Expand Up @@ -188,6 +191,12 @@ group("root") {
"//third_party/eyesfree:eyesfree_java",
]

if (has_chrome_android_internal) {
deps += [
"//clank",
]
}

deps -= [
"//apps", # Needs testing.
"//chrome/browser",
Expand Down
20 changes: 16 additions & 4 deletions build/config/android/config.gni
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,25 @@
# This file contains common system config stuff for the Android build.

if (is_android) {
has_chrome_android_internal = exec_script("//build/dir_exists.py",
[ rebase_path("//clank", root_build_dir) ],
"string") == "True"

if (has_chrome_android_internal) {
import("//clank/config.gni")
} else {
default_android_sdk_root = "//third_party/android_tools/sdk"
default_android_sdk_version = "21"
default_android_sdk_build_tools_version = "21.0.0"
}

declare_args() {
# Absolute directory containing the Android source code.
android_src = ""

android_sdk_root = "//third_party/android_tools/sdk"
android_sdk_version = "21"
android_sdk_root = default_android_sdk_root
android_sdk_version = default_android_sdk_version
android_sdk_build_tools_version = default_android_sdk_build_tools_version

# This is set when building the Android WebView inside the Android build
# system, using the 'android' gyp backend. The WebView code is still built
Expand All @@ -32,7 +45,6 @@ if (is_android) {
"You must specify android_src for an Android WebView build.")
}


# Host stuff -----------------------------------------------------------------

# Defines the name the Android build gives to the current host CPU
Expand Down Expand Up @@ -68,7 +80,7 @@ if (is_android) {
android_sdk = "${android_sdk_root}/platforms/android-${android_sdk_version}"

android_sdk_tools = "${android_sdk_root}/tools"
android_sdk_build_tools = "${android_sdk_root}/build-tools/21.0.0"
android_sdk_build_tools = "${android_sdk_root}/build-tools/$android_sdk_build_tools_version"

# Path to the SDK's android.jar
android_sdk_jar = "$android_sdk/android.jar"
Expand Down
6 changes: 3 additions & 3 deletions build/config/android/internal_rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ template("create_apk") {
_asset_location = invoker.asset_location
}

_version_code = "1"
_version_name = "Developer Build"
_version_code = invoker.version_code
_version_name = invoker.version_name

_base_apk_path = _base_path + ".apk_intermediates"

Expand Down Expand Up @@ -557,7 +557,7 @@ template("android_java_library") {
if (defined(invoker.testonly)) { testonly = invoker.testonly }

assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
|| defined(invoker.srcjars))
|| defined(invoker.srcjars) || defined(invoker.srcjar_deps))
assert(defined(invoker.build_config))
assert(defined(invoker.jar_path))
assert(defined(invoker.dex_path))
Expand Down
20 changes: 19 additions & 1 deletion build/config/android/rules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ template("jinja_template_resources") {
_build_config = _base_path + ".build_config"

write_build_config("${target_name}__build_config") {
build_config = _build_config
resources_zip = _resources_zip
type = "android_resources"
}

Expand Down Expand Up @@ -679,7 +681,7 @@ template("android_library") {
if (defined(invoker.testonly)) { testonly = invoker.testonly }

assert(defined(invoker.java_files) || defined(invoker.DEPRECATED_java_in_dir)
|| defined(invoker.srcjars))
|| defined(invoker.srcjars) || defined(invoker.srcjar_deps))
_base_path = "$target_gen_dir/$target_name"
_build_config = _base_path + ".build_config"
_jar_path = _base_path + ".jar"
Expand Down Expand Up @@ -989,6 +991,12 @@ template("android_apk") {
"$root_build_dir/lib.stripped/libchromium_android_linker.so"
]
}

_enable_relocation_packing = false
if (_use_chromium_linker && defined(invoker.enable_relocation_packing) &&
invoker.enable_relocation_packing) {
_enable_relocation_packing = true
}
}

_rebased_build_config = rebase_path(build_config, root_build_dir)
Expand Down Expand Up @@ -1157,6 +1165,16 @@ template("android_apk") {
dex_path = final_dex_path
load_library_from_apk = _load_library_from_apk

version_code = "1"
if (defined(invoker.version_code)) {
version_code = invoker.version_code
}

version_name = "Developer Build"
if (defined(invoker.version_name)) {
version_name = invoker.version_name
}

if (defined(invoker.asset_location)) {
asset_location = invoker.asset_location
}
Expand Down
4 changes: 4 additions & 0 deletions build/secondary/tools/grit/grit_rule.gni
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ template("grit") {
deps = [ ":$grit_custom_target" ]
public_configs = [ ":$grit_config" ]

if (defined(invoker.public_configs)) {
public_configs += invoker.public_configs
}

if (defined(invoker.visibility)) {
visibility = invoker.visibility
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/chrome_android_paks.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@
['icu_use_data_file_flag==1', {
'chrome_android_pak_input_resources': [
'<(PRODUCT_DIR)/icudtl.dat',
],
],
'chrome_android_pak_output_resources': [
'<(chrome_android_pak_output_folder)/icudtl.dat',
],
],
}],
],
},
Expand Down
7 changes: 7 additions & 0 deletions chrome/test/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,13 @@ source_set("test_support") {
]
}

if (enable_extensions) {
deps += [
"//chrome/common/extensions/api",
"//extensions:test_support",
]
}

if (is_linux) {
deps += [ "//crypto:platform" ]
}
Expand Down
27 changes: 27 additions & 0 deletions testing/android/junit/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

assert(is_android)

import("//build/config/android/rules.gni")

# TODO(GYP): should be java_library
# GYP: //testing/android/junit_test.gyp:junit_test_support
android_library("junit_test_support") {
DEPRECATED_java_in_dir = "java/src"
deps = [
"//third_party/junit"
]
}

# TODO(GYP): should be java_library
# GYP: //testing/android/junit_test.gyp:junit_unit_tests
android_library("junit_unittests") {
deps = [
":junit_test_support",
"//third_party/junit",
]
#main_class = "org.chromium.testing.local.JuniTestMain"
DEPRECATED_java_in_dir = "javatests/src"
}
2 changes: 2 additions & 0 deletions testing/android/junit/junit_test.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
'targets': [
{
# GN: //testing/android/junit:junit_test_support
'target_name': 'junit_test_support',
'type': 'none',
'dependencies': [
Expand All @@ -20,6 +21,7 @@
],
},
{
# GN: //testing/android/junit:junit_unittests
'target_name': 'junit_unit_tests',
'type': 'none',
'dependencies': [
Expand Down
20 changes: 20 additions & 0 deletions third_party/junit/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/android/rules.gni")

# TODO(GYP): should be java_prebuilt
# GYP: //third_party/junit.gyp:hamcrest_jar
android_java_prebuilt("hamcrest") {
jar_path = "src/lib/hamcrest-core-1.3.jar"
}

# TODO(GYP): should be java_library
# GYP: //third_party/junit.gyp:junit_jar
android_library("junit") {
deps = [
":hamcrest"
]
DEPRECATED_java_in_dir = "src/src/main/java"
}
2 changes: 2 additions & 0 deletions third_party/junit/junit.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
'targets': [
{
# GN: //third_party/junit:hamcrest
'target_name': 'hamcrest_jar',
'type': 'none',
'variables': {
Expand All @@ -15,6 +16,7 @@
]
},
{
# GN: //third_party/junit:junit
'target_name': 'junit_jar',
'type': 'none',
'dependencies': [
Expand Down
Loading

0 comments on commit ca675d3

Please sign in to comment.