]> sigrok.org Git - sigrok-util.git/commitdiff
Adapted new-driver to new build system
authorAbhishek Kumar <redacted>
Sat, 22 Mar 2014 06:40:10 +0000 (12:10 +0530)
committerBert Vermeulen <redacted>
Sat, 22 Mar 2014 20:29:45 +0000 (21:29 +0100)
source/new-driver

index 2f8d5a07bb1bf0e918c5b8c6cf56882880628de0..79be2ae690dcc9acd03ee99c62ddde6c45983e99 100755 (executable)
@@ -40,9 +40,12 @@ fi
 """
 TMPL_AUTOCONF_AC_CONFIG_FILES = "\t\t hardware/${short}/Makefile\n"
 TMPL_AUTOCONF_SUMMARY = 'echo "  - ${summary}"\n'
-TMPL_HWMAKE_SUBDIR = '\t${short}'
+
 TMPL_HWMAKE_DRIVERLIB = """if HW_${upper}
-libsigrokhardware_la_LIBADD += ${short}/libsigrok_hw_${lib}.la
+libsigrok_la_SOURCES += \
+       hardware/${short}/protocol.h \
+       hardware/${short}/protocol.c \
+       hardware/${short}/api.c
 endif
 
 """
@@ -56,7 +59,6 @@ TMPL_HWDRIVER_DIPTR = """\
        &${lib}_driver_info,
 #endif
 """
-FILE_DRV_MAKEFILE = 'drv-Makefile.am'
 FILE_DRV_API = 'drv-api.c'
 FILE_DRV_PROTOCOL = 'drv-protocol.c'
 FILE_DRV_PROTOCOL_H = 'drv-protocol.h'
@@ -119,29 +121,6 @@ def do_configure_ac(gitdir):
         raise Exception('AC_ARG_ENABLE markers not found in configure.ac')
     configure_ac = out
 
-    # add driver Makefile to AC_CONFIG_FILES
-    out = ''
-    state = 'copy'
-    for line in configure_ac.split('\n')[:-1]:
-        if state == 'copy':
-            if line.find("AC_CONFIG_FILES([Makefile") > -1:
-                state = 'acconf'
-        elif state == 'acconf':
-            m = re.match('\t\t hardware/([^/]+)/Makefile', line)
-            if m:
-                drv_short = m.group(1)
-                if drv_short.lower() > names['short']:
-                    out += tmpl(TMPL_AUTOCONF_AC_CONFIG_FILES)
-                    state = 'done'
-            else:
-                # new one at the end
-                out += tmpl(TMPL_AUTOCONF_AC_CONFIG_FILES)
-                state = 'done'
-        out += line + '\n'
-    if state != 'done':
-        raise Exception('AC_CONFIG_FILES marker not found in configure.ac')
-    configure_ac = out
-
     # add summary line
     out = ''
     state = 'copy'
@@ -208,25 +187,15 @@ def do_hwdriver(gitdir):
 
 
 def do_hwmake(gitdir):
-    path = gitdir + 'hardware/Makefile.am'
+    path = gitdir + 'Makefile.am'
     hwmake = open(path).read()
 
-    # add SUBDIRS entry
+    # add entry at correct place in Makefile
     out = ''
     state = 'copy'
     for line in hwmake.split('\n')[:-1]:
         if state == 'copy':
-            if line.find('SUBDIRS =') > -1:
-                state = 'subdirs'
-        elif state == 'subdirs':
-            m = re.match('\t([^ \\\]+\s*\\\)', line)
-            if m:
-                drv_short = m.group(1)
-                if drv_short.lower() > names['short']:
-                    out += tmpl(TMPL_HWMAKE_SUBDIR) + ' \\\n'
-                    state = 'driverlib'
-            else:
-                out += tmpl(TMPL_HWMAKE_SUBDIR) + ' \\\n'
+            if line.find('# Hardware drivers') > -1:
                 state = 'driverlib'
         elif state == 'driverlib':
             m = re.match('if [A-Z]{2}_(.*)$', line)
@@ -236,11 +205,8 @@ def do_hwmake(gitdir):
                     out += tmpl(TMPL_HWMAKE_DRIVERLIB)
                     state = 'done'
         out += line + '\n'
-    if state == 'driverlib':
-        # reached end of file, add it in here
-        out += tmpl(TMPL_HWMAKE_DRIVERLIB).strip()
-    elif state != 'done':
-        raise Exception('markers not found in hardware/Makefile.am')
+    if state != 'done':
+        raise Exception('markers not found in Makefile.am')
     hwmake = out
 
     open(path, 'w').write(hwmake)
@@ -249,7 +215,6 @@ def do_hwmake(gitdir):
 def do_driverskel(gitdir):
     drvdir = gitdir + 'hardware/' + names['short']
     os.mkdir(drvdir)
-    open(drvdir + '/Makefile.am', 'w').write(tmpl_file(FILE_DRV_MAKEFILE))
     open(drvdir + '/api.c', 'w').write(tmpl_file(FILE_DRV_API))
     open(drvdir + '/protocol.c', 'w').write(tmpl_file(FILE_DRV_PROTOCOL))
     open(drvdir + '/protocol.h', 'w').write(tmpl_file(FILE_DRV_PROTOCOL_H))
@@ -259,7 +224,7 @@ def make_patch(gitdir):
     os.chdir(gitdir)
     command('git add hardware/' + names['short'])
     cmd = 'git commit -m "%s: Initial driver skeleton." ' % names['short']
-    cmd += 'configure.ac hwdriver.c hardware/Makefile.am hardware/' + names['short']
+    cmd += 'configure.ac Makefile.am hwdriver.c hardware/' + names['short']
     command(cmd)
     cmd = "git format-patch HEAD~1"
     out, err = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE).communicate()