News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

RFC: Backticks

Started by oBFusCATed, June 14, 2021, 10:04:47 PM

Previous topic - Next topic

oBFusCATed

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.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

Is it Windows related?
I can only test on Windows.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

"cmd0|cmd1" support is unix only. Windows should support it already.
The cache clearing is os independent.
Any testing is welcome.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

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:

`echo aaa`

Then, I got such build command line:

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?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

What happens without the quotes?
Generally backticks are more useful in the compiler or linker options and not for search paths.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

Quote from: 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.

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

g++.exe -Wall -fexceptions -g -I"echo aaa" -c D:\code\test_git_temp\test_cmdcmd\main.cpp -o obj\Debug\main.o
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

quotes=="
backticks==`

::)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

I can't control the quote, it was always added by our compiler gcc plugin when generating the compile command.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

Then backticks are not meant to be used there. Use them in the other places.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

Quote from: oBFusCATed on June 20, 2021, 04:48:29 PM
Then backticks are not meant to be used there. Use them in the other places.

I put this line:

`echo -lm`

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


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, 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.

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

oBFusCATed

You don't need them there. wx-config works fine on linux as it is now.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

ollydbg

Quote from: 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.

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"

`wx-config-msys2 --libs --prefix=$(TARGET_COMPILER_DIR)`


And I got the final result of the linke command:


-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.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ollydbg

If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

ollydbg

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

`pkg-config --cflags opencv4`

and in library options in C::B build option

`pkg-config --libs opencv4`

Really nice feature, also, I think it should also work under Linux. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

AndrewCot

Will the changes also resolve the backticks enhancement in ticket 623?

https://sourceforge.net/p/codeblocks/tickets/623/