Author Topic: [SOLVED] How to use different building commands for different targets?  (Read 4819 times)

Offline gongminmin

  • Single posting newcomer
  • *
  • Posts: 3
I have a cross platform (windows & linux) project managed in CodeBlocks. Everything is OK until I add a .asm into the project. On Windows, the custom building command should be something like "yasm -Xgnu -fwin32 -o $object $file". However, on linux I'd like to change it into "yasm -Xgnu -felf32 -o $object $file" for 32-bit target, and "yasm -Xgnu -felf64 -o $object $file" for 64-bit target.
In Advance page of custom build dialog, the command is bind on compiler, not platform. And in my case, the compiler is always GNU GCC Compiler, no matter what platform it is. How can I handle this?
« Last Edit: May 26, 2008, 09:08:48 am by gongminmin »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7256
Re: How to use different building commands for different targets?
« Reply #1 on: May 22, 2008, 10:02:47 am »
You can add a custom-build command for special filetypes based on the extensions in "Settings -> Compiler and Debugger... -> Other settings -> Advanced options".

If you add a new source-extension to "Compile a single file to object file" you can enter whatever command you want to compile it.

This part is part of C::B configuartion and not part of the project.
So you can have different commands on different platforms without changing the project.

Offline gongminmin

  • Single posting newcomer
  • *
  • Posts: 3
Re: How to use different building commands for different targets?
« Reply #2 on: May 23, 2008, 05:48:13 am »
You can add a custom-build command for special filetypes based on the extensions in "Settings -> Compiler and Debugger... -> Other settings -> Advanced options".

If you add a new source-extension to "Compile a single file to object file" you can enter whatever command you want to compile it.

This part is part of C::B configuartion and not part of the project.
So you can have different commands on different platforms without changing the project.

Thanks for your reply. Is this the only way? It's very expensive for everyone that trying to open this project to change their C::B config. ANd maybe it would confilct with their original settings of that src-extension. Can C::B have some support to save the command line with different platforms in the .cbp?

Offline gongminmin

  • Single posting newcomer
  • *
  • Posts: 3
Re: How to use different building commands for different targets?
« Reply #3 on: May 26, 2008, 09:08:28 am »
[SOLVED]

I add a Custom variable named yasm_objfmt. Each configure has its own value of this variable. Than I change the ustom building command into "yasm -Xgnu -f$(yasm_objfmt) -o $object $file". It works!