You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
5.5 KiB

6 years ago
  1. from __future__ import print_function
  2. """SCons.Tool.gdc
  3. Tool-specific initialization for the GDC compiler.
  4. (https://github.com/D-Programming-GDC/GDC)
  5. Developed by Russel Winder (russel@winder.org.uk)
  6. 2012-05-09 onwards
  7. Compiler variables:
  8. DC - The name of the D compiler to use. Defaults to gdc.
  9. DPATH - List of paths to search for import modules.
  10. DVERSIONS - List of version tags to enable when compiling.
  11. DDEBUG - List of debug tags to enable when compiling.
  12. Linker related variables:
  13. LIBS - List of library files to link in.
  14. DLINK - Name of the linker to use. Defaults to gdc.
  15. DLINKFLAGS - List of linker flags.
  16. Lib tool variables:
  17. DLIB - Name of the lib tool to use. Defaults to lib.
  18. DLIBFLAGS - List of flags to pass to the lib tool.
  19. LIBS - Same as for the linker. (libraries to pull into the .lib)
  20. """
  21. #
  22. # Copyright (c) 2001 - 2017 The SCons Foundation
  23. #
  24. # Permission is hereby granted, free of charge, to any person obtaining
  25. # a copy of this software and associated documentation files (the
  26. # "Software"), to deal in the Software without restriction, including
  27. # without limitation the rights to use, copy, modify, merge, publish,
  28. # distribute, sublicense, and/or sell copies of the Software, and to
  29. # permit persons to whom the Software is furnished to do so, subject to
  30. # the following conditions:
  31. #
  32. # The above copyright notice and this permission notice shall be included
  33. # in all copies or substantial portions of the Software.
  34. #
  35. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  36. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  37. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  38. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  39. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  40. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  41. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  42. #
  43. __revision__ = "src/engine/SCons/Tool/gdc.py rel_3.0.0:4395:8972f6a2f699 2017/09/18 12:59:24 bdbaddog"
  44. import SCons.Action
  45. import SCons.Defaults
  46. import SCons.Tool
  47. import SCons.Tool.DCommon as DCommon
  48. def generate(env):
  49. static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
  50. static_obj.add_action('.d', SCons.Defaults.DAction)
  51. shared_obj.add_action('.d', SCons.Defaults.ShDAction)
  52. static_obj.add_emitter('.d', SCons.Defaults.StaticObjectEmitter)
  53. shared_obj.add_emitter('.d', SCons.Defaults.SharedObjectEmitter)
  54. env['DC'] = env.Detect('gdc') or 'gdc'
  55. env['DCOM'] = '$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -c -o $TARGET $SOURCES'
  56. env['_DINCFLAGS'] = '${_concat(DINCPREFIX, DPATH, DINCSUFFIX, __env__, RDirs, TARGET, SOURCE)}'
  57. env['_DVERFLAGS'] = '${_concat(DVERPREFIX, DVERSIONS, DVERSUFFIX, __env__)}'
  58. env['_DDEBUGFLAGS'] = '${_concat(DDEBUGPREFIX, DDEBUG, DDEBUGSUFFIX, __env__)}'
  59. env['_DFLAGS'] = '${_concat(DFLAGPREFIX, DFLAGS, DFLAGSUFFIX, __env__)}'
  60. env['SHDC'] = '$DC'
  61. env['SHDCOM'] = '$SHDC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -fPIC -c -o $TARGET $SOURCES'
  62. env['DPATH'] = ['#/']
  63. env['DFLAGS'] = []
  64. env['DVERSIONS'] = []
  65. env['DDEBUG'] = []
  66. if env['DC']:
  67. DCommon.addDPATHToEnv(env, env['DC'])
  68. env['DINCPREFIX'] = '-I'
  69. env['DINCSUFFIX'] = ''
  70. env['DVERPREFIX'] = '-version='
  71. env['DVERSUFFIX'] = ''
  72. env['DDEBUGPREFIX'] = '-debug='
  73. env['DDEBUGSUFFIX'] = ''
  74. env['DFLAGPREFIX'] = '-'
  75. env['DFLAGSUFFIX'] = ''
  76. env['DFILESUFFIX'] = '.d'
  77. env['DLINK'] = '$DC'
  78. env['DLINKFLAGS'] = SCons.Util.CLVar('')
  79. env['DLINKCOM'] = '$DLINK -o $TARGET $DLINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
  80. env['SHDLINK'] = '$DC'
  81. env['SHDLINKFLAGS'] = SCons.Util.CLVar('$DLINKFLAGS -shared -shared-libphobos')
  82. env['SHDLINKCOM'] = '$DLINK -o $TARGET $SHDLINKFLAGS $__SHDLIBVERSIONFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS'
  83. env['DLIB'] = 'lib' if env['PLATFORM'] == 'win32' else 'ar cr'
  84. env['DLIBCOM'] = '$DLIB $_DLIBFLAGS {0}$TARGET $SOURCES $_DLINKLIBFLAGS'.format('-c ' if env['PLATFORM'] == 'win32' else '')
  85. env['_DLIBFLAGS'] = '${_concat(DLIBFLAGPREFIX, DLIBFLAGS, DLIBFLAGSUFFIX, __env__)}'
  86. env['DLIBFLAGPREFIX'] = '-'
  87. env['DLIBFLAGSUFFIX'] = ''
  88. env['DLINKFLAGPREFIX'] = '-'
  89. env['DLINKFLAGSUFFIX'] = ''
  90. # __RPATH is set to $_RPATH in the platform specification if that
  91. # platform supports it.
  92. env['RPATHPREFIX'] = '-Wl,-rpath='
  93. env['RPATHSUFFIX'] = ''
  94. env['_RPATH'] = '${_concat(RPATHPREFIX, RPATH, RPATHSUFFIX, __env__)}'
  95. # Support for versioned libraries
  96. env['_SHDLIBVERSIONFLAGS'] = '$SHDLIBVERSIONFLAGS -Wl,-soname=$_SHDLIBSONAME'
  97. env['_SHDLIBSONAME'] = '${DShLibSonameGenerator(__env__,TARGET)}'
  98. # NOTE: this is a quick hack, the soname will only work if there is
  99. # c/c++ linker loaded which provides callback for the ShLibSonameGenerator
  100. env['DShLibSonameGenerator'] = SCons.Tool.ShLibSonameGenerator
  101. # NOTE: this is only for further reference, currently $SHDLIBVERSION does
  102. # not work, the user must use $SHLIBVERSION
  103. env['SHDLIBVERSION'] = '$SHLIBVERSION'
  104. env['SHDLIBVERSIONFLAGS'] = '$SHLIBVERSIONFLAGS'
  105. env['BUILDERS']['ProgramAllAtOnce'] = SCons.Builder.Builder(
  106. action='$DC $_DINCFLAGS $_DVERFLAGS $_DDEBUGFLAGS $_DFLAGS -o $TARGET $DLINKFLAGS $__DRPATH $SOURCES $_DLIBDIRFLAGS $_DLIBFLAGS',
  107. emitter=DCommon.allAtOnceEmitter,
  108. )
  109. def exists(env):
  110. return env.Detect('gdc')
  111. # Local Variables:
  112. # tab-width:4
  113. # indent-tabs-mode:nil
  114. # End:
  115. # vim: set expandtab tabstop=4 shiftwidth=4: