Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Moles

macrumors newbie
Original poster
Jul 9, 2009
20
0
Olathe
So I am grading papers written for linux in c++. I want to figure out a cool way to compile the programs (.cpp files) from the finder. I was thinking there has to be a way to use Automator to control click the .cpp file and create an object always named test. There probably won't be much linking right now, just standard libs. I just figured that I am spending a lot of time using terminal and figured someone either knows how to do the g++ <filename> -o test command with a service and might be able to help me. I have never used Automator yet so any help is appreciated.

Thanks in advance.
 
This seems like a good time for make. Are the source files always the same name? Otherwise, it should be easy to make a shell script:
Code:
g++ -o test $1
./test

should work to build and run, just pass the name of the source file to the script. I don't know that automator is going to do too much for you.

-Lee
 
This seems like a good time for make. Are the source files always the same name? Otherwise, it should be easy to make a shell script:
Code:
g++ -o test $1
./test

should work to build and run, just pass the name of the source file to the script. I don't know that automator is going to do too much for you.

-Lee

The reason I want Automator, is so I can use the context menu services to run the compile operation. I don't have problems running it in terminal. The structure the Professor sends me is a folder for each student, and in that student directory is the source file. I was just hoping someone had run into something like this and made a service to run the essentially shell script.
 
The reason I want Automator, is so I can use the context menu services to run the compile operation. I don't have problems running it in terminal. The structure the Professor sends me is a folder for each student, and in that student directory is the source file. I was just hoping someone had run into something like this and made a service to run the essentially shell script.

So I got this created, sort of. I added two modules, the first is get selected finder file or folder and the second is run a shell script where I pass the file as a variable to the shell script. Works great with two caviats that I am hoping to get help for.

#1: is there a way in automator to restrict the service to only running when say a .cpp file is selected in finder?

#2 the output is always getting put at root, I want the output to go into the current folder. Is there a way to get the folder portion from the file variable that is passed in automator?

Once I get this completed I will find somewhere to post it for anyone else who has this need. Thanks in advance for the help.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.