PDA

View Full Version : QtCreator 4.5.1--Automate Deployment to multiple devices?



davethomaspilot
28th August 2023, 20:21
I have a project that requires a compile time constant to be different for each target device (a security key).

Currently, I change the constant in the .pro file something like this:

DEFINES += KEY=\\"756eca076894f288182951f4e02191e2\\"

The key is specific to each target device.

When I want to deploy to a different device, I use "Manage Kits"->Manage and change the host name (ip address).

Right now I have a set of 10 devices I'm testing (they interact with each oth) and I need to deploy to all of them when I make a code change.

I could create a different project for each device--the project would only different in that one line in the .pro file and the target device's ip.

Is there a better way to do this? Like export a makefile and edit it do 10 builds, with each build deploying to a different device?

davethomaspilot
29th August 2023, 01:28
I guess I can use qmake to create a makefile and wrapped it with a script that changes the symbolic constant, builds, and executes the deploy steps that I have configured in the qtcreator project. Once for each target.

If there's a better way, I'd like to know about it.

d_stranz
29th August 2023, 16:13
Is the key / device pairing constant for every build iteration? (That is, the same device always has the same key?)

If so, this might be something you can automate with CMake. A top level CMakelist project with ten CMakelist subprojects. The top level project fires off the build of each subproject, and within each subproject, the script references the same source code but contains a different compile time define for the key and builds to a different output directory. Building a new release is as simple as running CMake on the top level.

This will work even if the keys change with each build; just add an extra step in each subproject build to generate a key and write it to a file that gets #include where needed in the source code. CMake has commands to execute other programs as part of a build.

davethomaspilot
4th November 2023, 22:12
Didn't check back in time!

I ended up creating a makefile and editing it. But, what you suggest sounds better.

But, I need to get up to speed on how to use CMake instead of the .pro file. Must do now--I'm moving up to QT6, cross-compiling for RPI Bookworm. So, I have to figure out how to change my .pro files to use CMake, I guess...

I'll do a little research, maybe post a question.