Newer
Older
alicedbg / dub.sdl
name "alicedbg"
description "Aiming to be a simple debugger"
homepage "http://github.com/dd86k/alicedbg"
authors "dd86k <dd@dax.moe>"
copyright "Copyright © dd86k <dd@dax.moe>"
license "BSD-3-Clause-Clear"

# NOTE: BetterC flag
#       We explicitly specify the betterC flag to support older DUB releases
#       Like v0.9.24

# NOTE: GDC 5.4
#       Doesn't work, ld whines about missing _tlsstart/_tlsend (TLS) references
#       value for C++/ObjC but not D:
#         -fno-rtti
#         -fno-weak
#         -fno-threadsafe-statics
#         -fextern-tls-init
#       -fno-switch-errors: not a command-line option
#       -nophoboslib: makes the linker complain more
#       Tried with "-fno-moduleinfo" "-fno-emit-moduleinfo"

# NOTE: GDC and betterC
#       Currently (even with GDC 10.3), when compiled with -fno-druntime
#       (similar to -betterC), the linker will whine about an undefined reference
#       to __gdc_personality_v0, because the gdc-druntime defines this reference.
#       Glibc (and subsequently, GCC) has a similiar function,
#       __gcc_personality_v0, that is served when unwinding the stack, so to
#       handle exceptions.

# NOTE: GDC 11.1 and betterC
#       Yes, it works with -fno-druntime, so it can be possible to add
#       -gdc-betterc build types in the future.

# NOTE: Configurations and Sub-Packages
#       Sub-packages do not take build type options from root dub file.
#       But since configurations do, they are defined here, this is important
#       because on the reliance on betterC.

# NOTE: Documentation (docs/ddox) builds
#       Works best with the "library" configuration (-c|--configuration)

#
# ANCHOR Configurations
#

# Application: Debugger (alicedbg)
configuration "debugger" {
	targetType "executable"
	targetName "alicedbg"
	sourcePaths "debugger" "common"
	importPaths "debugger" "common"
	mainSourceFile "debugger/main.d"
}

# Application: Dumper (alicedump)
configuration "dumper" {
	targetType "executable"
	targetName "alicedump"
	sourcePaths "dumper" "common"
	importPaths "dumper" "common"
	mainSourceFile "dumper/main.d"
}

# Application: Example (simple)
configuration "simple" {
	targetType "executable"
	targetName "simple"
	mainSourceFile "examples/simple.d"
}

# Library
# NOTE: DUB names it "alicedbg.lib" on Windows and "libalicedbg.a" elsewhere
configuration "library" {
	versions "StaticLib"
	sourcePaths "src"
}

# Dynamic library/Shared object
# NOTE: DUB names it "alicedbg.dll" on Windows and "libalicedbg.so" elsewhere
# NOTE: MSVC Linker can't find vcruntime140.lib with libs declaration
#       LIBPATH isn't compiler-provided one, but Windows SDK
configuration "shared" {
	versions "SharedLib" # "Shared" might confuse druntime
	targetType "dynamicLibrary"
	sourcePaths "src"
}

#
# ANCHOR Build types
#

## Debug builds

# Debug build with tracing enabled. This will be extremely verbose and the
# output will be cryptid.
# Only to be used with small reproductible bugs.
buildType "trace" {
	versions "Trace" "AdbgTrace"
	buildOptions "debugMode" "debugInfo"
	dflags "-betterC" "-vgc" "-vtls" platform="dmd"
	dflags "-betterC" "--vgc" platform="ldc"
	dflags "-ftransition=nogc" "-ftransition=tls" platform="gdc"
}

# Make the compiler print GC and TLS usage, and target information.
buildType "debugv" {
	versions "DebugV" "PrintTargetInfo"
	buildOptions "debugMode" "debugInfo"
	dflags "-betterC" "-vgc" "-vtls" platform="dmd"
	dflags "-betterC" "--vgc" platform="ldc"
	dflags "-ftransition=nogc" "-ftransition=tls" platform="gdc"
}

# Ditto but aimed for older compiler version
# Like older dmd versions, ldc 0.17.1, and gdc 6.0
buildType "debugv0" {
	versions "DebugV0" "PrintTargetInfo"
	buildOptions "debugMode" "debugInfo"
	dflags "-vgc" "-vtls" platform="dmd"
	dflags "--vgc" platform="ldc"
	dflags "-ftransition=nogc" "-ftransition=tls" "-fno-exceptions" "-fno-bounds-check" "-fno-assert" "-fno-builtin" platform="gdc"
}

# Make the compiler verbose instead of DUB.
buildType "debugvv" {
	versions "DebugVV"
	buildOptions "debugMode" "debugInfo"
	dflags "-betterC" "-v" platform="dmd"
	dflags "-betterC" "-v" platform="ldc"
	dflags "-v" platform="gdc"
}

# Compile in debug mode.
buildType "debug" {
	versions "Debug"
	buildOptions "debugMode" "debugInfo"
	dflags "-betterC" platform="dmd"
	dflags "-betterC" platform="ldc"
}

## Release builds

# Compile in release mode.
buildType "release" {
	versions "Release"
	buildOptions "releaseMode" "optimize"
	dflags "-betterC" platform="dmd"
	dflags "-betterC" platform="ldc"
}

# Compile in release mode with no bound checking.
buildType "release-nobounds" {
	versions "Release" "ReleaseNobounds"
	buildOptions "releaseMode" "optimize" "noBoundsCheck"
	dflags "-betterC" platform="dmd"
	dflags "-betterC" platform="ldc"
}

## Release-Static builds

# NOTE: DMD and GDC static builds tend to work better under glibc environments.

# Compile in release mode as statically linked.
buildType "release-static" {
	versions "Release" "ReleaseNobounds"
	buildOptions "releaseMode" "optimize"
	dflags "-betterC" "-L=-static" platform="dmd"
	dflags "-fno-druntime" "-Wl,-static" platform="gdc"
	dflags "-betterC" "--static" platform="ldc"
}

# Compile in release mode with no bound checking as statically linked.
buildType "release-nobounds-static" {
	versions "Release" "ReleaseNobounds"
	buildOptions "releaseMode" "optimize" "noBoundsCheck"
	dflags "-betterC" "-L=-static" platform="dmd"
	dflags "-fno-druntime" "-Wl,-static" platform="gdc"
	dflags "-betterC" "--static" platform="ldc"
}

#
# ANCHOR Integration tests
#
# NOTE: These MUST be ran as "dub test -b TEST"
# NOTE: Dedicated tests must only exist if one of these conditions are met
#       - Requires user input (e.g., readline)
#       - Are prone to crashing application (e.g., longjmp on Windows)
#

buildType "setjmp" {
	buildOptions "unittests"
	sourceFiles "tests/setjmp.d"
	sourcePaths "src"
}
buildType "readkey" {
	buildOptions "unittests"
	sourceFiles "tests/readkey.d" "app/term.d"
}
buildType "readln" {
	buildOptions "unittests"
	sourceFiles "tests/readln.d" "app/term.d"
}

#
# ANCHOR Documentation build types
#

buildType "docs" {
	buildRequirements "allowWarnings"
	buildOptions "syntaxOnly"
	dflags "-Dddocs"
}
buildType "ddox" {
	buildRequirements "allowWarnings"
	buildOptions "syntaxOnly"
	dflags "-Dddocs" "-Df__dummy.html" "-Xfdocs.json"
}