Author Topic: cbp2make - makefile generation tool  (Read 203329 times)

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 108
Re: cbp2make - makefile generation tool
« Reply #90 on: February 02, 2013, 12:55:40 am »
Update: (see rev.138) a small bugfix release

  • Fixed possible out-of-order execution of makefile rules when -jN option is used, which might happen due to missing dependencies between before-build,build,after-build rules.
  • Fixed possible 'could not find getcwd' build error in recent distributions due to missing #include.
  • Corrected default command templates for GCC dynamic library and executable linker.
  • Added support for multiple platform-specific library extensions. This list of file extensions is used to check whether a supplied file name is a full library name ("libabc.a") or just a base name ("abc") which requires "-l" linker option. See cbp2make.cfg configuration file, platforms section.

Offline freq

  • Single posting newcomer
  • *
  • Posts: 8
Re: cbp2make - makefile generation tool
« Reply #91 on: June 01, 2013, 10:46:49 am »
Can anyone explain tom how to use this tool?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: cbp2make - makefile generation tool
« Reply #92 on: June 01, 2013, 06:37:37 pm »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

mcwanghui

  • Guest
Re: cbp2make - makefile generation tool
« Reply #93 on: June 02, 2013, 12:29:07 pm »
great work! thank you very much!

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 108
Re: cbp2make - makefile generation tool
« Reply #94 on: June 09, 2013, 09:16:41 am »
Update: (see rev.147) an intermediate release

  • Fixed setting of automatic file prefix for targets ('lib' for static libraries, etc).
  • Partially reworked support for multiple toolchains. Different toolchains with incompatible command line switches can be used now in one project.
  • Declared MSVC and Borland toolchains, other toolchains known to C::B will be there in further releases.
  • Some other minor bugfixes and changes I don't remember  ;)


The progress on cbp2make became quite slow recently.
Despite many planned things are not there yet, I'd like to share some of already implemented improvements.

veneff

  • Guest
Re: cbp2make - makefile generation tool
« Reply #95 on: December 09, 2013, 03:55:52 pm »
This looks like a handy tool!

Is there a way to specify Code::Blocks's conf file?  I scanned this topic and looked at the config doc for cbp2make and did not see anything obvious.

I use several different conf file depending on the toolchain and whether the project build environment is portable or not.

Update: seems as if cbp2make does not reference a conf file.  I am getting error:

Generating makefile(s): test_UART.cbp.mak: Warning: toolchain 'armelfgcc' for target 'Debug' is not defined.
Warning: toolchain 'armelfgcc' for target 'Release' is not defined.
Warning: toolchain 'armelfgcc' for target 'Debug' is not defined.
Warning: toolchain 'armelfgcc' for target 'Release' is not defined.

Does this mean that global settings are not included?

Update 2:
I created a new armelfgcc toolchain entry in the CFG file.  cbp2make seems to be happy with that.
Now to move any global settings to the project settings.

Update 3:
Work pretty good!  But, it is ignoring assembly files (.s & .S).  I'll manually add those and report on progress.

Last Update:
I added the assembly files and the output file was generated successfully, when the (modified) make file was ran!
Two additional things I had to fix:
1) When clean is specified, the order that the directory deletions was done was incorrect.  It attempted to remove a parent directory before a sub directory was removed.  Also, it does not remove any nested parent directories that did not contain files. As an example: I had a source file file in level5
.\level1\level2\level3\level4\level5\file.o
it attempted to remove .\level1 before removing .\level1\level2\level3\level4\level5
Also, it did not attempt to remove .\level1\level2\level3\level4, .\level1\level2\level3 or .\level1\level2 directories I presume because they did not contain any object files.

2) Is there any way I can resolve the Code::Blocks predefined symbols %TARGET_OUTPUT_DIR% and %TARGET_OUTPUT_BASENAME% without defining exact directory and file name?

Ha, I lied, one more update:
I tried to add a single variable, but it is always added as a set.  It works OK, just adds a lot of unnecessary verbiage to the make file.

Thank you very much for putting the effort into creating this application!
Vance
« Last Edit: December 09, 2013, 08:16:04 pm by veneff »

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 108
Re: cbp2make - makefile generation tool
« Reply #96 on: March 10, 2014, 10:40:58 am »
Hi, veneff. Sorry for terribly long reply. Haven't check this forum thread for few months.

Currently cbp2make knows only few toolchains by default. It is planned to add all toolchains known to C::B, but only few defaults were hard-coded up until now. Update2 steps are entirely correct, this is the intended way to add toolchains unknown by default.

In order to process assembly file "*.s"/"*.S" you need a defined compiler tool in a toolchain that has these extensions declared as input file extensions (put <option source_extensions="s S"/> line in config xml of the assembler section).

Directory cleanup order may be incorrect, it is just extracted from the list of output file paths as I remember.

Built-in variables are not supported yet.
Adding support for them had been planned as a major update after rev.147,
but I had to put the project on hold due to horrible lack of spare time.

Offline Dvorkin

  • Multiple posting newcomer
  • *
  • Posts: 11
Re: cbp2make - makefile generation tool
« Reply #97 on: March 18, 2014, 01:07:11 pm »
cbp2make does not use global C::B compiler's settings.
There are -L"lib_path" and -lm linker's switches in C::B Settings->Compiler->Linker Settings, but there are not the switches in output makefile.

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 108
Re: cbp2make - makefile generation tool
« Reply #98 on: March 19, 2014, 10:12:14 am »
Dvorkin

Yes, that's true. cbp2make doesn't use anything that's outside of .cbp or .workspace file (and it shouldn't by design) since the major reason for developing cbp2make was to being able to build C::B projects on systems where C::B is not available. The suggested solution to pass information which is external to a project is to use local or global configuration of cbp2make where it stores information about toolchains and system commands. However, current version of cbp2make does not implement this kind of toolchain-wise settings.

As a quick workaround to this I would suggest to move these settings to global project settings.

Offline the.sniffer

  • Single posting newcomer
  • *
  • Posts: 2
Re: cbp2make - makefile generation tool
« Reply #99 on: December 28, 2014, 01:14:39 am »
Please be aware that there is an inconsistency in how cbp2make is handling generation of a list of linking libraries for the linker as compared to CodeBlocks.

For more information please see my reply to the Stack Overflow question: http://stackoverflow.com/questions/25670849/cbp2make-linking-libraries-with-a-on-windows/27672601#27672601

It is my opinion that cbp2make behaviour should be corrected to mach CB (required settings and variables holding file extensions are already present).

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 108
Re: cbp2make - makefile generation tool
« Reply #100 on: January 04, 2015, 07:21:13 pm »
Currently cbp2make doesn't make any difference between static and dynamic libraries when it is about to generate a line for the linker.
Well, my assumption about how this should work was wrong and this is why it is designed that way.

Input conditions are: ( ) a library has a known extension ( ) static ( ) dynamic ( ) any other extension ( ) no extension ( ) a library has a known prefix;
Possible actions: ( ) remove prefix ( ) remove extension ( ) add library linking switch;

the.sniffer, could you write down the required logic in these terms as you see it? (like you did on stackoverflow.com)

Offline the.sniffer

  • Single posting newcomer
  • *
  • Posts: 2
Re: cbp2make - makefile generation tool
« Reply #101 on: January 10, 2015, 10:55:29 am »
I'd suggest you have a look at "src/sdk/compilercommandgenerator.cpp" in CodeBlocks source code for the most accurate response. There are a lot of options that come into play, and I'd hate to make a mistake.

m.rap

  • Guest
Re: cbp2make - makefile generation tool
« Reply #102 on: January 21, 2015, 06:10:07 am »
this is really a great tool. in the previous version i got nothing wrong, but this latest one i have this problem:
i have static library project, for example the name is "abc". in the project properties it's already set that the output filename is "bin/Debug/libabc.a". but when i generate the makefile using cbp2make and build it, the output file is generated with the name "liblibabc.a" instead of "libabc.a". it results the linking process failed because the linker cannot find the library abc. why does it happen? or is there any workaround to fix this? thanks

EDIT:
apologies. as it turns out, i just realized that the version of codeblocks i used was 10.05 which i got from the wheezy distribution of debian. in this version the output file explicitly set as "libabc" unlike on the version 13.12 that just set as "abc".
« Last Edit: January 22, 2015, 05:07:37 am by m.rap »

Offline fruitCode

  • Multiple posting newcomer
  • *
  • Posts: 13
Re: cbp2make - makefile generation tool
« Reply #103 on: February 24, 2015, 11:11:46 am »
I have a workspace with 2 projects, one uses the MINGW GCC to build it and the other uses MINGW64 to build.
Actually these projects deliver a DLL, one for 32 bit and one for 64 bit.
cpb2make does not generate a makefile for the 64 bit project, it trows the error message:
Warning: toolchain 'gnu_gcc_compiler_w64' for target 'DLL' is not defined.

In code::blocks I defined the 64 compiler using the menu settings->compiler (as described in this clear expanation (thanks!!) http://yzhong.co/?p=622)

I can see one can add a configuration but how to do it? How does a configuration file look like? I looked at the output of cbp2make --config show but there is no folder location mentioned. I suppose I have to tell it through the configuration file where the compiler/linker is located? (Since I have two versions of MINGW on my computer)

Offline mirai

  • Multiple posting newcomer
  • *
  • Posts: 108
Re: cbp2make - makefile generation tool
« Reply #104 on: March 14, 2015, 02:11:03 pm »
fruitCode
Compiler settings from C::B are not transferred to cbp2make.cfg automatically, you have to specify options separately from C::B.

Run cbp2make --config --local , this will create cbp2make.cfg file in the current directory. Then you can edit this XML file either with a regular text editor or by running cbp2make with certain options. I think using a text editor would be easier.

Find a section like this
Code
        <toolchain platform="Windows" alias="gcc">
            <tool type="compiler" alias="gnu_c_compiler">
                <option description="GNU C Compiler" />
                <option program="gcc.exe" />
                <option make_variable="CC" />
                <option command_template="$compiler $options $includes -c $file -o $object" />
                <option source_extensions="c cc" />
                <option target_extension="o" />
                <option need_quoted_path="0" />
                <option need_full_path="0" />
                <option need_unix_path="0" />
                <option include_dir_switch="-I" />
                <option define_switch="-D" />
            </tool>
            <tool type="compiler" alias="gnu_cpp_compiler">
                <option description="GNU C++ Compiler" />
                <option program="g++.exe" />
                <option make_variable="CXX" />
                <option command_template="$compiler $options $includes -c $file -o $object" />
                <option source_extensions="cpp cxx" />
                <option target_extension="o" />
                <option need_quoted_path="0" />
                <option need_full_path="0" />
                <option need_unix_path="0" />
                <option include_dir_switch="-I" />
                <option define_switch="-D" />
            </tool>
            <tool type="static_library_linker" alias="gnu_static_linker">
                <option description="GNU Static Library Linker" />
                <option program="ar.exe" />
                <option make_variable="AR" />
                <option command_template="$lib_linker rcs $static_output $link_objects" />
                <option source_extensions="o obj" />
                <option target_extension="a" />
                <option need_quoted_path="0" />
                <option need_full_path="0" />
                <option need_unix_path="0" />
                <option library_dir_switch="-L" />
                <option link_library_switch="-l" />
                <option object_extension="o" />
                <option library_prefix="lib" />
                <option library_extension="a" />
                <option need_library_prefix="0" />
                <option need_library_extension="0" />
                <option need_flat_objects="0" />
            </tool>
            <tool type="dynamic_library_linker" alias="gnu_dynamic_linker">
                <option description="GNU Dynamic Library Linker" />
                <option program="g++.exe" />
                <option make_variable="LD" />
                <option command_template="$linker -shared $link_options $libdirs $link_objects $libs -o $exe_output" />
                <option source_extensions="o obj" />
                <option target_extension="dll" />
                <option need_quoted_path="0" />
                <option need_full_path="0" />
                <option need_unix_path="0" />
                <option library_dir_switch="-L" />
                <option link_library_switch="-l" />
                <option object_extension="o" />
                <option library_prefix="lib" />
                <option library_extension="dll" />
                <option need_library_prefix="0" />
                <option need_library_extension="0" />
                <option need_flat_objects="0" />
            </tool>
            <tool type="executable_binary_linker" alias="gnu_executable_linker">
                <option description="GNU Executable Binary Linker" />
                <option program="g++.exe" />
                <option make_variable="LD" />
                <option command_template="$linker $link_options $libdirs $link_objects $libs -o $exe_output" />
                <option source_extensions="o obj" />
                <option target_extension="exe" />
                <option need_quoted_path="0" />
                <option need_full_path="0" />
                <option need_unix_path="0" />
                <option library_dir_switch="-L" />
                <option link_library_switch="-l" />
                <option object_extension="o" />
                <option library_prefix="" />
                <option library_extension="" />
                <option need_library_prefix="0" />
                <option need_library_extension="0" />
                <option need_flat_objects="0" />
                <option option_wingui="-mwindows" />
            </tool>
            <tool type="resource_compiler" alias="gnu_windres_compiler">
                <option description="GNU Windows Resource Compiler" />
                <option program="windres.exe" />
                <option make_variable="WINDRES" />
                <option command_template="$rescomp -i $file -J rc -o $resource_output -O coff $includes" />
                <option source_extensions="rc res coff" />
                <option target_extension="o" />
                <option need_quoted_path="0" />
                <option need_full_path="0" />
                <option need_unix_path="0" />
                <option include_dir_switch="-I" />
                <option define_switch="-D" />
            </tool>
        </toolchain>

Copy this text next to itself and replace the value of "alias" option with exactly the same text as in .cbp file in line "<Option compiler = "gcc">", then modify options of build tools to match C::B settings.