| include_defs('//lib/js.defs') |
| |
| WCT_TEST_PATTERNS = [ |
| 'test/*.js', |
| 'test/*.html', |
| '**/*_test.html', |
| ] |
| PY_TEST_PATTERNS = ['polygerrit_wct_tests.py'] |
| APP_SRCS = glob( |
| ['**'], |
| excludes = [ |
| 'BUCK', |
| 'BUILD', |
| 'index.html', |
| 'test/**', |
| ] + WCT_TEST_PATTERNS + PY_TEST_PATTERNS) |
| |
| # List libraries to be copied statically into the build. (i.e. Libraries not |
| # expected to be Vulcanized.) |
| WEB_JS_LIBS = [ |
| ('bower_components/webcomponentsjs', 'webcomponents-lite.js'), |
| ('bower_components/highlightjs', 'highlight.min.js'), |
| ] |
| |
| # Map the static libraries to commands for the polygerrit_ui rule. |
| JS_LIBS_MKDIR_CMDS = [] |
| JS_LIBS_UNZIP_CMDS = [] |
| for lib in WEB_JS_LIBS: |
| JS_LIBS_MKDIR_CMDS.append('mkdir -p ' + lib[0]) |
| path = lib[0] + '/' + lib[1] |
| cmd = 'unzip -p $(location //polygerrit-ui:polygerrit_components) %s>%s' % (path, path) |
| JS_LIBS_UNZIP_CMDS.append(cmd) |
| |
| # TODO(dborowitz): Putting these rules in this package avoids having to handle |
| # the app/ prefix like we would have to if this were in the parent directory. |
| # The only reason for the app subdirectory in the first place was convenience |
| # when witing server.go; when that goes away, we can just move all the files and |
| # these rules up one directory. |
| genrule( |
| name = 'polygerrit_ui', |
| cmd = ' && '.join([ |
| 'mkdir $TMP/polygerrit_ui', |
| 'cd $TMP/polygerrit_ui', |
| 'mkdir -p {fonts,elements}', |
| ' && '.join(JS_LIBS_MKDIR_CMDS), |
| 'unzip -qd . $(location //polygerrit-ui:fonts)', |
| 'unzip -qd elements $(location :gr-app)', |
| 'cp -rp $SRCDIR/* .', |
| ' && '.join(JS_LIBS_UNZIP_CMDS), |
| 'cd $TMP', |
| 'zip -9qr $OUT .', |
| ]), |
| srcs = glob([ |
| 'favicon.ico', |
| 'index.html', |
| 'styles/**/*.css' |
| ]), |
| out = 'polygerrit_ui.zip', |
| visibility = ['PUBLIC'], |
| ) |
| |
| vulcanize( |
| name = 'gr-app', |
| app = 'elements/gr-app.html', |
| srcs = APP_SRCS, |
| components = '//polygerrit-ui:polygerrit_components', |
| ) |
| |
| bower_components( |
| name = 'test_components', |
| deps = [ |
| '//polygerrit-ui:polygerrit_components', |
| '//lib/js:iron-test-helpers', |
| '//lib/js:test-fixture', |
| '//lib/js:web-component-tester', |
| ], |
| ) |
| |
| genrule( |
| name = 'test_resources', |
| cmd = ' && '.join([ |
| 'cd $TMP', |
| 'unzip -q $(location :test_components)', |
| 'cp -r $SRCDIR/* .', |
| 'zip -r $OUT .', |
| ]), |
| srcs = APP_SRCS + glob(WCT_TEST_PATTERNS), |
| out = 'test_resources.zip', |
| ) |
| |
| python_test( |
| name = 'polygerrit_tests', |
| srcs = glob(PY_TEST_PATTERNS), |
| resources = [':test_resources'], |
| labels = [ |
| 'manual', |
| 'web', |
| ], |
| ) |