Closed Bug 1119365 Opened 9 years ago Closed 9 years ago

Implement |mach ide| for mobile/android and IntelliJ/Android Studio

Categories

(Firefox Build System :: Android Studio and Gradle Integration, defect)

All
Android
defect
Not set
normal

Tracking

(firefox39 fixed)

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: nalexander, Assigned: ahmedibrahimkhali, Mentored)

References

Details

(Whiteboard: [lang=python][good next bug])

Attachments

(2 files, 5 obsolete files)

In [1], there's an all-in-one |mach ide| command that prepares and launches an appropriate IDE.  This ticket tracks adding an "intellij" (and maybe "android studio") command to the list of supported IDEs.

Conceptually, this needs to:

1) |mach build|
2) |mach gradle-install|
3) open IntelliJ/Android Studio pointing at the $OBJDIR/mobile/android/gradle directory.

To achieve this, add a few choices to the "ide" argument at [1], add a new function implementing the logic above (crib heavily from what exists for Eclipse/Visual Studio, but please try to handle both Linux and Mac OS X when launching the IDE), and call your new function when the "ide" argument is one of the relevant ones.

[1] https://dxr.mozilla.org/mozilla-central/source/python/mozbuild/mozbuild/backend/mach_commands.py#30
Whiteboard: [lang=python][good second bug] → [lang=python][good next bug]
After I added few lines of code to handle the androidstudio case, The script fails in https://dxr.mozilla.org/mozilla-central/source/python/mozbuild/mozbuild/backend/mach_commands.py#59 with error http://pastebin.com/JX1N07Kj . So my question should I add a new backend ? `f yes, Where is the file that I should add the backend in ?
(In reply to Ahmed Khalil from comment #1)
> After I added few lines of code to handle the androidstudio case, The script
> fails in
> https://dxr.mozilla.org/mozilla-central/source/python/mozbuild/mozbuild/
> backend/mach_commands.py#59 with error http://pastebin.com/JX1N07Kj . So my
> question should I add a new backend ? `f yes, Where is the file that I
> should add the backend in ?

Hey, sorry for the delayed reply.  You should not need to add a new backend.  Can you post a patch with your changes, so that I can see how you're invoking |mach build| or |mach build-backend|?
Flags: needinfo?(nalexander)
Attached patch mach_ide.patch (obsolete) — Splinter Review
Here is the changed lines that you requested
Attachment #8564239 - Flags: feedback+
Attachment #8564239 - Flags: feedback+ → feedback?(nalexander)
/r/3951 - Bug 1119365 - "Implement |mach ide| for mobile/android and IntelliJ/Android Studio" [f=ahmedibrahimkhali]

Pull down this commit:

hg pull review -r 518ef16f8193880075c6b5ac374cc43f74a6d89a
Hey Ahmed!  I started playing with your commit and ended up building some of the extra functionality.  Can you take a look at the commit I posted above, see how it works for you, and give me some feedback?
Flags: needinfo?(ahmedibrahimkhali)
Comment on attachment 8564239 [details] [diff] [review]
mach_ide.patch

Review of attachment 8564239 [details] [diff] [review]:
-----------------------------------------------------------------

Hey!  This is a good start -- I posted an improved version for you to take a look at.
Attachment #8564239 - Flags: feedback?(nalexander) → feedback+
Attached patch mach_commands.patch (obsolete) — Splinter Review
I've augmented your patch and added "intellij" ide entry.
As we discussed on the IRC, when "intellij" is used Intellij entries are preferred over Android Studio with the opposite when using 'androidstudio' ide.
Please note that this behavior is only followed when on Mac unlike on Linux where the corresponding ide is used directly without any preferences.
Attachment #8564239 - Attachment is obsolete: true
Flags: needinfo?(ahmedibrahimkhali)
Attachment #8566825 - Flags: review?(nalexander)
Comment on attachment 8566825 [details] [diff] [review]
mach_commands.patch

Review of attachment 8566825 [details] [diff] [review]:
-----------------------------------------------------------------

This is looking really good!  Can you post a new single patch (against fx-team or mozilla-central) with my small comments, and then I'll test and land.  Thanks for your work!

I wonder if you would be interested in helping with another Python thing -- adding a mach command to install the MOZ_HOST_BIN utilities.  If you're interested, ping me in Bug 1126424.  Thanks again!

::: python/mozbuild/mozbuild/backend/mach_commands.py
@@ +106,5 @@
>          return os.path.join(self.topobjdir, 'msvc', 'mozilla.sln')
>  
>      def get_gradle_path(self):
>          return os.path.join(self.topobjdir, 'mobile', 'android', 'gradle', 'build.gradle')
> +    

nit: delete trailing whitespace through-out.

@@ +109,5 @@
>          return os.path.join(self.topobjdir, 'mobile', 'android', 'gradle', 'build.gradle')
> +    
> +    def get_mac_ide_preferences(self, ide):
> +        if sys.platform == 'darwin':
> +            android_studio_prefs = ['/Applications/Android Studio.app'];

Why don't we make these lists AS and IJ specific -- so just the one location for AS, and 4 locations for IJ.  (But not mixing the lists.)
Attachment #8566825 - Flags: review?(nalexander) → review+
Attached patch mach_commands.patch (obsolete) — Splinter Review
Here is a single patch rebased on the original version
Attachment #8566825 - Attachment is obsolete: true
Attachment #8567069 - Flags: review?(nalexander)
Attached patch mach_commands.patch (obsolete) — Splinter Review
Removed a trailing white space
Attachment #8567069 - Attachment is obsolete: true
Attachment #8567069 - Flags: review?(nalexander)
Attachment #8567070 - Flags: review?(nalexander)
Hi Nick, any updates on the review ?
Flags: needinfo?(nalexander)
(In reply to Ahmed Khalil from comment #11)
> Hi Nick, any updates on the review ?

Hey!  Sorry for the long delay -- I've been traveling, sick, and building Firefox for iOS.  Always feel free to ping me.

The code looks good, but my local testing showed some odd behaviour.  In the version I pushed to you, I opened $OBJDIR/mobile/android/gradle/build.gradle.  That does the right thing when the project hasn't been imported yet, but not when it has.  Can you investigate opening $OBJDIR/mobile/android/gradle/.idea/SOMETHING if it exists, and build.gradle otherwise?  What we want is to import if we haven't already.  (To test this, you can just delete .idea locally.)

Let me know what you discover.  It would be nice to get this working smoothly, but if not, what we have is a big improvement.
Flags: needinfo?(nalexander)
Comment on attachment 8567070 [details] [diff] [review]
mach_commands.patch

Review of attachment 8567070 [details] [diff] [review]:
-----------------------------------------------------------------

This code looks great!  I've asked for a functionality change (or at least investigation) -- let's see where that ends up.

Thanks, Ahmed!
Attachment #8567070 - Flags: review?(nalexander) → review+
Hi Nick,
I investigated what you said, and you are right. the ide commands tries to reimport project although it is already imported.

I think to fix this issue, I'll check if "$OBJDIR/mobile/android/gradle/.idea" already exists or not.

If yes then I'll issue the command with "$OBJDIR/mobile/android/gradle" directory and the IDE will open without the import dialog.

I'll post another patch in the next few minutes.
This patch fixes the reimporting issue.
Attachment #8567070 - Attachment is obsolete: true
Attachment #8570462 - Flags: review?(nalexander)
Comment on attachment 8570462 [details] [diff] [review]
mach_command_fix.patch

Review of attachment 8570462 [details] [diff] [review]:
-----------------------------------------------------------------

Very nice!  I'll land this with just a minor tweak (I want to include build_gradle in one of the function names).  Thanks for working on this!
Attachment #8570462 - Flags: review?(nalexander) → review+
Ahmed: your Python seems very strong.  I have two rather unusual Python projects, if you're interested -- one is re-working the GeckoView library packaging to upload an AAR file, for use from Gradle.  I wrote a job to do this, and a blog post about it at http://www.ncalexander.net/blog/2014/07/10/build-your-own-browser-a-maven-repository-for-geckoview/, and now it makes sense to do it as part of the build.  This would be a follow-up to Bug 1093242.  I don't think I have a ticket tracking this change yet.

The other is much more open-ended: it has to do with downloading the Gecko libraries without compiling them.  It's also a follow-up to Bug 1093242, and it's very loosely tracked by Bug 1124378 and some work in progress code in my tree.  This ticket might involve writing: a Mercurial extension; a web service; a Mozilla Pulse aggregator; a mach command; and some build system code.  It's pretty open-ended :)
Assignee: nobody → ahmedibrahimkhali
Status: NEW → ASSIGNED
Hi Nick,
The two projects that you've mentioned looks very appealing to me. I guess I'm going to start with first one, and I would be happy if you mentored me across it.

I've seen Bug 1093242 and seems that you've done the script that uploads the aar files, so what still needs to be done is to execute that script during the build and packaging phases, am I right ?

About the my last uploaded patch, do you just need to include build_gradle in get_gradle_path for example ,to be get_build_gradle_path ?
Flags: needinfo?(nalexander)
(In reply to Ahmed Khalil from comment #19)
> Hi Nick,
> The two projects that you've mentioned looks very appealing to me. I guess
> I'm going to start with first one, and I would be happy if you mentored me
> across it.

Great!  I will file a ticket to set some direction.  Ping me if I lag on this :)
 
> I've seen Bug 1093242 and seems that you've done the script that uploads the
> aar files, so what still needs to be done is to execute that script during
> the build and packaging phases, am I right ?
> 
> About the my last uploaded patch, do you just need to include build_gradle
> in get_gradle_path for example ,to be get_build_gradle_path ?

Yep, pretty much.  I did this and landed the patch with the slight modifications.
Flags: needinfo?(nalexander)
https://hg.mozilla.org/mozilla-central/rev/352ebcbf802e
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 39
This needs documentation in the mobile wiki.  NI to me for that.
Flags: needinfo?(nalexander)
Keywords: dev-doc-needed
(In reply to Nick Alexander :nalexander from comment #22)
> This needs documentation in the mobile wiki.  NI to me for that.

Finally added a section: https://wiki.mozilla.org/Mobile/Fennec/Android/IDEs#Really_quick_start

I ran into some problems with IntelliJ resolving symlinked paths, so we may need to update this |mach ide| command or the documentation.
Flags: needinfo?(nalexander)
Attachment #8565755 - Attachment is obsolete: true
Is the information in https://wiki.mozilla.org/Mobile/Fennec/Android/IDEs#Really_quick_start stuff that should be reflected into the MDN article here: https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/mach? If so, then it would be great if nalexander could help with that; otherwise, I'll look into it when I can.

Are there any bugs about fixing the problems mentioned in c#23? If so, I need to look at those, so I can provide information about when they were corrected (if they have been).
Flags: needinfo?(nalexander)
Sorry for the delayed reply.

(In reply to Eric Shepherd [:sheppy] from comment #26)
> Is the information in
> https://wiki.mozilla.org/Mobile/Fennec/Android/IDEs#Really_quick_start stuff
> that should be reflected into the MDN article here:
> https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/mach? If
> so, then it would be great if nalexander could help with that; otherwise,
> I'll look into it when I can.

Two things: Mobile team has debated moving documentation into MDN a lot.  Our Wiki based system is working for us, and unifying similar documentation is a time sync, so we're pretty happy not to do it.

As for the stuff in this ticket: it could be added to documentation, but |mach ide| hasn't had the testing and love of other methods, so we're happy to leave it out.

> Are there any bugs about fixing the problems mentioned in c#23? If so, I
> need to look at those, so I can provide information about when they were
> corrected (if they have been).

No, there are no bugs; no, I don't think it's relevant to anybody as yet.  It's very specific to IntelliJ: you need to manually refresh.  There are other things that will remove that, but they've nothing to do with |mach ide|.
Flags: needinfo?(nalexander)
I'm going to remove the dev-doc-needed flag: we're happy with this being off the beaten path.  I have some changes to the Android Gradle/IntelliJ integration that make |mach ide| more interesting.
Keywords: dev-doc-needed
If we get to a point where documenting this on MDN would be worthwhile, let us know!
Product: Firefox for Android → Firefox Build System
Target Milestone: Firefox 39 → mozilla39
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: