Skip to content

Latest commit

 

History

History
212 lines (181 loc) · 9.09 KB

XDS_M2.md

File metadata and controls

212 lines (181 loc) · 9.09 KB

XDS Modula-2 Quick Reference

XDS Modula-2 This document gathers XDS Modula-2 related informations.

Build scenarios

We typically have to deal with one of the following build scenarios :

  • we build a Modula-2 application.
  • we build a Modula-2 library.

In most cases our program will depend on one or more Modula-2 libraries :

  • XDS standard libraries such as InOut,
  • user-defined libraries such as Terminal2 (see below).

Scenario 1 – Building an application

This scenario is the simple one :

  1. We just need the XDS compiler xc.exe.
  2. xc.exe works relative to the current working directory so we define target as our working directory
    • where we copy resp. generate the input files – e.g. the project file – and
    • which we set as the working directory before running xc.exe.

Example Hello has the following directory structure :

> cd
F:\examples\Hello
 
> tree /f /a . | findstr /v /b [A-Z]
|   build.bat
|   build.sh
|   Makefile
\---src
    \---main
        +---mod
        |       hello.mod
        \---mod-adw
                hello.mod

The working directory target\ looks as follows after executing the build command :

> tree /f /a target | findstr /v /b [A-Z]
|   Hello.exe
|   Hello.obj
|   Hello.prj
|   tmp.lnk
\---mod
        hello.mod
  • The input files are :
    • 1 source file mod\hello.mod we simply copy from our source directory.
    • 1 project file Hello.prj we create before invoking the XDS compiler with option =p<project_file>. For instance 1 :
      > type target\Hello.prj
      -cpu = 486
      -lookup = *.sym = sym;C:\opt\XDS-Modula-2\sym
      -lookup = *.dll|*.lib = bin;C:\opt\XDS-Modula-2\bin
      -m2
      % -verbose
      -werr
      % main module of the program
      !module mod\Hello.mod
      
  • The output files are Hello.obj and Hello.exe.

Note: See the PDF document C:\opt\XDS-Modula-2\pdf\xc.pdf for more details.

Scenario 2 – Building a library

This scenario is more involved :

  1. We need both the XDS compiler xc.exe and the XDS library manager xlib.exe.
  2. Again we define target as our build directory
    • where we copy resp. generate the input files – e.g. the project files – and
    • which we set as the working directory before running the XDS tools.

The project directory for the Terminal2 library looks as follows :

> cd
F:\examples\Terminal2
 
> tree /f /a . | findstr /v /b [A-Z]
|   build.bat
|   build.sh
|   Makefile
\---src
    +---main
    |   +---def
    |   |       Terminal2.def
    |   +---mod
    |   |       Terminal2.mod
    |   \---mod-adw
    |           Terminal2.mod
    \---test
        \---mod
                Terminal2Test.mod

The working directory target\ looks as follows after executing the build command :

> tree /f /a target | findstr /v /b [A-Z]
  |   Terminal2.dll
  |   Terminal2.lib
  |   Terminal2.obj
  |   Terminal2.prj
  |   Terminal2Test.exe
  |   Terminal2Test.obj
  |   Terminal2Test.prj
  |   tmp.lnk
  +---def
  |       Terminal2.def
  +---mod
  |       Terminal2.mod
  +---sym
  |       Terminal2.sym
  \---test
          Terminal2Test.mod
  • The input files are :
    • 3 source files def\Terminal2.def, mod\Terminal2.mod and test\Terminal2Test.mod (test module) we simply copy from our source directory.
    • 2 project files Terminal2.prj and Terminal2Test.prj we create before invoking the XDS compiler with option =p<project_file>. For instance 1 :
      > type target\Terminal2.prj
      % write -gendll- to generate an .exe
      -gendll+
      -usedll+
      -dllexport+
      -implib-
      -cpu = 486
      -lookup = *.sym = sym;C:\opt\XDS-Modula-2\sym
      -lookup = *.dll|*.lib = bin;C:\opt\XDS-Modula-2\bin
      -m2
      % -verbose
      -werr
      % main module of the program
      !module mod\Terminal2.mod
      
  • The output files are Terminal2.dll, Terminal2.lib, Terminal2.obj, Terminal2Text.objand Terminal2Text.exe.

Finally we support 3 ways to build a Modula-2 library, namely with a batch file (build.bat), a shell script (build.sh) or a GNU make file (Makefile). For instance :

> build
Usage: build { <option> | <subcommand> }
 
  Options:
    -adw         select ADW Modula-2 toolset
    -debug       print commands executed by this script
    -gm2         select GNU Modula-2 toolset
    -verbose     print progress messages
    -xds         select XDS Modula-2 toolset (default)
 
  Subcommands:
    clean        delete generated object files
    compile      compile Modula-2 source files
    install      install library into directory "..\lib\xds"
    run          execute program "Terminal2Test"

We execute the subcommand install to install the generated files into directory lib\xds\ such that Modula-2 application can refer to them via an IMPORT clause :

> cd
F:\examples\lib
 
> tree /f /a . | findstr /v /b [A-Z]
\---xds
        Liste.dll
        Liste.lib
        Liste.obj
        Liste.sym
        Terminal2.dll
        Terminal2.lib
        Terminal2.sym

Footnotes

[1] Additional MSYS packages

The following command prints the full list of compiler options :
> "%XDS_HOME%\bin\xc.exe" =compile =options
  Options:
  -ALWAYSINLINE      +ASSERT            -BSALPHA           -BSCLOSURE
  -BSREDEFINE        -CHANGESYM         +CHECKDINDEX       +CHECKDIV
[...]

mics/December 2024