Author Topic: log filename including compiler, version, linker and debug or release ?  (Read 1568 times)

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 47
I am working to ensure portability across several compilers and would like to be able to save the log file for various combinations of compiler, compiler version, linker, dat and time, and debug or release.

For example I'd like the log file to be named like

    I:\Cpp\multiprecision\show_numeric_limits\show_numeric_limits_build_clang900_lld_debug_log.html
    I:\Cpp\multiprecision\show_numeric_limits\show_numeric_limits_build_gcc810_cl_release_log.html

This is possible now, but only with some tedious file renaming, and I'm making mistakes :-(

Could a macro be used somehow?

Thanks

Paul


Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2545
Re: log filename including compiler, version, linker and debug or release ?
« Reply #1 on: October 18, 2019, 11:37:42 pm »
generally it should be possible... I think i found a bug in the scripting code that makes a problem here.... Will report back

Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2545
Re: log filename including compiler, version, linker and debug or release ?
« Reply #2 on: October 19, 2019, 12:27:39 am »
Code: [Select]
[[IO.CopyFile(_("$(PROJECTNAME)_build_log.html"), _("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"), true );]]

Ok, this should work if you post it in the post build process...

Sadly, this has to be in one line...
If you want it in one file we can modify it to run only a script file...

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: log filename including compiler, version, linker and debug or release ?
« Reply #3 on: October 24, 2019, 06:43:37 pm »
Sorry for delay.

Thanks for this that looks plausible - but I must be doing something wrong  :(

I've copied your line (as one line) into the box marked Build Options for the compiler debug Clang900 Pre/post build steps (and also ticked the 'Always execute, even if target is uptodate box in case that would help?).'

But when I rebuild, the Build log now says

  Output file is bin\Debug\hello_boost_exception.exe with size 272.50 KB
  Running target post-build steps
  Nothing to be done (all items are up-to-date).

What am I doing wrong?

PS While we are at it, would a date and time be possible too (rather than relying on the file properties CreateDate?

PPS I presume this could also be done similarly for one file of type .log or .txt




Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2545
Re: log filename including compiler, version, linker and debug or release ?
« Reply #4 on: October 25, 2019, 08:37:10 am »
Does it ask for write permission? There is a security feature that should ask for permission if you use the IO namespace of squirrel.
Have you tried to copy it in the project build options for testing?
Did you not forget to add the
Code: [Select]
[[]] at the beginning and end of the squirrel line? It should exactly look like my code in the forum post.
What version of codeblocks do you use? I think i made some bug fixes in squirrel scripting after the release...
What happens if you paste the line, without
Code: [Select]
[[]], in the scripting console (view->scripting console) at the bottom line (warning this can overwrite your build log).

Quote
While we are at it, would a date and time be possible too (rather than relying on the file properties CreateDate?
you can do this in two ways:
1) Variable expansion: http://wiki.codeblocks.org/index.php/Variable_expansion
Add
Code: [Select]
$(NOW) where you want to have the date. For example:
Code: [Select]
[[IO.CopyFile(_("$(PROJECTNAME)_build_log.html"), _("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_$(NOW)_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"), true );]]Would add the date and time before the compiler id.
2) Using the squirrel function. But this would make the code longer and less readable, so i omit it here... If you want it that way, you can ask and i will try to create something...

Code: [Select]
I presume this could also be done similarly for one file of type .log or .txtSquirrel is a full touring complete scripting language. You can do everything with it :)
Some bindings are missing, but if you need it we can implement it...

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: log filename including compiler, version, linker and debug or release ?
« Reply #5 on: October 26, 2019, 11:30:03 am »
1  No it doesn't request write permission.

2 I've added the line into the script console sans [[ ]] (shown - hope you have a wide screen ;-) ) but it doesn't like it.
See message box (not obvious to me what is wrong from this).

(But I start to get the idea - it's just getting the details exactly right?)

Thanks




Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2545
Re: log filename including compiler, version, linker and debug or release ?
« Reply #6 on: October 27, 2019, 07:41:12 pm »
ok, this error is somehow expected, because
Code: [Select]
GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget() is probably null if you run this code in the command line

What about the other things?
Quote
Have you tried to copy it in the project build options for testing?
What version of codeblocks do you use?
Please post a rebuild log if possible (build->Rebuild and then post the content of the "build log" tab here. And please use code tags for this (the # symbol in the post editor))
What if you put a simple
Code: [Select]
[[Log(_("test"))]] in the pre or post build steps? Does it show in the codeblocks log tab?

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: log filename including compiler, version, linker and debug or release ?
« Reply #7 on: October 28, 2019, 05:40:59 pm »
I am using Codeblocks 17.12, the latest as I understand it.

A hello_world-ish program build (standard settings) has a Build log thus:

Code: [Select]

-------------- Clean: Debug_clang900 in hello_exceptions (compiler: LLVM Clang 900 Compiler)---------------

Cleaned "hello_exceptions - Debug_clang900"

-------------- Build: Debug_clang900 in hello_exceptions (compiler: LLVM Clang 900 Compiler)---------------

clang++.exe -g --verbose  -c I:\Cpp\hello_boost\hello_exceptions\hello_exceptions.cpp -o obj\Debug\hello_exceptions.o
clang++.exe  -o bin\Debug\hello_exceptions.exe obj\Debug\hello_exceptions.o   
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\LLVM\clang-900\LLVM\bin
 "C:\\LLVM\\clang-900\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.24.28207 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello_exceptions.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -gcodeview -debug-info-kind=limited -momit-leaf-frame-pointer -v -coverage-notes-file "I:\\Cpp\\hello_boost\\hello_exceptions\\obj\\Debug\\hello_exceptions.gcno" -resource-dir "C:\\LLVM\\clang-900\\LLVM\\lib\\clang\\9.0.0" -internal-isystem "C:\\LLVM\\clang-900\\LLVM\\lib\\clang\\9.0.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\VC\\Tools\\MSVC\\14.24.28207\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\winrt" -fdeprecated-macro -fdebug-compilation-dir "I:\\Cpp\\hello_boost\\hello_exceptions" -ferror-limit 19 -fmessage-length 0 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.24.28207 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -faddrsig -o "obj\\Debug\\hello_exceptions.o" -x c++ "I:\\Cpp\\hello_boost\\hello_exceptions\\hello_exceptions.cpp"
clang -cc1 version 9.0.0 based upon LLVM 9.0.0 default target x86_64-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
 C:\LLVM\clang-900\LLVM\lib\clang\9.0.0\include
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.24.28207\include
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt
End of search list.
Output file is bin\Debug\hello_exceptions.exe with size 231.00 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Build log saved as:
file://I:/Cpp/hello_boost/hello_exceptions/hello_exceptions_build_log.html
 

I've put [[Log(_("test"))]]  in both pre and post builds (and ticked the alwasy execute, for good measure ;-) and the log is:


Code: [Select]
-------------- Clean: Debug_clang900 in hello_exceptions (compiler: LLVM Clang 900 Compiler)---------------

Cleaned "hello_exceptions - Debug_clang900"
Running target pre-build steps

-------------- Build: Debug_clang900 in hello_exceptions (compiler: LLVM Clang 900 Compiler)---------------

clang++.exe -g --verbose  -c I:\Cpp\hello_boost\hello_exceptions\hello_exceptions.cpp -o obj\Debug\hello_exceptions.o
clang++.exe  -o bin\Debug\hello_exceptions.exe obj\Debug\hello_exceptions.o   
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\LLVM\clang-900\LLVM\bin
 "C:\\LLVM\\clang-900\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.24.28207 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello_exceptions.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -gcodeview -debug-info-kind=limited -momit-leaf-frame-pointer -v -coverage-notes-file "I:\\Cpp\\hello_boost\\hello_exceptions\\obj\\Debug\\hello_exceptions.gcno" -resource-dir "C:\\LLVM\\clang-900\\LLVM\\lib\\clang\\9.0.0" -internal-isystem "C:\\LLVM\\clang-900\\LLVM\\lib\\clang\\9.0.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\VC\\Tools\\MSVC\\14.24.28207\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\winrt" -fdeprecated-macro -fdebug-compilation-dir "I:\\Cpp\\hello_boost\\hello_exceptions" -ferror-limit 19 -fmessage-length 0 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.24.28207 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -faddrsig -o "obj\\Debug\\hello_exceptions.o" -x c++ "I:\\Cpp\\hello_boost\\hello_exceptions\\hello_exceptions.cpp"
clang -cc1 version 9.0.0 based upon LLVM 9.0.0 default target x86_64-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
 C:\LLVM\clang-900\LLVM\lib\clang\9.0.0\include
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.24.28207\include
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt
End of search list.
Output file is bin\Debug\hello_exceptions.exe with size 231.00 KB
Running target post-build steps
Nothing to be done (all items are up-to-date).

I note
Code: [Select]
Running target pre-build steps
Code: [Select]
Running target post-build steps
and

Code: [Select]
Nothing to be done (all items are up-to-date).
Is the trouble that this is over-riding the production of a .html log at all?

Thanks for your continued help.

PS I'd like to have an icon to click that *always* 'Rebuild and run' (I find that the' Build and run' does rebuild when I think it should rebuild).   

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6664
    • My Best Post
Re: log filename including compiler, version, linker and debug or release ?
« Reply #8 on: October 28, 2019, 07:02:50 pm »
The pre/post for the target or for the project?
If target which target?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6664
    • My Best Post
Re: log filename including compiler, version, linker and debug or release ?
« Reply #9 on: October 28, 2019, 07:14:26 pm »
Did you check the codeblocks tab instead of the build log tab?

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2545
Re: log filename including compiler, version, linker and debug or release ?
« Reply #10 on: October 28, 2019, 07:42:40 pm »
Did you check the codeblocks tab instead of the build log tab?
As Tim noted, the "log" message of the command
Code: [Select]
[[Log(_("Test")) should appear  in the "Code::Blocks" of the "logs&others" view. If not, you put things in the wrong place...

Again as Tim noted the right place is Project->Build options->Select the project name on the right side->Pre/post build steps->Post build steps

Maybe you can make a screenshot of the dialog?

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: log filename including compiler, version, linker and debug or release ?
« Reply #11 on: October 29, 2019, 11:18:24 am »
Ah - I see - I was expecting to see "test" in the Build Log tab.

But I only have Build Log and Build messages tabs (I deleted the others on the grounds that they were not useful to me).  Perhaps a mistake :-(

How do I restore to get the Code::blocks tab in Logs and Others?

PS I think I have the command in the right place, but not seeing the output from it.  And perhaps I need to RTFM on scripting (I hoped not to have to know that - my brain is full ;-)


Online gd_on

  • Regular
  • ***
  • Posts: 488
Re: log filename including compiler, version, linker and debug or release ?
« Reply #12 on: October 29, 2019, 11:49:50 am »
Code: [Select]
How do I restore to get the Code::blocks tab in Logs and Others?In "logs & other", right clic on a tab, then choose "Toggle..." to restore the masked tabs
gd_on
Windows 10, svn C::B (last version or almost!), WxWidgets 3.1.3, Compilers 8.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\MinGW64) or 32 bits (sjlj, posix in C:\MinGW32).

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 47
Re: log filename including compiler, version, linker and debug or release ?
« Reply #13 on: October 29, 2019, 03:40:37 pm »
After restoring the Code::blocks tab (thanks for info on this - I have much to learn  :(  ).

s expected
Code::Blocks window contains

Rebuild project:4
test
test

and if I paste the full command given into the post_build box (leaving the [[test]] command in the pre-build box).

It now asks for permission (which I gave for all future uses of the script) and the Code::blocks window now contains

Rebuild project:4
test


and the Build log is as before

Code: [Select]
-------------- Clean: Debug_clang900 in hello_exceptions (compiler: LLVM Clang 900 Compiler)---------------

Cleaned "hello_exceptions - Debug_clang900"
Running target pre-build steps

-------------- Build: Debug_clang900 in hello_exceptions (compiler: LLVM Clang 900 Compiler)---------------

clang++.exe -g --verbose  -c I:\Cpp\hello_boost\hello_exceptions\hello_exceptions.cpp -o obj\Debug\hello_exceptions.o
clang++.exe  -o bin\Debug\hello_exceptions.exe obj\Debug\hello_exceptions.o   
clang version 9.0.0 (tags/RELEASE_900/final)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\LLVM\clang-900\LLVM\bin
 "C:\\LLVM\\clang-900\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.24.28207 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello_exceptions.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -gcodeview -debug-info-kind=limited -momit-leaf-frame-pointer -v -coverage-notes-file "I:\\Cpp\\hello_boost\\hello_exceptions\\obj\\Debug\\hello_exceptions.gcno" -resource-dir "C:\\LLVM\\clang-900\\LLVM\\lib\\clang\\9.0.0" -internal-isystem "C:\\LLVM\\clang-900\\LLVM\\lib\\clang\\9.0.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview\\VC\\Tools\\MSVC\\14.24.28207\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.18362.0\\winrt" -fdeprecated-macro -fdebug-compilation-dir "I:\\Cpp\\hello_boost\\hello_exceptions" -ferror-limit 19 -fmessage-length 0 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.24.28207 -std=c++14 -fdelayed-template-parsing -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -faddrsig -o "obj\\Debug\\hello_exceptions.o" -x c++ "I:\\Cpp\\hello_boost\\hello_exceptions\\hello_exceptions.cpp"
clang -cc1 version 9.0.0 based upon LLVM 9.0.0 default target x86_64-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
 C:\LLVM\clang-900\LLVM\lib\clang\9.0.0\include
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.24.28207\include
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt
End of search list.
Output file is bin\Debug\hello_exceptions.exe with size 231.00 KB
Running target post-build steps
Nothing to be done (all items are up-to-date).

Is the script line not quite right yet?


Online BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2545
Re: log filename including compiler, version, linker and debug or release ?
« Reply #14 on: October 29, 2019, 03:57:07 pm »
Do you have a new file beside the log file? You should not see anything in the log output, but there should be a new log file, called like the compiler beside the old html log file.
If you want to know how the file is called, paste the following in the post build steps and look in the log
Quote
[[Log(_("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"))]]