Assistance in using jungle files for Device Qualifiers.

For my watch application, I have separate image resources for round and rectangular watch screens, and they are defined in their own resources folders, but I'm unable to make it work with jungle files.
When I locate the two resource folders ("resources-round" and "resources-rectangle") in

A) the root of the project, the code fails to compile, "Undefined symbol.." with this code:


(new Ui.Bitmap({:rezId=>Rez.Drawables.NavIcon

,:locX=> xOffset

,:locY=> yOffset

})).draw(dc);



B) However, when the folders are located in the "resources" folder under the root of the project, the code compiles, but at run-time the round resources are being displayed on a rectangular watch.


I have made the following entries in the monkey.jungle file:

Round.resourcePath = $(base.resourcePath);resources-round

rectangle.resourcePath = $(base.resourcePath);resourcse-rectangle



But they don't seem to operate.

It seems that the correct approach should be A), but I'm unable to make it work.





(Mac, High Sierra, Eclipse Oxygen, SDK 3.0.3)
  • Why do you override the round.resourcepath with the base.resourcepath?
    I would expect this:
    Round.resourcePath = $(Round.resourcePath);whatever you want to add here...


    (On a side-note personally I don't use the common device qualifiers such as round and rectangle, but go for the per device qualifiers instead as we have seen in the past that for instance the fenix5s changed fonts all of the sudden.)

    Another thing I do is place my jungle specific resources in another folder but the resources* folder, this allows me to combine the common system (and place whatever I want in there, eg language specific files), and my own jungle system where the files reside in the _jungle folder.
    a simple example:

    project.manifest = manifest.xml

    #ciq1
    fr230.resourcePath = $(fr230.resourcePath);_jungle\ciq1\properties_ciq1.xml

    #just copy it to the fr235 as it should act the same as the fr230 for this app
    fr235.resourcePath = $(fr230.resourcePath)
  • Hi RaceQs , is it possible this is just a typo? I see that your resources-rectangle is mispelled in the code snippet you shared:

    rectangle.resourcePath = $(base.resourcePath);resourcse-rectangle

    Also, you should be able to go with option A without adding those instructions into your jungle file. The default.jungle will apply the following instructions for you if you have the folders in your root project directory:

    # Set the base properties, base represents the root of the Monkey C Project
    base.sourcePath = .\**.mc
    base.resourcePath = resources

    # Set the round family qualifier
    round = $(base)
    round.resourcePath = $(round.resourcePath);resources-round

    # Set the rectangle family qualifier
    rectangle = $(base)
    rectangle.resourcePath = $(rectangle.resourcePath);resources-rectangle


    These instructions should accomplish what you seem to be attempting to build unless I have misunderstood your intent. Please let me know if that works for you - otherwise, I would be happy to investigate further.

    Marianne


  • Hi peterdedeker, I "overrode the round.resourcepath with the base.resourcepath" because I really don't understand the syntax, thanks. Your suggestions re device specific qualifiers is good, thanks.

    Hi Marianne , yes a typo that I caught later, but not the base problem.

    I copied your code but still get compile errors "Undefined symbol {...} detected" for all the symbols referenced in the round and rectangle resource files.

    I suspect I have made some kindergarten error in referencing them:

    (new Ui.Bitmap({:rezId=>Rez.Drawables.NavIcon

    ,:locX=> xOffset

    ,:locY=> yOffset

    })).draw(dc);



    I have, for example, a NavIcon in both locations


    (I keep getting obscure errors from the Forum site like

    Error while saving content: SyntaxError: JSON Parse error: Unexpected identifier "Please", so have gone with a vanilla layout.)
    Here's some screenshots (I was unable to paste images!)

    PS it all worked fine when I last worked on it last year in SDK 2.? on my Win10/Eclipse Neon. I've been absent since then and have only just returned to the strange new world of Mac/SDK 3, Eclipse Oxygen)
  • RaceQs, your screenshots seem to suggest a combination of things could be tricking you up. Undefined symbol checking is a more recent feature of the compiler. That feature in combination with Jungles and our resource overriding system could be causing these errors. Are you getting them when you actually build for a round / rectangle device (either by launching the simulator or exporting the app)? Or are you only seeing the errors for an automatic build of the project?

    An automatic build of the project does not have any device context - it just builds the source / resources defined for the base qualifier within the Jungle. Your base qualifier, as is currently defined, pulls in all the source code within the root of the project. That source code is referencing symbols that never actually get defined for an automatic build because they are symbols from either resources-round or resources-rectangle specific builds.

    The beauty of Jungles is that we have really given our developers the power to define their project builds in whatever way works best for them. If what I suggested is the case, then there are a number of ways that you can use Jungles to get around these automatic build errors if they bother you. It just depends on which way you would prefer to do it:
    • You could set automatic (base) builds to a default device
    • You could only pull source code that is the not referencing the Rez module into base auto-builds, then add that source code just to builds with a device context
    • You could possibly use (if it makes sense) excluded annotations
    For example, if you want to set a default device:
    # Set the base properties, base represents the root of the Monkey C Project
    base.sourcePath = .\**.mc
    base.resourcePath = resources;resources-round

    # Set the round family qualifier
    round = $(base)

    # Set the rectangle family qualifier
    rectangle = $(base)
    rectangle.resourcePath = $(rectangle.resourcePath);resources-rectangle


    Please let me know if this helps,
    Marianne
  • Thanks for the additional info.
    I'm seeing the errors for an automatic build of the project.

    When use your first suggestion, a default device, set to rectangle, the build now fails only on the round code even though I am using the excludeAnnotations.
    project.manifest = manifest.xml

    round.excludeAnnotations = rectangle

    rectangle.excludeAnnotations = round



    and(:round)

    function drawRoundIcons(dc, drawLines) {

    var yOffset = 2;

    if (drawLines){

    dc.setColor(0xFFFFFF, 0xFFFFFF);

    dc.drawLine (screenWidth/2 - 89, 101, screenWidth/2 + 89, 101);

    dc.drawLine (screenWidth/2 - 76, 165, screenWidth/2 + 76, 165);

    ....
    if (isTouchScreen){

    horizNavIcon.draw(dc);}

    else{

    //screen navigation buttons - arrow-04

    (new Ui.Bitmap({:rezId=>Rez.Drawables.navButtons

    ,:locX=> 4

    ,:locY=> 89

    })).draw(dc);

    }




    }
    ....


    }

    It looks like the excludeAnnotations isn't working as expected.

    Just for clarification, in my code, the "navButtons" is only defined for round devices, and so I would have thought the excludeAnnotations for round would not encounter the round code.

    [LATE NEWS]
    Seems the builder it not recognising that the viviactive-hr is not a round device:
    When I use vivoactive_hr.excludeAnnotations = round instead of
    round.excludeAnnotations, it does exclude the (:round) code when building for the VA-HR.
    Maybe I should have listened to @peterdedeker in the first place!
  • I'm seeing the errors for an automatic build of the project.


    This is because your base does not have the excludedAnnotations code.

    The base part is used for two things:
    - automatic build
    - inclusion in device specific builds (unless overriden)

    so as an example:
    project.manifest = manifest.xml

    #fix autobuild
    base.sourcePath = $(round.sourcePath)
    base.resourcePath = $(round.resourcePath)
    base.excludedAnnotations = $(round.excludedAnnotations)
    # take care with the latter as a side-effect of this is if you for instance in your rectangle instructions you have no excludedAnnotations it will include the base excludedAnnotations. This side-effect was the cause of a bug in my sources :)

    round.sourcePath = $(round.sourcePath);any extra folders you may want
    round.resourcePath = $(round.resourcePath);any extra folders you may want
    round.excludedAnnotations = rectangle

    rectangle.sourcePath = $(rectangle.sourcePath);any extra folders you may want
    rectangle.resourcePath = $(rectangle.resourcePath);any extra folders you may want
    rectangle.excludedAnnotations = round


    For the automatic build errors you can change these to build warnings by including the following compiler directive (I'd wish this was the default behavior as it gives all the benefits without the downsides of the syntax checking):
    --Eno-invalid-symbol

    The vivoactive hr not being recognized as a rectangular device might be indeed a bug though...



  • What's happening is with auto-build there's no actual build target, so that's why you need defaults as Peter indicated. You can see if this is the problem by building with an actual target, even if you got an error with the auto-build.

    I just added this to one of my apps as a test:
    rectangle.sourcePath= $(srcBase);source-maps
    rectangle.resourcePath = $(resBase);resources-maps

    and it worked as expected for the va-hr (built it using maps), so not sure why it's not for you with the vahr. I'm using the 3.0.3 SDK.
  • Thanks Jim and Peter, I agree with both of you. Unfortunately, the --Eno-invalid-symbol compiler flag is not documented yet. However, there is a ticket open to do so. That is also a way that you could suppress the build errors for an auto-build. These would now just be warnings.
  • @peterdedeker Could I ask you to check out the possible bug with the VA-HR not being recognised as round? I'm not yet sure of may way around this part of the woods.
  • The va-hr isn't round. In post 8, I verified it's one of the rectangles and works as that.