cancel
Showing results for 
Search instead for 
Did you mean: 

[RESOLVED] Access to STM32CubeIDE env vars when building from the command line.

JChrist
Associate III

I have a script in my project that generates code prior to a build that works great. However, I'm trying to set up command line builds and I'm getting an error when I build from the command line:

Contains: Variable references empty selection: ${project_loc}

I tried to set this variable in the shell prior to building but no luck.

I can probably work around this in one of two ways:

  • Hard code the path to the project (but this may break build on other machines)
  • Disable the script and call it on the command line (but this break the build in the IDE)

Command line:

/opt/st/stm32cubeide_1.4.0/stm32cubeide --launcher.suppressErrors -nosplash -application org.eclipse.cdt.managedbuilder.core.headlessbuild -cleanBuild my_project/Release -data ~/stm32/workspace -D CMD_LINE_VAR

If anyone has any suggestions that would be great.

Builder setup:

Project -> Properties -> Builders -> Main0693W00000QNbjwQAD.png

1 ACCEPTED SOLUTION

Accepted Solutions
JChrist
Associate III

EDIT: Realized I was working through this as I was writing the details so the start of the message didn't line up with the end so I edited it to so that it makes more sense.

Thanks for the tip. The environment variable ${project_loc}

doesn't work here so I have to hardcode the path to the script.

Interestingly this working path of this script is the {project_loc}/{Configuration}. I was able to get this to work by doing the following.

Make the path to the script ../ like this:

../utilities/build/pre-build.sh

Then in the script I have to back up to the project directory like this:

cd ..

This then allows the script to run in the IDE and from the command line builds while being agnostic to the absolute path to the project. This in turn accomplished my goal so that it can run on multiple computers and build both from the command line and from within STM32CubeIDE.

Thanks,

Jacob

View solution in original post

4 REPLIES 4
mattias norlander
ST Employee

Not all fields inside Eclipse/CDT are able to interpret environmental variables, but try this:

${env_var:project_loc}

That would fetch the value stored in the variable project_loc.

JChrist
Associate III

Thanks for the suggestion but it didn't work. When I tried to build in Eclipse I got the following error:

Errors occurred during the build.

Errors running builder 'Integrated External Tool Builder' on project 'apm-dongle-bootloader-stm32f446re'.

The file does not exist for the external tool named git_repoversion.

The file does not exist for the external tool named git_repoversion.

Jacob

Semer CHERNI
ST Employee

May be you could try to use the pre build step instead of the launch configuration.

The pre build step is intended to be use in this case.

0693W00000QNsQXQA1.png

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

JChrist
Associate III

EDIT: Realized I was working through this as I was writing the details so the start of the message didn't line up with the end so I edited it to so that it makes more sense.

Thanks for the tip. The environment variable ${project_loc}

doesn't work here so I have to hardcode the path to the script.

Interestingly this working path of this script is the {project_loc}/{Configuration}. I was able to get this to work by doing the following.

Make the path to the script ../ like this:

../utilities/build/pre-build.sh

Then in the script I have to back up to the project directory like this:

cd ..

This then allows the script to run in the IDE and from the command line builds while being agnostic to the absolute path to the project. This in turn accomplished my goal so that it can run on multiple computers and build both from the command line and from within STM32CubeIDE.

Thanks,

Jacob