SDK Compiler Exclusions

Could someone better explain how the compiler exclusions actually work, and how to implement it? ( Build File Exclusions )
For example, I've got 2 folders called "resources-rectangle-205x148" and "resources-semiround-215x180".
Both of those directories have sub-directories under them with family specific background images and layout files.
If I put code like this in their respective resources.xml file, would the build ignore the other folder completely?
<build>
<exclude file="*.bak"/>
<exclude dir="../resources-rectangle-205x148" />
</build>

Could this be used to ignore fonts that are not being used for that model, from the main /resources/fonts folder? Or are those ignored if they aren't defined in the family specific layouts.xml ?

Additionally, I don't fully understand what's going on with the build/export process.
When we run the App Export Wizard (or the Build for Device Wizard), and it builds the file to upload to GC store (or side-load), does it contain all of the raw code for everything (like a .zip), that the Garmin side uses to build the app on the fly when someone downloads it?
or is it just a collection of builds for every "supported" device in the manifest?
What's going on in the package and on the backend of things we cannot see?
How does the store know which subset of the code/resources is what we want to show up/work on specific devices?

The more I pick up the pieces, the more questions I have, and the more vague the programmer's guide becomes.. :confused:
If this was already outlined somewhere, link please!
  • Ok, with
    "resources-rectangle-205x148" and "resources-semiround-215x180"

    You have device specific resources over-rides. So the first one is for devices that are a rectangle and 205x148, and the second, for semin-rounds that are 215x180

    if your building things for a target that's a 205x148 rectangle, only things in that directory are used for the compile. If the target is a semi-round, only things in that directory are used. So in one, you don't need to exclude the other.

    Consider this setup. I do device specific and not family specific resources.



    The resources for only a specific target is used. I expanded the va-hr, and you'll see the it's got a launcher_icon for that device (the others are similar, with just properly sized icons for those devices)

    With nothing else, I'll build correctly for each device.

    But in this case, you'll see "mybuild.xml" for this project, I have a different source file for each device, with specific things for that device. Here's what's in "mybuild.xml" for the va-hr:

    <build>
    <exclude file="../source/edge520.mc"/>
    <exclude file="../source/fr735.mc"/>
    <exclude file="../source/edge820.mc"/>
    <exclude file="../source/edge1000.mc"/>
    <exclude file="../source/fenix21.mc"/>
    </build>

    Out of the device specific .mc files, the one I don't exclude on the va-hr is the vahr.mc file.

    So when I build for the va-hr, it's properly sized icon is used, and it's device specific code is used. When I build for the 735, same thing. it's icon and it's code.

    (the code part is the only reason I use "exclude file")

    when it comes to building a .iq, you are actually building a .zip file (it's just called .iq), and it's got a structure based on "part number" which is like target devices, but there are more (the 235 and 235j are different part numbers, but considered the same target in the sim, for example). For each of these, a separate .prg is compiled, using the things I mentioned above.

    So basically, there is a .prg built for the va-hr with it's icon and code, and a .prg built for the 735 with it's icon and code. using the two device I mentioned.
  • That is exactly what I was wanting to know!
    Thank you jim_m_58!

    Unrelated to original post:
    How are you doing the different .mc files?
    Do you have a main WhateverView.mc/WhateverApp.mc that does something?
    Doesn't
    getInitialView() in WhateverApp.mc need to return [ new WhateverView() ];
  • What I do (and some won't like this method :) ) is I only have the original view.

    In each device specific .mc, I have the same class. So for example:

    class Thisdevice {

    }


    Then I have the device specific functions, etc, in that class...

    In the main view I'll have:
    var deviceSpecific = new ThisDevice();

    and when I use one the functions in the view, I'll reference it as:

    deviceSpecific.doXYZ();
  • I think how you use the exclusions depends very much on what you need at the time.

    If you need a completely different implementation depending on the annotation, then putting the annotation on the class or the file containing the class makes sense.

    If you're working on something where functionality needs to be shared among several classes, I think Jim's pattern (similar to the Bridge design pattern) makes a lot of sense. It puts the common code into a single location and allows you to share it.

    If you just need to override a tiny bit of functionality that is isolated to a single class, then it may make sense to put that functionality into a function and then annotate the various versions of that function. For example...

    class MyView extends Ui.View
    {
    // snipped for brevity

    function onLayout(dc) {
    setLayout(getDeviceSpecificLayout(dc));
    }

    // devices with landscape mode support (like the edge_1000) should should exclude :no_landscape_mode
    (:no_landscape_mode) hidden function getDeviceSpecificLayout(dc) {
    return Rez.Layouts.MyViewLayout(dc);
    }

    // devices without landscape mode support (like the fenix3) should should exclude :has_landscape_mode
    (:has_landscape_mode) hidden function getDeviceSpecificLayout(dc) {
    var dx = dc.getWidth();
    var dy = dc.getHeight();

    if (dx < dy) {
    return Rez.Layouts.MyViewLayout_Landscape(dc);
    }
    else {
    return Rez.Layouts.MyViewLayout_Portrait(dc);
    }
    }
    }


    Travis