Prebuild script (Eclipse)

Is something like this possible? It should work for running a watchface as well as for exporting it.

I know I can manually build the watchface, but I'd like to stay with the current IDE...

Background

I want to automate things across all my watchfaces, e.g. I want to remove a setting (e.g. the 6th data field) in all devices with a screen resolution <= 218 and also generate a setting .mc file where I do generate variables that I can use in code to check what the current settings are. I also want to use this to define the desired font and if it is a system font or must be loaded and more... I just need to integrate a custom batch/powershell/whatever script that I can execute before each build like it is possible in Visual Studio e.g.

Or another use case is to add settings for normal devices like "battery saver mode" = [off, always, during sleep, during sleep time] vs for amoled displayes where you want a setting like "always on" = [on, off]

  • To be honest, my first reaction is your build is far too complex and you need to make it simpler with things like barrels and jungles.  Barrels for common code and jungles for device specific stuff.

    Supporting anything built like this seems like it would be a nightmare.

  • I don't use barrels for common code, because they add overhead, instead of them I use relative includes inside the monkey.junge like ../shared/source-fenix6x

    I do use jungles for device specific code as well.

    But I see following problems:

    Problem 1

    How to define big settings that reuse the same list? E.g. I have 15 data fields in my watchface and all of them can display ~30 types of data. Whenever I add a new data type, I have to add it to all 15 data fields. And because I use shared code between my watchfaces (e.g. I have a common code base to calculate values, labels, units and even graph data) I must make this change in all my watchfaces. Normally you define a resource and reuse this resource, but that's not possible with monkey c.

    Problem 2

    In one of my projects 80% of the devices do support 6 data fields in a vertical stripe, the rest only 5. Again I must copy the whole settings file and remove the 6th data field from the copy. In every future change I must adjust 2 files in the same way. I now would like to support even smaller devices in which I would only display 4 data fields - again I must copy the settings file and maintaining copies of files with a single change is cumbersome...

    Problems like this can be solved very easily with a script and some common definitions - I've tried it already and it was not very much work and makes settings management a lot simplier. Those are just the first 2 small use cases where I will use a script to generate files.

    I don't see any possibility to solve above 2 problems with barrels or jungles...

  • I'm not a huge fan of Eclipse (and I'd prefer to never have to use it again), but what you want is possible, using an external tool builder.

    Select your project and look under: Properties > Builders

    Create a new builder and specify the script you want to run whenever the relevant "resources" are changed:

    Builder > Build Options: Specify a working set of relevant resources

    If you're looking for C-style conditional compilation by any chance, that's also possible. I personally do it for one project to save memory while eliminating duplicated code (which happens when you rely solely on annotations, if you're also trying to save as much memory as possible).

    forums.garmin.com/.../solution-for-line-by-line-mc-conditional-compilation

  • Thanks for the idea - I checked the link and actually c style like ifdefs would be exactly what I need as well. But in the end I found in my tests that mostly I need a simply replace script to do use something simple for this now that simply converts file.mc.base to file.mc files and replaces placeholders in the file.