X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-util.git;a=blobdiff_plain;f=source%2Fnew-driver;h=6d77220fc9ad41128525dbd6b21e9ecc117e9630;hp=7a9131493ad1e5bf7d8fa4fdb583e29cd7b3fad2;hb=87604b0c3ec0115a89921039ff12a6fa4606ddcb;hpb=6ebf301648769e8899f6c7f3dbb66cc8607dfe7e diff --git a/source/new-driver b/source/new-driver index 7a91314..6d77220 100755 --- a/source/new-driver +++ b/source/new-driver @@ -28,13 +28,7 @@ import socket import datetime TMPL_AUTOCONF_DRIVER = "DRIVER([${name}], [${short}])\n" -TMPL_AUTOCONF_AM_CONDITIONAL = """\ -AM_CONDITIONAL(HW_${upper}, test x$HW_${upper} = xyes) -if test "x$HW_${upper}" = "xyes"; then - AC_DEFINE(HAVE_HW_${upper}, 1, [${name} support]) -fi - -""" +TMPL_AUTOCONF_DRIVER2 = "DRIVER2([HW_${upper}], [$HW_${upper}], [HAVE_HW_${upper}])\n" TMPL_HWMAKE_DRIVERLIB = """if HW_${upper} libsigrok_la_SOURCES += \\ @@ -50,7 +44,7 @@ extern SR_PRIV struct sr_dev_driver ${lib}_driver_info; """ TMPL_DRIVERS_POINTER = """\ #ifdef HAVE_HW_${upper} - &${lib}_driver_info, + (DRVS) {&${lib}_driver_info, NULL}, #endif """ FILE_DRV_API = 'drv-api.c' @@ -73,7 +67,7 @@ def new_driver(): tmp = tempfile.mkdtemp() try: os.chdir(tmp) - process = Popen("git clone " + LIBSR, shell=True, stderr=PIPE) + process = Popen("git clone --depth=1 " + LIBSR, shell=True, stderr=PIPE) out, err = process.communicate() if process.returncode: raise Exception(err.decode()) @@ -88,7 +82,7 @@ def new_driver(): shutil.rmtree(tmp) -# add DRIVER and AM_CONDITIONAL/AC_DEFINE entries to configure.ac +# add DRIVER and DRIVER2 entries to configure.ac def do_autoconf(gitdir): cacpath = gitdir + 'configure.ac' configure_ac = open(cacpath).read() @@ -107,18 +101,18 @@ def do_autoconf(gitdir): state = 'automake' active = False elif state == 'automake': - m = re.match('AM_CONDITIONAL\(HW_([^,]+)', line) + m = re.match('DRIVER2\(\[([^\]]+)', line) if m: active = True else: - submatch = re.match('(if|\s*AC_DEFINE|fi|$)', line) + submatch = re.match('DRIVER2\(\[([^\]]+)', line) if active and submatch is None: - # we're past the conditionals - out += tmpl(TMPL_AUTOCONF_AM_CONDITIONAL) + # we're past the DRIVER2 list + out += tmpl(TMPL_AUTOCONF_DRIVER2) state = 'done' if active: - if (m and m.group(1) > names['upper']): - out += tmpl(TMPL_AUTOCONF_AM_CONDITIONAL) + if (m and m.group(1) > 'HW_' + names['upper']): + out += tmpl(TMPL_AUTOCONF_DRIVER2) state = 'done' out += line + '\n' if state != 'done':