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

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
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


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
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

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #2 on: October 19, 2019, 12:27:39 am »
Code
[[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: 75
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




Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
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
[[]]
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
 [[]]
, 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
$(NOW)
where you want to have the date. For example:
Code
[[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
 I presume this could also be done similarly for one file of type .log or .txt
Squirrel 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: 75
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




Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
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
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
 [[Log(_("test"))]]
in the pre or post build steps? Does it show in the codeblocks log tab?

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
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

-------------- 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
-------------- 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
Running target pre-build steps
Code
Running target post-build steps

and

Code
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: 7582
    • 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 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • 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 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
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
[[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: 75
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 ;-)


Offline gd_on

  • Lives here!
  • ****
  • Posts: 796
Re: log filename including compiler, version, linker and debug or release ?
« Reply #12 on: October 29, 2019, 11:49:50 am »
Code
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 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.4 (tests with 3.3), Msys2 Compilers 13.2.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
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
-------------- 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?


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
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"))]]

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: log filename including compiler, version, linker and debug or release ?
« Reply #15 on: October 30, 2019, 11:19:52 am »
Sorry - I was expecting info and link about it, as before.

I now have four copy files

hello_exceptions_build_log_Debug_clang900_2019-10-29-14.32_llvm_clang_900_compiler.html

which looks very promising.

But now have clearly messed something else because now the variables are not expanding :-(



with prebuild

Code
[[Log(_("Logging $(PROJECT_NAME) to Code::blocks log."))]]


and post build

Code
[[Log(_("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"))]]
the Codeblocks log says


Code
Logging $(PROJECT_NAME) to Code::blocks log.
$(PROJECTNAME)_build_log_Debug_clang900_llvm_clang_900_compiler.html

and attempts to $NOW$ similar do not expand as expected ???

Sorry to be fumbling so much with this.



Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #16 on: October 30, 2019, 12:53:30 pm »
Sorry, i forget to explain:

The file functions do replace the variables automatically. The Log function not. (see: The NOTE at http://wiki.codeblocks.org/index.php/Scripting_commands#IO_namespace )
If you want to replace the Variables in the Log output you have to run it trough
Code
ReplaceMacros()
so
Code
Log(ReplaceMacros(_("Logging $(PROJECT_NAME) to Code::blocks log.")))
should work as expected....

More information here: http://wiki.codeblocks.org/index.php/Scripting_commands

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: log filename including compiler, version, linker and debug or release ?
« Reply #17 on: October 30, 2019, 07:43:18 pm »
Prebuild
Code
[[Log(_("Logging $(PROJECT_NAME) to Code::blocks log."))]]
[[Log(ReplaceMacros(_("Logging $(PROJECT_NAME) to Code::blocks log.")))]]

postbuild
[[IO.CopyFile(_("$(PROJECTNAME)_build_log.html"), _("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_$(NOW)_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"), true );]]


gives this

Code
Rebuild project:4
Logging $(PROJECT_NAME) to Code::blocks log.
Logging hello_exceptions to Code::blocks log.
$(PROJECTNAME)_build_log_Debug_clang900_llvm_clang_900_compiler.html


So your advice is correct.

But I seemed to have stopped it expanding the file copy too?

and I am now not getting any log files from using any of the previous suggested postbuild commands :-(

(If i have NO postbuild, I get the expected html log file where I expect it).

What have I done to mess this up?


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #18 on: October 31, 2019, 09:02:54 am »
Can you post the project file?
With your description it is quite hard to tell...
Maybe the log file gets copied somewhere you are not expecting? Have you tried to search for the file?

If you have only the described steps, why is there this output :
Code
$(PROJECTNAME)_build_log_Debug_clang900_llvm_clang_900_compiler.html
This can not come from
Code
[[Log(_("Logging $(PROJECT_NAME) to Code::blocks log."))]]
[[Log(ReplaceMacros(_("Logging $(PROJECT_NAME) to Code::blocks log.")))]]
or
Code
[[IO.CopyFile(_("$(PROJECTNAME)_build_log.html"), _("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_$(NOW)_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"), true );]]
so maybe you have a log to much somewhere?

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: log filename including compiler, version, linker and debug or release ?
« Reply #19 on: October 31, 2019, 10:56:03 am »
If I have no pre or post build, I get one file where I expect it

Build log saved as:
file://I:/Cpp/hello_boost/hello_exceptions/hello_exceptions_build_log.html

If I add

Code
[[IO.CopyFile(_("$(PROJECTNAME)_build_log.html"), _("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_$(NOW)_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"), true );]]

and rebuild project

I get messages

Running target post-build steps in Build log
Rebuild project:4 in Code::blocks log



The copyfile doesn't seem to do anything.  Have I lost the permission setting?  (I have all the boxes ticked in the Settings, Script settings, Security.

Attached source and .cbp project as .7z.






Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #20 on: October 31, 2019, 01:13:22 pm »
For me this works as expected... ( i had to replace your compiler by my default gcc, because otherwise wired things happened...)

Are you sure you are running the debug target (Near the gear toolbar icon you can use to compile is a drop down menu. There you can select the target you are compiling.)?
you have put the log output in the "release"  target and the log copy script in the debug "target". In the build options you select the target on the tree control on the left. If you select the project name it will be executed by all targets...

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: log filename including compiler, version, linker and debug or release ?
« Reply #21 on: October 31, 2019, 01:57:12 pm »
I've tried this on another machine with similar failure, so I must have something different?

I am 99% confident that I am editing the right build options debug_gcc81 (because behaviour changes by adding post-build option).

Attached is snip of attempt to get permission to copy (that looks right).  I actually chose "Allow this script", but I still don't get any .html log file, not the expected one that I get rebuilding with no post build events (but then deleted).  But no .html log files generated.

My scripting settings have Copy files ticked on this machine (I have ticked them all on the other).

My hello_world.cbp and main.cpp are at J:\Cpp\hello_world, as was my .html log file.

Global compiler settings also attached.

Thanks for your considerable patience so far, but can you see what I am doing wrong?

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #22 on: October 31, 2019, 02:34:04 pm »
Yes! You use the wrong target...

Codeblocks has 4 hierarchies:
1) Workspace (loose collection of projects
2) Projects (collection of targets that have something in common, like compiler options)
3) Virtual targets, a collection of targets, that have to build at the same time (can not have any speciffic settings)
4) Targets: The actual receipts to make your program

Your project is build like this:
Code
   hello_exceptions    <- Project
        |
        |----- Debug_clang900      <-- Target
        |----- Release_clang900    <-- Target

And your pre and post build steps look like this:
Code
   hello_exceptions
        |
        |----- Debug_clang900
        |          |-----Post build [[IO.copy log]]
        |
        |----- Release_clang900
                   |----  Pre build: [[Log()]]

Codeblocks starts at the top and goes down the tree, but only one branch. If you build "Debug_clang900" target only this build steps are executed....
So you can do this (Solution 1):
Code
   hello_exceptions
        |
        |----- Debug_clang900
        |          |----- Post build [[IO.copy log]]
        |
        |----- Release_clang900
                   |---- Post build [[IO.copy log]]
                   |---- Pre build: [[Log()]]


or this (Solution 2):
Code
   hello_exceptions
        |---- Post build [[IO.copy log]]
        |
        |----- Debug_clang900
        |          |----- Pre build: [[Log()]]
        |
        |----- Release_clang900

Or you select the right target:
To select a target:
Build->Select Target->Debug_clang900
Build->Rebuild
And you will get the copied log


To fix the post build steps (solution 1)
Project->Build options->Select Debug_clang900 on the left->Pre/Post build steps->Copy your script -> Select Release_clang900 on the left-> Pre/Post build steps-> paste the script

To fix the project (solution 2)
Remove the Script from Project->Build options->Select Debug_clang900 on the left->Pre/Post build steps
Add it to Project->Build options->Select Project name on the left->Pre/Post build steps

[Edit:] I messed up the debug and release things. Now they should be in sync with your project file
« Last Edit: October 31, 2019, 02:37:31 pm by BlueHazzard »

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: log filename including compiler, version, linker and debug or release ?
« Reply #23 on: October 31, 2019, 03:49:45 pm »
Thanks for improving my understanding of projects and build options.

I've tried to sort things out and have tried taking the scripts trust off, so that it asks for copy permission thus.

So is appears to be about to copy (but should the $PROJECTNAME) be already expanded at this point?

Even if I give permission, then I don't get any .html log file(s).  I expect two files - is this ocrrect.

Code::blocks log says

Rebuild project:4
Log prebuild clang 900 debug
Log clang pre copy 900 debug
Log clang post copy 900 debug

Build log says

Code
-------------- 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 this expected?  I haven't changed the source but have rebuilt.

For Clang I confirm that I have the box ticked for create a log file (and do get a .html log if I remove the copy line from the postbuild options)

I still conclude that I appear not to be getting a log file to copy.

If the copy fails, should there be an error message somewhere?

Since this works once, your basic code is correct, something has changed in my setup?

But perhaps I have wasted enough of your time already?  Thanks for your patience.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #24 on: October 31, 2019, 04:01:04 pm »
Quote
Even if I give permission, then I don't get any .html log file(s).  I expect two files - is this ocrrect.
This is the files i get:
Code
hello_exceptions.cbp
hello_exceptions.cpp
hello_exceptions.depend
hello_exceptions.layout
hello_exceptions_build_log.html
hello_exceptions_build_log_Debug_clang900_2019-10-31-13.08_gcc.html
hello_exceptions_build_log_Debug_clang900_2019-10-31-13.09_gcc.html
hello_exceptions_build_log_Debug_clang900_2019-10-31-13.09_gcc22.html
hello_exceptions_build_log_Debug_clang900_2019-10-31-15.54_gcc.html

You still have not answered what version of codeblocks you are using... I use the latest nightly....
Quote
Build log says
Nothing to be done (all items are up-to-date).       <<<<<<<<<<  is this expected?  I haven't changed the source but have rebuilt.
Yes... This is a bug in the build system logging...

Quote
For Clang I confirm that I have the box ticked for create a log file (and do get a .html log if I remove the copy line from the postbuild options)
Out of curiosity, have you tried with the gcc compiler (do you have gcc installed)

Quote
But perhaps I have wasted enough of your time already?  Thanks for your patience.
Try with a new project and the default compiler and look...

Have you tried the Settings->Scripting->Trusts and Settings->Scripting->Security->Copy files?

[Edit:]
Quote
If the copy fails, should there be an error message somewhere?
I honestly don't know... Probably not, because in macro replacement (the thing you do) the whole scripting output is redirected into void....

Quote
I still conclude that I appear not to be getting a log file to copy.
So you do not get a log file, if the post build steps with the script are activated, but if you remove the script you get a log file?
« Last Edit: October 31, 2019, 04:04:09 pm by BlueHazzard »

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: log filename including compiler, version, linker and debug or release ?
« Reply #25 on: October 31, 2019, 06:05:37 pm »
If i remove the copy script line from the post-build script, I get this in the Code::blocks log

Rebuild project:4
Log prebuild clang 900 debug
Log clang pre copy 900 debug
Log clang post copy 900 debug

and this in the build log

Output file is bin\Debug\hello_exceptions.exe with size 231.00 KB
Running target post-build steps

but NO log file(s).

If I remove the two log statements so that the postbuild box is empty,

I get I:\Cpp\hello_boost\hello_exceptions\hello_exceptions_build_log.html 

and this in the Build log

Build log saved as:
file://I:/Cpp/hello_boost/hello_exceptions/hello_exceptions_build_log.html

Code::Blocks log contains Rebuild project:4
Log prebuild clang 900 debug

So that seems to show that any post-build stops the production of a .html log file.
That surely should not happen?  Is this a key clue?

I'm using the current website release 17.12.

Perhaps I should use a nightly build

But since I have once had a html file and copy including the compiler, etc, this doesn't seem likely to be the cause or cure.

I tried on the other machine using gcc81 with the same result.

I sense that I have altered something else, that makes it behave like this, but I have no idea what.

Yet more thanks. Any other suggestions? 







Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #26 on: October 31, 2019, 07:28:47 pm »
I would try to update codeblocks...

But this for sure looks suspicious...

[edit]
I can reproduce this.... There is no log generated.... I will look into it. Thank you for reporting...

What i did:
1) add post build steps to all targets
2) Change compiler to other name
3) Rebuild:
3.1) A build log is generated, the scripts are called and the log is copied
3.2) Make a second rebuild. The scripts are executed, but no build log is generated....


Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: log filename including compiler, version, linker and debug or release ?
« Reply #27 on: November 01, 2019, 12:10:11 pm »
Thank you for your patience in dealing with this mysterious issue.

Would editing the default.conf XML might be better way of dealing with new compilers/versions?

Will an upgrade to a nightly overwrite all my changes to new compilers?

I am particularly keen to use Clang-9.0.0 with important progress in using constexpr to provide compile-time computation, even with Boost.Multiprecision at 128-bit up to hundreds of decimal digits precision.

(I'd also like to use gcc 9 but there is no binary available for mingw-w64 on Windows 10 yet).

But I await your further investigation.


Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #28 on: November 02, 2019, 01:02:46 am »
small update:
I have found out, that only a script in the post build steps triggers the bug... I can run a script in the pre build step and all works, i can run normal commands in the post build step and it works, only a script triggers the bug...
The bug is, that no build log is generated...

Beside this, there it could also be a problem that the build log is not fulushed at the point the post build step runs... So it could be possible that you copy a old build log, but this is a second problem i try to solve. First lets find out, why the build log is not saved if a script is run in the post build step....

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #29 on: November 04, 2019, 10:33:19 pm »
Ok i have found out, what the problem is, and i found a hack to circumvent it...

The problem is that the build log is saved in the "after process closed" (=OnJobEnd()) handler, only if the command queue is empty. If the queue is not empty a new "build process" (=DoRunQueue())  is started and no build log is saved. The problem is, that running a script, does not start a new process, and for this the "after process closed" is not called (because no process is started). And for this no build log is saved....

So to trigger the OnJobEnd function you can add a command that creates a process. For example:
Code
[[IO.CopyFile(_("$(PROJECTNAME)_build_log.html"), _("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_$(NOW)_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"), true );]]
CMD /C
This will create a process and for this call the OnJobEnd() function and then generate a log file...

The second question is, what build log gets copied...

For the devs: The relevant code is in compiler.gcc:3958
Code
                BuildStateManagement();
                if (m_CommandQueue.GetCount())
                {
                    DoRunQueue();
                    return;
                }
m_CommandQueue.GetCount() is not empty, because script commands are there, but OnJobEnd() is not called because the scipts do not trigger it...
I think this could be a quite common workflow... Any ideas how to solve this...

[edit:] I think it would also be quite handy to be able to add text from scripting to the build log...

[edit2:] As expected... you copy the log of the previous build...
« Last Edit: November 04, 2019, 10:51:58 pm by BlueHazzard »

Offline pabristow

  • Multiple posting newcomer
  • *
  • Posts: 75
Re: log filename including compiler, version, linker and debug or release ?
« Reply #30 on: November 05, 2019, 01:01:57 pm »
:) Works for me.

8)

Would be nice not to have to provide the CMD /C(easily forgotten), but works.

Screen snips attached.  One just shows the (copy) filename generated, the other a diff from the original log file with 'standard' file name.

Thanks.  Sorry this was such a marathon.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: log filename including compiler, version, linker and debug or release ?
« Reply #31 on: November 05, 2019, 01:37:29 pm »
Be carefull! The copy is the log from the previous build, not from the current build!!!!

I have a plan to solve this and will provide a patch for review for the other devs in the next days.

Offline Thoth

  • Multiple posting newcomer
  • *
  • Posts: 11
Hi Everyone,

I am using CodeBlocks 20.03 on Debian 10 and FreeBSD 12.

When I use the Squirrel command in the post-build step, no change is made to the name of the build log file.
Code
[[IO.CopyFile(_("$(PROJECTNAME)_build_log.html"), _("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_$(TDAY)_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"), true );]]
CMD /C

I believe it is because my $(PROJECT_NAME) is "LPO LogIt" and the name of the build log is lpo_log_it_build_log.html.
Code
I am guessing that 
CopyFile(_("$(PROJECTNAME)_build_log.html")
results in
CopyFile(_("LPO LogIt_build_log.html")
Is this correct?

Also, I am guessing that the log file creation functionality uses the Code::Blocks project file name as a fallback.

How can I access the actual name of the generated log file so that I can rename it to include the date and perhaps process it with html2text?

FYI, No log file is created without the trailing "CMD /C" which generates an error on both systems.


=thoth=

« Last Edit: July 17, 2022, 10:50:54 pm by Thoth »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Quote
FYI, No log file is created without the trailing "CMD /C" which generates an error on both systems.
obvisouly, because this is windows only

The build log file is named like this:
Code
basename = wxFileName(m_pProject->GetFilename()).GetName();
basepath = m_pProject->GetBasePath();
....
m_BuildLogFilename = basepath;
m_BuildLogFilename << basename << _T("_build_log.html");

if i look at the macromanager code, that handles the replacing of the files i can see that
Code
PROJECTFILE
should be the same name

the of you used "PROJECTNAME" is the name of the project, that has not to be the same as the project file name