Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

An example of boostraping D in any project

License

NotificationsYou must be signed in to change notification settings

wilzbach/d-bootstrap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build StatusCode coverage

To get you started with D, this is a small hello world application.The Makefile will automatically download a D compiler - no installation necessary:

make./bin/hello

You can use LDC as well:

make bin/hello_opt./bin/hello_opt

I'm sure you can take it from there. It's all up to you!Happy coding!

I don't like Make

Instead of a Makefile, you can of course always usethe install script to setup a D compiler:

source $(curl https://dlang.org/install.sh | bash -s dmd)

Or maybe you have a D compiler already installed on your system?You can use this Makefile for bootstrapping your D compilerand making sure the same compiler is used on all systems:

make setup-dmd./bin/dmd

Analogous the commandmake setup-ldc makes sureldc is installed locally and availableviabin/ldc (LLVM-like interface) andbin/ldmd (DMD-like interface).

I want to use package X

For more advanced projects, usage ofDUB

  • D's package manager - is recommended.If you work in a environment where a D compiler isn't easily available or yousimply want to lock your project to a specific compiler version,you can use the packageddub for your scripts:

    ./bin/dub

Of course, you can also calldub from Make and integrate dub with other build steps:

make dub

I want to use Travis for my project

Simplyenable the project on Travis.

I want to use Continuous Integration service X for my project

The D compiler bootstrapping inmake willauto-magically work.Alternatively, usethe install script.

I want to have nice documentation for my project

The easiest way to get started, is to useddox:

dub -b ddox

Have a look atveelo's gistto see how it can be setup to automatically publish the latest documentation toyour GitHub pages.

You might also want to trydpldocs.info's automatic generation.

I want to have tests and code coverage for my project

First, add a unittests:

unittest{assert(1==1,"D math works as expected.");}

All tests can be executed with:

dub test

To generate coverage listing too, use theunittest-cov build mode:

dub test -b unittest-cov

You can browse the.lst files manually, but if you use GitHub or BitBucket,usage of theCodeCov app is recommended.

I want to have static code analysis and linting

D-Scanner is the swiss-army knifefor D source code:

dub fetch dscannerdub run dscanner -- --styleCheck source

Add a custom configuration:

dub run dscanner -- --defaultConfigmv ~/.config/dscanner/dscanner.ini .dscanner.inidub run dscanner -- --styleCheck source --config .dscanner.ini

I want to have automatic source formatting

dfmt is a source code formatter for D:

dub fetch dfmtdub run dfmt

Why don't you use Docker?

Docker is typically used to allow a consistent work environment, but in my use cases Docker isn't available.If you want to use Docker, check out theD docker images.

What are the other Makefile targets?

TargetDescription
bin/helloA normal build with DMD
bin/hello_optAn optimized build with LDC
bin/hello_ltoAn optimized build with LDC and link-time optimization (LTO)
dubRuns the application via DUB
dub_optRuns the application via DUB with LDC
testRuns all unittests
styleRuns static code analysis and style checking
formatReformats all code
cleanRemoves all generated data

I have more questions

Feel to ask them at theD: Learn Forum.

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp