Home Download Buy Blog Forum Support

Custom build : g++.sublime-build

Custom build : g++.sublime-build

Postby GMath on Tue Dec 06, 2011 9:34 pm

Hello,

I'm trying to make my own sublime-build that'll run "g++ -W -Wall -Werror *.cpp" in the directory of the current directory.
For the moment, I've this :
Code: Select all
{
   "cmd": ["/usr/bin/g++", "-W", "-Wall", "-Werror", "$file"],
   "working_dir": "${file_path}"
}


But it runs only on the current file (g++ -W -Wall -Werror main.cpp)

I've already tried :
Code: Select all
{
   "cmd": ["/usr/bin/g++", "-W", "-Wall", "-Werror", "*.cpp"],
   "working_dir": "${file_path}"
}

But it tries on a file "*.cpp" not on the pattern *.cpp
Code: Select all
i686-apple-darwin11-llvm-g++-4.2: *.cpp: No such file or directory
i686-apple-darwin11-llvm-g++-4.2: no input files
GMath
 
Posts: 13
Joined: Tue Dec 06, 2011 9:27 pm

Re: Custom build : g++.sublime-build

Postby GMath on Mon Dec 12, 2011 9:00 pm

Bump
GMath
 
Posts: 13
Joined: Tue Dec 06, 2011 9:27 pm

Re: Custom build : g++.sublime-build

Postby jps on Tue Dec 13, 2011 12:24 pm

"*.cpp" will pass *.cpp as a literal argument to g++. Usually the shell would expand glob patterns before launching the process, if you want to use shell features, then try this instead:

Code: Select all
{
   "cmd": ["/usr/bin/g++ -W -Wall -Werror *.cpp"],
   "working_dir": "${file_path}",
   "shell": true
}


Alternatively, you can explicitly call bash in the "cmd", or call a shell script.
jps
Site Admin
 
Posts: 3067
Joined: Wed Mar 19, 2008 12:33 pm

Re: Custom build : g++.sublime-build

Postby GMath on Tue Dec 13, 2011 7:46 pm

Thanks, works great :)
GMath
 
Posts: 13
Joined: Tue Dec 06, 2011 9:27 pm

Re: Custom build : g++.sublime-build

Postby adn on Sun Mar 18, 2012 12:06 am

I've made it possible to build and run with this:
{
"cmd": ["gcc -Wall ${file} -o ${file_base_name} && ./${file_base_name}"],
"working_dir": "${file_path}",
"shell": true
}

Thanks a lot!
adn
 
Posts: 5
Joined: Mon Mar 05, 2012 8:35 pm


Return to Technical Support

Who is online

Users browsing this forum: Exabot [Bot], Google [Bot], Yahoo [Bot] and 33 guests