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

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 --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 not to specify -arch=x86 when building 32-bit version (dub will overwrite -m32mscoff with unsupported -m32 switch). If you use libclang versions <= 3.7, you may need to install MinGW for header files. 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


DStep

DStep是将C和Objective-C头文件转换为D模块的工具。

下载

有关最新版本,请参阅:发布/最新

预编译二进制文件可用于OS X,Linux和FreeBSD,为64位。见 发布部分。

Arch软件包可在[社区]资料库中获得(感谢МихаилСтрашун):

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

或通过 Dub 进行安装

许可证

源代码可在 Boost Software License 1.0 下获得

建设

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

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 –build=release to build 32-bit version

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

Remarks

构建32位版本需要Visual Studio工具链的32位变体存在于 PATH 中。 64位也是一样。当构建32位版本( dub 将覆盖 -m32mscoff 不支持时,记住指定 -arch = x86 -m32 switch)。如果您使用libclang版本&lt; = 3.7,您可能需要为头文件安装MinGW。记住将LLVM安装到其默认安装路径,并将其二进制文件添加到 PATH 环境变量中(否则可能需要更改 dub.json )。

用法

$ dstep Foo.h -o Foo.d

要翻译Objective-C标题,请添加 -ObjC 标志。

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

为了一次翻译多个文件,只需将所有文件传递给dstep。 在这种情况下,尽管如此, -o (如果给定)将指向输出目录名称。 该目录将被创建,如果它不存在。

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

使用 -h 获取使用信息。可以使用Clang识别的任何标志。

限制/已知问题

  • 除了简单的常量和函数之外,不会翻译预处理宏。

  • 不将 #include 转换为 import

    转换了几个标准的C头
  • 根本不翻译C ++

  • 伞头。一些标题仅用于包含其他标题。如果这些其他标头包含某种形式的保护,例如 #error ,要直接包含,这可能会导致DStep的问题

  • 某些标题设计为始终与其他头文件一起包含在内。这些头可能非常好地使用来自其他头文件的符号,而不包括它们本身。由于DStep旨在一个一个地转换头文件,这不起作用。这有两种解决方法:

    1. 为头文件实际使用的头文件添加 #include -directives
    2. 使用Clang中可用的 -include&lt; file&gt; 标志来指示应该在应该翻译的文件之前处理给定的&lt; file&gt; 。 DStep接受Clang接受的所有标志




相关问题推荐