28

I am new to eclipse and wanted to do the following:

  1. Use my custom build commands with eclipse. Until now I only saw make all. I use a shell script for building my project; how can I use that in an Eclipse environment?
  2. When I create a new project with the existing source code, it doesn't add the files, without building the code and if code fails to build (because I generally don't have make all).

How do I resolve this issue?

Jeff Bowman
  • 90,959
  • 16
  • 217
  • 251
Viks
  • 760
  • 4
  • 12
  • 26

5 Answers5

26

You can add a custom builder in the "Builders" category of the project properties.

project->properties->builders->new

there you can also deactivate the default eclipse builders..

hope that helped

fasseg
  • 17,504
  • 8
  • 62
  • 73
13

In addition to what smeg4brains said and assuming that you are using the CDT plugin you can go to:

project -> properties -> C/C++ Build

Uncheck Use default build command on the Builder Settings tab and replace make with e.g. scons.

On the Behaviour tab you can then specify the target to call for the Build and Clean phase.

To resolve your second issue open the Project menu and uncheck Build automatically. This will prevent Eclipse from building the project when it thinks it is necessary.

MKroehnert
  • 3,637
  • 2
  • 34
  • 43
  • 2
    Doesn't solve my issue. I need to do something like this ./build.sh ARGC1 ARGC2 – Viks Jun 04 '10 at 19:15
  • 7
    That is exactly what you can do if you follow my description. Use `${workspace_loc:/YOUR_PROJ/build.sh}` instead of the `make` command and replace the `Build` flag `all` with `ARGC1 ... ARGCN` on the behaviour tab. That is how I use custom build scripts instead of using make. – MKroehnert Jun 04 '10 at 20:19
  • how would you manage build configurations and integrate with debugger? – mert inan Jun 11 '12 at 15:30
  • Run/Debug configurations are independent from how your project is actually build. You deal with them same way as you would do it with the default build configuration. – MKroehnert Jun 12 '12 at 08:46
  • 2
    I unchecked "Use default build command", and in the build command, I fill in the path to my .sh file: "${workspace_loc:/SampleApp}/build_native.sh", when I run the build, eclipse print the correct full path to the file on the console, but the file is never executed... any idea why? I'm on eclipse helios on OSX 10.7 – Zennichimaro Apr 24 '13 at 10:23
  • 1
    Maybe the executable Bits are not set on your script file. – MKroehnert Apr 24 '13 at 11:09
4

If you want to add other your own commands then the easiest way is to write Ant file for your project so by clicking once you can execute all your commands.To see how to write Ant file click here

Rupeshit
  • 1,476
  • 1
  • 14
  • 23
1

I was able to do something similar to have protoc run on my .proto files. I did it by adding a "Make Target" to the project.

Dave Johansen
  • 889
  • 1
  • 7
  • 23
0

A lot of stuff in Eclipse you can get around using Ant, which are XML scripts, and there is also a ANT project builder which uses those. If you don't like to mess with frankly quite touchy GUI options, just write a build.xml and use ANT build as the project builder.

Ate Somebits
  • 287
  • 1
  • 18