blob: 4aea193e4b6512fd0f264e141522245728635ebf [file] [log] [blame]
#!/usr/bin/env python
# Copyright (c) 2017 Google Inc. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
Verifies the use of linker flags in environment variables.
In this test, gyp and build both run in same local environment.
import TestGyp
import re
import subprocess
import sys
FORMATS = ('make', 'ninja')
if sys.platform.startswith('linux'):
test = TestGyp.TestGyp(formats=FORMATS)
CHDIR = 'ldflags-from-environment'
with TestGyp.LocalEnv({'LDFLAGS': '-Wl,--dynamic-linker=/target',
'LDFLAGS_host': '-Wl,--dynamic-linker=/host',
test.run_gyp('test.gyp', chdir=CHDIR)'test.gyp', chdir=CHDIR)
def GetDynamicLinker(p):
p = test.built_file_path(p, chdir=CHDIR)
r = re.compile(r'\[Requesting program interpreter: ([^\]]+)\]')
proc = subprocess.Popen(['readelf', '-l', p], stdout=subprocess.PIPE)
o = proc.communicate()[0].decode('utf-8')
assert not proc.returncode
if GetDynamicLinker('ldflags') != '/target':
if GetDynamicLinker('ldflags_host') != '/host':