Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
406 lines (342 sloc) 9.95 KB
# Copyright 2012 Google Inc. All Rights Reserved.
__author__ = 'benvanik@google.com (Ben Vanik)'
# Master anvil-build BUILD file for wtf
# ------------------------------------------------------------------------------
# Third Party
# ------------------------------------------------------------------------------
JS_COMPILER_JAR='third_party:closure_compiler_jar'
SOY_COMPILER_JAR='third_party:closure_templates_jar'
file_set(
name='all_externs',
srcs=glob('externs/**/*.js'))
# ------------------------------------------------------------------------------
# Soy Templates
# ------------------------------------------------------------------------------
closure_soy_library(
name='wtf_hud_soy_js',
srcs=glob('src/wtf/hud/**/*.soy'),
compiler_jar=SOY_COMPILER_JAR)
closure_soy_library(
name='wtf_ui_soy_js',
srcs=glob('src/wtf/ui/**/*.soy') +
glob('src/wtf/app/ui/**/*.soy'),
compiler_jar=SOY_COMPILER_JAR)
file_set(
name='all_soy_js',
srcs=[
':wtf_hud_soy_js',
':wtf_ui_soy_js'
])
# ------------------------------------------------------------------------------
# JavaScript
# ------------------------------------------------------------------------------
# wtf src/
file_set(
name='wtf_src_js',
srcs=glob('src/**/*.js'))
# Testing support files
file_set(
name='testing_files',
srcs=[
'node_modules/mocha/mocha.js',
'node_modules/mocha/mocha.css',
'node_modules/chai/chai.js',
])
SHARED_JS_FLAGS=[
'--define=goog.DEBUG=false',
'--define=goog.asserts.ENABLE_ASSERTS=false',
]
RELEASE_JS_FLAGS=[
'--use_types_for_optimization',
'--language_in=ECMASCRIPT5_STRICT',
#'--collapse_variable_declarations',
#'--collapse_anonymous_functions',
#'--collapse_properties',
#'--disambiguate_properties',
# rewrites things to be smaller but likely not better
# http://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/javascript/jscomp/FunctionRewriter.java
#'--rewrite_function_expressions=false',
# slow - may want disabled
#'--devirtualize_prototype_methods',
#'--devirtualize_prototype_methods=false',
]
# deps.js only
closure_js_library(
name='wtf_js_deps',
out='wtf_js',
mode='DEPS',
entry_points=[
'wtf.analysis.exports',
'wtf.app.background.exports',
'wtf.app.ui.exports',
'wtf.hud.exports',
'wtf.trace.exports',
],
srcs=[
'third_party:all_closure_js',
':wtf_src_js',
':all_soy_js',
],
compiler_jar=JS_COMPILER_JAR)
# ------------------------------------------------------------------------------
# JavaScript : trace_web
# ------------------------------------------------------------------------------
WTF_TRACE_WEB_SRCS=[
':wtf_src_js',
':wtf_hud_soy_js',
]
# All uncompiled JS
file_set(
name='all_trace_web_uncompiled_js',
srcs=[
'third_party:all_closure_js',
'third_party:closure_uncompiled_js',
] + WTF_TRACE_WEB_SRCS)
# All compiled JS
file_set(
name='all_trace_web_compiled_js',
srcs=[
'third_party:all_closure_js',
] + WTF_TRACE_WEB_SRCS)
WTF_TRACE_WEB_ENTRY_POINTS=[
'wtf.ext',
'wtf.trace.exports',
'wtf.hud.exports',
]
# wtf_trace_web_js_uncompiled
closure_js_library(
name='wtf_trace_web_js_uncompiled',
deps_out='wtf_trace_web_js',
mode='UNCOMPILED',
entry_points=WTF_TRACE_WEB_ENTRY_POINTS + ['wtf.analysis.exports'],
srcs=':all_trace_web_uncompiled_js',
externs=[':all_externs'],
compiler_jar=JS_COMPILER_JAR,
wrap_with_global='this')
# wtf_trace_web_js_compiled
closure_js_library(
name='wtf_trace_web_js_compiled',
deps_out='wtf_trace_web_js',
mode='ADVANCED',
entry_points=WTF_TRACE_WEB_ENTRY_POINTS,
srcs=':all_trace_web_compiled_js',
externs=[':all_externs'],
compiler_jar=JS_COMPILER_JAR,
compiler_flags=SHARED_JS_FLAGS + RELEASE_JS_FLAGS + [
'--define=wtf.ENABLE_TRACING=true',
'--define=wtf.hud.exports.ENABLE_EXPORTS=true',
'--define=wtf.trace.exports.ENABLE_EXPORTS=true',
'--output_wrapper="if(!window.wtf){(function(){%output%}).call(window);}"',
])
file_set(
name='wtf_trace_web_debug',
srcs=[
':testing_files',
':wtf_trace_web_js_uncompiled',
])
file_set(
name='wtf_trace_web_release',
srcs=[
':wtf_trace_web_js_compiled',
],
src_exclude_filter='*-deps.js')
# ------------------------------------------------------------------------------
# JavaScript : node
# ------------------------------------------------------------------------------
closure_js_library(
name='wtf_node_js_compiled',
deps_out='wtf_node_js',
# TODO(benvanik): fix exports so ADVANCED can be used
mode='SIMPLE',
pretty_print=True,
entry_points=[
'wtf.analysis.exports',
'wtf.analysis.node',
'wtf.trace.exports',
'wtf.trace.node',
],
srcs=[
'third_party:all_closure_js',
':wtf_src_js',
],
externs=[':all_externs'],
compiler_jar=JS_COMPILER_JAR,
compiler_flags=SHARED_JS_FLAGS + RELEASE_JS_FLAGS + [
'--define=goog.DEBUG=false',
'--define=goog.asserts.ENABLE_ASSERTS=false',
'--define=wtf.NODE=true',
'--define=wtf.ENABLE_TRACING=true',
'--define=wtf.analysis.exports.ENABLE_EXPORTS=true',
'--define=wtf.trace.exports.ENABLE_EXPORTS=true',
'--output_wrapper="module.exports = (function(exports){%output%;return this.wtf;}).call(global); delete global.wtf;"',
])
file_set(
name='wtf_node_release',
srcs=[
':wtf_node_js_compiled',
],
src_exclude_filter='*-deps.js')
# ------------------------------------------------------------------------------
# JavaScript : app
# ------------------------------------------------------------------------------
# TODO(benvanik): move to app/BUILD?
WTF_UI_SRCS=[
':wtf_src_js',
':wtf_ui_soy_js',
]
# All uncompiled JS
file_set(
name='all_ui_uncompiled_js',
srcs=[
'third_party:all_closure_js',
'third_party:closure_uncompiled_js',
'app:debug_js_srcs',
] + WTF_UI_SRCS)
# All compiled JS
file_set(
name='all_ui_compiled_js',
srcs=[
'third_party:all_closure_js',
'app:release_js_srcs',
] + WTF_UI_SRCS)
WTF_UI_ENTRY_POINTS=[
'wtf.analysis.exports',
'wtf.app.background.exports',
'wtf.app.ui.exports',
]
# wtf_ui_js_uncompiled
closure_js_library(
name='wtf_ui_js_uncompiled',
deps_out='wtf_ui_js',
mode='UNCOMPILED',
entry_points=WTF_UI_ENTRY_POINTS,
srcs=':all_ui_uncompiled_js',
externs=[':all_externs'],
compiler_jar=JS_COMPILER_JAR,
wrap_with_global='this',
file_list_out='wtf_ui_js.list')
# wtf_trace_web_js_compiled
closure_js_library(
name='wtf_ui_js_compiled',
deps_out='wtf_ui_js',
mode='ADVANCED',
entry_points=WTF_UI_ENTRY_POINTS,
srcs=':all_ui_compiled_js',
externs=[':all_externs'],
compiler_jar=JS_COMPILER_JAR,
compiler_flags=SHARED_JS_FLAGS + RELEASE_JS_FLAGS + [
'--define=wtf.analysis.exports.ENABLE_EXPORTS=true',
'--define=wtf.app.background.exports.ENABLE_EXPORTS=true',
'--define=wtf.app.ui.exports.ENABLE_EXPORTS=true',
],
wrap_with_global='window')
# ------------------------------------------------------------------------------
# JS linting
# ------------------------------------------------------------------------------
CLOSURE_LINTER_PATH='third_party/closure-linter/'
closure_js_fixstyle(
name='all_js_fixstyle',
namespaces=['goog', 'wtf',],
srcs=[':wtf_src_js'],
linter_path=CLOSURE_LINTER_PATH)
closure_js_lint(
name='all_js_lint',
namespaces=['goog', 'wtf',],
srcs=[':all_js_fixstyle'],
linter_path=CLOSURE_LINTER_PATH)
# ------------------------------------------------------------------------------
# Testing
# ------------------------------------------------------------------------------
TEST_REQUIRES=[
('node module', 'mocha@1.4.2'),
('node module', 'chai@1.2.0'),
]
file_set(
name='test_external',
deps=[':fast'],
requires=TEST_REQUIRES)
shell_execute(
name='wtf_js_test',
srcs=glob('src/**/*_test.js'),
deps=[':fast'],
command=[
'node_modules/mocha/bin/mocha',
'--ui', 'tdd',
'--reporter', 'dot',
'--require', 'src/wtf/bootstrap/mocha.js',
],
requires=TEST_REQUIRES)
# ------------------------------------------------------------------------------
# Target rules
# ------------------------------------------------------------------------------
file_set(
name='setup',
requires=[
('node', '>=0.6.14'),
] + TEST_REQUIRES)
file_set(
name='lint',
deps=':all_js_lint')
file_set(
name='fixstyle',
deps=':all_js_fixstyle')
file_set(
name='fast',
deps=[
':testing_files',
':wtf_js_deps',
'app:fast',
])
file_set(
name='deps',
srcs=[
':wtf_js_deps',
])
file_set(
name='test',
deps=[':wtf_js_test'])
file_set(
name='debug',
srcs=[
':testing_files',
':deps',
':wtf_trace_web_debug',
'app:debug',
])
archive_files(
name='wtf-trace-web-api',
srcs=[
':wtf_trace_web_release',
'wtf-trace-shim.js',
])
file_set(
name='injector',
srcs=[
'injector/wtf-injector-chrome:wtf-injector-chrome',
])
file_set(
name='app',
srcs=[
'app:wtf-chrome-app',
])
file_set(
name='release',
srcs=[
':deps',
':wtf_trace_web_release',
':wtf_node_release',
'app:release',
'app:wtf-chrome-app',
':wtf-trace-web-api',
':injector',
],
src_exclude_filter='*-deps.js',
deps=[
#':all_js_lint',
])
file_set(
name='gh-pages',
srcs=[
':wtf_trace_web_release',
'app:app_files'
])