Skip to content

Latest commit

 

History

History
185 lines (159 loc) · 7.94 KB

XDS_M2.md

File metadata and controls

185 lines (159 loc) · 7.94 KB

XDS Modula-2 Quick Reference

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

In this project we deal with two build scenarios :

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

In most cases our code will depend on some other Modula-2 libraries :

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

Application builds

This scenario is the simple one :

  1. We only need the XDS compiler xc.exe.
  2. xc.exe works relative to the current working directory so we define target as our build 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.

The project directory for the Hello application is organized as follows :

> 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

Let's now have a closer look at the build directory target :

> tree /f /a target | findstr /v /b [A-Z]
|   Hello.exe
|   Hello.obj
|   Hello.prj
|   tmp.lnk
|
\---mod
        hello.mod
  • Input files for the Hello application are just one top-level module (target\mod\).
  • The XDS compiler provides option =p <project_file> to specify the build configuration; we generate the project file Hello.prj during the build process and pass it as argument to the XDS compiler. For instance :
      > type target\Hello.prj
      -cpu = 486
      -lookup = *.sym = sym;C:\opt\XDS-Modula-2\sym
      -m2
      -verbose
      -werr
      % main module of the program
      !module mod\Hello.mod
      

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

Library builds

This scenario is more involved :

  1. We need both the XDS compiler xc.exe and the XDS library manager xlib.exe.
  2. As for the application builds 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 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

Let's again have a closer look at the build directory target :

> 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
  • Input files include at least a definition module (target\def\), an implementation module (target\mod\) and a test module (target\test\).
  • The XDS compiler provides option =p <project_file> to specify the build configuration; we generate the two project files Terminal2.prj and Terminal2Test.prj during the build process and pass them to the XDS compiler. For instance :
      > 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
      -m2
      % main module of the program
      !module mod\Terminal2.mod
      

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
    -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

mics/November 2023