linkers.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. # Copyright 2012-2017 The Meson development team
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. # Unless required by applicable law or agreed to in writing, software
  7. # distributed under the License is distributed on an "AS IS" BASIS,
  8. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing permissions and
  10. # limitations under the License.
  11. from .mesonlib import Popen_safe
  12. class StaticLinker:
  13. pass
  14. class VisualStudioLinker(StaticLinker):
  15. always_args = ['/NOLOGO']
  16. def __init__(self, exelist):
  17. self.exelist = exelist
  18. def get_exelist(self):
  19. return self.exelist[:]
  20. def get_std_link_args(self):
  21. return []
  22. def get_buildtype_linker_args(self, buildtype):
  23. return []
  24. def get_output_args(self, target):
  25. return ['/OUT:' + target]
  26. def get_coverage_link_args(self):
  27. return []
  28. def get_always_args(self):
  29. return VisualStudioLinker.always_args
  30. def get_linker_always_args(self):
  31. return VisualStudioLinker.always_args
  32. def build_rpath_args(self, build_dir, from_dir, rpath_paths, build_rpath, install_rpath):
  33. return []
  34. def thread_link_flags(self):
  35. return []
  36. def get_option_link_args(self, options):
  37. return []
  38. @classmethod
  39. def unix_args_to_native(cls, args):
  40. from .compilers import VisualStudioCCompiler
  41. return VisualStudioCCompiler.unix_args_to_native(args)
  42. def get_link_debugfile_args(self, targetfile):
  43. # Static libraries do not have PDB files
  44. return []
  45. class ArLinker(StaticLinker):
  46. def __init__(self, exelist):
  47. self.exelist = exelist
  48. self.id = 'ar'
  49. pc, stdo = Popen_safe(self.exelist + ['-h'])[0:2]
  50. # Enable deterministic builds if they are available.
  51. if '[D]' in stdo:
  52. self.std_args = ['csrD']
  53. else:
  54. self.std_args = ['csr']
  55. def build_rpath_args(self, build_dir, from_dir, rpath_paths, build_rpath, install_rpath):
  56. return []
  57. def get_exelist(self):
  58. return self.exelist[:]
  59. def get_std_link_args(self):
  60. return self.std_args
  61. def get_output_args(self, target):
  62. return [target]
  63. def get_buildtype_linker_args(self, buildtype):
  64. return []
  65. def get_linker_always_args(self):
  66. return []
  67. def get_coverage_link_args(self):
  68. return []
  69. def get_always_args(self):
  70. return []
  71. def thread_link_flags(self):
  72. return []
  73. def get_option_link_args(self, options):
  74. return []
  75. @classmethod
  76. def unix_args_to_native(cls, args):
  77. return args[:]
  78. def get_link_debugfile_args(self, targetfile):
  79. return []