Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: selevo on May 31, 2020, 09:11:43 am

Title: How can I create (when building) hex files in two folders at the same time?
Post by: selevo on May 31, 2020, 09:11:43 am
My programming program takes a hex file from the folder C: \ proghex
And my projects are in different places and hex files are created inside their folders.
Can I create hex files in two places at once?
In the folder C: \ proghex and as usual in the project folder.
-
Thank's
Title: Re: How can I create (when building) hex files in two folders at the same time?
Post by: hongwenjun on May 31, 2020, 04:12:46 pm
Code
#include <stdio.h>

int main(int argc, char* argv[])
{
    printf("%s\n",argv[1]);
    return 0;
}

Use the source code above, then set the command line parameters as shown below

(https://i.loli.net/2020/05/31/GwhgHolvrxt9ipj.png)
Title: Re: How can I create (when building) hex files in two folders at the same time?
Post by: BlueHazzard on May 31, 2020, 11:33:25 pm
Do you really need the hex file in both folder? Or is it enough in one?

If really both are needed, then you have to copy the files. You can do this with two ways:
1) Squirrel scripting
2) Operating system native copy function

Both have to go in the post build step

Project->Build options->Pre/post build steps->Post build
Then you can
1)
Code
[[IO.CopyFile(_("$(TARGET_OUTPUT_FILE)"), _("C:\hexprog"), true );]]
2)
Code
cmd /c xcopy /D /Y PATH\TO\OUTPUT\FILE PATH/TO/NEW/FILE 

If you do not need have the hex file in both:
Project->Properties->Build targets->select both targets from the left side->Output file

If you want to use codeblocks to start your programmer and feed the output file directly to the programmer you can use the tools+ plugin to start it directly from codeblocks and feed the outptu file directly
Title: Re: How can I create (when building) hex files in two folders at the same time?
Post by: selevo on June 01, 2020, 08:53:16 am
Thank's
I will test your idea
------
Yes, I need in two places that the files would be automatically created and updated in two folders after build projects without  other action hands  .
I have a dumb program for updating firmware, it contains one button and there is nothing more in it, it can only take a hex file from one place and program the controller.