Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: oBFusCATed on June 14, 2021, 10:04:47 pm

Title: RFC: Backticks
Post by: oBFusCATed on June 14, 2021, 10:04:47 pm
I've tried to introduce automatic support for gtk 2 or 3 on linux.
I've failed to do it and this happened because it was not possible to expand backticks of complex expressions like "cmd0|cmd1".
I've added this feature in this branch: https://github.com/obfuscated/codeblocks_sf/tree/experiments/backticks

After I've done the above I've remembered about the dreaded backtick expression cache problem and I've tried to resolve it, too.
Please test with your projects. Use --debug-log to see if the cache isn't cleared too often. It should be cleared once per operation like Build/Rebuild/Clear.
Title: Re: RFC: Backticks
Post by: ollydbg on June 15, 2021, 01:03:47 pm
Is it Windows related?
I can only test on Windows.
Title: Re: RFC: Backticks
Post by: oBFusCATed on June 15, 2021, 02:16:43 pm
"cmd0|cmd1" support is unix only. Windows should support it already.
The cache clearing is os independent.
Any testing is welcome.
Title: Re: RFC: Backticks
Post by: ollydbg on June 19, 2021, 01:54:43 pm
I can build this branch under Windows.

But I don't know how to test it.

I can write some code in the compiler include search path, such as:

Code
`echo aaa`

Then, I got such build command line:

Code
g++.exe -Wall -fexceptions -g -I"`echo aaa`" -c D:\code\test_git_temp\test_cmdcmd\main.cpp -o obj\Debug\main.o

It looks like the backtick not get executed?
Title: Re: RFC: Backticks
Post by: oBFusCATed on June 19, 2021, 01:58:56 pm
What happens without the quotes?
Generally backticks are more useful in the compiler or linker options and not for search paths.
Title: Re: RFC: Backticks
Post by: ollydbg on June 19, 2021, 02:04:23 pm
What happens without the quotes?
Generally backticks are more useful in the compiler or linker options and not for search paths.

If I remove the backtick, then the build log becomes:

Code
g++.exe -Wall -fexceptions -g -I"echo aaa" -c D:\code\test_git_temp\test_cmdcmd\main.cpp -o obj\Debug\main.o
Title: Re: RFC: Backticks
Post by: oBFusCATed on June 19, 2021, 03:12:10 pm
quotes=="
backticks==`

 ::)
Title: Re: RFC: Backticks
Post by: ollydbg on June 20, 2021, 04:40:32 pm
I can't control the quote, it was always added by our compiler gcc plugin when generating the compile command.
Title: Re: RFC: Backticks
Post by: oBFusCATed on June 20, 2021, 04:48:29 pm
Then backticks are not meant to be used there. Use them in the other places.
Title: Re: RFC: Backticks
Post by: ollydbg on June 21, 2021, 06:16:24 am
Then backticks are not meant to be used there. Use them in the other places.

I put this line:

Code
`echo -lm`

In the linker settings->Other linker options, and it works, here is the log:

Code
g++.exe  -o bin\Debug\test_cmdcmd.exe obj\Debug\main.o  -lm  
Output file is bin\Debug\test_cmdcmd.exe with size 60.84 KB
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I think the backtick should also enabled in the search path settings, because for example, we can use
something like: eranif/wx-config-msys2: wx-config tool for MSYS2 based installation of wxWidgets using the mingw64 repository (https://github.com/eranif/wx-config-msys2), Oh, maybe, those tools can be only used in the "Other linker options" or "Other Compiler options".  So, we don't need use backtick in the search directories.

Title: Re: RFC: Backticks
Post by: oBFusCATed on June 21, 2021, 09:16:19 am
You don't need them there. wx-config works fine on linux as it is now.
Title: Re: RFC: Backticks
Post by: ollydbg on June 22, 2021, 05:50:56 am
You don't need them there. wx-config works fine on linux as it is now.

The good news is that eranif's wx-config-msys2 tool also works well with our C::B's backtick system.

I try to add those lines in the "Other linker options"
Code
`wx-config-msys2 --libs --prefix=$(TARGET_COMPILER_DIR)`

And I got the final result of the linke command:

Code
-LF:\code\msys2-64\mingw64\\lib -pipe -Wl,--subsystem,windows -mwindows -lwx_mswu_xrc-3.1 -lwx_mswu_html-3.1 -lwx_mswu_qa-3.1 -lwx_mswu_core-3.1 -lwx_baseu_xml-3.1 -lwx_baseu_net-3.1 -lwx_baseu-3.1

The only issue is that for C::B, we have $(TARGET_COMPILER_DIR) translated to "F:\code\msys2-64\mingw64\", while, wx-config-msys2 expect there is no ending backslash for the path, so you see double backslashes in the generated command line.
Title: Re: RFC: Backticks
Post by: ollydbg on June 22, 2021, 05:58:42 am
I report the path issue here: Feature request: do not add the backslash if the prefix path has the ending backslash Issue #2 eranif/wx-config-msys2 (https://github.com/eranif/wx-config-msys2/issues/2)
Title: Re: RFC: Backticks
Post by: ollydbg on June 23, 2021, 12:09:25 pm
FYI:

I recently found that msys2 has a nice tool named pkg-config, which is located in msys2_root/mingw64/bin/pkg-config.exe

Now, I see in code::blocks, it can support many libraries. For example, if you want to link opencv library.

You just have to add one line in compiler options in C::B build option

Code
`pkg-config --cflags opencv4`

and in library options in C::B build option

Code
`pkg-config --libs opencv4`

Really nice feature, also, I think it should also work under Linux. :)
Title: Re: RFC: Backticks
Post by: AndrewCot on June 25, 2021, 08:16:32 am
Will the changes also resolve the backticks enhancement in ticket 623?

https://sourceforge.net/p/codeblocks/tickets/623/
Title: Re: RFC: Backticks
Post by: oBFusCATed on June 29, 2021, 12:15:23 am
Probably.