How do you use Scons?

PB5PB5 Posts: 4Member

I've been playing around with Godot for the past few weeks and like it - but the .apk files it builds internally are far too large to use in the real world. From the forums and documentation I can see that you have to compile it yourself using scons - but I can't figure that out. Can someone please tell me step-by-step what to do?

What I've got so far:
* I've installed git and installed the source of Godot in the git folder.
* I've installed python.
* I've installed scons.

What I don't know and everything I've tried gives me an error message is:

  1. Where do I run it from? The command prompt? or Python? and what directory must I be in?
  2. How do I tell it what game to compile?
  3. What is the difference between the 4 export options for Android? What if I need just 1 file with 32bit and 64bit included? Which options must I choose? All of them?

Thanks.

Comments

  • TwistedTwiglegTwistedTwigleg Posts: 1,689Admin
    edited July 17

    I've only complied Godot for Windows and Linux, so compiling for Android might need some adjustments, but to answer your questions:


    Where do I run it from? The command prompt? or Python? and what directory must I be in?

    You compile through the command prompt using the following syntax: C:\path_to_godot_source> scons platform=platform_name_here. To build for Android, you will need to insert the following into the command prompt:

    C:\path_to_godot_source> scons platform=android android_arch=armv7
    # Or
    C:\path_to_godot_source> scons platform=android android_arch=arm64v8
    # Or
    C:\path_to_godot_source> scons platform=android android_arch=x86
    

    Which you will need depends on the architecture of your target Android device(s).

    Then you will need to build the output Godot creates using gradlew with the following (still in the command prompt):

    cd platform/android/java
    # On Windows
    .\gradlew build
    # On Linux and macOS
    ./gradlew build
    

    And then the built APK files will be located in the bin folder. (Most of this is taken from the Godot documentation for compiling for Android)

    As for which directory you need to be in, you need to be in the Godot source directory, so the directory containing README.md and SConstruct


    How do I tell it what game to compile?

    You don't, instead you tell the Godot editor to use your custom APK files. I have not done this myself, but the documentation has a section for using the exported Android APK files as export templates in the editor.

    Looking at the documentation, the easiest way is probably just to point the Custom Package property fields (Debug and Release) to your exported APK files.


    What is the difference between the 4 export options for Android? What if I need just 1 file with 32bit and 64bit included? Which options must I choose? All of them?

    I don't have a lot of experience with this one, so I'm not totally sure what the procedure is for Android. For Desktop, the easiest way to make a single export that works on multiple platforms is to compile the 32 bit version, since 64 bit computers should be able to load the exports without any difficulties.
    (A noticeable exception being Apple computers, which soon will only support 64 bit applications)


    Hopefully this helps!
    (Side note: Welcome to the forums)

  • CalinouCalinou Posts: 291Admin Godot Developer
    edited July 17

    I've been playing around with Godot for the past few weeks and like it - but the .apk files it builds internally are far too large to use in the real world.

    If you don't want to build it from source, you can export one APK per architecture using Google Play's multiple APK support. One reason Godot's exported APKs are so large by default is that they include both ARMv7 (armeabi-v7a) and ARMv8 (arm64-v8a) architectures in the same binary. If you uncheck one of those in the export preset, Godot will automatically strip unchecked architectures from the final APK, making it much smaller.

    Still, you can achieve further optimizations by compiling an export template from source, especially by disabling 3D support if you don't use it. See godot-size-benchmarks for a comparison of the APK file size depending on the enabled features.

  • PB5PB5 Posts: 4Member
    edited July 18

    Thank you for the replies. It's still not working out for me.

    I'm aware that Google as the multiple .apk files system - but I also release games at Amazon and Itch.io - and there I can only submit a single .apk.

    In the other software I use I have never encountered ARMv7 or Arm64 and what all that means - because the software handles it automatically - all I ever do is say - build .apk - so I will go look to see if I can find out more information on what packages I need to include to work on most cell phones / tablet.

    @TwistedTwigleg - as far as I understand the templates are to compile the .apk and people need to change them only when they include extras - like advertising or in-app purchase. It doesn't further have anything to do with the export process. I do have those 2 files in my template folder. I can build an .apk and tested it to work on my phone - so that part is okay.

    However, anything about scons I type on the command prompt line windows just says - no such internal or external command. (I battled to install scons and eventually that only worked by giving a full path name and full command to every element in the instruction.)

    Could you perhaps tell me how you export to Windows and I can see if I can figure out the Android from that?

    I know there's something about env = Environment(ENV = {'PATH' : path}) that I need to setup - I'm just not sure where or in what sequence to stop Windows telling me that there's no such command.

    (The last time I ran commands from the command line was back when we were all using DOS ... so this is very new / strange to me.)

  • KiwoTezKiwoTez Posts: 8Member

    I use scons with the visual studio command prompt. I don't know if it's related but give it a try if you have it installed.
    Also I have python 2.7 installed. Maybe your python version is incompatible?
    I guess scons is installed in Python27\Lib\site-packages. I have scons-related files both in there and Python27\Scripts. I also have Python27\Scripts in my path and scons command works both from cmd and visual studio command prompt. Make sure it's correctly installed

    @PB5 said:
    In the other software I use I have never encountered ARMv7 or Arm64 and what all that means

    I haven't either and wonder how other developers handle this. maybe they all just use armv7 or use some sort of compression?

  • PB5PB5 Posts: 4Member

    The scons installed itself into the Python directory - so I assume I have it installed correctly. The scons docs say any later version of Python is okay - and I took the most recent. The issues I had with installation was that I had to run everything as administrator and provide paths - it might have something to do with user permissions / Windows versions.

    So far what I've figured out on the Android exports is:

    ARMeabi v7 is the popular 32 bit version
    and ARM64 is the popular 64 bit version

    There were a number of devices that came out with X86 (32 bit) and X86 64 bit - but that there aren't many of them around according to Unity blog posts - who are withdrawing support for these devices.

    Google Play requires 64 bit as from today for any new apps or updates and will throw out apps that only support 32 in 2021 - so you'd have to provide 32 + 64 bit. (The 64 bit devices can read 32 bit apps - much like Windows can - I don't know what Google's issues are ...)

    The other software I use add 2.5mb - 7.5mb to my assets as an export for Android. Godot adds 28mb - 40mb. I've seen the results of a few scons tests where they managed to get their file sizes down to 6mb with scons. But I've also seen at itch.io that even very small Godot games released there are 40mb+ in size. So clearly a lot of users aren't getting the scons step right (or even know they should be doing it.)

  • CalinouCalinou Posts: 291Admin Godot Developer
    edited August 4

    (The 64 bit devices can read 32 bit apps - much like Windows can - I don't know what Google's issues are ...)

    64-bit binaries provide better performance, which is likely the reason Google now requires all applications to feature 64-bit binaries. (Applications that don't bundle native code won't have to do anything to comply with this requirement.)

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file