home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / EDGE1_704.DMS / in.adf / ExtraStuff / Edge_SasC.lha / compilerinterface.txt < prev    next >
Encoding:
Text File  |  1993-08-19  |  14.7 KB  |  431 lines

  1. Henrik Nordstroms compiler-interface for Edge, a quick description
  2.  
  3. This compiler-interface is build up by a collection of ARexx-macros
  4. for Edge, and includes the following features:
  5.  
  6. * Automatic errorparsing
  7. * Easy compiling of single sourcefiles
  8. * Easy handling of multiple sourcefile-projects using makefiles
  9. * Adding of prototypes to C-file
  10. * Calling of GNU-Indent on a file in Edge
  11.  
  12. As of this writing, this set of scripts only supports SAS/C (version 5 and 6)
  13. but it's quiet easy to add support for other compilers.
  14. see section 3.4 for SAS/C dependencies, and section 4 for information
  15. about how to write your own errorparsers.
  16.  
  17. ********** File Contents ************
  18.  1 Installing
  19.  2 Quick tutorial
  20.    1. Single sourcefile
  21.    2. Project with makefile 
  22.  3 Special hints
  23.    1. Working with multiple projects at the same time
  24.    2. Some changes to the menu, to make lift easier
  25.    3. Default compiler-interface options
  26.    4. Use this interface without SAS/C 5.10
  27.    5. Customizing the default_project for hn_newproject
  28.    6. ECHO: handler
  29.    7. Specialstrings in linkoptions
  30.    8. String-requesters in Edge...
  31.  4 Including new Languages
  32.  5 Example menu (se install directory for file version)
  33.  6 Local user variables usage
  34.  7 ARexx Macros
  35.  8 Copyright notices
  36.  9 Where I can be reached, if you have any questions
  37.  
  38. 1**********  Installing *************
  39.  
  40.  1. Install CompilerInterface
  41.     It's most easily done by the install-script, but here is a brief
  42.     desctription on how to do it manually.
  43.     1. Copy rexx-files to REXX: directory
  44.     2. include compiler-menu in edgeprg:edge.menu
  45.     3. Install ECHO-handler
  46.  2. Se special-hints in this document (3.2 and 3.3)
  47.  
  48. 2********** Quick tutorial ********** (SAS/C 6.x)
  49.  
  50. 2.1 Single sourcefile
  51.  
  52.    1 Enter a small c-program, and name it
  53.        ex) test.c
  54.          #include <stdio.h>
  55.          void main()
  56.          {
  57.            printf("Hello world\n");
  58.          }
  59.    2 select "Compiler » Options"
  60.      enter LINK
  61.            
  62.    3 Select "Compiler » Link Options"
  63.      press Amiga-X OK for default (see section 3.3, 3.7 and hn_compile
  64.      for more detailed description)
  65.     
  66.    4 Select "Compile & link" from compiler-menu
  67.   
  68.    5. Select "Execute" from Compiler-part of Compiler-menu
  69.  
  70.   If errors should occur during step 4, press CANCEL on the requester
  71.   that tells you "nn errors found in xxxx.c" and press "RAmiga-shift-j" to
  72.   jump to the errors in the source-file.
  73.  
  74. 2.2 Project with makefile
  75.    1 Select "Project » New project" from compiler-menu to create a
  76.      project directory.
  77.      
  78.    2 Create some sourcefiles
  79.       ex)
  80.   
  81.       test1.c:
  82.         extern void test(void);
  83.         void main()
  84.         {
  85.          test();
  86.         }
  87.     
  88.       test2.c:
  89.         #include <stdio.h>
  90.         void test(void)
  91.         {
  92.          printf("Hello world!\n");
  93.         }
  94.  
  95.    3 Select "project » Edit project" from compiler-menu to create a
  96.      makefile (hn_editproject), se also Hints section
  97.      
  98.      ex) (1 TAB before all commands...)
  99.      test: test1.o test2.o
  100.              slink lib:c.o test1.o test2.o to test lib lib:sc.lib
  101.      test1.o: test1.c
  102.              sc test1.c
  103.      test2.o: test2.c
  104.              sc test2.c
  105.  
  106.    4 Select "Build" from compiler-menu (hn_build)
  107.    5 Select "Execute" from project-part of compiler-menu
  108.      (hn_runproject)
  109.      
  110.   If errors should occur during step 4, press OK on the requester
  111.   that tells you "nn errors found in xxxx.c" and press "RAmiga-shift-j" to
  112.   jump to the errors found in this source-file.
  113.   If errors occured in some other sourcefile, load the failing sourcefile
  114.   and select "Project » Read errors"
  115.  
  116. 3*********** Special hints ************
  117.  
  118. 3.1 It's possible to work on multiple project simoultainuos, just load
  119.     sourcefiles from the different projects and off you go :).
  120.     All project-information is kept in a local user-variable (_fe_User9)
  121.     and local user-variables is stored in the icon-information when
  122.     the file is saved. (This means that it's not neccesary to select a
  123.     project before working whith it..)
  124.  
  125. 3.2 Change the new-command in "Open New" and "Open New File" to
  126.     new COPYLS, otherwise all compiler/project information is cleared
  127.     (restored to default...) when starting a new file
  128.  
  129.    ex) (From my menu.. keymap S )
  130.     ITEM "Open New"         KEY="?" Q="RCommand" QM="Shift" COMMAND new COPYLS
  131.     ; Special Open New File... Open requester before open window
  132.     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'
  133.  
  134. 3.3 Select some default-options before Localsettings->Save
  135.    ex) Compiler » Options
  136.          <empty> (Press Amiga-X OK)
  137.        Compiler » Link Options
  138.          <empty> (Press Amiga-X OK)
  139.          this will give you something like
  140.          "lib:c.o $* to $@ LIB lib:sc.lib lib:amiga.lib" and it automatically
  141.          adjust for any "linker" options
  142.        Compiler » Outputdir
  143.          <empty> (Press Amiga-X OK)
  144.        Env » Local Settings » Save
  145.        
  146.        Now you always have those settings if you don't specify anything
  147.        else.  
  148.  
  149. 3.4 To use this compiler-interface without SAS/C, those files has
  150.     to be changed according to your compiler:
  151.     
  152.     hn_newproject:     change SASCSETUP to what you require to create
  153.                        a new project-directory (SASCSETUP creates a new
  154.                        directory if it not exists, and copies files from
  155.                        sc:starter_project, without disturbing existing files)
  156.     hn_compile_c.edge: compilercaller, see hn_compile_c_sc*.edge
  157.     hn_readerr_c.edge: errorparser, see hn_readerr_c_sc*.edge
  158.     hn_addprotos.edge: Change compiler-call for prototype generation
  159.     hn_runproject:     Change cpr to your favorite debugger
  160.     hn_runcompiled:    Change cpr to your favorite debugger
  161.    
  162. 3.5 To customize default-project for hn_newproject
  163.     change/add files in sc:starter_project
  164.     
  165.     ex) Add the following: (se install-directory for file-version)
  166.     
  167.     makefile: 1 TAB before all commands.. $(CC) $(ASM) $(LINK) 
  168. # Makefile for project
  169.  
  170. # Change this to the main file name (whitout ext)
  171. # This is also the name of the executable file
  172. MAIN=
  173.  
  174. # Add .o files for all other sourcefiles after $(MAIN).o
  175. # Ex) if graphics.c is one subpart of the project:
  176. #    OBJFILES=lib:c.o $(MAIN).o graphics.o
  177. OBJFILES=lib:c.o $(MAIN).o
  178.  
  179. # Default linker-libraries
  180. # add lib:scm.lib before lib:sc.lib if using math..
  181. LINKLIBS=lib:sc.lib lib:amiga.lib
  182.  
  183. # C-compiler
  184. CC=SC
  185. CFLAGS = 
  186.  
  187. # Assembler
  188. ASM=asm
  189. AFLAGS= -iinclude:
  190.  
  191. # Linker
  192. LINK=slink
  193.  
  194. #Default rules
  195. # C source files (.c -> .o)
  196. .c.o:
  197.     $(CC) $(CFLAGS) $*.c
  198. # ASM source files ( .a .s .asm -> .o)
  199. .a.o:
  200.     $(ASM) $(AFLAGS) -o$*.o $*.a
  201. .s.o:
  202.     $(ASM) $(AFLAGS) -o$*.o $*.s
  203. .asm.o:
  204.     $(ASM) $(AFLAGS) -o$*.o $*.asm
  205.  
  206. # Use defaultrules for compiling... then link
  207. $(MAIN): $(OBJFILES)
  208.     $(LINK) $(OBJFILES) TO $(MAIN) LIB $(LINKLIBS)
  209.  
  210. #Special rules: 
  211. #destination: dependency-files
  212. #        compile-command(s)
  213. #Ex (sound.c -> sound.o, recompile if sound.c or sound.h is changed)
  214. #sound.o: sound.c sound.h
  215. #        $(CC) $(CFLAGS) -y -b0 sound.c
  216.      
  217.    Using this makefile, it's quite easy to start a simple project, just
  218.    enter main-filename after MAIN= and add ojectfiles for all other
  219.    sourcefiles after OBJFILES=$(MAIN).o (On the same line)
  220.  
  221. 3.6 ECHO: is a generic handler, not specifically written for this compiler-
  222.     interface, and might be used/rewritten as you whish.. source is included.
  223.     see EchoHandler directory.
  224.  
  225. 3.7 Linkoptions has some special-strings to make life easier
  226.     <empty> -> use default, wich varies according to some compiler-flags
  227.                standard: "lib:c.o $* to $@ LIB lib:sc.lib lib:amiga.lib"
  228.                highly recomended! just set compileroptions as usual,
  229.                and off you go... (Compile/Compile&link)
  230.                SAS/C 5.10 flags implemented: -L -b -r -w
  231.                is SAS/C 6.x this is the same as AUTO linking...
  232.     AUTO -> Use compiler-builtin linking if aviable
  233.             Not recomended together with SAS/C 5.10... *.lmk (with-file
  234.             for blink) is created in source-directory, not in current
  235.             directory as the documentation states... which means that
  236.             the *.lmk file will pop up as a window in Edge
  237.             Works very well with SAS/C 6.x
  238.     $* -> objectfile (same as $@.o or $$.o)
  239.     $@ -> filename without .ext
  240.     ex) If your file is dh0:source/test.c and outputdir is ram: then
  241.       $* is replaced with ram:test.o
  242.       $@ is replaced with ram:test
  243.  
  244. 3.8 Edge:s string-requesters are is bit odd...
  245.     To enter <nothing> you have to clear the requester, and then press
  246.     the OK-gadget, if you press Enter as usual it's almost the same as
  247.     pressing the Cancel-gadget...
  248.     This "Feature" has effect on "Compiler » Options",
  249.     "Compiler » Link Options" and "Indent Options » Custom"
  250.     To clear the gadget you HAVE to press OK!
  251.     
  252. 4******* Including new Languages ******
  253.  
  254.  This requires some knowledge in ARexx...
  255.  
  256.  1. Write a caller script, hn_compile_<filetype>.edge
  257.     The caller script is responsible for calling the compiler and for 
  258.     adjusting linktoptions according to link affecting compilerflags.
  259.     it also calls the errorparser.
  260.     if everything OK, return new linkoptions,
  261.     if error, return numeric errorcode.
  262.     see hn_compile_*.edge    
  263.     
  264.  2. Write a errorparser for errors, se hn_readerr_*.edge
  265.  
  266. 5************ Example menu ************
  267.  
  268. MENU    Compiler
  269. MENU "Project"
  270.     ITEM "Select project..."    COMMAND hn_projectsettings PROJECT
  271.     ITEM "Select sub-project..."    COMMAND hn_projectsettings SUBPROJECT
  272.     ITEM "New project..."    COMMAND hn_projectsettings NEW
  273.     ITEM "Edit project"    COMMAND hn_projectsettings EDIT
  274.     ITEM "Read errors"    COMMAND hn_readerr PROJECT
  275.     ITEM "Arguments..."    COMMAND hn_projectsettings ARGUMENTS
  276.     ITEM "Debug"    COMMAND hn_runproject DEBUG
  277. ENDMENU
  278. ITEM "Build"    COMMAND hn_build
  279. ITEM "Execute"    COMMAND hn_runproject RUN
  280. BAR
  281. MENU "Compiler"
  282.     ITEM "Options..."    COMMAND hn_compilesettings COMPILER
  283.     ITEM "Link options..."    COMMAND hn_compilesettings LINK
  284.     ITEM "Output dir..."    COMMAND hn_compilesettings OUTDIR
  285.     ITEM "Read errors"    COMMAND hn_readerr COMPILE
  286.     ITEM "Link"        COMMAND hn_compile LINKONLY
  287.     ITEM "Arguments..."    COMMAND hn_compilesettings ARGUMENTS
  288.     ITEM "Debug" COMMAND hn_runcompiled DEBUG
  289. ENDMENU
  290. ITEM "Compile"    COMMAND hn_compile COMPLIE
  291. ITEM "Compile & link"    COMMAND hn_compile LINK
  292. ITEM "Execute"    COMMAND hn_runcompiled RUN
  293. BAR
  294. ITEM "Add prototypes" COMMAND hn_addprotos
  295. ITEM "Indent" COMMAND hn_IndentCFile
  296. MENU " options"
  297.     ITEM " -kr" COMMAND hn_IndentCFile -kr
  298.     ITEM " -gnu" COMMAND hn_IndentCFile -gnu
  299.     ITEM " -orig" COMMAND hn_IndentCFile -orig
  300.     ITEM "custom..." COMMAND hn_IndentOptions
  301. ENDMENU
  302. ENDMENU
  303.  
  304. 6******** Local user variables ********
  305.  
  306.  Miscalenous:
  307.     _FE_User7  indentoptions
  308.  
  309.  "Single-file" compiling:
  310.     _FE_User8  compilerflags,linkoptions,outputdir,argumentline
  311.  
  312.  Project-handling:
  313.     _FE_User9  ProjectDirectory,argumentline
  314.  
  315. 7************ ARexx Macros ************
  316.  
  317. hn_build              Build current project
  318. hn_projectsettings    Change project settings/create project
  319. hn_runproject         Execute/Debug project
  320.  
  321. hn_compile            Compile current file
  322. hn_compilesettings    Change compilation settings
  323. hn_runcompiled        Run/Debug compiled file
  324.  
  325. hn_readerr            Parse errors for this file
  326.  
  327. hn_IndentCFile        Run GNU-Indent on current file
  328. hn_IndentOptions      Select GNU-Indent options
  329. hn_AddProtos          Add prototypes to SAS/C file
  330.  
  331. --------- Project handling ----------
  332. Edge macro: hn_Build
  333.  Usage:    hn_build
  334.  Synopsis: Build current project
  335.  
  336. Edge macro: hn_ProjectSettings
  337.  Usage:    hn_projectsettings PROJECT|SUBPROJECT|ARGUMENTS|EDIT|NEW
  338.             PROJECT    : Select main project
  339.             SUBPROJECT : Select sub project
  340.             ARGUMENTS  : Select arguments used when running program
  341.             EDIT       : Edit project makefile
  342.             NEW        : Create a NEW project
  343.  
  344. Edge macro: hn_runproject
  345.  Usage:    hn_runproject [RUN|DEBUG]
  346.  Synopsis: Run/Debug selected project
  347.  
  348.  
  349. ------ "Single-file" compiling ------
  350.  
  351. Edge macro: hn_compile
  352.  Usage:    hn_compile [COMPILE|LINK|LINKONLY]
  353.            COMPILE  Compile file
  354.            LINK     Compile & link file
  355.            LINKONLY Only link file
  356.  Synopsis: Compile, and optionally link current file
  357.  Special-strings in linkoptions:
  358.            <empty> -> Automatically adjust according to compiler-flags
  359.            AUTO -> Use compilers builtin linking instead
  360.            $* -> objectfile (same as $@.o)
  361.            $@ -> output filename (outdir+filename without .ext)
  362.  
  363. Edge macro: hn_compilesettings
  364.  Usage:    hn_compileoptions [COMPILER|OUTDIR|LINK|ARGUMENTS]
  365.  Synopsis: Change settings for hn_compile
  366.  
  367. Edge macro: hn_rumcompiled
  368.  Usage:    hn_runcompiled [RUN|DEBUG]
  369.  Synopsis: Run/Debug compiled program
  370.  
  371. ----------- Error Parsing -----------
  372.  
  373. Edge macro: hn_readerr
  374.  Usage:    hn_readerr [<errorfile>|PROJECT|COMPILE],[<filename>],[0|1|LINK]
  375.            <errorfile> : read errors from errorfile
  376.            PROJECT     : read errors from current project-errorfile
  377.            COMPILE     : read errors from current compile-errorfile
  378.            <filename>  : source-filename
  379.            LINK        : Supress requesters if all OK..
  380.            Default     : COMPILE,<currentfile>,0
  381.  Synopsis: Select errorfile and parser according to current filename
  382.            and arguments.
  383.  
  384. ----------- Miscalenous ------------
  385.  
  386. Edge macro: hn_IndentCFile
  387.  Usage:    hn_IndentCFile
  388.  Synopsis: Run GNU-Indent on current file
  389.  
  390. Edge macro: hn_indentoptions
  391.  Usage:    hn_indentoptions
  392.  Synopsis: select GNU-Indent options
  393.  
  394. Edge macro: hn_addprotos
  395.  Usage:    hn_addprotos
  396.  Synopsis: Add prototypes to SAS/C file
  397.            (at cursor, if not done before)
  398.  
  399. ----------- INTERNAL ----------------
  400. hn_compile_c.edge            Call C compiler
  401. hn_compile_asm.edge        Call ASM compiler
  402. hn_readerr_c.edge            Parse C errors
  403. hn_readerr_asm.edge        Parse ASM errors
  404. hn_createproject.edge    Create a new project directory
  405. hn_link.edge                Call linker
  406.  
  407. 8********* Copyright Notes: *********
  408.  
  409. Henrik Nordstroms Compiler Interface for Edge is ©1991-1992 Henrik Nordström
  410. It might be distributed together with Edge or througth any of the
  411. Public Domain channels or uploaded to BBS:es, but except for distribution
  412. together whith Edge, no fee except P&P (up to 5US$) is allowed.
  413.  
  414. SAS and SAS/C are registered trademarks in the USA of
  415.  SAS Institute Inc., Cary, NC, USA
  416. Lattice is a registered trademark of Lattice, Inc.
  417. LMK is a registered trademark of Lattice, Inc.
  418. cpr is SAS/C CodePRrobe source debugger, © SAS Institure Inc.
  419.  
  420. 9*********** Where I can be reached *************
  421. E-Mail:
  422.   sp2henno@obelix.his.se
  423.  
  424. Mail:
  425.   Henrik Nordström
  426.   Ängsvägen 1
  427.   s-756 45 Uppsala
  428.  
  429. Phone:
  430.   +46-(0)500-484896
  431.