gyptest-rpath.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env python
  2. # Copyright (c) 2012 Google Inc. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """
  6. Verifies that LD_DYLIB_INSTALL_NAME and DYLIB_INSTALL_NAME_BASE are handled
  7. correctly.
  8. """
  9. import TestGyp
  10. import re
  11. import subprocess
  12. import sys
  13. if sys.platform == 'darwin':
  14. test = TestGyp.TestGyp(formats=['ninja', 'make', 'xcode'])
  15. CHDIR = 'rpath'
  16. test.run_gyp('test.gyp', chdir=CHDIR)
  17. test.build('test.gyp', test.ALL, chdir=CHDIR)
  18. def GetRpaths(p):
  19. p = test.built_file_path(p, chdir=CHDIR)
  20. r = re.compile(r'cmd LC_RPATH.*?path (.*?) \(offset \d+\)', re.DOTALL)
  21. proc = subprocess.Popen(['otool', '-l', p], stdout=subprocess.PIPE)
  22. o = proc.communicate()[0]
  23. assert not proc.returncode
  24. return r.findall(o)
  25. if (GetRpaths('libdefault_rpath.dylib') != []):
  26. test.fail_test()
  27. if (GetRpaths('libexplicit_rpath.dylib') != ['@executable_path/.']):
  28. test.fail_test()
  29. if (GetRpaths('libexplicit_rpaths_escaped.dylib') !=
  30. ['First rpath', 'Second rpath']):
  31. test.fail_test()
  32. if (GetRpaths('My Framework.framework/My Framework') != ['@loader_path/.']):
  33. test.fail_test()
  34. if (GetRpaths('executable') != ['@executable_path/.']):
  35. test.fail_test()
  36. test.pass_test()