Native extensions + CI builds

Hello everyone!

I’ve just now added a first CI (continuous integration, a.k.a “autobuilder”) script to one of our extensions, extension-websocket. Having such a script makes it easier for us to verify that the extension builds properly for each platform after each commit we make to the repository. It also helps us make sure that the extension builds between Defold versions. The plan is to add such a script to all our supported extensions.

The script currently does these things:

  • Find the stable version of Defold
  • Download bob.jar
  • Resolve dependencies
  • Build the extension (i.e. the sample project)
  • Bundle the example project

This script is triggered on each push/pull request, but it’s also scheduled to build twice a month, to make sure the code doesn’t grow old between released Defold versions.

How to add the script to my native extension

The script is written to be very low maintenance, and could be used as-is.

Copy the bob.yml file into your repository, to .github/workflows/bob.yml, commit the file and push to your repository.

You can see the builds under the “Actions” tab in the github repo: example

Note, if you copy this script, it might be good if you change the cron job to some different time or date, as to not crowd the build server all at once :slight_smile:

How to write a Github CI script

You write a script (in Yaml) for Github Actions, which might look like this.

I hope this can give you a hint on how to start testing your own extensions and/or your games hosted on Github.

If you’re not using Github there are usually similar functionalities there.

13 Likes

Awesome!

This seems like a great place to plug my setup-defold Github Action which automatically downloads bob.jar and dmengine_headless in CI scripts :grinning:

5 Likes

I’m adding it for all my libraries now. Thank you!

4 Likes

For the next repo, I’d also try out the github action that @dapetcu21 wrote.
Hopefully it will remove some more boiler plate.

4 Likes

Thanks for sharing this script.

When I try to use it, I get the following error

armv7a-linux-androideabi16-clang++ -c -O2 -g -gdwarf-2 -fpic -ffunction-sections -fstack-protector -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fomit-frame-pointer -fno-strict-aliasing -funwind-tables -isysroot=/opt/platformsdk/android/android-ndk-r20/toolchains/llvm/prebuilt/linux-x86_64/sysroot -DANDROID -Wa,--noexecstack -DDLIB_LOG_DOMAIN="FIREBASEREMOTECONFIG" -DDM_PLATFORM_ANDROID -DDDF_EXPOSE_DESCRIPTORS -DLUA_BYTECODE_ENABLE_32 -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -DDM_RELEASE  -fno-exceptions -fvisibility=hidden -std=c++11  -Iupload/defold/firebase_remoteconfig/include -Ibuild/firebase_remoteconfig/ -Iupload/ -Iupload/defold/ironsource/include  -I/var/extender/sdk/1f5712609c345f870b691a85d611d4825d22a718/defoldsdk//include -I/var/extender/sdk/1f5712609c345f870b691a85d611d4825d22a718/defoldsdk//sdk/include -I/var/extender/sdk/1f5712609c345f870b691a85d611d4825d22a718/defoldsdk//ext/include  -I/opt/platformsdk/android/android-ndk-r20/sources/android/native_app_glue -I/opt/platformsdk/android/android-ndk-r20/sources/android/cpufeatures  upload/defold/firebase_remoteconfig/src/firebase_remoteconfig.cpp -obuild/firebase_remoteconfig.cpp_2.o
upload/defold/firebase_remoteconfig/src/firebase_remoteconfig.cpp:2:9: warning: 'DLIB_LOG_DOMAIN' macro redefined [-Wmacro-redefined]
#define DLIB_LOG_DOMAIN LIB_NAME
        ^
<command line>:2:9: note: previous definition is here
#define DLIB_LOG_DOMAIN "FIREBASEREMOTECONFIG"
        ^
upload/defold/firebase_remoteconfig/src/firebase_remoteconfig.cpp:8:10: fatal error: 'luautils.h' file not found
#include "luautils.h"
         ^~~~~~~~~~~~
1 warning and 1 error generated.

On my local machine, I can compile fine.
The problem seems to be coming from the firebase extension, how come the build behaviour is different on the CI server than on my machine?

There is no “luautils.h” in that extension.

Have you added the dependencies as specified in the manual?