| |
| Posted by Burton Radons | PermalinkReply |
|
Burton Radons
| Okay, I finally finished digc. For some reason I thought writing a parser to handle version statements properly would be a good idea. Then I started thinking that I should store the parsed data as DOM so I started writing a DOM implementation. Then I thought that I don't like how my implementation wouldn't be able to interface with other languages or use the other features OMG CORBA is built for, so I started looking in the CORBA documentation. Then I realised I forgot about digc.
The digc documentation says it all, so I'll repeat it here. The big changes are that it uses a builder program so that it can work no matter where you decided to install DMD (it'll search out the most obvious suspects). The stripper also works with the newer revisions of the language. Finally, it strips version statements. Here's the archive:
http://www.smocky.com/arc/digc-0.0.15.zip
There is no Linux version yet.
Here's the documentation:
Introduction
---------------------------------------
digc is a compiler manager for the dmd compiler for D. It simplifies all tasks, makes distributing libraries a snap (and if you don't want to distribute your source, it protects it), and turns DLL creation in Windows from an exercise in obfuscated frustration into a seven-letter command-line parameter.
Building
---------------------------------------
To build digc, run make_digc. It will search for the installation directories of DMD itself, but in case you have them installed in strange locations you can overload these; use "make_digc -help" for a summary.
Compiling Programs
---------------------------------------
Here is an example of compiling two programs:
@code
digc halhello.d / cartoon.d -then-run -windowed -O -release
@endcode
The first program built is halhello.exe using halhello.d aas source. The "/" separates programs; all programs in one command share options (such as -windowed, -O, and -release).
The second program built is cartoon.exe using cartoon.d as source. If both programs are successfully compiled, then it runs cartoon.exe afterwards (that's the meaning of -then-run). -windowed says to compile them as windowed applications rather than DOS applications. -O and -release are DMD commands that are passed through unmolested.
Note that you don't specify any libraries to use. digc identifies the
necessary libraries automatically from the source.
To build an executable of a certain name, rather than extracting it from the first source file, use "-exe=" followed by the name without extension; for example, "-exe=halhello".
Compiling Libraries
---------------------------------------
A stripped version of the library source is stored in the library file. All function bodies (except for functions within templates) and unnecessary whitespace is removed. When digc determines that the library is being used by a program, it regenerates this ABI transparently.
If providing source is undesirable, you only need to include the library binary.
For example, if we have a module like this:
module x;
void foo () { }
Then we can compile it into a library with this command:
digc x.d -lib=x -install
This creates the library file and installs it on this computer. You can now switch to another directory so that x.d is not visible in the imports. If you have another module like this:
module y;
import x;
Then compile it with digc, it will regenerate the interface for the "x" library and allow it to work properly.
"version" and "debug" statements are collapsed during stripping of a library; the version and debug levels and settings will not be alterable after compilation. This collapsing is currently not robust; template objects should use version statements at the top scope only. For example, this is okay:
template x ()
{
version (a)
...
}
However, this might cause a problem:
template y ()
{
void foo ()
{
version (a)
...
}
}
To create a shared library, add the "-shared" option. In Windows this creates a DLL file as well as a LIB file, and it automatically exports all variables from the library. This makes it behave similarly to Linux shared libraries. However, the DLL uses its own independent garbage collector, so you must be careful to copy data properly.
Build Files
---------------------------------------
Build files are an optional method of compilation that makes creating large, multi-library packages much easier. To start building a package, use -build=path:
digc -build=net
This searches for a file named "build" under the net directory. Here's a sample build file:
// comment
build sub1 sub2
version ver1
{
build sub3
}
library lib1
{
version ver2
{
add file1
-O
}
add file2 file3*
}
example exa1
{
add file5
}
TODO.
Options Summary
---------------------------------------
Here is a summary of the command-line options.
files
Add files to the compilation. This can include wildcards, which
are expanded on Windows.
-not=wildcard
Exclude these files from the compilation. Arguments are
evaluated in left-to-right order.
-exe=name
Build an executable with the given name; do not give an
extension. If this argument is not provided, the name of the
executable is taken from the first source file after removing
its extension.
-lib=name
Build a library with the given name; do not provide an
extension.
-shared
For libraries, make this a shared library. In Windows this
means to make a DLL. You can expect that the shared library
will have a different GC context, so you must be careful to copy
data properly.
-windowed
Compile under windowed mode. Under Windows, this means that the
program will not create a DOS Prompt when executed.
-then=cmd
Run the command after successful compilation of all programs.
-then-run
Run the program being specified after successful compilation of
all programs.
-install
Copy created executables to the DMD binary directory (DMD_bin),
created libraries to the DMD library directory (DMD_lib), and
created shared libraries to the system directory
(SystemDirectory).
-build=path
Compile the build file in the specified path.
-no-create-assembly-file
Don't create and compile in an assembly file on Windows. This
file tells Windows that it is XP-capable and can be skinned
using new-style widgets.
-no-delete-temp-dir
Don't delete the temporary directory used when expanding library
files. This command is here mostly for when you think digc is
stripping libraries incorrectly.
You can use a set of expansions for various system directories by using
$[XXX], $(XXX), or ${XXX}; for example, ${SystemDirectory}. These directories
are:
SystemDirectory
The system library directory; in Windows this is the
windows\system32 directory. In Linux this would be
/usr/local/lib.
DMD_bin
The location of DMD's binary files.
DMD_lib
The location of DMD's library files.
DMD_src
The location of DMD's source files.
Phobos
The location of Phobos.
|