D Language Tutorial

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
jussij
Site Admin
Posts: 2551
Joined: Fri Aug 13, 2004 5:10 pm

D Language Tutorial

Post by jussij »

Install the D Compiler
Before attempting to use these D language build tools make sure the D compiler has been installed correctly.

Setting up the Language Server
To setup the D language server follow the instructions found here: https://www.zeusedit.com/lsp/d-dls.html

NOTE: For information on using the DUB Build Manager refer to this link.

Using a Build Tool to Manage the Project Build

As the D project grows in complexity, the management of the build will be made easier if a build tool is used.

Zeus really does not care which build tool is used and when it comes to D it turns out there are several options ;)


Using Bud to Manage the Project Build

The first option would be manage the build using the Bud build tool.

To manage the project using Bud change the Workspace Options to use the following command lines:
  • Make Command Line: bud main
  • Clean Command Line: bud -clean main
  • Make Command Line: bud -full main
NOTE: Bud expects the top most file of the application's hierarchy to be passed in via the command line, so for this example that file is main. If your project uses a different top file then just change the name to suit.

IMPORTANT: For this to work make sure the Bud executable is in the system PATH.


Using DSSS to Manage the Project Build

Another option would be to use DSSS to manage the build.

To use DSSS requires the creation of a dsss.conf for each of the two projects in the workspace. Here is a DSSS tutorial on how to create these conf files.

With the dsss.conf files created in the correct folder location, just change the Zeus workspace Make Command Line: to be: dsss build


Using a Make File to Manage the Project Build
It is also possible to manage the build using a simple make file.

Because the main.d references some functions in the mathLIB module, a compile and link process will be needed to create the executable.

The command line in the D Document type could be adjusted to include the missing files, but a better alternative is to create a make file to handle the process of building the project.

1: Create the main.mak file in this folder location:

Code: Select all

C:\d\main\main.mak

The main.mak file should look like this:

Code: Select all

# Simple Makefile to Create my main.exe

DMD=dmd.exe

# Make sure the mathLib location is in the include path
DFLAGS=-O -release -nofloat -w -Ic:\d

.d.obj:
   $(DMD) -c $(DFLAGS) $*

main : main.exe

# ink the exectutable with the mathLIB.lib file
main.exe : main.obj
   dmd -ofmain.exe main.obj ..\mathLIB\mathLIB.lib

clean:
   del main.exe math.obj

2: Create the mathLIB.mak file in this folder location:

Code: Select all

C:\d\mathLIB\mathLIB.mak

The mathLIB.mak file should look like this:

Code: Select all

# Simple Makefile to Create my mathLIB

DFLAGS=-O -release -nofloat -w

DMD=dmd.exe

.d.obj:
   $(DMD) -c $(DFLAGS) $*

mathLIB : mathLIB.lib

mathLIB.lib : math1.obj math2.obj
   dmd -ofmathLIB.lib -lib math1.obj math2.obj

clean:
   del math1.obj math2.obj mathLIB.lib

3: Use the Zeus Workspace, Options menu and in the General section for the main project add the following command lines:
  • Make Command Line: make -f main.mak
  • Clean Command Line: make -f main.mak clean
4: Use the Zeus Workspace, Options menu and in the General section for the mathLIB project
  • Make Command Line: make -f mathLIB.mak
  • Clean Command Line: make -f mathLIB.mak clean
5: Now the build and clean operations can be run from withing Zeus using the Workspace, Build menu or by right clicking on the project in the Workspace navigator and selecting make or clean options.

Now when these make menus are run on the mathLIB and main projects a mathLIB.lib and main.exe files are produced:

Code: Select all

C:\d\main>dir *.exe
 Directory of C:\d\main

09/03/2009  11:39           133,660 main.exe
               1 File(s)        133,660 bytes
               0 Dir(s)     789,381,120 bytes free

Related Topics:
Using the D Programming Language with Zeus.
Getting the D language debugger to work with Zeus.
Intergrating the D programming language help file.
Intergrating the D programming language Tango help file.
Writing Zeus macros using D scripting module.
Post Reply