@ -432,7 +432,20 @@ class BasePlatformTests(unittest.TestCase):
def get_compdb ( self ) :
def get_compdb ( self ) :
with open ( os . path . join ( self . builddir , ' compile_commands.json ' ) ) as ifile :
with open ( os . path . join ( self . builddir , ' compile_commands.json ' ) ) as ifile :
return json . load ( ifile )
contents = json . load ( ifile )
# If Ninja is using .rsp files, generate them, read their contents, and
# replace it as the command for all compile commands in the parsed json.
if len ( contents ) > 0 and contents [ 0 ] [ ' command ' ] . endswith ( ' .rsp ' ) :
# Pretend to build so that the rsp files are generated
self . build ( [ ' -d ' , ' keeprsp ' , ' -n ' ] )
for each in contents :
# Extract the actual command from the rsp file
compiler , rsp = each [ ' command ' ] . split ( ' @ ' )
rsp = os . path . join ( self . builddir , rsp )
# Replace the command with its contents
with open ( rsp , ' r ' , encoding = ' utf-8 ' ) as f :
each [ ' command ' ] = compiler + ' ' + f . read ( )
return contents
def get_meson_log ( self ) :
def get_meson_log ( self ) :
with open ( os . path . join ( self . builddir , ' meson-logs ' , ' meson-log.txt ' ) ) as f :
with open ( os . path . join ( self . builddir , ' meson-logs ' , ' meson-log.txt ' ) ) as f :
@ -712,20 +725,18 @@ class AllPlatformTests(BasePlatformTests):
def test_internal_include_order ( self ) :
def test_internal_include_order ( self ) :
testdir = os . path . join ( self . common_test_dir , ' 138 include order ' )
testdir = os . path . join ( self . common_test_dir , ' 138 include order ' )
self . init ( testdir )
self . init ( testdir )
execmd = fxecmd = None
for cmd in self . get_compdb ( ) :
for cmd in self . get_compdb ( ) :
if cmd [ ' file ' ] . endswith ( ' /main.c ' ) :
if ' someexe ' in cmd [ ' command ' ] :
cmd = cmd [ ' command ' ]
execmd = cmd [ ' command ' ]
break
continue
else :
if ' somefxe ' in cmd [ ' command ' ] :
raise Exception ( ' Could not find main.c command ' )
fxecmd = cmd [ ' command ' ]
if cmd . endswith ( ' .rsp ' ) :
continue
# Pretend to build so that the rsp files are generated
if not execmd or not fxecmd :
self . build ( [ ' -d ' , ' keeprsp ' , ' -n ' ] )
raise Exception ( ' Could not find someexe and somfxe commands ' )
# Extract the actual command from the rsp file
# Check include order for 'someexe'
rsp = os . path . join ( self . builddir , cmd . split ( ' cl @ ' ) [ 1 ] )
incs = [ a for a in shlex . split ( execmd ) if a . startswith ( " -I " ) ]
with open ( rsp , ' r ' , encoding = ' utf-8 ' ) as f :
cmd = f . read ( )
incs = [ a for a in shlex . split ( cmd ) if a . startswith ( " -I " ) ]
self . assertEqual ( len ( incs ) , 8 )
self . assertEqual ( len ( incs ) , 8 )
# target private dir
# target private dir
self . assertPathEqual ( incs [ 0 ] , " -Isub4/someexe@exe " )
self . assertPathEqual ( incs [ 0 ] , " -Isub4/someexe@exe " )
@ -743,6 +754,27 @@ class AllPlatformTests(BasePlatformTests):
self . assertPathEqual ( incs [ 6 ] , " -Isub1 " )
self . assertPathEqual ( incs [ 6 ] , " -Isub1 " )
# target internal dependency include_directories: source dir
# target internal dependency include_directories: source dir
self . assertPathBasenameEqual ( incs [ 7 ] , ' sub1 ' )
self . assertPathBasenameEqual ( incs [ 7 ] , ' sub1 ' )
# Check include order for 'somefxe'
incs = [ a for a in shlex . split ( fxecmd ) if a . startswith ( ' -I ' ) ]
self . assertEqual ( len ( incs ) , 9 )
# target private dir
self . assertPathEqual ( incs [ 0 ] , ' -Isomefxe@exe ' )
# target build dir
self . assertPathEqual ( incs [ 1 ] , ' -I. ' )
# target source dir
self . assertPathBasenameEqual ( incs [ 2 ] , os . path . basename ( testdir ) )
# target internal dependency correct include_directories: build dir
self . assertPathEqual ( incs [ 3 ] , " -Isub4 " )
# target internal dependency correct include_directories: source dir
self . assertPathBasenameEqual ( incs [ 4 ] , ' sub4 ' )
# target internal dependency dep include_directories: build dir
self . assertPathEqual ( incs [ 5 ] , " -Isub1 " )
# target internal dependency dep include_directories: source dir
self . assertPathBasenameEqual ( incs [ 6 ] , ' sub1 ' )
# target internal dependency wrong include_directories: build dir
self . assertPathEqual ( incs [ 7 ] , " -Isub2 " )
# target internal dependency wrong include_directories: source dir
self . assertPathBasenameEqual ( incs [ 8 ] , ' sub2 ' )
def test_compiler_detection ( self ) :
def test_compiler_detection ( self ) :
'''
'''