Using DUB (D Language) inside Zeus

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: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Using DUB (D Language) inside Zeus

Post by jussij »

Building a DUB Package using Zeus

From the DUB home page:

DUB is a build tool for D projects with support for automatically retrieving dependencies and integrating them in the build process.

From that same page DUB relyies the following conventions:
  • Folders named "source" or "src" get automatically scanned for sources and are treated as import folders.
  • A file "app.d", or "<package name>.d" is treated as containing the applications main() and automatically gets excluded in library builds of the package
  • The two configurations "application" and "library" get added automatically, depending on the availability of those files
  • A folder "views" is automatically treated as a string import folder (the -J switch)
Using that information I should be easy enough to setup a Zeus workspace to work with DUB and below are the steps on how to do this.

1) Download the DUB zipped binaries for Windows (X86) from here: http://code.dlang.org/download

2) Extract the files in the zip file to this folder:

Code: Select all

C:\Program Files\Zeus\zGNU
3) To test DUB I needed something to build so I went to the DUB project page: http://code.dlang.org/

For this test I selected the Carbon library project found here: http://code.dlang.org/packages/carbon

The source for that project is found here: https://github.com/k3kaimu/carbon

I put the source files of that project into local disk location:

Code: Select all

C:\Projects\Carbon
4) To create a Zeus Workspace for this Carbon project I used the WorkSpace, New menu and created an empty workspace with these details:

Code: Select all

     Workspace Name: Carbon
Workspace Directory: C:\Projects\Carbon
            Folders: Source;
To add the D source code to that workspace select the Source folder and use the mouse right click to bring up the popup menu.

Next select the Add files to folder option and in the resulting dialog type in *.d as the file filter, select all the resulting files and add them to the folder.

5) To attach DUB to the Carbon workspace do the following:
  • Use the Workspace, Option menu to open the workspace properties dialog.
  • Set the configuration to Debug (using the combo box found in the top right of the dialog)
  • Set the Make command line to dub build
  • Apply those changes
That's it. The Carbon project can now be built from inside Zeus.

To run the build select the Carbon project from the workspace and use the mouse right click to select the Make menu option.

That will result in the following output in the project build window:

Code: Select all

--------------------Configuration: Carbon - Debug--------------------
Using workspace project options....

carbon: ["carbon"]
Building carbon configuration "use_as_lib", build type debug.
Running dmd...
Once the build is complete (as shown by the caption text) you will see that DUB has created this file for that project:

Code: Select all

 Directory of C:\Projects\Carbon\.dub\build\use_as_lib-debug-windows-x86-dmd-205D7FA3726F759B34B1F7ABD4BE9F7E

17/08/2014  03:46 PM    <DIR>          .
17/08/2014  03:46 PM    <DIR>          ..
17/08/2014  03:46 PM           630,272 carbon.lib
               1 File(s)        630,272 bytes
               2 Dir(s)   1,216,479,232 bytes free
Last edited by jussij on Tue Aug 26, 2014 7:01 am, edited 1 time in total.
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Creating a New DUB Package

The example above used an existing DUB package, but it is also easy to create a new DUB package and build that from inside of Zeus.

Here are the steps to achieving that goal.

Step 1)
Create a new D project on the disk with the following folder structure:

Code: Select all

md c:\Projects
md c:\Projects\"Test Project"
Step 2)
Use DUB to initialise that new project as follows:

Code: Select all

cd c:\Projects\"Test Project"
DUB.exe init "Test Project"
Step 3)
Start Zeus and use the Workspace, New menu to create a new worspace with the following details:

Code: Select all

Workspace Name: DUB Test
Directory: c:\Projects\Test Project
Folders: Source
Step 4)
Using the Workspace, Options menu, select the Debug Configuration from the top left and in the Project panel, set the Make Command entry field as follows:

Code: Select all

dub.exe build
In the Debugging panel set the Executable entry field as follows:

Code: Select all

dub.exe run
IMPORTANT: Also select the capture standard output and standard error options.

Step 5)
To add the source file created by Step 2) to the workspace, open the c:\Projects\"Test Project"\Source\app.d file and in the Workspace panel, right click on the Source folder and use the Add Current File to Folder option to add the file to the workspace.

Building and Running
To build the workspace use the Workspace, Build, Make menu and you should see this output:

Code: Select all

Checking dependencies in 'C:\Projects\Test Project'
Building configuration "application", build type debug
Compiling...
Linking...
To run the project use the Workspace, Build, Start Debug Executable menu and you should see this output:

Code: Select all

Checking dependencies in 'C:\Projects\Test Project'
Target is up to date. Skipping build.
Running test project.exe
Edit source/app.d to start your project.
NOTE: Both of those menus can be configured to be keyboard driven.

NOTE: More details on how to configure DUB packages can be found here: http://code.dlang.org/package-format
Post Reply