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

Issue 694699 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner:
OOO until Feb 4th
Closed: Sep 2017
Cc:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug

Blocking:
issue 620034



Sign in to add a comment

Add native code editing support to Android Studio project generation

Project Member Reported by agrieve@chromium.org, Feb 21 2017

Issue description

From what I can tell, the only reasonable way to do this is to generate cmake project files.

Luckily, it looks like skia team did this already:

bin/gn gen out/config --ide=json --json-ide-script=third_party/skia/gn/gn_to_cmake.py

The work involved here might largely be around upstreaming this script (likely to //tools/gn) and calling it from generate_gradle.py.
 
In case it's helpful, Android team is also generating cmake projects:
https://android.googlesource.com/platform/build/soong/+/master/docs/clion.md
Note that the gn_to_cmake.py in Skia is more or less the cmake.py I wrote for gyp which has been modified to work with gn. It could use some refactoring at the least and doesn't handle everything (though it does handle everything Skia needs, and then some). There are people on Skia using it, but I'm not actively working on it at the moment because I generally use KDevelop and wrote a project manager plugin which understands gn project.json files directly (which is much, much faster).

On the other hand, the existing gn_to_cmake.py is probably a great place to start if you need such a thing since it already works around a lot of impedance mismatches between gn and cmake. 
As a note, if all you're looking for is code editing support, gn_to_cmake.py is probably fine. It should handle all the compiler flags, defines, and includes correctly.

Comment 4 by wnwen@chromium.org, Mar 1 2017

Cc: -wnwen@chromium.org
Owner: wnwen@chromium.org
Status: Assigned (was: Available)
The script works perfectly (after adding in caching for GetObjectSourceDependencies, it was taking forever).

"gn gen out/config --ide=json --json-ide-script=../../third_party/skia/gn/gn_to_cmake.py" didn't work for me, it never ran the script, I suspect I'm not passing in the right args, I just get right to "Done" with no CMakeList.txt generated.

However, since project.json included all gn targets under the sun, Android Studio did not like that and crashed. After some imperfect target filtering, more crashes. I will see about importing your script and manually filtering target/source_set/shared_library etc in generate_gradle.py.
> "gn gen out/config --ide=json --json-ide-script=../../third_party/skia/gn/gn_to_cmake.py"
> didn't work for me, it never ran the script, I suspect I'm not passing in the right args,
> I just get right to "Done" with no CMakeList.txt generated.

Note that the CMakeList.txt will be generated into the out/config directory, next to the project.json file. Seems like that command should work though.

Comment 6 by wnwen@chromium.org, Mar 7 2017

Hmm... interestingly the full command works now on all my out directories.
Project Member

Comment 7 by bugdroid1@chromium.org, Mar 8 2017

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

commit a45e8b336d2b214cfd5db0b3e3b5b85b688ce8db
Author: wnwen <wnwen@chromium.org>
Date: Wed Mar 08 20:08:42 2017

Android: Upstream gn_to_cmake.py

The script was originally //third_party/skia/gn/gn_to_cmake.py

Planning to use it to enable editing native files in android studio.

Currently script does not allow full build, intended for editing only.

BUG= 694699 

Review-Url: https://codereview.chromium.org/2733353003
Cr-Commit-Position: refs/heads/master@{#455521}

[add] https://crrev.com/a45e8b336d2b214cfd5db0b3e3b5b85b688ce8db/build/android/gradle/gn_to_cmake.py

Project Member

Comment 8 by bugdroid1@chromium.org, May 9 2017

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

commit 23bc56150efb4ae54f6662e8552ac693fb41d485
Author: avayvod <avayvod@chromium.org>
Date: Tue May 09 13:02:47 2017

[Android, Tools] Speed up gn_to_cmake.py with caching

BUG= 694699 
TEST=local run

Review-Url: https://codereview.chromium.org/2866863003
Cr-Commit-Position: refs/heads/master@{#470299}

[modify] https://crrev.com/23bc56150efb4ae54f6662e8552ac693fb41d485/build/android/gradle/gn_to_cmake.py

Comment 9 by wnwen@chromium.org, Sep 6 2017

Status: WontFix (was: Assigned)
Not going to happen with cmake. Simply too overbearing for Chrome due to the sheer size of the project.

We are hoping that android team's work on separating gradle from the android plugin will allow us to plug in gn as an alternative for android studio's native build system.

Sign in to add a comment