This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS 5.1: XDC : how can I access eclipse build variables from within an XDC Script ?



Hi,

how can I access eclipse build variables, like ${ProjName} or ${build_type}, from within an XDC script?

I just wanted to write a common .cfg file for 2 eclipse projects, e.g. master_project and slave_project. So I would like to make different configurations, depending on the actual value of ${ProjName}

I looked at the Program Object (like Program.name), but this is not what I am looking for.

many thanks

Alois

 

 

 

  • Hi Alois,

    our appologies.  This one seems to have slipped through the cracks.

    I am going to try and help answer your question.

    Have a look at this xdc document right off of the eclipse site.

     

    http://rtsc.eclipse.org/cdoc-tip/xdc/cfg/Program.html

    Please keep us informed as to whether you have further questions.

    Best Regards,
    Lisa

  • Hi Alois,

    just thought I would check once again whether the site was helpful/whether there is an update to your enquiry.

    Best Regards,
    Lisa

  • Hi Lisa,

    your hint was helpful, I used variable Program.name to identify the projects name.

    e.g.

    if (Program.name == "flexwarp_multicore_master.xe66") {
        var ThisIsMaster = true;
    } else {
        var ThisIsMaster = false;
    }

    This works fine for me, but it seems to be some sort of hack for my purpose.

    I wanted to check the name of the actual eclipse project name, instead of the executable name.

    best regards

    Alois

  • Hi Alois,

    Ok, I have some further feedback for you so please let us know if it helps.

    Best Regards,
    Lisa

    The configuration tool command line tool is designed to work outside the CCS environment (to allow one to build embedded products without CCS).  As a result, it has no direct knowledge of the CCS/eclipse project/workspace variables.

     

    However, since this tool is invoked by CCS _and_ it’s possible to pass arguments to the tool that can be accessed by configuration scripts, it should be possible to do what you want.  Let me first explain how arguments can be passed to the command line tool that can be accessed by configuration scripts.  Then we can look at ways to get CCS to pass the desired variables to the tool.

     

    Passing arguments to scripts

    The configuration command line tool is always run as follows:

    xs [xs options …] xdc.tools.configuro [configuro options …] app.cfg

     

    The xs command starts a Rhino JavaScript interpreter which then finds and runs the JavaScript command xdc.tools.configuro with the arguments that appear after “xdc.tools.configuro” on the command line above.

     

    Since Rhino is implemented in Java it can access Java system properties and the xs command supports a –D option that allows one to define new Java system properties that can be directly accessed by configuration scripts. In addition, the xdc.tools.configuro command script’s options supports a –cfgArgs option that allows one to pass arguments directly to scripts.

     

    So, there are (at least) two ways to pass CCS build variables to a configuration script from the command line:

    1. use the –D option of the xs command; see http://rtsc.eclipse.org/docs-tip/Command_-_xs and http://rtsc.eclipse.org/docs-tip/Command_-_xs#Controlling_the_xs_Context.2FEnvironment
    2. use the –cfgArgs option of the xdc.tools.configuro script; see http://rtsc.eclipse.org/cdoc-tip/index.html#xdc/tools/configuro/package.html.

     

    Accessing the arguments is different in the two cases and is described in the links provided.

     

    Getting CCS to pass build variables to scripts

    Unfortunately  I’m not an expert on how CCS runs the xs xdc.tools configuration tool.

     

    However, I believe it is possible to use the project’s “CCS Build/XDCtools” properties to pass the desired build variables by leveraging the command line options above by either

    • passing options to xs; e.g., -DProjName=${ProjName} (see first screen shot below) or
    • passing options to xdc.tools.configuro; e.g., -cfgArgs={ProjName:${ProjName} (see second screen shot below)

     

     

     

     

     

  • Hi Lisa,

    this is exactly what I looked for!

    I tried the -DProjName=${ProjName} method, which works fine.


    many thanks and best regards

    Alois

  • Hi Alois,

    great, glad to hear that helped!  All the best.

    Best Regards,
    Lisa