Ray Milkey

Fix from Brian for checkstyle rule with no sources

Change-Id: I37a85b38b61d9b008dc3456345bbd9ded6718281
...@@ -109,27 +109,30 @@ def osgi_jar( ...@@ -109,27 +109,30 @@ def osgi_jar(
109 ) 109 )
110 110
111 ### Checkstyle 111 ### Checkstyle
112 - chk_cmd = '#!/bin/sh\n' 112 + if srcs:
113 - base = get_base_path() 113 + chk_cmd = '#!/bin/sh\n'
114 - chk_cmd += ' '.join(( 'java -jar $(location //lib:checkstyle)', 114 + base = get_base_path()
115 - '-c $(location //tools/build/conf:checkstyle-xml)', 115 + chk_cmd += ' '.join(( 'java -jar $(location //lib:checkstyle)',
116 - ' '.join(['%s/%s' % (base, s) for s in srcs]) )) 116 + '-c $(location //tools/build/conf:checkstyle-xml)',
117 - chk_cmd += ' | grep -E "^[^: ]*:\d+:\d+: error:"' 117 + ' '.join(['%s/%s' % (base, s) for s in srcs]) ))
118 - chk_cmd += ' | sed "s#^.*%s/#%s:#g"\n' % (base, name) 118 + chk_cmd += ' | grep -E "^[^: ]*:\d+:\d+: error:"'
119 - chk_cmd += 'test ${PIPESTATUS[0]} -eq 0\n' # status of java command 119 + chk_cmd += ' | sed "s#^.*%s/#%s:#g"\n' % (base, name)
120 - genrule( 120 + chk_cmd += 'test ${PIPESTATUS[0]} -eq 0\n' # status of java command
121 - name = name + '-checkstyle-sh', 121 + genrule(
122 - bash = "echo '%s' > $OUT && chmod +x $OUT" % chk_cmd, 122 + name = name + '-checkstyle-sh',
123 - srcs = srcs, 123 + bash = "echo '%s' > $OUT && chmod +x $OUT" % chk_cmd,
124 - out = 'checkstyle.sh', 124 + srcs = srcs,
125 - ) 125 + out = 'checkstyle.sh',
126 - 126 + )
127 - sh_test( 127 +
128 - name = name + '-checkstyle', 128 + sh_test(
129 - test = ':' + name + '-checkstyle-sh', 129 + name = name + '-checkstyle',
130 - deps = [ ':'+ bare_jar_name ], 130 + test = ':' + name + '-checkstyle-sh',
131 - labels = [ 'checkstyle' ], 131 + deps = [ ':'+ bare_jar_name ],
132 - ) 132 + labels = [ 'checkstyle' ],
133 + )
134 + else:
135 + print 'Not generating checkstyle rule for %s because there are no sources.' % name
133 136
134 # TODO add project config for intellij 137 # TODO add project config for intellij
135 # project_config( 138 # project_config(
......