The custom variable LEX_OUTPUT reasonably defined in the .cbp file (see xml snip below) is converted to '| gawk -f .\FlexOutput.awk >' where the required slash is annoyingly replaced by a backslash in the build options view and when running a build. A nasty workaround is to edit the custom variable every time when the project is newly loaded. ???
How can the conversion be avoided - or is this a bug (happy to file a bug if pointed to where to report it)?
Living on Win10 with CB16.01 (Jan 25, 2016).
Thanks,
J.
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Build>
<Environment>
<Variable name="LEX_OUTPUT" value="| gawk -f ./FlexOutput.awk >" />
</Environment>
</Build>
</Project>
</CodeBlocks_project_file>
Thanks, this does not work unfortunately:<Variable name="LEX_OUTPUT" value="| gawk -f $TO_UNIX_PATH{.\FlexOutput.awk} >" />
which is what you suggested translates upon a build to ... | gawk -f {.\FlexOutput.awk} > ...
, i.e. $TO_UNIX_PATH is dropped without any impact, but leaving the curly brackets in place.
I checked that - in contrast to functions '$F{}' - variables '$V()' are correctly expanded.
... or am I missing something here? ::)
I'm not sure I understand what is expected to happen and what happens in your environment.
Can you explain? Provide a log?
Here is mine, running on linux:
-------------- Clean: Debug in VariableExpansion (compiler: GNU GCC Compiler)---------------
Cleaned "VariableExpansion - Debug"
Running target pre-build steps
echo PATH_SLASH: ./main.c
echo PATH_BACKSLSASH: ./main.c
PATH_SLASH: ./main.c
echo TO_UNIX_PATH{(PATH_SLASH)}: ./main.c
PATH_BACKSLSASH: ./main.c
echo TO_UNIX_PATH{(PATH_BACKSLASH)}: ./main.c
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `echo TO_UNIX_PATH{(PATH_SLASH)}: ./main.c'
I'm not sure I understand what is expected to happen and what happens in your environment.
Can you explain? Provide a log?
Sure - here is my commented log
-------------- Clean: Debug in VariableExpansion (compiler: GNU GCC Compiler)---------------
Cleaned "VariableExpansion - Debug"
[ 25.0%] Running target pre-build steps
An entered slash (original version of PATH_SLASH was './main.c') saved as backslash in .cpb as shipped in my tiny example ... This is the crux of the whole thing here I believe.
[ 50.0%] echo PATH_SLASH: .\main.c
PATH_SLASH: .\main.c
Effectively the same since PATH_SLASH and PATH_BACKSLASH have same values unfortunately:
[ 75.0%] echo PATH_BACKSLSASH: .\main.c
PATH_BACKSLSASH: .\main.c
TO_UNIX_PATH properly converts a backslash to a slash when given as pre-build command
[100.0%] echo TO_UNIX_PATH{(PATH_SLASH)}: ./main.c
TO_UNIX_PATH(PATH_SLASH): ./main.c
echo TO_UNIX_PATH{(PATH_BACKSLASH)}: ./main.c
linux dislikes the next line apparently ... no idea why:
TO_UNIX_PATH(PATH_BACKSLASH): ./main.c
The next section runs the compiler directive to compile 'main.x' with target 'main.xx' - like %.xx: %.x in make syntax - with the following compiler commands (from 'compiler_config.txt' in my .7z docarated with some comments):
NB: Typo in the definition of $PATH_BACKSLASH_MACRO: Should be '$TO_UNIX_PATH' (instead of 'PATH_TO_UNIX'). Please amend in the .cbp.
echo 1 - PATH_BACKSLASH: $(PATH_BACKSLASH) // works - expand project variable
echo 2 - TO_UNIX_PATH(PATH_BACKSLASH): $TO_UNIX_PATH{$(PATH_BACKSLASH)} // works - expand function (in compiler command (!)) applied to project variable
echo 3 - $PATH_BACKSLASH_MACRO // fails - expand defined as project variable defined '$TO_UNIX_PATH{$PATH_BACKSLASH}' to see when functions are parsed and expanded
echo 4 - $$(PATH_BACKSLASH_MACRO) // fails - just tried because of the documentation given in the project variable definition window which appears to be confusing in the light of the result of the forth command
... back to my log again:
-------------- Build: Debug in VariableExpansion (compiler: GNU GCC Compiler)---------------
[ 16.7%] mingw32-gcc.exe -Wall -g -c C:\myDevel\myprogs\CodeBlocks\VariableExpansion\main.c -o obj\Debug\main.o
here the user-defined compiler step:
[ 33.3%] echo 1 - PATH_BACKSLASH: .\main.c
echo 2 - TO_UNIX_PATH(PATH_BACKSLASH): ./main.c
echo 3 - {.\main.c
echo 4 - $(PATH_BACKSLASH_MACRO)
1 - PATH_BACKSLASH: .\main.c
2 - TO_UNIX_PATH(PATH_BACKSLASH): ./main.c
3 -
4 - $(PATH_BACKSLASH_MACRO)
[ 50.0%] mingw32-g++.exe -o bin\Debug\VariableExpansion.exe obj\Debug\main.o -static-libgcc -static-libstdc++
Output file is bin\Debug\VariableExpansion.exe with size 31.97 KB
The test above check how/when built-in functions are expanded. However my basic question I was starting off with was is why a slash the user edits in some config interfact is saved as backslash in the .cbp xml structure? Is there any need for that? As a not so nice workaround I solved the issue by explicitly using a conversion function in a compiler directive.
NB: It appears that the functions like 'TO_UNIX_PATH' convert every slash or backslash appropriately, regardless if the argument is a proper path or not.
Sorry again for that lengthy thing here, but you asked for that. ::)