tool/compile_gatt: normalize paths, use os specific path separators

This commit is contained in:
Matthias Ringwald 2019-09-06 14:46:25 +02:00
parent 948e8bfe93
commit 78b65b0a93

22
tool/compile_gatt.py Executable file → Normal file
View File

@ -115,6 +115,7 @@ current_service_start_handle = 0
current_characteristic_uuid_string = "" current_characteristic_uuid_string = ""
defines_for_characteristics = [] defines_for_characteristics = []
defines_for_services = [] defines_for_services = []
include_paths = []
handle = 1 handle = 1
total_size = 0 total_size = 0
@ -883,19 +884,18 @@ def listHandles(fout):
fout.write('\n') fout.write('\n')
def getFile( fileName ): def getFile( fileName ):
inc = args.I for d in include_paths:
for d in inc: fullFile = os.path.normpath(d + os.sep + fileName) # because Windows exists
fullFile = d[0] + fileName # print("test %s" % fullFile)
print("test %s" % fullFile)
if os.path.isfile( fullFile ) == True: if os.path.isfile( fullFile ) == True:
return fullFile return fullFile
print ("'{0}' not found".format( fileName )) print ("'{0}' not found".format( fileName ))
print ("Include paths: %s" % ", ".join(inc)) print ("Include paths: %s" % ", ".join(include_paths))
exit(-1) exit(-1)
btstack_root = os.path.abspath(os.path.dirname(sys.argv[0]) + '/..') btstack_root = os.path.abspath(os.path.dirname(sys.argv[0]) + '/..')
default_includes = [ btstack_root + '/src/', btstack_root + '/src/ble/gatt-service/'] default_includes = [os.path.normpath(path) for path in [ btstack_root + '/src/', btstack_root + '/src/ble/gatt-service/']]
parser = argparse.ArgumentParser(description='BLE GATT configuration generator for use with BTstack') parser = argparse.ArgumentParser(description='BLE GATT configuration generator for use with BTstack')
@ -908,11 +908,13 @@ parser.add_argument('hfile', metavar='hfile', type=str,
args = parser.parse_args() args = parser.parse_args()
# add include path arguments
if args.I != None:
for d in args.I:
include_paths.append(os.path.normpath(d[0]))
# append default include paths # append default include paths
if args.I == None: include_paths.extend(default_includes)
args.I = []
for d in default_includes:
args.I.append([d])
try: try:
# read defines from bluetooth_gatt.h # read defines from bluetooth_gatt.h