A tool for converting C and Objective-C headers to D modules
C D C++ PowerShell Shell Objective-C
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin Compile as 32bit binary for now. Jan 24, 2012
clang feature-refactor-driver Mar 19, 2018
dstep Fix #197: Memory Leak. Jun 20, 2018
resources Update internal headers to version 4.0.0 Jul 3, 2017
tests Fix #192: Fail to convert nuklear. Apr 17, 2018
tools Fix #185: dub.json preGenerateCommand fails from dub package Mar 10, 2018
.editorconfig Add .editorcofig matching current style Jul 25, 2016
.gitignore Move tests to the `tests` directory Oct 21, 2017
.gitmodules Factor out common application code to new project. May 3, 2012
.travis.yml Move LLVM version matrix to Travis CI and Appveyor build scripts Oct 6, 2017
CONTRIBUTING.md Add CONTIBUTING.md. Aug 8, 2016
README.markdown Fix the dub warning about -m32mscoff. Jul 25, 2017
appveyor.ps1 Move LLVM version matrix to Travis CI and Appveyor build scripts Oct 6, 2017
appveyor.yml Improve the translation of file names to module names. Oct 11, 2017
build.bat Add build script for Windows. Oct 27, 2013
build.sh Add configuration script to auto detect libclang Jun 11, 2017
changelog.md Fix #192: Fail to convert nuklear. Apr 17, 2018
configure Add configuration script to auto detect libclang Jun 11, 2017
configure.d Add support for fully static linking Jul 16, 2017
dub.json Adds support for bit fields. Mar 18, 2018
dub.selections.json Remove unused dependencies from dub.json Aug 14, 2016
generate_libclang_bindings.sh Update libclang bindings. Mar 18, 2018
run.sh Fix #49: Function-typed parameter is not handled Feb 14, 2016
test.d Adjust to the new test directory structure Oct 21, 2017
todo.taskpaper Replace tabs with spaces. Jan 24, 2015
unittest.d Fix #47: Adds support for preprocessor constants. May 28, 2016

README.markdown

DStep

DStep is a tool for translating C and Objective-C headers to D modules.

Download

For the latest release see: releases/latest.

Pre-compiled binaries are available for OS X, Linux and FreeBSD, as 64bit. See the releases section.

Arch packages are available in [community] repository (thanks to Михаил Страшун):

https://www.archlinux.org/packages/?q=dstep

Alternatively install via Dub

License

The source code is available under the Boost Software License 1.0

Building

Posix

Requirements

Building

  1. Install all requirements, see above

  2. Clone the repository by running:

     $ git clone git://github.com/jacob-carlborg/dstep.git
    
  3. Run dub build

A configuration script will try to automatically locate libclang by looking through a couple of default search paths. If libclang is not found in any of the default paths, please manually invoke the configuration script and specify the path to where libclang is installed using the --llvm-path flag.

$ ./configure --llvm-path /usr/lib/llvm-4.0/lib

Windows

Requirements

Building

  1. Install all requirements, see above

  2. Clone the repository by running:

     $ git clone git://github.com/jacob-carlborg/dstep.git
    
  3. Run dub build --arch=x86_mscoff --build=release to build 32-bit version

  4. Run dub build --arch=x86_64 --build=release to build 64-bit version

Remarks

Building 32-bit version requires a 32-bit variant of the Visual Studio toolchain to be present in PATH. The same for 64-bit. Remember to specify --arch=x86_mscoff when building 32-bit version. The architecture specification is mandatory as with the default architecture or --arch=x86 dub will try to use unsupported OPTLINK linker. OPTLINK linker requires unsupported version of libclang binaries. Remember to install LLVM to its default installation path and to add its binaries to the PATH environmental variable (otherwise you may need to change dub.json).

Usage

$ dstep Foo.h -o Foo.d

For translating Objective-C headers add the -ObjC flag.

$ dstep Foo.h -o Foo.d -ObjC

For translating multiple files at once, simply pass all the files to dstep. In this case though, -o (if given) would point to output directory name. The directory will be created if it doesn't exist.

$ dstep Foo1.h Foo2.h Foo3.h .... FooN.h -o ./outputDirectory/

Use -h for usage information. Any flags recognized by Clang can be used.

Limitations/Known issues

  • Doesn't translate preprocessor macros, with exception to simple constants and functions.

  • Doesn't translate #include to import. A few standard C headers are translated

  • Doesn't translate C++ at all

  • Umbrella headers. Some headers just serve to include other headers. If these other headers contain some form of protection, like #error, to be included directly this can cause problems for DStep

  • Some headers are designed to always be included together with other header files. These headers may very well use symbols from other header files without including them itself. Since DStep is designed to convert header files one-by-one this doesn't work. There are two workarounds for this:

    1. Add #include-directives for the header files the header file is actually using
    2. Use the -include <file> flag available in Clang to indicate the given <file> should be processed before the file that should be translated. DStep accepts all flags Clang accepts