Define from environment variable

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JaSi_1632926
Level 4
Level 4
Welcome! 25 replies posted 10 replies posted

Hello,

   

I'd like to set a #define in my code (or most likely -D to the compiler) based on an environment variable. It will be used by our continuous integration system to set version that should be compiled into the product.

   

Is there any way to do this? I'm using PSoC Creator 4.0 together with a PSoC 4 (4200 series).

   

Thanks, Jacob

0 Likes
1 Solution
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

There is not a means to do this in the cyprjmgr tool. To support this flexibility, I would suggest you to choose to export your project as a Makefile and use that file as the basis for your build system. Export to Makefile is a new feature available in PSoC Creator 4.0.

View solution in original post

0 Likes
7 Replies
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

I assume that on your CI system you are calling the compile process via the command line? In that case, you can hand in a define to the compiler via -D.

0 Likes
JaSi_1632926
Level 4
Level 4
Welcome! 25 replies posted 10 replies posted

Hello,
on the CI system I'm building by calling cyprjmgr like this: "c:\Program Files (x86)\Cypress\PSoC Creator\4.0\PSoC Creator\bin\cyprjmgr.exe" -wrk WORKSPACE.cywrk -prj "PROJECT" -build

   

Can I pass in -D defines to that?

   

Thanks, Jacob

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

To get  information on the parameters of the command line compilation, type this command:

   

“[Path of installation folder of Creator]\[version of Creator]\PSoC Creator\bin\cyprjmgr.exe" -h

   

For example, the final command for a 64-bit system could be:

   

"C:\Program Files (x86)\Cypress\PSoC Creator\4.0\PSoC Creator\bin\cyprjmgr.exe" -h

0 Likes

Hello,
I can't find any option to cyprjmgr that suits my need. Any idea?

   

Thanks, Jacob

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

There is not a means to do this in the cyprjmgr tool. To support this flexibility, I would suggest you to choose to export your project as a Makefile and use that file as the basis for your build system. Export to Makefile is a new feature available in PSoC Creator 4.0.

0 Likes
AnkitaS_51
Employee
Employee
100 likes received 50 likes received 25 likes received

However, you can open the project in PSoC Creator and set the necessary #defines in the project build settings.  These will be used when building the project via prjmgrtool.exe-

   

 

   

JaSi_1632926
Level 4
Level 4
Welcome! 25 replies posted 10 replies posted

Opening the project in PSoC Creator isn't really feasible in an automated build system.

   

I will try the Makefile way.

   

Thanks, Jacob

0 Likes