Author Topic: RFC: Backticks  (Read 4254 times)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13405
    • Travis build status
RFC: Backticks
« 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.
(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!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5361
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: RFC: Backticks
« Reply #1 on: June 15, 2021, 01:03:47 pm »
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13405
    • Travis build status
Re: RFC: Backticks
« Reply #2 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.
(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!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5361
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: RFC: Backticks
« Reply #3 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?
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13405
    • Travis build status
Re: RFC: Backticks
« Reply #4 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.
(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!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5361
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: RFC: Backticks
« Reply #5 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
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13405
    • Travis build status
Re: RFC: Backticks
« Reply #6 on: June 19, 2021, 03:12:10 pm »
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!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5361
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: RFC: Backticks
« Reply #7 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.
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13405
    • Travis build status
Re: RFC: Backticks
« Reply #8 on: June 20, 2021, 04:48:29 pm »
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!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5361
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: RFC: Backticks
« Reply #9 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, 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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13405
    • Travis build status
Re: RFC: Backticks
« Reply #10 on: June 21, 2021, 09:16:19 am »
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!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5361
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: RFC: Backticks
« Reply #11 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.
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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5361
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
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.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5361
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: RFC: Backticks
« Reply #13 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. :)
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.

Offline AndrewCot

  • Multiple posting newcomer
  • *
  • Posts: 95
Re: RFC: Backticks
« Reply #14 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/