dmd.mars
Entry point for DMD.
Discussion
This modules defines the entry point (main) for DMD, as well as related utilities needed for arguments parsing, path manipulation, etc... This file is not shared with other compilers which use the DMD front-end.
License
Source: mars.d
Documentation: https://dlang.org/phobos/dmd_mars.html
-
Declaration
structDMDparams;DMD-specific parameters.
-
Declaration
boolparseCommandlineAndConfig(size_targc, const(char)**argv, ref Paramparams, ref Stringsfiles);Parses the command line arguments and configuration
filesParameters
size_targcNumber of arguments passed via command line
const(char)**argvArray of string arguments passed via command line
Paramparamsparametes from
argvStringsfilesfilesfromargvReturn Value
trueon faiure -
Declaration
voidemitMakeDeps(ref Paramparams);Emit the makefile dependencies for the -makedeps switch
-
Declaration
intmain(intargc, char**argv);DMD's entry point, C
main.Discussion
Without
-lowmem, we need to switch to the bump-pointer allocation scheme right from the start, before any module ctors are run, so we need this hook before druntime is initialized and_Dmainis called.Return Value
Return code of the application
-
Declaration
int_Dmain(char[][]);Manual D main (for druntime initialization), which forwards to
tryMain.Return Value
Return code of the application
-
Declaration
voidgetenv_setargv(const(char)*envvalue, Strings*args);Parses an environment variable containing command-line flags and append them to
.argsDiscussion
This function is used to read the content of DFLAGS. Flags are separated based on spaces and tabs.
Parameters
const(char)*envvalueThe content of an environment variable
Strings*argsArray to append the flags to, if any.
-
Declaration
const(char)[]parse_arch_arg(Strings*args, const(char)[]arch);Parse command line arguments for the last instance of -m32, -m64 or -m32mscoff to detect the desired architecture.
Parameters
Strings*argsCommand line arguments
const(char)[]archDefault value to use for architecture. Should be "32" or "64"
Return Value
"32", "64" or "32mscoff" if the "-m32", "-m64", "-m32mscoff" flags were passed, respectively. If they weren't, return
.arch -
Declaration
const(char)[]parse_conf_arg(Strings*args);Parse command line arguments for the last instance of -conf=path.
Parameters
Strings*argsCommand line arguments
Return Value
The 'path' in -conf=path, which is the path to the config file to use
-
Declaration
voidaddDefaultVersionIdentifiers(const ref Paramparams, const ref Targettgt);Add default
versionidentifier for dmd, and set the target platform in. https://dlang.org/spec/version.html#predefined-versionsparamsDiscussion
Needs to be run after all arguments parsing (command line, DFLAGS environment variable and config file) in order to add final flags (such as
X86_64or theCRuntimeused).Parameters
Paramparamswhich target to compile for (set by
setTarget())Targettgttarget
-
Declaration
voidflushMixins();we want to write the mixin expansion file also on error, but there are too many ways to terminate dmd (e.g. fatal() which calls exit(EXIT_FAILURE)), so we can't rely on scope(exit) ... in tryMain() actually being executed so we add atexit(&
flushMixins); for those fatal exits (with the GC still valid) -
Declaration
boolparseCommandLine(const ref Stringsarguments, const size_targc, ref Paramparams, ref Stringsfiles);Parse command line
arguments.Discussion
Prints message(s) if there are errors.
Parameters
Stringsargumentscommand line
argumentssize_targcargument count
Paramparamsset to result of parsing
argumentsStringsfilesset to
filespulled fromargumentsReturn Value
trueif errors in command line -
Declaration
ModulecreateModule(const(char)*file, ref Stringslibmodules);Creates the module based on the
fileprovidedDiscussion
The
fileis dispatched in one of the various arrays (global.params.{ddocfiles,dllfiles,jsonfiles,etc...}) according to its extension. If it is a binaryfile, it is added tolibmodules.Parameters
const(char)*fileFile name to dispatch
StringslibmodulesArray to which binaries (shared/static libs and object files) will be appended
Return Value
A D module
-
Declaration
ModulescreateModules(ref Stringsfiles, ref Stringslibmodules);Creates the list of modules based on the
filesprovidedDiscussion
Files are dispatched in the various arrays (global.params.{ddocfiles,dllfiles,jsonfiles,etc...}) according to their extension. Binary
filesare added tolibmodules.Parameters
StringsfilesFile names to dispatch
StringslibmodulesArray to which binaries (shared/static libs and object
files) will be appendedReturn Value
An array of path to D modules