Author Topic: Copying a target  (Read 3579 times)

Offline johne53

  • Regular
  • ***
  • Posts: 253
Copying a target
« on: September 17, 2007, 12:17:37 pm »
After building a target with C::B, suppose I want to copy it to another folder (e.g. I had a workspace building 5 x DLL's or Shared Objects and I wanted to copy them all into a common folder). I assume I'd have to do this as a post-build step. Can anyone tell me what the appropriate command would be?

Offline johne53

  • Regular
  • ***
  • Posts: 253
Re: Copying a target
« Reply #1 on: September 21, 2007, 06:00:15 pm »
Can no-one suggest a suitable post-build command line?

(preferably one that works for both Windows and Linux).

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Copying a target
« Reply #2 on: September 21, 2007, 06:35:47 pm »
You can use the $(TARGETNAME_OUTPUT_FILE) variable at every target's post build step, and maybe some other variable like $(PROJECT_DIR) to determine the target location (see the WiKi under "variable expansion" for a complete list of available variables). Then use the copy or cp command.

However, it's much easier to just change the output directories of all targets under "Project properties", so the libraries are created in the right location. No copying necessary.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Biplab

  • Developer
  • Lives here!
  • *****
  • Posts: 1874
    • Biplab's Blog
Re: Copying a target
« Reply #3 on: September 21, 2007, 06:58:21 pm »
After building a target with C::B, suppose I want to copy it to another folder (e.g. I had a workspace building 5 x DLL's or Shared Objects and I wanted to copy them all into a common folder). I assume I'd have to do this as a post-build step. Can anyone tell me what the appropriate command would be?

1) Create a batch file for windows with the command to copy the required files and similarly create one shell script for Linux.
2) Add the following command to the Post-Build section.
Code
[[ if (PLATFORM == PLATFORM_MSW) { print("cmd /C \"test.bat\""); } else { print("/bin/sh foo.sh"); } ]]
Please note that the above code won't work if it's splitted into multiple lines. Also adjust the command for Linux as I've not tested it.

You can also use the script to copy files. But that would raise a security warning (which you can disable at your wish). IMHO, the first method is the better one.
Be a part of the solution, not a part of the problem.