home *** CD-ROM | disk | FTP | other *** search
- Henrik Nordstroms compiler-interface for Edge, a quick description
-
- This compiler-interface is build up by a collection of ARexx-macros
- for Edge, and includes the following features:
-
- * Automatic errorparsing
- * Easy compiling of single sourcefiles
- * Easy handling of multiple sourcefile-projects using makefiles
- * Adding of prototypes to C-file
- * Calling of GNU-Indent on a file in Edge
-
- As of this writing, this set of scripts only supports SAS/C (version 5 and 6)
- but it's quiet easy to add support for other compilers.
- see section 3.4 for SAS/C dependencies, and section 4 for information
- about how to write your own errorparsers.
-
- ********** File Contents ************
- 1 Installing
- 2 Quick tutorial
- 1. Single sourcefile
- 2. Project with makefile
- 3 Special hints
- 1. Working with multiple projects at the same time
- 2. Some changes to the menu, to make lift easier
- 3. Default compiler-interface options
- 4. Use this interface without SAS/C 5.10
- 5. Customizing the default_project for hn_newproject
- 6. ECHO: handler
- 7. Specialstrings in linkoptions
- 8. String-requesters in Edge...
- 4 Including new Languages
- 5 Example menu (se install directory for file version)
- 6 Local user variables usage
- 7 ARexx Macros
- 8 Copyright notices
- 9 Where I can be reached, if you have any questions
-
- 1********** Installing *************
-
- 1. Install CompilerInterface
- It's most easily done by the install-script, but here is a brief
- desctription on how to do it manually.
- 1. Copy rexx-files to REXX: directory
- 2. include compiler-menu in edgeprg:edge.menu
- 3. Install ECHO-handler
- 2. Se special-hints in this document (3.2 and 3.3)
-
- 2********** Quick tutorial ********** (SAS/C 6.x)
-
- 2.1 Single sourcefile
-
- 1 Enter a small c-program, and name it
- ex) test.c
- #include <stdio.h>
- void main()
- {
- printf("Hello world\n");
- }
- 2 select "Compiler » Options"
- enter LINK
-
- 3 Select "Compiler » Link Options"
- press Amiga-X OK for default (see section 3.3, 3.7 and hn_compile
- for more detailed description)
-
- 4 Select "Compile & link" from compiler-menu
-
- 5. Select "Execute" from Compiler-part of Compiler-menu
-
- If errors should occur during step 4, press CANCEL on the requester
- that tells you "nn errors found in xxxx.c" and press "RAmiga-shift-j" to
- jump to the errors in the source-file.
-
- 2.2 Project with makefile
- 1 Select "Project » New project" from compiler-menu to create a
- project directory.
-
- 2 Create some sourcefiles
- ex)
-
- test1.c:
- extern void test(void);
- void main()
- {
- test();
- }
-
- test2.c:
- #include <stdio.h>
- void test(void)
- {
- printf("Hello world!\n");
- }
-
- 3 Select "project » Edit project" from compiler-menu to create a
- makefile (hn_editproject), se also Hints section
-
- ex) (1 TAB before all commands...)
- test: test1.o test2.o
- slink lib:c.o test1.o test2.o to test lib lib:sc.lib
- test1.o: test1.c
- sc test1.c
- test2.o: test2.c
- sc test2.c
-
- 4 Select "Build" from compiler-menu (hn_build)
- 5 Select "Execute" from project-part of compiler-menu
- (hn_runproject)
-
- If errors should occur during step 4, press OK on the requester
- that tells you "nn errors found in xxxx.c" and press "RAmiga-shift-j" to
- jump to the errors found in this source-file.
- If errors occured in some other sourcefile, load the failing sourcefile
- and select "Project » Read errors"
-
- 3*********** Special hints ************
-
- 3.1 It's possible to work on multiple project simoultainuos, just load
- sourcefiles from the different projects and off you go :).
- All project-information is kept in a local user-variable (_fe_User9)
- and local user-variables is stored in the icon-information when
- the file is saved. (This means that it's not neccesary to select a
- project before working whith it..)
-
- 3.2 Change the new-command in "Open New" and "Open New File" to
- new COPYLS, otherwise all compiler/project information is cleared
- (restored to default...) when starting a new file
-
- ex) (From my menu.. keymap S )
- ITEM "Open New" KEY="?" Q="RCommand" QM="Shift" COMMAND new COPYLS
- ; Special Open New File... Open requester before open window
- ITEM "Open New File..." KEY="+" Q="RCommand" QM="Shift" COMMAND 'options results;getenvvar _fe_path;filepath=result;getenvvar _fe_name;filename=result;requestfile TITLE """Open new file""" PATH """"filepath"""" FILE """"filename"""" SAVE;if RC==0 then do;filename=result;new COPYLS;address value result;open """"filename"""";putenvvar _fe_dosname """"filename"""";end;exit'
-
- 3.3 Select some default-options before Localsettings->Save
- ex) Compiler » Options
- <empty> (Press Amiga-X OK)
- Compiler » Link Options
- <empty> (Press Amiga-X OK)
- this will give you something like
- "lib:c.o $* to $@ LIB lib:sc.lib lib:amiga.lib" and it automatically
- adjust for any "linker" options
- Compiler » Outputdir
- <empty> (Press Amiga-X OK)
- Env » Local Settings » Save
-
- Now you always have those settings if you don't specify anything
- else.
-
- 3.4 To use this compiler-interface without SAS/C, those files has
- to be changed according to your compiler:
-
- hn_newproject: change SASCSETUP to what you require to create
- a new project-directory (SASCSETUP creates a new
- directory if it not exists, and copies files from
- sc:starter_project, without disturbing existing files)
- hn_compile_c.edge: compilercaller, see hn_compile_c_sc*.edge
- hn_readerr_c.edge: errorparser, see hn_readerr_c_sc*.edge
- hn_addprotos.edge: Change compiler-call for prototype generation
- hn_runproject: Change cpr to your favorite debugger
- hn_runcompiled: Change cpr to your favorite debugger
-
- 3.5 To customize default-project for hn_newproject
- change/add files in sc:starter_project
-
- ex) Add the following: (se install-directory for file-version)
-
- makefile: 1 TAB before all commands.. $(CC) $(ASM) $(LINK)
- # Makefile for project
-
- # Change this to the main file name (whitout ext)
- # This is also the name of the executable file
- MAIN=
-
- # Add .o files for all other sourcefiles after $(MAIN).o
- # Ex) if graphics.c is one subpart of the project:
- # OBJFILES=lib:c.o $(MAIN).o graphics.o
- OBJFILES=lib:c.o $(MAIN).o
-
- # Default linker-libraries
- # add lib:scm.lib before lib:sc.lib if using math..
- LINKLIBS=lib:sc.lib lib:amiga.lib
-
- # C-compiler
- CC=SC
- CFLAGS =
-
- # Assembler
- ASM=asm
- AFLAGS= -iinclude:
-
- # Linker
- LINK=slink
-
- #Default rules
- # C source files (.c -> .o)
- .c.o:
- $(CC) $(CFLAGS) $*.c
- # ASM source files ( .a .s .asm -> .o)
- .a.o:
- $(ASM) $(AFLAGS) -o$*.o $*.a
- .s.o:
- $(ASM) $(AFLAGS) -o$*.o $*.s
- .asm.o:
- $(ASM) $(AFLAGS) -o$*.o $*.asm
-
- # Use defaultrules for compiling... then link
- $(MAIN): $(OBJFILES)
- $(LINK) $(OBJFILES) TO $(MAIN) LIB $(LINKLIBS)
-
- #Special rules:
- #destination: dependency-files
- # compile-command(s)
- #Ex (sound.c -> sound.o, recompile if sound.c or sound.h is changed)
- #sound.o: sound.c sound.h
- # $(CC) $(CFLAGS) -y -b0 sound.c
-
- Using this makefile, it's quite easy to start a simple project, just
- enter main-filename after MAIN= and add ojectfiles for all other
- sourcefiles after OBJFILES=$(MAIN).o (On the same line)
-
- 3.6 ECHO: is a generic handler, not specifically written for this compiler-
- interface, and might be used/rewritten as you whish.. source is included.
- see EchoHandler directory.
-
- 3.7 Linkoptions has some special-strings to make life easier
- <empty> -> use default, wich varies according to some compiler-flags
- standard: "lib:c.o $* to $@ LIB lib:sc.lib lib:amiga.lib"
- highly recomended! just set compileroptions as usual,
- and off you go... (Compile/Compile&link)
- SAS/C 5.10 flags implemented: -L -b -r -w
- is SAS/C 6.x this is the same as AUTO linking...
- AUTO -> Use compiler-builtin linking if aviable
- Not recomended together with SAS/C 5.10... *.lmk (with-file
- for blink) is created in source-directory, not in current
- directory as the documentation states... which means that
- the *.lmk file will pop up as a window in Edge
- Works very well with SAS/C 6.x
- $* -> objectfile (same as $@.o or $$.o)
- $@ -> filename without .ext
- ex) If your file is dh0:source/test.c and outputdir is ram: then
- $* is replaced with ram:test.o
- $@ is replaced with ram:test
-
- 3.8 Edge:s string-requesters are is bit odd...
- To enter <nothing> you have to clear the requester, and then press
- the OK-gadget, if you press Enter as usual it's almost the same as
- pressing the Cancel-gadget...
- This "Feature" has effect on "Compiler » Options",
- "Compiler » Link Options" and "Indent Options » Custom"
- To clear the gadget you HAVE to press OK!
-
- 4******* Including new Languages ******
-
- This requires some knowledge in ARexx...
-
- 1. Write a caller script, hn_compile_<filetype>.edge
- The caller script is responsible for calling the compiler and for
- adjusting linktoptions according to link affecting compilerflags.
- it also calls the errorparser.
- if everything OK, return new linkoptions,
- if error, return numeric errorcode.
- see hn_compile_*.edge
-
- 2. Write a errorparser for errors, se hn_readerr_*.edge
-
- 5************ Example menu ************
-
- MENU Compiler
- MENU "Project"
- ITEM "Select project..." COMMAND hn_projectsettings PROJECT
- ITEM "Select sub-project..." COMMAND hn_projectsettings SUBPROJECT
- ITEM "New project..." COMMAND hn_projectsettings NEW
- ITEM "Edit project" COMMAND hn_projectsettings EDIT
- ITEM "Read errors" COMMAND hn_readerr PROJECT
- ITEM "Arguments..." COMMAND hn_projectsettings ARGUMENTS
- ITEM "Debug" COMMAND hn_runproject DEBUG
- ENDMENU
- ITEM "Build" COMMAND hn_build
- ITEM "Execute" COMMAND hn_runproject RUN
- BAR
- MENU "Compiler"
- ITEM "Options..." COMMAND hn_compilesettings COMPILER
- ITEM "Link options..." COMMAND hn_compilesettings LINK
- ITEM "Output dir..." COMMAND hn_compilesettings OUTDIR
- ITEM "Read errors" COMMAND hn_readerr COMPILE
- ITEM "Link" COMMAND hn_compile LINKONLY
- ITEM "Arguments..." COMMAND hn_compilesettings ARGUMENTS
- ITEM "Debug" COMMAND hn_runcompiled DEBUG
- ENDMENU
- ITEM "Compile" COMMAND hn_compile COMPLIE
- ITEM "Compile & link" COMMAND hn_compile LINK
- ITEM "Execute" COMMAND hn_runcompiled RUN
- BAR
- ITEM "Add prototypes" COMMAND hn_addprotos
- ITEM "Indent" COMMAND hn_IndentCFile
- MENU " options"
- ITEM " -kr" COMMAND hn_IndentCFile -kr
- ITEM " -gnu" COMMAND hn_IndentCFile -gnu
- ITEM " -orig" COMMAND hn_IndentCFile -orig
- ITEM "custom..." COMMAND hn_IndentOptions
- ENDMENU
- ENDMENU
-
- 6******** Local user variables ********
-
- Miscalenous:
- _FE_User7 indentoptions
-
- "Single-file" compiling:
- _FE_User8 compilerflags,linkoptions,outputdir,argumentline
-
- Project-handling:
- _FE_User9 ProjectDirectory,argumentline
-
- 7************ ARexx Macros ************
-
- hn_build Build current project
- hn_projectsettings Change project settings/create project
- hn_runproject Execute/Debug project
-
- hn_compile Compile current file
- hn_compilesettings Change compilation settings
- hn_runcompiled Run/Debug compiled file
-
- hn_readerr Parse errors for this file
-
- hn_IndentCFile Run GNU-Indent on current file
- hn_IndentOptions Select GNU-Indent options
- hn_AddProtos Add prototypes to SAS/C file
-
- --------- Project handling ----------
- Edge macro: hn_Build
- Usage: hn_build
- Synopsis: Build current project
-
- Edge macro: hn_ProjectSettings
- Usage: hn_projectsettings PROJECT|SUBPROJECT|ARGUMENTS|EDIT|NEW
- PROJECT : Select main project
- SUBPROJECT : Select sub project
- ARGUMENTS : Select arguments used when running program
- EDIT : Edit project makefile
- NEW : Create a NEW project
-
- Edge macro: hn_runproject
- Usage: hn_runproject [RUN|DEBUG]
- Synopsis: Run/Debug selected project
-
-
- ------ "Single-file" compiling ------
-
- Edge macro: hn_compile
- Usage: hn_compile [COMPILE|LINK|LINKONLY]
- COMPILE Compile file
- LINK Compile & link file
- LINKONLY Only link file
- Synopsis: Compile, and optionally link current file
- Special-strings in linkoptions:
- <empty> -> Automatically adjust according to compiler-flags
- AUTO -> Use compilers builtin linking instead
- $* -> objectfile (same as $@.o)
- $@ -> output filename (outdir+filename without .ext)
-
- Edge macro: hn_compilesettings
- Usage: hn_compileoptions [COMPILER|OUTDIR|LINK|ARGUMENTS]
- Synopsis: Change settings for hn_compile
-
- Edge macro: hn_rumcompiled
- Usage: hn_runcompiled [RUN|DEBUG]
- Synopsis: Run/Debug compiled program
-
- ----------- Error Parsing -----------
-
- Edge macro: hn_readerr
- Usage: hn_readerr [<errorfile>|PROJECT|COMPILE],[<filename>],[0|1|LINK]
- <errorfile> : read errors from errorfile
- PROJECT : read errors from current project-errorfile
- COMPILE : read errors from current compile-errorfile
- <filename> : source-filename
- LINK : Supress requesters if all OK..
- Default : COMPILE,<currentfile>,0
- Synopsis: Select errorfile and parser according to current filename
- and arguments.
-
- ----------- Miscalenous ------------
-
- Edge macro: hn_IndentCFile
- Usage: hn_IndentCFile
- Synopsis: Run GNU-Indent on current file
-
- Edge macro: hn_indentoptions
- Usage: hn_indentoptions
- Synopsis: select GNU-Indent options
-
- Edge macro: hn_addprotos
- Usage: hn_addprotos
- Synopsis: Add prototypes to SAS/C file
- (at cursor, if not done before)
-
- ----------- INTERNAL ----------------
- hn_compile_c.edge Call C compiler
- hn_compile_asm.edge Call ASM compiler
- hn_readerr_c.edge Parse C errors
- hn_readerr_asm.edge Parse ASM errors
- hn_createproject.edge Create a new project directory
- hn_link.edge Call linker
-
- 8********* Copyright Notes: *********
-
- Henrik Nordstroms Compiler Interface for Edge is ©1991-1992 Henrik Nordström
- It might be distributed together with Edge or througth any of the
- Public Domain channels or uploaded to BBS:es, but except for distribution
- together whith Edge, no fee except P&P (up to 5US$) is allowed.
-
- SAS and SAS/C are registered trademarks in the USA of
- SAS Institute Inc., Cary, NC, USA
- Lattice is a registered trademark of Lattice, Inc.
- LMK is a registered trademark of Lattice, Inc.
- cpr is SAS/C CodePRrobe source debugger, © SAS Institure Inc.
-
- 9*********** Where I can be reached *************
- E-Mail:
- sp2henno@obelix.his.se
-
- Mail:
- Henrik Nordström
- Ängsvägen 1
- s-756 45 Uppsala
-
- Phone:
- +46-(0)500-484896
-