New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 827294 link

Starred by 3 users

Issue metadata

Status: ExternalDependency
Owner:
OOO until Feb 4th
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocked on:
issue 799954
issue 840542

Blocking:
issue 620034



Sign in to add a comment

Android Studio: Enable basic C/C++ editing

Project Member Reported by wnwen@chromium.org, Mar 29 2018

Issue description

Goal: Match Eclipse's C++ editing using custom CMakeList.txt.

Android Studio allows adding native code to our project by means of a custom CMakeList.txt file: https://developer.android.com/studio/projects/configure-cmake.html#create_script

We will generate this similar to Eclipse's out/Debug/eclipse-cdt-settings.xml and using the same mechanism that we currently use to generate gradle files.

The explicit non-goal is to allow building the apk (with or without native) or using the resulting library in Android Studio. Simply to enable editing.
 

Comment 1 by wnwen@chromium.org, Apr 12 2018

Blockedon: 799954

Comment 2 by wnwen@chromium.org, Apr 25 2018

First approach is adding --native-target to generate_gradle.py for each native target with sources or transitive sources you want to edit.

Comment 3 by wnwen@chromium.org, May 7 2018

Blockedon: 840542
Project Member

Comment 4 by bugdroid1@chromium.org, May 10 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f3c401c7f25b5dfeb934212ab0934c638855a7ac

commit f3c401c7f25b5dfeb934212ab0934c638855a7ac
Author: Peter Wen <wnwen@chromium.org>
Date: Thu May 10 16:16:05 2018

Android: Basic support for C++ in Android Studio

Add a new flag for generate_gradle.py, --native-target <gn target name>.
This allows C++ editing when --all is either passed or implicit (by
default). Starting with --native-target //chrome/android:monochrome in
Android Studio Canary (3.2) will result in most of the C++ files being
indexed and available both via the Android project view as well as the
double shift "search everywhere" box.

Switched maven URL to use "google()" instead, this works for all Android
Studio 3.0+, which covers all of stable/beta/canary.

Add specific AndroidManifest.xml to be used for the _all pseudo gradle
module since Android Studio now requires minSdk to not be specified in
the AndroidManifest.xml file.

Bug: 841529,827294, 840368 
Change-Id: Ifdee12bf7f9e7faf81cabf92dbf4c5613eb89996
Reviewed-on: https://chromium-review.googlesource.com/1053117
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557543}
[add] https://crrev.com/f3c401c7f25b5dfeb934212ab0934c638855a7ac/build/android/gradle/AndroidManifest.xml
[modify] https://crrev.com/f3c401c7f25b5dfeb934212ab0934c638855a7ac/build/android/gradle/android.jinja
[add] https://crrev.com/f3c401c7f25b5dfeb934212ab0934c638855a7ac/build/android/gradle/cmake.jinja
[modify] https://crrev.com/f3c401c7f25b5dfeb934212ab0934c638855a7ac/build/android/gradle/generate_gradle.py
[modify] https://crrev.com/f3c401c7f25b5dfeb934212ab0934c638855a7ac/build/android/gradle/root.jinja

Project Member

Comment 5 by bugdroid1@chromium.org, May 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/667abd57b9b7979cb921c7cae7db6f0636366ad8

commit 667abd57b9b7979cb921c7cae7db6f0636366ad8
Author: Peter Wen <wnwen@chromium.org>
Date: Thu May 17 00:12:25 2018

Android: Fix Android Studio native targets

CMake does not like .cc files mixed with .h files in add_library targets
so we filter only for .cc files.

Bug: 827294
Change-Id: I793d39b90d5f38d9c66704b19c39d0cc48ebdf43
Reviewed-on: https://chromium-review.googlesource.com/1062076
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: Eric Stevenson <estevenson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559355}
[modify] https://crrev.com/667abd57b9b7979cb921c7cae7db6f0636366ad8/build/android/gradle/generate_gradle.py
[modify] https://crrev.com/667abd57b9b7979cb921c7cae7db6f0636366ad8/docs/android_studio.md

Project Member

Comment 6 by bugdroid1@chromium.org, May 17 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8393de89df09cc7883fba09891b4e6969023efa9

commit 8393de89df09cc7883fba09891b4e6969023efa9
Author: Peter Wen <wnwen@chromium.org>
Date: Thu May 17 20:58:54 2018

Android: Update script and docs for Android Studio

Add conditional check to run `gn gen` if build.ninja does not exist.
This can happen if the out directory is deleted. This way devs won't
have to run `gn gen` manually when `generate_gradle.py` fails.

Update docs for native code editing to start with a lighter target than
`//chrome/browser:browser` and add instructions to manually make
temporary edits to CMakeLists.txt.

Reorder jinja templates to make it easier to see shorter sections.

Bug: 827294,620034
Change-Id: I25be0a67b5f19dc4d1b15e675f0bf1a5beac761c
Reviewed-on: https://chromium-review.googlesource.com/1064696
Commit-Queue: Peter Wen <wnwen@chromium.org>
Reviewed-by: agrieve <agrieve@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559671}
[modify] https://crrev.com/8393de89df09cc7883fba09891b4e6969023efa9/build/android/gradle/android.jinja
[modify] https://crrev.com/8393de89df09cc7883fba09891b4e6969023efa9/build/android/gradle/cmake.jinja
[modify] https://crrev.com/8393de89df09cc7883fba09891b4e6969023efa9/build/android/gradle/generate_gradle.py
[modify] https://crrev.com/8393de89df09cc7883fba09891b4e6969023efa9/docs/android_studio.md

Labels: DevX
Status: ExternalDependency (was: Assigned)
Unfortunately this requires performance overhauls to Android Studio's native code handling that is beyond the scope of this effort. i.e. Editing thousands of chrome c++ files is way too slow right now.

May revisit this at some point given improvements to Android Studio or more options for build systems.

Sign in to add a comment