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 © 2019-2023 dd86k <dd@dax.moe>"
license "BSD-3-Clause"

# 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.

#TODO: Consider renaming version Trace to AdbgTrace to avoid library conflicts
#TODO: Make docs/ddox builds only peek in src/ and not in app/

#
# ANCHOR Configurations
#

# Not a subPackage because I want to avoid generating a seperate library
configuration "application" {
	targetType "executable"
	sourcePaths "app"
	importPaths "app"
	mainSourceFile "app/main.d"
}
configuration "library" {
	sourcePaths "src"
}

#
# ANCHOR Build types
#

# 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"
	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"
}

# 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"
}

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

#
# ANCHOR Unit 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 "readline" {
	buildOptions "unittests"
	sourceFiles "tests/readline.d"
	sourcePaths "app" "src"
}

#
# ANCHOR Examples
#

subPackage {
	name "example-simple-v1"
	targetType "executable"
	targetName "simple-v1"
	sourcePaths "src"
	importPaths "src"
	mainSourceFile "examples/simple-v1.d"
	dflags "-betterC" "-vgc" "-vtls" platform="dmd"
	dflags "-betterC" "--vgc" platform="ldc"
	dflags "-ftransition=nogc" "-ftransition=tls" platform="gdc"
}

subPackage {
	name "example-simple"
	targetType "executable"
	targetName "simple"
	sourcePaths "src"
	importPaths "src"
	mainSourceFile "examples/simple.d"
	dflags "-betterC" "-vgc" "-vtls" platform="dmd"
	dflags "-betterC" "--vgc" platform="ldc"
	dflags "-ftransition=nogc" "-ftransition=tls" platform="gdc"
}