Initial Commit
[packages] / xemacs-packages / ede / ede.texi
1 \input texinfo   @c -*-texinfo-*-
2 @c
3 @c $Id: ede.texi,v 1.1 2007-11-26 15:22:13 michaels Exp $
4 @c
5 @setfilename ede.info
6 @settitle Emacs Development Environment
7
8 @ifinfo
9 @format
10 START-INFO-DIR-ENTRY
11 * ede: (ede).       Objects for Emacs
12 END-INFO-DIR-ENTRY
13 @end format
14 @end ifinfo
15
16 @titlepage
17 @sp 10
18 @center @titlefont{ede}
19 @vskip 0pt plus 1 fill
20 Copyright @copyright{} 1998, 1999, 2000, 2001, 2004, 2005 Eric M. Ludlam
21 @end titlepage
22
23 @contents
24
25 @node top, EDE Project Concepts, (dir), (dir)
26 @comment  node-name,  next,  previous,  up
27
28 EDE is a collection of definitions called the 
29 @emph{Emacs Development Extensions}.  EDE provides the gloss that
30 simplifies the learning curve for all the very useful functionality of
31 building and debugging under emacs.  In doing so it attempts to emulate
32 a typical IDE (Integrated Development Environment).  What this means is
33 that EDE will manage or create your makefiles and other building
34 environment duties so the developer can concentrate on code, and not
35 support files.  In doing so, it will be much easier for new programmers
36 to learn and adopt the GNU ways of doing things.
37 @refill
38
39 @menu
40 * EDE Project Concepts::        EDE Project Concepts
41 * EDE Mode::                    Turning on EDE mode.
42 * Creating a project::          Creating a project.
43 * Modifying your project::      Adding and removing files and targets.
44 * Building and Debugging::      Initiating a build or debug session.
45 * Miscellaneous commands::      Other project related commands.
46 * Project types::               There are different types of projects.
47 * Extending EDE::               Programming tips when extending.
48 * Project::                     
49 * Targets::                     
50 * Sourcecode::                  
51 * Compilers::                   
52
53 @detailmenu
54  --- The Detailed Node Listing ---
55
56 Modifying your project
57
58 * Add/Remove target::           
59 * Add/Remove files::            
60 * Customize Features::          
61 * EDE Project Features::        
62
63 EDE Project Features
64
65 * Changing Compilers and Flags::  
66 * Configurations::              
67
68 Project types
69
70 * Make and Automake projects::  Project types of @samp{ede-project}
71 * Automake direct projects::    Project interface on hand-written automake files.
72
73 Extending EDE
74
75 * User interface methods::      Methods associated with keybindings
76 * Base project methods::        The most basic methods on EDE objects.
77 * Sourcecode objects::          Defining new sourcecode classes.
78 * Compiler and Linker objects::  Defining new compilers and linkers.
79
80 Class hierarchies
81
82 * Project    :: The different project types.
83 * Targets    :: The different target types.
84 * Sourcecode :: Source Code management types.
85 * Compilers  :: Compiler management types.
86
87 @end detailmenu
88 @end menu
89
90 @node EDE Project Concepts, EDE Mode, top, top
91 @chapter EDE Project Concepts
92
93 EDE is a generic interface for managing projects.  In other words,
94 there is one set of menus and keybindings specified by EDE, but there
95 are multiple ways a project can be expressed via a build system.
96
97 You can learn about multiple @ref{Project types}, or the specific
98 build or debug commands in other chapters.
99
100 In EDE, a project hierarchy matches a directory hierarchy.  There
101 would be a project root, and subprojects in different subdirectories.
102
103 Within each project, there can be multiple targets.  A target at the
104 simplest level is a named collection of files within a project.  There
105 are two important reasons for specifying a target.
106
107 @enumerate
108 @item
109 A collection of files to be added to a distribution.
110 @item
111 A collection of files that can be built into something else.
112 @end enumerate
113
114 If you intend to write code, and have it tarred up and distributed
115 under the GPL, all important files must be a part of some target so
116 that they will be added to the distribution file.
117
118 Targets that are lists of files that can be built into something else
119 will also be distributed, but the build process will also convert
120 those files into some specified built thing, such as a program or
121 compiled documentation.
122
123 Lastly, EDE provides a way for other tools to easilly learn file
124 associations.  For example, a program might need to restrict some sort
125 of search to files in a single target, or need to discover the
126 location of documentation or interface files.  EDE can provide this
127 information.
128
129 @node EDE Mode, Creating a project, EDE Project Concepts, top
130 @chapter EDE Mode
131
132 EDE is implemented as a minor-mode, which augments other modes such as C
133 mode, and Texinfo mode.  You can turn EDE on for all buffers by running
134 the command @code{global-ede-mode}, or by putting this in your
135 @file{~/.emacs} file.
136
137 @example
138 (require 'ede)
139 (global-ede-mode t)
140 @end example
141
142 When EDE is active for a given buffer, the menu item ``Project''
143 appears.  This menu contains several high-level functions to make
144 working on a code set easier.  These items and keybindings never change
145 regardless of the type of project you are actually working on.
146
147 The @file{ede.el} file is a minimal set of loading routines.  When
148 different types of projects are encountered, source code for those
149 projects are loaded at that time.
150
151 @node Creating a project, Modifying your project, EDE Mode, top
152 @chapter Creating a project
153
154 To create a new project, first load a file you would want in that
155 project into a buffer.  If you have a hierarchy of directories, choose
156 a file in the topmost directory first.  From this buffer, run
157 @command{ede-new}.
158
159 EDE can support several types of projects.  When creating a new
160 project with the command @command{ede-new} you must choose the type of
161 project you would like to create.  @xref{Project types}.
162
163 Each type has it's own benefits or language specific enhancements.  You
164 will be prompted for the type of project you would like to create.  The
165 simplest and most language agnostic project type is @emph{Make}.  A
166 derivation of this is the @samp{Automake} type.
167
168 Not all project types can be created in this way.  For example, there
169 are two ways to handle Automake based projects.  One is by making an
170 @emph{Automake} project with @command{ede-new}.  The other is to just write
171 some automake files which EDE with automatically detect this, and put
172 you into a different Automake mode.  Any GNU project using Automake
173 will be detected in this way, and you can use EDE to modify those
174 Makefiles for you.
175
176 @section Creating a subproject
177
178 A subproject is merely a project in a subdirectory of another project.
179 You can create a subproject by using the @command{ede-new} command (or
180 @samp{"Create Project"} from the menu) while a in a subdirectory below
181 an existing project.  This new project will be automatically added to
182 the parent project, and will be automatically loaded when the parent
183 is read.
184
185 When using a project command that invovles a makefile, EDE uses
186 the top-most project's makefile as a starting place for the build.  How
187 the toplevel project handles subprojects in the build process is
188 dependendent on that project's type.
189
190 @node Modifying your project, Building and Debugging, Creating a project, top
191 @chapter Modifying your project
192
193 Your project and targets are systems with lots of options.  Generic
194 features are listed here.  You will need to read sections on specific
195 project types for detailed information on the project you might be
196 using.
197
198 @menu
199 * Add/Remove target::           
200 * Add/Remove files::            
201 * Customize Features::          
202 * EDE Project Features::        
203 @end menu
204
205 @node Add/Remove target, Add/Remove files, Modifying your project, Modifying your project
206 @section Add/Remove target
207
208 A project with no targets isn't very useful, so you can use EDE to add
209 and remove targets from your project.
210
211 You can create a new target with the @command{ede-new-target} command
212 @kbd{C-c . t}.  If appropriate you will be given the option to add the
213 current buffer into the newly created target.
214
215 When creating a target, you will be given an option list of target
216 types.  Each target type will have its own build process and class of
217 files it will accept.
218
219 You can remove a target with the command @code{ede-delete-target}.
220
221 The add and remove commands are in the @samp{Project->Project Options}
222 menu.
223
224 @node Add/Remove files, Customize Features, Add/Remove target, Modifying your project
225 @section Add/Remove files
226
227 A target with no files isn't very useful, so you can use EDE to add
228 and remove files to targets.  Sometimes files can belong to multiple
229 targets, and that is ok.
230
231 You can add files into targets with the command @command{ede-add-file}
232 bound to @kbd{C-c . a}.   If there are no targets created that you
233 wish to use, you can type in @samp{new target} to create a new target
234 apropriate for the file you are adding.
235
236 You can remove files from a target with the @command{ede-remove-file}
237 bound to @kbd{C-c . d}.  If the file is in multiple targets, it will
238 query for every target it could be removed from.
239
240 When you are working in a project, if you load a new file into a
241 buffer that is not a part of an active target, EDE will automatically
242 remind you to add it to a target of your choosing.  If you do not wish
243 to add it to a target, you can choose @samp{none}.  You can customize
244 the behavior with the variable @command{ede-auto-add-method}.
245
246 @node Customize Features, EDE Project Features, Add/Remove files, Modifying your project
247 @section Customize Features
248
249 A project, and it's targets, are objects using the @samp{EIEIO} object
250 system. @xref{(eieio)EIEIO}.  These objects have data fields containing
251 important information related to your work.
252
253 If the high-level functions aren't enough, you can tweak all
254 user-customizable fields at any time by running the command
255 @command{customize-project} or @command{customize-target}.  This will
256 load the current project or target into a @emph{customization buffer}
257 where you tweak individual slots.  This is usually necessary for
258 project modes that are very complex.
259
260 Some project modes do not have a project file, but directly read a
261 Makefile, or existing file.  Instead of letting you directly edit the
262 object, you can edit the file.  Use the command
263 @command{ede-edit-file-target} bound to @kbd{C-c . e}.
264
265 @node EDE Project Features,  , Customize Features, Modifying your project
266 @section EDE Project Features
267
268 This section details user facing features of an EDE @samp{Make} style
269 project.  The specified options may be the same as in a
270 @samp{Automake} project, but are not the same as in an direct Automake
271 project.
272
273 To modify any of the specific features mentioned here, you need to
274 customize the project or target with @command{customize-project} or
275 @command{customize-target}.
276
277 When you are customizing, you are directly manipulating slot values in
278 EIEIO objects.  If you are interested in additional details, see
279 @ref{Extending EDE}
280
281 @menu
282 * Changing Compilers and Flags::  
283 * Configurations::              
284 @end menu
285
286 @node Changing Compilers and Flags, Configurations, EDE Project Features, EDE Project Features
287 @subsection Changing Compilers and Flags
288
289 Targets that build stuff need compilers.  To change compilers, you
290 need to customize the desired target.
291
292 In the @samp{[Make]} section, you can then choose a new compiler or
293 linker from the list.  If a linker you need is not available, you will
294 need to create a new one.  @ref{Compiler and Linker objects}.
295
296 If an existing compiler or linker is close, but you need to modify
297 some flag set such as adding an include path you will need to add a
298 configuration variable.
299
300 To start, you should create the basic setup, and construct a makefile
301 with @command{ede-proj-regenerate}.  Look in the @file{Makefile} to
302 see what commands are inserted.  Once you have determined the variable
303 you need to modify, you can add a configuration for it.
304 @ref{Configurations}.
305
306 @node Configurations,  , Changing Compilers and Flags, EDE Project Features
307 @subsection Configurations
308
309 Configurations specify different ways to build a project.  For
310 example, you may configure a project to be in ``debug'' mode, or
311 perhaps in ``release'' mode.
312
313 The project, and each target type all have a slot named
314 @code{configuration-variables}.  To add new variables to a
315 configuration find this slot in the custom buffer, and insert a new
316 configuration.  Name it either ``debug'' or ``release'', then insert
317 some number of name/value pairs to it.
318
319 You can have any number of valid configurations too.  To add a new
320 configuration, customize your project.  Work in the @samp{[Settings]}
321 block for ``configurations''.  Add a new named configuration here.
322
323 To switch between different active conifigurations, modify the
324 ``configuration default'' slot.
325
326 @node Building and Debugging, Miscellaneous commands, Modifying your project, top
327 @chapter Building and Debugging
328
329 EDE assumes you are writing some sort of program, so attempts to
330 facilitate this activity.  EDE will associate the current buffer with a
331 target.  The target then knows how to compile or debug the given source
332 file.
333
334 The following commands enable compilation and debugging.
335
336 @table @kbd
337 @item C-c . c
338 Compile the current target.
339 @item C-c . C
340 Compile the entire project.
341 @item c-c . D
342 Debug the current target.
343 @item ede-make-dist
344 Build a distribution file for your project.
345 @end table
346
347 These commands, plus project or target specific options are available
348 in the @samp{Project} menu.
349
350 @node Miscellaneous commands, Project types, Building and Debugging, top
351 @chapter Miscellaneous commands
352
353 @section Rescan
354
355 If you opt to go in and edit EDE project files directly, perhaps with
356 the @command{ede-edit-file-target}, you will need to have Emacs rescan
357 the project files to update the internal data structures.
358
359 Use @command{ede-rescan-toplevel} bound to @kbd{C-c . g} to refresh
360 your system.
361
362 @section Speedbar
363
364 EDE also supports the speedbar package.  While speedbar works great
365 against directories already, EDE provides a project display mode.
366 This lets you look at your source files as they are structured in your
367 project.  Thus, where many files may be clumped together in one
368 directory, the Project view will provide a hierarchical view of your
369 files as grouped by target.
370
371 You can activate speedbar in this mode with the command
372 @command{ede-speedbar}.  This is bound to @kbd{C-c . s}.
373
374 @node Project types, Extending EDE, Miscellaneous commands, top
375 @chapter Project types
376
377 There are two types of project modes currently.  One is
378 @samp{ede-project}, and shows up as @samp{Make} and @samp{Automake}
379 when creating new projects.
380
381 The other is project type handles automake projects directly from the
382 automake files.  EDE cannot make new projects of this type, assuming
383 the user will do it themselves.  Use @samp{ede-project} in
384 @samp{Automake} mode to have EDE create @file{Makefile.am} file, and a
385 @file{configure.in} file.
386 @refill
387
388 @menu
389 * Make and Automake projects::  Project types of @samp{ede-project}
390 * Automake direct projects::    Project interface on hand-written automake files.
391 @end menu
392
393 @node Make and Automake projects, Automake direct projects, Project types, Project types
394 @section Make and Automake projects
395
396 A project of @samp{ede-project} type creates a file called
397 @file{Project.ede} in every project directory.  This is used to track
398 your configureation information.  If you configure this project to be
399 in @samp{Makefile} mode, then this project will autogenerate a
400 @file{Makefile}.  If you configure it in @samp{Automake} mode a
401 @file{Makefile.am} file will be created.  The automake bootstrapping
402 routines will also improt and maintain a configure.am script and a
403 host of other files required by Automake.
404
405 @node Automake direct projects,  , Make and Automake projects, Project types
406 @section Automake direct projects
407
408 The project type that reads @file{Makefile.am} directly is derived
409 from the sources of the original @file{project-am.el} mode that was
410 distributed independently.  This mode eventually became EDE.  The
411 @samp{project-am} project will read existing automake files, but will
412 not generate them automatically, or create new ones.  As such, it is
413 useful as a browsing tool, or as maintenance in managing file lists.
414
415 @node Extending EDE, Project, Project types, top
416 @chapter Extending EDE
417
418 This chapter is intended for users who want to write new parts or fix
419 bugs in EDE.  A knowledge of Emacs Lisp, and some EIEIO(CLOS) is
420 required.
421
422 EDE's dependance on EIEIO, the CLOS package for Emacs lets EDE define
423 two object superclasses, specifically the PROJECT and TARGET.  All
424 commands in EDE are usually meant to address the current project, or
425 current target.
426
427 All specific projects in EDE derive subclasses of the EDE superclasses.
428 In this way, specific behaviors such as how a project is saved, or how a
429 target is compiled can be customized by a project author in detail.  EDE
430 communicates to these project objects via an API using methods.  The
431 commands you use in EDE mode are high-level functional wrappers over
432 these methods.  For details on different types of projects,
433 @ref{Project types}.  @ref{(eieio)Top}. For details on using EIEIO to
434 extending classes, and writing methods.
435
436 If you intend to exted EDE, it is most likely that a new target type is
437 needed in one of the existing project types.  The rest of this chapter
438 will discuss extending the @code{ede-project} class, and it's targets.
439 See @file{project-am.el} for basic details on adding targets to it.
440
441 For the @code{ede-project} type, the core target class is called
442 @code{ede-proj-target}.  Inheriting from this will give you everything
443 you need to start, including adding your sources into the makefile.  If
444 you also need additional rules in the makefile, you will want to inherit
445 from @code{ede-proj-target-makefile} instead.  You may want to also add
446 new fields to track important information.
447
448 If you are building currently unsuported code into a program or shared
449 library, it is unlikely you need a new target at all.  Instead you
450 would need to create a new compiler or linker object that compiles
451 source code of the desired type. @ref{Compiler and Linker objects}.
452
453 Once your new class exists, you will want to fill in some basic methods.
454 See the @file{ede-skel.el} file for examples of these.  The files
455 @file{ede-proj-info.el} and @file{ede-proj-elisp.el} are two interesting
456 examples.
457
458 @menu
459 * User interface methods::      Methods associated with keybindings
460 * Base project methods::        The most basic methods on EDE objects.
461 * Sourcecode objects::          Defining new sourcecode classes.
462 * Compiler and Linker objects::  Defining new compilers and linkers.
463 @end menu
464
465 @node User interface methods, Base project methods, Extending EDE, Extending EDE
466 @section User interface methods
467
468 These methods are core behaviors associated with user commands.
469 If you do not implement a method, there is a resonable default that
470 may do what you need.
471
472 @table @code
473 @item project-add-file
474 Add a file to your project.  Override this if you want to put new
475 sources into different fields depending on extension, or other details.
476 @item project-remove-file
477 Reverse of project-add-file.
478 @item project-compile-target
479 Override this if you want to do something special when the user
480 "compiles" this target.
481 @item project-debug-target
482 What to do when a user wants to debug your target.
483 @item project-update-version
484 Easily update the version number of your project.
485 @item project-edit-file-target
486 Edit the file the project's information is stored in.
487 @item project-new-target
488 Create a new target in a project.
489 @item project-delete-target
490 Delete a target from a project.
491 @item project-make-dist
492 Make a distribution (tar archive) of the project.
493 @item project-rescan
494 Rescan a project file, changing the data in the existing objects.
495 @end table
496
497 @node Base project methods, Sourcecode objects, User interface methods, Extending EDE
498 @section Base project methods
499
500 These methods are important for querying base information from project
501 and target types:
502
503 @table @code
504 @item ede-name
505 Return a string that is the name of this target.
506 @item ede-target-name
507 Return a string that is the name of the target used by a Make system.
508 @item ede-description
509 A brief description of the project or target.  This is currently used
510 by the @samp{ede-speedbar} interface.
511 @item ede-want-file-p
512 Return non-nil if a target will accept a given file.
513 It is generally unecessary to override this.  See the section on source
514 code.
515 @item ede-buffer-mine
516 Return non-nil if a buffer belongs to this target.  Used during
517 association when a file is loaded.  It is generally unecessary to
518 override this unless you keep auxilliary files.
519 @end table
520
521 These methods are used by the semantic package extentions @xref{(semantic)Top}.
522
523 @table @code
524 @item ede-buffer-header-file
525 Return a header file belonging to a given buffer.  Prototypes are place
526 there when appropriate
527 @item ede-buffer-documentation-files
528 Return the documentation file information about this file would be
529 stored in.
530 @item ede-documentation
531 List all documentation a project or target is responsible for.
532 @end table
533
534 @node Sourcecode objects, Compiler and Linker objects, Base project methods, Extending EDE
535 @section Sourcecode objects
536
537 EDE projects track source file / target associates via source code
538 objects.  The definitions for this is in @file{ede-source.el}.  A source
539 code object contains methods that know how to identify a file as being
540 of that class, (ie, a C file ends with @file{.c}).  Some targets can
541 handle many different types of sources which must all be compiled
542 together.  For example, a mixed C and C++ program would have
543 instantiations of both sourcecode types.
544
545 When a target needs to know if it will accept a source file, it
546 references its list of source code objects.  These objects then make
547 that decision.
548
549 Source code objects are stored in the target objects as a list of
550 symbols, where the symbol's value is the object.  This enables the
551 project save file mechanism to work.
552
553 Here is an example for an instantiation of an Emacs Lisp source code object:
554
555 @example
556 (defvar ede-source-emacs
557   (ede-sourcecode "ede-emacs-source"
558                   :name "Emacs Lisp"
559                   :sourcepattern "\\.el$"
560                   :garbagepattern '("*.elc"))
561   "Emacs Lisp source code definition.")
562 @end example
563
564 If you want to recycle parts of an existing sourcecode object, you can
565 clone the original, and then just tweak the parts that are different.
566 For example:
567
568 @example
569 (defvar ede-source-emacs-autoload
570   (clone ede-source-emacs "ede-source-emacs-autoload"
571          :name "Emacs Lisp Autoload"
572          :sourcepattern "-loaddefs\\.el")
573   "Emacs Lisp autoload source code.")
574 @end example
575
576 In this case, the garbage pattern is the same.
577
578 @xref{Sourcecode}.
579
580 @node Compiler and Linker objects,  , Sourcecode objects, Extending EDE
581 @section Compiler and Linker objects
582
583 In order for a target to create a @file{Makefile}, it must know how to
584 compile the sources into the program or desired data file, and
585 possibly link them together.
586
587 A compiler object instantiation is used to associate a given target
588 with a given source code type.  Some targets can handle many types of
589 sources, and thus has many compilers available to it.  Some targets
590 may have multiple compilers for a given type of source code.
591
592 EDE will examine the actual source files in a target, cross reference
593 that against the compiler list to come up with the final set of
594 compilers that will be inserted into the Makefile.
595
596 Compiler instantiations must also insert variables specifying the
597 compiler it plans to use, in addition to creating Automake settings for
598 @file{configure.in} when appropriate.
599
600 Compiler objects are stored in the target objects as a list of
601 symbols, where the symbols value is the object.  This enables the
602 project output mechanism to work more efficiently.
603
604 Targets will also have a special "compiler" slot which lets a user
605 explicitly choose the compiler they want to use.
606
607 Here is an example for texinfo:
608
609 @example
610 (defvar ede-makeinfo-compiler
611   (ede-compiler
612    "ede-makeinfo-compiler"
613    :name "makeinfo"
614    :variables '(("MAKEINFO" . "makeinfo"))
615    :commands '("makeinfo -o $@ $<")
616    :autoconf '(("AC_CHECK_PROG" . "MAKEINFO, makeinfo"))
617    :sourcetype '(ede-makeinfo-source)
618    )
619   "Compile texinfo files into info files.")
620 @end example
621
622 @xref{Compilers}.
623
624 When creating compiler instatiations, it may be useful to @code{clone}
625 an existing compiler variable.  Cloning allows you to only modify
626 parts of the original, while keeping the rest of the same.
627 Modification of the original will result in the clone also being
628 changed for shared value slots.
629
630 The second important object is the linker class.  The linker is similar
631 to the compiler, except several compilers might be used to create some
632 object files, and only one linker is used to link those objects together.
633
634 See @file{ede-proj-obj.el} for examples of the combination.
635
636 @section Class hierarchies
637
638 @menu
639 * Project    :: The different project types.
640 * Targets    :: The different target types.
641 * Sourcecode :: Source Code management types.
642 * Compilers  :: Compiler management types.
643 @end menu
644
645 @defindex pj
646 @defindex tg
647 @defindex sc
648 @defindex cm
649
650 @node Project, Targets, Extending EDE, top
651 @chapter Project
652
653 @include ede-projects.texi
654
655 @node Targets, Sourcecode, Project, top
656 @chapter Targets
657
658 @include ede-targets.texi
659
660 @node Sourcecode, Compilers, Targets, top
661 @chapter Sourcecode
662
663 The source code type is an object designed to associated files with
664 targets.
665
666 @include ede-sourcecode.texi
667
668 @node Compilers,  , Sourcecode, top
669 @chapter Compilers
670
671 The compiler object is designed to associate source code with
672 compilers.  The target then references the compilers it can use.
673 When the makefile is created, this object type knows how to create
674 compile commands.
675
676 @include ede-compilers.texi
677
678 @bye