[[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...
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 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, in the scripting console (view->scripting console) at the bottom line (warning this can overwrite your build log).
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 where you want to have the date. For example:
[[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...
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...
ok, this error is somehow expected, because GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget()
is probably null if you run this code in the command line
What about the other things?
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 in the pre or post build steps? Does it show in the codeblocks log tab?
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:
-------------- 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:
-------------- 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
Running target pre-build steps
Running target post-build steps
and
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).
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
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
-------------- 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?
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
[[Log(_("Logging $(PROJECT_NAME) to Code::blocks log."))]]
and post build
[[Log(_("$(PROJECTNAME)_build_log_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetTitle() + _("_") + GetProjectManager().GetActiveProject().GetCurrentlyCompilingTarget().GetCompilerID() + _(".html"))]]
the Codeblocks log says
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.
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
so
Log(ReplaceMacros(_("Logging $(PROJECT_NAME) to Code::blocks log.")))
should work as expected....
More information here: http://wiki.codeblocks.org/index.php/Scripting_commands
Prebuild
[[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
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?
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 :
$(PROJECTNAME)_build_log_Debug_clang900_llvm_clang_900_compiler.html
This can not come from
[[Log(_("Logging $(PROJECT_NAME) to Code::blocks log."))]]
[[Log(ReplaceMacros(_("Logging $(PROJECT_NAME) to Code::blocks log.")))]]
or
[[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?
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
[[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.
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:
hello_exceptions <- Project
|
|----- Debug_clang900 <-- Target
|----- Release_clang900 <-- Target
And your pre and post build steps look like this:
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):
hello_exceptions
|
|----- Debug_clang900
| |----- Post build [[IO.copy log]]
|
|----- Release_clang900
|---- Post build [[IO.copy log]]
|---- Pre build: [[Log()]]
or this (Solution 2):
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
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
-------------- 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.
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:
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....
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...
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)
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:]
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....
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?
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:
[[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
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...
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.
[[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.
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=
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:
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
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