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

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 »