Is there any way to pass chosen defined-symbols to C compiler on CLI when using BuildExistingProject_v2.py so that CI can automatically build 2 flavors with OPTION1=1 (w/ sequence A) and not (w/ sequence B) with the C code like below?
#if OPTION1
// Run sequence A
#else
// Run sequence B
#endif
I know symbols can be defined for C compiler on Simplicity Studio GUI , but I want to know how to pass defined symbols dynamically for every single headless build (probably with "-D" option).
Discussion Forums
Simplicity Studio
Unanswered
Hi @hayashi,
The Python scripts do not currently support the capability to add or modify the symbols defined in the project settings. The Simplicity Studio python interface has been expanded to support the capability and I am planning on modifying the example Python scripts to show how to do it. This has been requested by a few other customers so I will try and work on this soon.
Thanks for your reply. Please let me know once you complete the example python scripts modification.
0
Hi @jpitt,
The Simplicity Studio python interface has been expanded to support the capability and I am planning on modifying the example Python scripts to show how to do it.
I also want to know the detail. Which script is your latest example for this topic? Ones on AN1121 seems not to be updated.
BTW, I have tried to find the API in Studio.project package and could get the macro definitions from project, but I cannot find how to set another definition...
(Pdb) for D in Studio.project.getProjectModel('soc-empty').model.macroDefinitions: print D
MMacroDefinitionImpl(builtin: false) (languageCompatibility: c asm) (name: __HEAP_SIZE, value: 0xD00)
MMacroDefinitionImpl(builtin: false) (languageCompatibility: c asm) (name: __STACK_SIZE, value: 0x800)
MMacroDefinitionImpl(builtin: false) (languageCompatibility: c asm) (name: __StackLimit, value: 0x20000000)
MMacroDefinitionImpl(builtin: false) (languageCompatibility: c asm) (name: HAL_CONFIG, value: 1)
0
Hi Takashi Ando,
Sorry I haven't had much of a chance to work on this in quite a while. I did get to the point that I could manually modify the build existing project script for various options that could be added, but I haven't had a change to modify the script to accept arguments plus other changes I would like to make to the script. If you want to try to add that capability on your own, you are in the right area.
The highlighted code needs to be added to the script before the call to build the project:
So the command line arguments the script takes would need to be modified to take the macro name and value and then those would replace the "BuildOption" and "1" strings. My intent is to use a -D, --define command line argument as would be passed to gcc.
I hope this is enough information to allow you to implement this on your own and hopefully I will be able to free up some time to update the various scripts.
Thank you,
jpitt
0
Hi jpitt,
Thanks a lot for your information. I tried to run BuildExistingProject_v2.py with your patch, but null pointer exception occurred at running function Studio.project.buildProject() in the script...
I couldn't step in the function on pdb as below (I guess the function just binds to java lib), so cannot find more factor of the exception. Can you find any solution?
I used original BuildExistingProject_v2.py attached on AN1121 and modified it as below patch. If no BUILD_ADD_OPTIONS in buildOptions, this script succeeded to build the project.
how is the status of headless builds for emberznet on simplicity studio 5, the same as 4?
0
Hi jpitt,
How about my below issue? Do you have any idea?
I tried to run BuildExistingProject_v2.py with your patch, but null pointer exception occurred at running function Studio.project.buildProject() in the script...
I couldn't step in the function on pdb as below (I guess the function just binds to java lib), so cannot find more factor of the exception. Can you find any solution?
And I'm also interested in whether this script can be used on SimplicityStudio 5.
how is the status of headless builds for emberznet on simplicity studio 5, the same as 4?
Regards,
0
Hi All,
The status of headless builds should be the same for Simplicity Studio 5 as for Simplicity Studio 4 - the supplied Python scripts have worked in my testing. Since Simplicity Studio 5 "Project Configurator" projects (Bluetooth, Flex and OpenThread) generate the project on every edit to the project configurator file (the .slcp file) a script that does a generate is not necessary. Simplicity Studio 5 EmberZNet projects do not yet use the Project Configurator, they still use AppBuilder and so the "ImportAndGenerateIsc_v4Pub.py" script should still work.
My previous example for adding a -D argument to a project was wrong, it was based on an older script I had. I apologize for that. Please try adding this snippet to the "BuildExistingProject_v2.py" script after the "print projInfo" line and replacing up to the line that begins with 'buildOptions':
projModel = getProjectModel(proj_)
model = projModel.getModel()
if not buildConfig:
buildConfig = projInfo[INFO_CURRENT_CONFIG]
Note the above snippets are also adding an Include statement to the project for Include path "C:/temp/test_v4_workspace/TestAddIncludePath/"
I have tested the above and I do see the -DBuildOption=1 and -IC:/temp/test_v4_workspace/TestAddIncludePath on the command lines passed to the compiler.
Thank you,
jpitt
0
Hi jpitt,
Thank you for your snippet! I could also add macro and include path on BuildExistingProject_v2.py. I encountered the same issue "our removed library object is automatically reverted" I posted at past, but could avoid it with my below patch to remove link of "binapploader.o".
How to pass defined symbols to C compiler for headless builds
Hi,
We're running CI builds based on "AN1121: Headless Builds with Simplicity Studio v4" like below.
Is there any way to pass chosen defined-symbols to C compiler on CLI when using BuildExistingProject_v2.py so that CI can automatically build 2 flavors with OPTION1=1 (w/ sequence A) and not (w/ sequence B) with the C code like below?
I know symbols can be defined for C compiler on Simplicity Studio GUI , but I want to know how to pass defined symbols dynamically for every single headless build (probably with "-D" option).
Hi @hayashi,
The Python scripts do not currently support the capability to add or modify the symbols defined in the project settings. The Simplicity Studio python interface has been expanded to support the capability and I am planning on modifying the example Python scripts to show how to do it. This has been requested by a few other customers so I will try and work on this soon.
Thank you,
jpitt
@jpitt,
Thanks for your reply. Please let me know once you complete the example python scripts modification.
Hi @jpitt,
I also want to know the detail. Which script is your latest example for this topic? Ones on AN1121 seems not to be updated.
BTW, I have tried to find the API in Studio.project package and could get the macro definitions from project, but I cannot find how to set another definition...
Hi Takashi Ando,
Sorry I haven't had much of a chance to work on this in quite a while. I did get to the point that I could manually modify the build existing project script for various options that could be added, but I haven't had a change to modify the script to accept arguments plus other changes I would like to make to the script. If you want to try to add that capability on your own, you are in the right area.
The highlighted code needs to be added to the script before the call to build the project:
macro = Studio.project.projectModelFactory.createMMacroDefinition()
macro.setName("BuildOption")
macro.setValue("1")
buildOptions = {
OPTION_BUILD_TYPE: BUILD_TYPE_FULL,
OPTION_BUILD_CONFIG: buildConfig,
OPTION_NO_AUTO_ENABLE : noAutoEnable,
BUILD_ADD_OPTIONS: macro
}
results = Studio.project.buildProject(proj_, buildOptions, None)
So the command line arguments the script takes would need to be modified to take the macro name and value and then those would replace the "BuildOption" and "1" strings. My intent is to use a -D, --define command line argument as would be passed to gcc.
I hope this is enough information to allow you to implement this on your own and hopefully I will be able to free up some time to update the various scripts.
Thank you,
jpitt
Hi jpitt,
Thanks a lot for your information. I tried to run BuildExistingProject_v2.py with your patch, but null pointer exception occurred at running function Studio.project.buildProject() in the script...
I couldn't step in the function on pdb as below (I guess the function just binds to java lib), so cannot find more factor of the exception. Can you find any solution?
I used original BuildExistingProject_v2.py attached on AN1121 and modified it as below patch. If no BUILD_ADD_OPTIONS in buildOptions, this script succeeded to build the project.
Hi jpitt,
How about my below issue? Do you have any idea?
And I'm also interested in whether this script can be used on SimplicityStudio 5.
Regards,
Hi All,
The status of headless builds should be the same for Simplicity Studio 5 as for Simplicity Studio 4 - the supplied Python scripts have worked in my testing. Since Simplicity Studio 5 "Project Configurator" projects (Bluetooth, Flex and OpenThread) generate the project on every edit to the project configurator file (the .slcp file) a script that does a generate is not necessary. Simplicity Studio 5 EmberZNet projects do not yet use the Project Configurator, they still use AppBuilder and so the "ImportAndGenerateIsc_v4Pub.py" script should still work.
My previous example for adding a -D argument to a project was wrong, it was based on an older script I had. I apologize for that. Please try adding this snippet to the "BuildExistingProject_v2.py" script after the "print projInfo" line and replacing up to the line that begins with 'buildOptions':
projModel = getProjectModel(proj_)
model = projModel.getModel()
if not buildConfig:
buildConfig = projInfo[INFO_CURRENT_CONFIG]
macro = Studio.project.projectModelFactory.createMMacroDefinition()
macro.setName("BuildOption")
macro.setValue("1")
model.getMacroDefinitions().add(macro)
uri = "C:/temp/test_v4_workspace/TestAddIncludePath/"
incl = Studio.project.projectModelFactory.createMIncludePath()
incl.setUri(uri)
incl.setUser(0)
model.getIncludePaths().add(incl)
Studio.project.updateProjectFromModel(proj_,projModel, None)
Note the above snippets are also adding an Include statement to the project for Include path "C:/temp/test_v4_workspace/TestAddIncludePath/"
I have tested the above and I do see the -DBuildOption=1 and -IC:/temp/test_v4_workspace/TestAddIncludePath on the command lines passed to the compiler.
Thank you,
jpitt
Hi jpitt,
Thank you for your snippet! I could also add macro and include path on BuildExistingProject_v2.py. I encountered the same issue "our removed library object is automatically reverted" I posted at past, but could avoid it with my below patch to remove link of "binapploader.o".
Regards,
Ando