News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Convert backslashes to slashes in tools configuration

Started by Bluescreen2001, February 22, 2017, 08:04:45 PM

Previous topic - Next topic

Bluescreen2001

Hi

I am using Code::Block on Windows for ARM development. I flash my controllers using OOCD. This tool wants it's pathnames with forward slashes even on windows. If I use some variables in the tool configuration Code::Blocks inserts the pathnames with backslashes like normal on windows.
Lets say I want to give the full path to my target output file. I try it this way:

$(PROJECT_DIR)$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_FILENAME)

This expands to:
D:\Entwickl\WinARM\Projects\Blink\default\Blink.elf

It's a typical Windows path like expected. But I need a Linux-like path with forward slashes:
D:/Entwickl/WinARM/Projects/Blink/default/Blink.elf

1. Is there any way to convert the variables to this "linux-like" syntax, may some kind of script or special syntax?
As I noted Code::Blocks accepts a varity of forms of variables like     
    $VARIABLE
    $(VARIABLE)
    ${VARIABLE}
    %VARIABLE%
Maybe it would be nice to interpret them slightly different like $VARIABLE = use forward slashes %VARIABLE% = use backslashes or something. And maybe adding a special character befor the variable name to signal a full path, like this: $_VARIABLE
What do you think about that?

2. Is there an easier way to get the full path of a target output file like as linking all these variable together.

BTW.: it is very helpful that the configurate tools dialog shows examples of the variables, but they are outdated.

BlueHazzard

#1
How the h*** does the program read from the filesys?

Anyway  here is a solution for your problem. It is probably not the nicest, but hey it works ;)

You can add this lane in the ToolsPlus plugin
YOURCOMMAND [[local test = ReplaceMacros(_T("$(PROJECT_DIR)$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_FILENAME)")); test.Replace(_T("\\"),_T("/")); print(test);]]

greetings

[EDIT:] you can shrink it to:
YOURCOMMAND [[local test = ReplaceMacros(_T("$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)")); test.Replace(_T("\\"),_T("/")); print(test);]]

oBFusCATed

There should be a bit easier way to do it with this:
$TO_UNIX_PATH{\test\test\test}
(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!]

Bluescreen2001

Sorry for the late answer. I missed the forum's notification somehow.

Both versions does as desired. Thank you very much!  :)


BlueHazzard