Buck: Disable cast checking in GWT compiler only in release mode

DisableCastChecking option was first added in I5dc633d5b. Since Issue
3389, that caused breakage of all Google products for many weeks, this
option is added again in the development build to prevent such severe
regressions in future.

Because the generated javascript code is bigger with cast checks, this
option is still added in release mode.

Side effect of this change is that the plugins that expose GWT module
are compiled without DisableCastChecking option in Gerrit tree mode.
Standalone bucklets driven build mode is not affected by this change.

Another side effect, that 'soyc' target for "compiler story" was
duplicated and the corresponding release mode with DisableCastChecking
is also provided with alias 'soyc_r'.

TEST PLAN:

  $ buck build gerrit

should pass only -XdisableClassMetadata option to GWT compiler. Whereas

  $ buck build release

should pass both -XdisableClassMetadata -XdisableCastChecking options.

Bug: Issue 3389
Change-Id: Ia99647357e7bff889137d4855e9c0059e6c6a4f3
This commit is contained in:
David Ostrovsky 2015-06-05 08:26:35 +02:00
parent ddb3c62e5b
commit d7b40c70fe
5 changed files with 66 additions and 54 deletions

View File

@ -13,6 +13,7 @@
release = //:release
safari = //:safari
soyc = //gerrit-gwtui:ui_soyc
soyc_r = //gerrit-gwtui:ui_soyc_r
withdocs = //:withdocs
[buildfile]

2
BUCK
View File

@ -6,7 +6,7 @@ gerrit_war(name = 'chrome', ui = 'ui_chrome')
gerrit_war(name = 'firefox', ui = 'ui_firefox')
gerrit_war(name = 'safari', ui = 'ui_safari')
gerrit_war(name = 'withdocs', docs = True)
gerrit_war(name = 'release', docs = True, context = ['//plugins:core'], visibility = ['//tools/maven:'])
gerrit_war(name = 'release', ui = 'ui_optdbg_r', docs = True, context = ['//plugins:core'], visibility = ['//tools/maven:'])
API_DEPS = [
'//gerrit-extension-api:extension-api',

View File

@ -1,62 +1,13 @@
include_defs('//gerrit-gwtui/gwt.defs')
include_defs('//tools/gwt-constants.defs')
from multiprocessing import cpu_count
CPU_COUNT = cpu_count()
DEPS = GWT_COMMON_DEPS + [
'//gerrit-gwtexpui:CSS',
'//lib:gwtjsonrpc',
]
genrule(
name = 'ui_optdbg',
cmd = 'cd $TMP;' +
'unzip -q $(location :ui_dbg);' +
'mv' +
' gerrit_ui/gerrit_ui.nocache.js' +
' gerrit_ui/dbg_gerrit_ui.nocache.js;' +
'unzip -qo $(location :ui_opt);' +
'mkdir -p \$(dirname $OUT);' +
'zip -qr $OUT .',
out = 'ui_optdbg.zip',
visibility = ['PUBLIC'],
)
gwt_binary(
name = 'ui_opt',
modules = [MODULE],
module_deps = [':ui_module'],
deps = DEPS + ([':ui_dbg'] if CPU_COUNT < 8 else []),
local_workers = CPU_COUNT,
strict = True,
experimental_args = GWT_COMPILER_ARGS,
vm_args = GWT_JVM_ARGS,
)
gwt_binary(
name = 'ui_soyc',
modules = [MODULE],
module_deps = [':ui_module'],
deps = DEPS + [':ui_dbg'],
local_workers = CPU_COUNT,
strict = True,
experimental_args = GWT_COMPILER_ARGS + ['-compileReport'],
vm_args = GWT_JVM_ARGS,
)
gwt_binary(
name = 'ui_dbg',
modules = [MODULE],
style = 'PRETTY',
optimize = 0,
module_deps = [':ui_module'],
deps = DEPS,
local_workers = CPU_COUNT,
strict = True,
experimental_args = GWT_COMPILER_ARGS,
vm_args = GWT_JVM_ARGS,
visibility = ['//:eclipse'],
)
gwt_genrule(MODULE, DEPS)
gwt_genrule(MODULE, DEPS, '_r')
gwt_user_agent_permutations(
name = 'ui',

View File

@ -11,6 +11,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from multiprocessing import cpu_count
BROWSERS = [
'chrome',
@ -25,6 +26,63 @@ ALIASES = {
'msie': 'ie9',
}
MODULE = 'com.google.gerrit.GerritGwtUI'
CPU_COUNT = cpu_count()
def gwt_genrule(module, deps, suffix = ""):
dbg = 'ui_dbg' + suffix
opt = 'ui_opt' + suffix
soyc = 'ui_soyc' + suffix
args = GWT_COMPILER_ARGS_RELEASE_MODE if suffix == "_r" else GWT_COMPILER_ARGS
genrule(
name = 'ui_optdbg' + suffix,
cmd = 'cd $TMP;' +
'unzip -q $(location :%s);' % dbg +
'mv' +
' gerrit_ui/gerrit_ui.nocache.js' +
' gerrit_ui/dbg_gerrit_ui.nocache.js;' +
'unzip -qo $(location :%s);' % opt +
'mkdir -p \$(dirname $OUT);' +
'zip -qr $OUT .',
out = 'ui_optdbg' + suffix + '.zip',
visibility = ['PUBLIC'],
)
gwt_binary(
name = opt,
modules = [module],
module_deps = [':ui_module'],
deps = deps + ([':' + dbg] if CPU_COUNT < 8 else []),
local_workers = CPU_COUNT,
strict = True,
experimental_args = args,
vm_args = GWT_JVM_ARGS,
)
gwt_binary(
name = dbg,
modules = [module],
style = 'PRETTY',
optimize = 0,
module_deps = [':ui_module'],
deps = deps,
local_workers = CPU_COUNT,
strict = True,
experimental_args = args,
vm_args = GWT_JVM_ARGS,
visibility = ['//:eclipse'],
)
gwt_binary(
name = soyc,
modules = [module],
module_deps = [':ui_module'],
deps = deps + [':' + dbg],
local_workers = CPU_COUNT,
strict = True,
experimental_args = args + ['-compileReport'],
vm_args = GWT_JVM_ARGS,
)
def gwt_user_agent_permutations(
name,
@ -37,7 +95,6 @@ def gwt_user_agent_permutations(
deps = [],
browsers = BROWSERS,
visibility = []):
from multiprocessing import cpu_count
for ua in browsers:
impl = ua
if ua in ALIASES:
@ -74,7 +131,7 @@ def gwt_user_agent_permutations(
draft_compile = draft_compile,
module_deps = module_deps + [':%s_gwtxml_lib' % gwt_name],
deps = deps,
local_workers = cpu_count(),
local_workers = CPU_COUNT,
strict = True,
experimental_args = GWT_COMPILER_ARGS,
vm_args = GWT_JVM_ARGS,

View File

@ -2,6 +2,9 @@ GWT_JVM_ARGS = ['-Xmx512m']
GWT_COMPILER_ARGS = [
'-XdisableClassMetadata',
]
GWT_COMPILER_ARGS_RELEASE_MODE = GWT_COMPILER_ARGS + [
'-XdisableCastChecking',
]