From 442e6ee76a845a7fe3a16a7189bdc8da031f1208 Mon Sep 17 00:00:00 2001 From: kjellander Date: Mon, 20 Jun 2016 01:34:06 -0700 Subject: [PATCH] Workaround java.gypi inclusion error in Chromium builds. In order to switch Chromium to use WebRTC targets instead of duplicated code listings in src/third_party/libjingle it must be possible for Chromium to process webrtc/api/api.gyp. This is currently not possible since it includes build/java.gypi, of which the path is different in a Chromium checkout. It's not possible to resolve this in another way since 'includes' processing takes place early in the GYP cycle, before it's possible to use variables. They're also processed ignoring conditional statements, resulting in an error when api.gyp is processed. BUG=webrtc:4256 TBR=perkj@webrtc.org NOTRY=True Review-Url: https://codereview.webrtc.org/2080563002 Cr-Commit-Position: refs/heads/master@{#13208} --- all.gyp | 5 ++++ webrtc/api/api.gyp | 29 ------------------- webrtc/api/api_java.gyp | 52 ++++++++++++++++++++++++++++++++++ webrtc/api/api_tests.gyp | 2 +- webrtc/build/android_tests.gyp | 4 +-- webrtc/webrtc_examples.gyp | 2 +- 6 files changed, 61 insertions(+), 33 deletions(-) create mode 100644 webrtc/api/api_java.gyp diff --git a/all.gyp b/all.gyp index abf6e6860d..238229063e 100644 --- a/all.gyp +++ b/all.gyp @@ -36,6 +36,11 @@ '<(webrtc_vp9_dir)/vp9.gyp:*', ], 'conditions': [ + ['OS=="android" and build_with_chromium==0', { + 'dependencies': [ + 'webrtc/api/api_java.gyp:*', + ], + }], ['include_tests==1', { 'includes': [ 'webrtc/webrtc_tests.gypi', diff --git a/webrtc/api/api.gyp b/webrtc/api/api.gyp index f63e7e4b11..8525eb09c7 100644 --- a/webrtc/api/api.gyp +++ b/webrtc/api/api.gyp @@ -89,35 +89,6 @@ 'use_native_jni_exports': 1, }, }, - { - # |libjingle_peerconnection_java| builds a jar file with name - # libjingle_peerconnection_java.jar using Chrome's build system. - # It includes all Java files needed to setup a PeeerConnection call - # from Android. - 'target_name': 'libjingle_peerconnection_java', - 'type': 'none', - 'dependencies': [ - 'libjingle_peerconnection_so', - ], - 'variables': { - # Designate as Chromium code and point to our lint settings to - # enable linting of the WebRTC code (this is the only way to make - # lint_action invoke the Android linter). - 'android_manifest_path': '<(webrtc_root)/build/android/AndroidManifest.xml', - 'suppressions_file': '<(webrtc_root)/build/android/suppressions.xml', - 'chromium_code': 1, - 'java_in_dir': 'java', - 'webrtc_base_dir': '<(webrtc_root)/base', - 'webrtc_modules_dir': '<(webrtc_root)/modules', - 'additional_src_dirs' : [ - 'java/android', - '<(webrtc_base_dir)/java/src', - '<(webrtc_modules_dir)/audio_device/android/java/src', - - ], - }, - 'includes': ['../../build/java.gypi'], - }, # libjingle_peerconnection_java ] }], ], # conditions diff --git a/webrtc/api/api_java.gyp b/webrtc/api/api_java.gyp new file mode 100644 index 0000000000..e69f0e2789 --- /dev/null +++ b/webrtc/api/api_java.gyp @@ -0,0 +1,52 @@ +# Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. +# +# Use of this source code is governed by a BSD-style license +# that can be found in the LICENSE file in the root of the source +# tree. An additional intellectual property rights grant can be found +# in the file PATENTS. All contributing project authors may +# be found in the AUTHORS file in the root of the source tree. + +# This file exists only because there's no other way to avoid errors in the +# Chromium build due to the inclusion of build/java.gypi. GYP unfortunately +# processes all 'includes' for all .gyp files, ignoring conditions. This +# processing takes place early in the cycle, before it's possible to use +# variables. It will go away when WebRTC has fully migrated to GN. + +{ + 'includes': [ '../build/common.gypi', ], + 'conditions': [ + ['OS=="android"', { + 'targets': [ + { + # |libjingle_peerconnection_java| builds a jar file with name + # libjingle_peerconnection_java.jar using Chrome's build system. + # It includes all Java files needed to setup a PeeerConnection call + # from Android. + 'target_name': 'libjingle_peerconnection_java', + 'type': 'none', + 'dependencies': [ + '<(webrtc_root)/api/api.gyp:libjingle_peerconnection_so', + ], + 'variables': { + # Designate as Chromium code and point to our lint settings to + # enable linting of the WebRTC code (this is the only way to make + # lint_action invoke the Android linter). + 'android_manifest_path': '<(webrtc_root)/build/android/AndroidManifest.xml', + 'suppressions_file': '<(webrtc_root)/build/android/suppressions.xml', + 'chromium_code': 1, + 'java_in_dir': 'java', + 'webrtc_base_dir': '<(webrtc_root)/base', + 'webrtc_modules_dir': '<(webrtc_root)/modules', + 'additional_src_dirs' : [ + 'java/android', + '<(webrtc_base_dir)/java/src', + '<(webrtc_modules_dir)/audio_device/android/java/src', + + ], + }, + 'includes': ['../../build/java.gypi'], + }, + ], # targets + }], # OS=="android" + ], # conditions +} diff --git a/webrtc/api/api_tests.gyp b/webrtc/api/api_tests.gyp index 303c1ef72a..5ff062a1b4 100644 --- a/webrtc/api/api_tests.gyp +++ b/webrtc/api/api_tests.gyp @@ -129,7 +129,7 @@ 'target_name': 'libjingle_peerconnection_android_unittest', 'type': 'none', 'dependencies': [ - '<(webrtc_root)/api/api.gyp:libjingle_peerconnection_java', + '<(webrtc_root)/api/api_java.gyp:libjingle_peerconnection_java', ], 'variables': { 'apk_name': 'libjingle_peerconnection_android_unittest', diff --git a/webrtc/build/android_tests.gyp b/webrtc/build/android_tests.gyp index fdf72737a1..7803b9a419 100644 --- a/webrtc/build/android_tests.gyp +++ b/webrtc/build/android_tests.gyp @@ -126,7 +126,7 @@ }, 'dependencies': [ '<(webrtc_root)/api/api_tests.gyp:peerconnection_unittests', - '<(webrtc_root)/api/api.gyp:libjingle_peerconnection_java', + '<(webrtc_root)/api/api_java.gyp:libjingle_peerconnection_java', ], 'includes': [ '../../build/apk_test.gypi', @@ -264,7 +264,7 @@ 'target_name': 'android_junit_tests', 'type': 'none', 'dependencies': [ - '<(webrtc_root)/api/api.gyp:libjingle_peerconnection_java', + '<(webrtc_root)/api/api_java.gyp:libjingle_peerconnection_java', '<(DEPTH)/base/base.gyp:base_java', '<(DEPTH)/base/base.gyp:base_java_test_support', '<(DEPTH)/base/base.gyp:base_junit_test_support', diff --git a/webrtc/webrtc_examples.gyp b/webrtc/webrtc_examples.gyp index 1b3c76c83e..0978404435 100755 --- a/webrtc/webrtc_examples.gyp +++ b/webrtc/webrtc_examples.gyp @@ -409,7 +409,7 @@ 'target_name': 'AppRTCDemo', 'type': 'none', 'dependencies': [ - 'api/api.gyp:libjingle_peerconnection_java', + 'api/api_java.gyp:libjingle_peerconnection_java', ], 'variables': { 'apk_name': 'AppRTCDemo',