X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=source%2Fnew-driver;h=14178d3241dfb5849abe4886aff646601444f6d1;hb=0b0d0cc0a8a89c1b81d1952c08ce100a334d6bcc;hp=64a20c927bab56ba253f21af42fed023cc7e9872;hpb=bc02c2bf465c0ad26410596f0b8ac0a9be57ea0c;p=sigrok-util.git diff --git a/source/new-driver b/source/new-driver index 64a20c9..14178d3 100755 --- a/source/new-driver +++ b/source/new-driver @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 ## ## This file is part of the sigrok-util project. ## @@ -29,13 +29,13 @@ import datetime TMPL_AUTOCONF_DRIVER = "SR_DRIVER([{name}], [{short}])\n" -TMPL_FILES = ('api.c', 'protocol.c', 'protocol.h') +TMPL_FILES = ('protocol.h', 'protocol.c', 'api.c') TMPL_HWMAKE_DRIVERLIB = """if HW_{upper} -libsigrok_la_SOURCES +=""" +src_libdrivers_la_SOURCES +=""" for tmpl_file in TMPL_FILES: - TMPL_HWMAKE_DRIVERLIB += " \\\nsrc/hardware/{short}/" + tmpl_file -TMPL_HWMAKE_DRIVERLIB += "\nendif" + TMPL_HWMAKE_DRIVERLIB += " \\\n\tsrc/hardware/{short}/" + tmpl_file +TMPL_HWMAKE_DRIVERLIB += "\nendif\n" def tmpl(template, names): @@ -59,7 +59,7 @@ def new_driver(srcurl, tmpldir, names): do_autoconf(gitdir, names) do_automake(gitdir, names) do_driverskel(gitdir, tmpldir, names) - make_patch(gitdir) + make_patch(gitdir, names) except Exception as e: raise print(e) @@ -108,7 +108,7 @@ def do_automake(gitdir, names): if drv_short > names['upper']: out += tmpl(TMPL_HWMAKE_DRIVERLIB, names) state = 'done' - elif not re.match(r'\s*libsigrok_la_SOURCES\b|\s*src/hardware/|endif\b', line): + elif not re.match(r'\s*src_libdrivers_la_SOURCES\b|\s*src/hardware/|endif\b', line): print("[%s]" % line.strip()) # we passed the last entry out += tmpl(TMPL_HWMAKE_DRIVERLIB, names) @@ -178,7 +178,7 @@ if __name__ == '__main__': author, email = parse_gitconfig() parser = ArgumentParser(description='Bootstrap a new sigrok hardware driver') - parser.add_argument('name', help='new driver name') + parser.add_argument('name', nargs='*', default=[], help='new driver name') parser.add_argument('--giturl', default=defaulturl, help='URL of the libsigrok git repository ' '(defaults to {0})'.format(defaulturl)) @@ -193,8 +193,10 @@ if __name__ == '__main__': if not opts.author or not opts.email: parser.error('Please provide your username and email address, ' - 'or set your git configuration up.') - name = opts.name + 'or set your git configuration up.') + name = ' '.join(opts.name) + if not name: + parser.error('Please provide a driver name.') names = { 'name': name, 'short': re.sub('[^a-z0-9]', '-', name.lower()),