User forums > Using Code::Blocks
Convert backslashes to slashes in tools configuration
(1/1)
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:
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
--- Code: --- YOURCOMMAND [[local test = ReplaceMacros(_T("$(PROJECT_DIR)$(TARGET_OUTPUT_DIR)$(TARGET_OUTPUT_FILENAME)")); test.Replace(_T("\\"),_T("/")); print(test);]]
--- End code ---
greetings
[EDIT:] you can shrink it to:
--- Code: --- YOURCOMMAND [[local test = ReplaceMacros(_T("$(PROJECT_DIR)$(TARGET_OUTPUT_FILE)")); test.Replace(_T("\\"),_T("/")); print(test);]]
--- End code ---
oBFusCATed:
There should be a bit easier way to do it with this:
--- Code: ---$TO_UNIX_PATH{\test\test\test}
--- End code ---
Bluescreen2001:
Sorry for the late answer. I missed the forum's notification somehow.
Both versions does as desired. Thank you very much! :)
BlueHazzard:
I have updated the wiki, because i also didn't knew that this functions existed
http://wiki.codeblocks.org/index.php/Variable_expansion#Build_in_functions_for_path_conversion
Navigation
[0] Message Index
Go to full version