mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-25 16:43:28 +00:00
introduced cmd line args in script
This commit is contained in:
parent
8e8debb67a
commit
17065c116c
@ -8,7 +8,7 @@ pages:
|
|||||||
- [how_to.md, How to use BTstack]
|
- [how_to.md, How to use BTstack]
|
||||||
- [protocols.md, Supported Protocols]
|
- [protocols.md, Supported Protocols]
|
||||||
- [profiles.md, Supported Profiles]
|
- [profiles.md, Supported Profiles]
|
||||||
- [examples/generated.md, Embedded Examples]
|
- [examples/examples.md, Embedded Examples]
|
||||||
- [porting.md, Porting to Other Platforms]
|
- [porting.md, Porting to Other Platforms]
|
||||||
- [integration.md, Integrating with Existing Systems]
|
- [integration.md, Integrating with Existing Systems]
|
||||||
- [appendix/apis.md, APIs]
|
- [appendix/apis.md, APIs]
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import os
|
import os, sys, getopt, re
|
||||||
import re
|
|
||||||
import sys
|
|
||||||
|
|
||||||
class State:
|
class State:
|
||||||
SearchStartAPI = 0
|
SearchStartAPI = 0
|
||||||
@ -9,11 +7,6 @@ class State:
|
|||||||
SearchEndAPI = 2
|
SearchEndAPI = 2
|
||||||
DoneAPI = 3
|
DoneAPI = 3
|
||||||
|
|
||||||
docs_folder = "docs/appendix/"
|
|
||||||
appendix_file = docs_folder + "apis.md"
|
|
||||||
btstack_folder = "../../"
|
|
||||||
code_identation = " "
|
|
||||||
|
|
||||||
api_header = """
|
api_header = """
|
||||||
|
|
||||||
## API_TITLE API {#sec:API_LABLEAPIAppendix}
|
## API_TITLE API {#sec:API_LABLEAPIAppendix}
|
||||||
@ -23,31 +16,15 @@ api_header = """
|
|||||||
api_ending = """
|
api_ending = """
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# [file_name, api_title, api_lable]
|
|
||||||
list_of_apis = [
|
|
||||||
[btstack_folder+"include/btstack/run_loop.h", "Run Loop", "runLoop"],
|
|
||||||
[btstack_folder+"src/hci.h", "HCI", "hci"],
|
|
||||||
[btstack_folder+"src/l2cap.h", "L2CAP", "l2cap"],
|
|
||||||
[btstack_folder+"src/rfcomm.h", "RFCOMM", "rfcomm"],
|
|
||||||
[btstack_folder+"src/sdp.h", "SDP", "sdp"],
|
|
||||||
[btstack_folder+"src/sdp_client.h", "SDP Client", "sdpClient"],
|
|
||||||
[btstack_folder+"src/sdp_query_rfcomm.h", "SDP RFCOMM Query", "sdpQueries"],
|
|
||||||
[btstack_folder+"ble/gatt_client.h", "GATT Client", "gattClient"],
|
|
||||||
[btstack_folder+"src/pan.h", "PAN", "pan"],
|
|
||||||
[btstack_folder+"src/bnep.h", "BNEP", "bnep"],
|
|
||||||
[btstack_folder+"src/gap.h", "GAP", "gap"],
|
|
||||||
[btstack_folder+"ble/sm.h", "SM", "sm"]
|
|
||||||
]
|
|
||||||
|
|
||||||
def replacePlaceholder(template, title, lable):
|
def replacePlaceholder(template, title, lable):
|
||||||
api_title = title + " API"
|
api_title = title + " API"
|
||||||
snippet = template.replace("API_TITLE", title).replace("API_LABLE", lable)
|
snippet = template.replace("API_TITLE", title).replace("API_LABLE", lable)
|
||||||
return snippet
|
return snippet
|
||||||
|
|
||||||
def writeAPI(fout, infile_name):
|
def writeAPI(fout, api_filename, mk_codeidentation):
|
||||||
global code_identation
|
|
||||||
state = State.SearchStartAPI
|
state = State.SearchStartAPI
|
||||||
with open(infile_name, 'rb') as fin:
|
with open(api_filename, 'rb') as fin:
|
||||||
for line in fin:
|
for line in fin:
|
||||||
if state == State.SearchStartAPI:
|
if state == State.SearchStartAPI:
|
||||||
parts = re.match('\s*(/\*).*API_START.*(\*/)',line)
|
parts = re.match('\s*(/\*).*API_START.*(\*/)',line)
|
||||||
@ -65,24 +42,58 @@ def writeAPI(fout, infile_name):
|
|||||||
if parts:
|
if parts:
|
||||||
state = State.DoneAPI
|
state = State.DoneAPI
|
||||||
return
|
return
|
||||||
fout.write(code_identation + line)
|
fout.write(mk_codeidentation + line)
|
||||||
|
|
||||||
def process_and_write_api(fout, api_tuple):
|
|
||||||
infile_name = api_tuple[0]
|
|
||||||
if not infile_name:
|
|
||||||
return
|
|
||||||
|
|
||||||
api_title = api_tuple[1]
|
|
||||||
api_lable = api_tuple[2]
|
|
||||||
|
|
||||||
fout.write(replacePlaceholder(api_header, api_title, api_lable))
|
|
||||||
writeAPI(fout, infile_name)
|
|
||||||
|
|
||||||
|
|
||||||
with open(appendix_file, 'w') as aout:
|
|
||||||
for api_tuple in list_of_apis:
|
|
||||||
infile_name = api_tuple[0]
|
|
||||||
if not infile_name:
|
|
||||||
continue
|
|
||||||
process_and_write_api(aout, api_tuple)
|
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
btstackfolder = "../../"
|
||||||
|
docsfolder = "docs/"
|
||||||
|
mk_codeidentation = " "
|
||||||
|
|
||||||
|
outputfile = docsfolder + "appendix/apis.md"
|
||||||
|
|
||||||
|
cmd = 'update_apis.py [-b <btstackfolder>] [-o <outputfile>]'
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(argv,"hiso:",["bfolder=","ofile="])
|
||||||
|
except getopt.GetoptError:
|
||||||
|
print cmd
|
||||||
|
sys.exit(2)
|
||||||
|
for opt, arg in opts:
|
||||||
|
if opt == '-h':
|
||||||
|
print cmd
|
||||||
|
sys.exit()
|
||||||
|
elif opt in ("-b", "--bfolder"):
|
||||||
|
btstackfolder = arg
|
||||||
|
elif opt in ("-o", "--ofile"):
|
||||||
|
outputfile = arg
|
||||||
|
print 'BTstack folder is ', btstackfolder
|
||||||
|
print 'Output file is ', outputfile
|
||||||
|
|
||||||
|
|
||||||
|
# [file_name, api_title, api_lable]
|
||||||
|
list_of_apis = [
|
||||||
|
[btstackfolder+"include/btstack/run_loop.h", "Run Loop", "runLoop"],
|
||||||
|
[btstackfolder+"src/hci.h", "HCI", "hci"],
|
||||||
|
[btstackfolder+"src/l2cap.h", "L2CAP", "l2cap"],
|
||||||
|
[btstackfolder+"src/rfcomm.h", "RFCOMM", "rfcomm"],
|
||||||
|
[btstackfolder+"src/sdp.h", "SDP", "sdp"],
|
||||||
|
[btstackfolder+"src/sdp_client.h", "SDP Client", "sdpClient"],
|
||||||
|
[btstackfolder+"src/sdp_query_rfcomm.h", "SDP RFCOMM Query", "sdpQueries"],
|
||||||
|
[btstackfolder+"ble/gatt_client.h", "GATT Client", "gattClient"],
|
||||||
|
[btstackfolder+"src/pan.h", "PAN", "pan"],
|
||||||
|
[btstackfolder+"src/bnep.h", "BNEP", "bnep"],
|
||||||
|
[btstackfolder+"src/gap.h", "GAP", "gap"],
|
||||||
|
[btstackfolder+"ble/sm.h", "SM", "sm"]
|
||||||
|
]
|
||||||
|
|
||||||
|
with open(outputfile, 'w') as fout:
|
||||||
|
for api_tuple in list_of_apis:
|
||||||
|
api_filename = api_tuple[0]
|
||||||
|
api_title = api_tuple[1]
|
||||||
|
api_lable = api_tuple[2]
|
||||||
|
|
||||||
|
fout.write(replacePlaceholder(api_header, api_title, api_lable))
|
||||||
|
writeAPI(fout, api_filename, mk_codeidentation)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main(sys.argv[1:])
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import os
|
import os, sys, getopt, re
|
||||||
import re
|
|
||||||
import sys, getopt
|
|
||||||
|
|
||||||
# Defines the names of example groups. Preserves the order in which the example groups will be parsed.
|
# Defines the names of example groups. Preserves the order in which the example groups will be parsed.
|
||||||
list_of_groups = ["Hello World", "GAP", "SDP Queries", "SPP Server", "BNEP/PAN", "Low Energy", "Dual Mode"]
|
list_of_groups = ["Hello World", "GAP", "SDP Queries", "SPP Server", "BNEP/PAN", "Low Energy", "Dual Mode"]
|
||||||
@ -305,29 +303,34 @@ def processExamples(intro_file, examples_folder, examples_ofile):
|
|||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
btstack_folder = "../../"
|
btstackfolder = "../../"
|
||||||
docs_folder = "docs/examples/"
|
docsfolder = "docs/"
|
||||||
inputfolder = btstack_folder + "example/embedded/"
|
|
||||||
outputfile = docs_folder + "generated.md"
|
inputfolder = btstackfolder + "example/embedded/"
|
||||||
intro_file = "docs/examples/intro.md"
|
introfile = docsfolder + "examples/intro.md"
|
||||||
|
outputfile = docsfolder + "examples/examples.md"
|
||||||
|
|
||||||
|
cmd = 'update_listings.py [-f <inputfolder>] [-i <introfile>] [-o <outputfile>]'
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv,"hiso:",["ifolder=","ofile="])
|
opts, args = getopt.getopt(argv,"hiso:",["ffolder=","ifile=","ofile="])
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
print 'update_listings.py [-i <inputfolder>] [-o <outputfile>]'
|
print cmd
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
for opt, arg in opts:
|
for opt, arg in opts:
|
||||||
if opt == '-h':
|
if opt == '-h':
|
||||||
print 'update_listings.py [-i <inputfolder>] [-s] [-o <outputfile>]'
|
print cmd
|
||||||
sys.exit()
|
sys.exit()
|
||||||
elif opt in ("-i", "--ifolder"):
|
elif opt in ("-f", "--ffolder"):
|
||||||
inputfolder = arg
|
inputfolder = arg
|
||||||
|
elif opt in ("-i", "--ifile"):
|
||||||
|
introfile = arg
|
||||||
elif opt in ("-o", "--ofile"):
|
elif opt in ("-o", "--ofile"):
|
||||||
outputfile = arg
|
outputfile = arg
|
||||||
print 'Input folder is ', inputfolder
|
print 'Input folder is ', inputfolder
|
||||||
|
print 'Intro file is ', introfile
|
||||||
print 'Output file is ', outputfile
|
print 'Output file is ', outputfile
|
||||||
|
|
||||||
processExamples(intro_file, inputfolder, outputfile)
|
processExamples(introfile, inputfolder, outputfile)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user