11
11
import logging
12
12
import os
13
13
import re
14
- import shlex
15
14
import warnings
16
15
17
16
import yaml
18
17
19
- from codebasin import util
18
+ from codebasin import CompileCommand , util
20
19
21
20
log = logging .getLogger ("codebasin" )
22
21
@@ -418,11 +417,10 @@ def load_database(dbpath, rootdir):
418
417
419
418
configuration = []
420
419
for e in db :
421
- # Database may not have tokenized arguments
422
- if "command" in e :
423
- argv = shlex .split (e ["command" ])
424
- elif "arguments" in e :
425
- argv = e ["arguments" ]
420
+ command = CompileCommand .from_json (e )
421
+ if not command .is_supported ():
422
+ continue
423
+ argv = command .arguments
426
424
427
425
# Extract defines, include paths and include files
428
426
# from command-line arguments
@@ -444,19 +442,19 @@ def load_database(dbpath, rootdir):
444
442
# - relative to a directory
445
443
# - as an absolute path
446
444
filedir = rootdir
447
- if " directory" in e :
448
- if os .path .isabs (e [ " directory" ] ):
449
- filedir = e [ " directory" ]
445
+ if command . directory is not None :
446
+ if os .path .isabs (command . directory ):
447
+ filedir = command . directory
450
448
else :
451
449
filedir = os .path .realpath (
452
450
rootdir ,
453
- os .path .join (e [ " directory" ] ),
451
+ os .path .join (command . directory ),
454
452
)
455
453
456
- if os .path .isabs (e [ "file" ] ):
457
- path = os .path .realpath (e [ "file" ] )
454
+ if os .path .isabs (command . filename ):
455
+ path = os .path .realpath (command . filename )
458
456
else :
459
- path = os .path .realpath (os .path .join (filedir , e [ "file" ] ))
457
+ path = os .path .realpath (os .path .join (filedir , command . filename ))
460
458
461
459
# Compilation database may contain files that don't
462
460
# exist without running make
0 commit comments