Merge branch 'stable-2.8'

* stable-2.8:
  Update buck
  Remove temporary files created by --list-plugins operation
  --list-plugins should not start init step
  Handle KeyboardInterrupt in Buck build wrapper scripts
This commit is contained in:
Shawn Pearce
2013-10-18 10:10:13 -07:00
9 changed files with 55 additions and 26 deletions

View File

@@ -1 +1 @@
182669c0decd69f7fcd16add278eeb816bfc9890
3fd3ea153c5444df2376de8ee87594a52a45bf52

View File

@@ -75,7 +75,9 @@ public class BaseInit extends SiteProgram {
@Override
public int run() throws Exception {
final SiteInit init = createSiteInit();
beforeInit(init);
if (beforeInit(init)) {
return 0;
}
init.flags.autoStart = getAutoStart() && init.site.isNew;
init.flags.skipPlugins = skipPlugins();
@@ -108,7 +110,8 @@ public class BaseInit extends SiteProgram {
return false;
}
protected void beforeInit(SiteInit init) throws Exception {
protected boolean beforeInit(SiteInit init) throws Exception {
return false;
}
protected void afterInit(SiteRun run) throws Exception {

View File

@@ -76,11 +76,12 @@ public class Init extends BaseInit {
}
@Override
protected void beforeInit(SiteInit init) throws Exception {
protected boolean beforeInit(SiteInit init) throws Exception {
ErrorLogFile.errorOnlyConsole();
if (!skipPlugins) {
final List<PluginData> plugins = InitPlugins.listPlugins(init.site);
final List<PluginData> plugins =
InitPlugins.listPluginsAndRemoveTempFiles(init.site);
ConsoleUI ui = ConsoleUI.getInstance(false);
verifyInstallPluginList(ui, plugins);
if (listPlugins) {
@@ -92,8 +93,10 @@ public class Init extends BaseInit {
} else {
ui.message("No plugins found.\n");
}
return true;
}
}
return false;
}
@Override

View File

@@ -51,6 +51,14 @@ public class InitPlugins implements InitStep {
}
public static List<PluginData> listPlugins(SitePaths site) throws IOException {
return listPlugins(site, false);
}
public static List<PluginData> listPluginsAndRemoveTempFiles(SitePaths site) throws IOException {
return listPlugins(site, true);
}
private static List<PluginData> listPlugins(SitePaths site, boolean deleteTempPluginFile) throws IOException {
final File myWar = GerritLauncher.getDistributionArchive();
final List<PluginData> result = Lists.newArrayList();
try {
@@ -69,6 +77,9 @@ public class InitPlugins implements InitStep {
final InputStream in = zf.getInputStream(ze);
final File tmpPlugin = PluginLoader.storeInTemp(pluginName, in, site);
final String pluginVersion = getVersion(tmpPlugin);
if (deleteTempPluginFile) {
tmpPlugin.delete();
}
result.add(new PluginData(pluginName, pluginVersion, tmpPlugin));
}

View File

@@ -16,14 +16,14 @@
from __future__ import print_function
from multiprocessing import cpu_count
from os import environ, makedirs, mkdir, path
from os import makedirs, mkdir, path
from subprocess import Popen, PIPE
from sys import argv, stderr
cp, opt, end, TMP = [], [], False, environ['TMP']
module, outzip = argv[1], argv[2]
cp, opt, end = [], [], False
module, TMP, outzip = argv[1], argv[2], argv[3]
for a in argv[3:]:
for a in argv[4:]:
if end:
if a.endswith('.jar'):
cp.append(path.expandvars(a))

View File

@@ -38,7 +38,7 @@ def war(
context = [],
visibility = []
):
cmd = ['$(exe //tools:pack_war)', '-o', '$OUT']
cmd = ['$(exe //tools:pack_war)', '-o', '$OUT', '--tmp', '$TMP']
for l in libs:
cmd.extend(['--lib', l])
for l in pgmlibs:

View File

@@ -54,7 +54,7 @@ def gwt_application(
compiler_jvm_flags = [],
deps = [],
visibility = []):
cmd = ['$(exe //lib/gwt:compiler)', module_target, '$OUT']
cmd = ['$(exe //lib/gwt:compiler)', module_target, '$TMP', '$OUT']
cmd += compiler_opts + ['--', '$DEPS']
genrule(
name = name,

View File

@@ -21,6 +21,7 @@ from os import path
from subprocess import Popen, PIPE, CalledProcessError, check_call
from xml.dom import minidom
import re
import sys
MAIN = ['//tools/eclipse:classpath']
GWT = ['//gerrit-gwtui:ui_module']
@@ -141,17 +142,21 @@ def gen_classpath():
with open(p, 'w') as fd:
doc.writexml(fd, addindent=' ', newl='\n', encoding='UTF-8')
if args.src:
try:
if args.src:
try:
check_call([path.join(ROOT, 'tools', 'download_all.py'), '--src'])
except CalledProcessError as err:
exit(1)
gen_project()
gen_classpath()
try:
check_call([path.join(ROOT, 'tools', 'download_all.py'), '--src'])
targets = ['//tools:buck.properties'] + MAIN + GWT
check_call(['buck', 'build'] + targets)
except CalledProcessError as err:
exit(1)
gen_project()
gen_classpath()
try:
targets = ['//tools:buck.properties'] + MAIN + GWT
check_call(['buck', 'build'] + targets)
except CalledProcessError as err:
except KeyboardInterrupt:
print('Interrupted by user', file=sys.stderr)
exit(1)

View File

@@ -13,18 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from optparse import OptionParser
from os import environ, makedirs, path, symlink
from os import makedirs, path, symlink
from subprocess import check_call
import sys
from util import check_output
opts = OptionParser()
opts.add_option('-o', help='path to write WAR to')
opts.add_option('--lib', action='append', help='target for WEB-INF/lib')
opts.add_option('--pgmlib', action='append', help='target for WEB-INF/pgm-lib')
opts.add_option('--tmp', help='temporary directory')
args, ctx = opts.parse_args()
war = environ['TMP']
war = args.tmp
root = war[:war.index('buck-out')]
jars = set()
@@ -43,6 +46,10 @@ if args.lib:
link_jars(args.lib, path.join(war, 'WEB-INF', 'lib'))
if args.pgmlib:
link_jars(args.pgmlib, path.join(war, 'WEB-INF', 'pgm-lib'))
for s in ctx:
check_call(['unzip', '-q', '-d', war, s])
check_call(['zip', '-9qr', args.o, '.'], cwd = war)
try:
for s in ctx:
check_call(['unzip', '-q', '-d', war, s])
check_call(['zip', '-9qr', args.o, '.'], cwd = war)
except KeyboardInterrupt:
print('Interrupted by user', file=sys.stderr)
exit(1)