Remove xdisplaycheck, emacs, and vim from tools
We don't need xdisplaycheck any more with x11 disabled. Emacs and vim are setup for Chromium, and are not really useful for us. Change-Id: Ia04e8458ea24e1980918de7eab74705e56b90735
This commit is contained in:
parent
d2b38ce118
commit
b387b4083c
|
@ -1,16 +0,0 @@
|
||||||
; To get syntax highlighting and tab settings for gyp(i) files, add the
|
|
||||||
; following to init.el:
|
|
||||||
; (setq-default chrome-root "/path/to/chrome/src/")
|
|
||||||
; (add-to-list 'load-path (concat chrome-root "tools/emacs"))
|
|
||||||
; (require 'chrome-filetypes)
|
|
||||||
|
|
||||||
(define-derived-mode gyp-mode python-mode "Gyp"
|
|
||||||
"Major mode for editing Generate Your Project files."
|
|
||||||
(setq indent-tabs-mode nil
|
|
||||||
tab-width 2
|
|
||||||
python-indent 2))
|
|
||||||
|
|
||||||
(add-to-list 'auto-mode-alist '("\\.gyp$" . gyp-mode))
|
|
||||||
(add-to-list 'auto-mode-alist '("\\.gypi$" . gyp-mode))
|
|
||||||
|
|
||||||
(provide 'chrome-filetypes)
|
|
|
@ -1,122 +0,0 @@
|
||||||
;; Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
|
||||||
;; Use of this source code is governed by a BSD-style license that can be
|
|
||||||
;; found in the LICENSE file.
|
|
||||||
|
|
||||||
;; Set up flymake for use with chromium code. Uses ninja (since none of the
|
|
||||||
;; other chromium build systems have latency that allows interactive use).
|
|
||||||
;;
|
|
||||||
;; Requires a modern emacs (GNU Emacs >= 23) and that gyp has already generated
|
|
||||||
;; the build.ninja file(s). See defcustoms below for settable knobs.
|
|
||||||
|
|
||||||
|
|
||||||
(require 'flymake)
|
|
||||||
|
|
||||||
(defcustom cr-flymake-ninja-build-file "out/Debug/build.ninja"
|
|
||||||
"Relative path from chromium's src/ directory to the
|
|
||||||
build.ninja file to use.")
|
|
||||||
|
|
||||||
(defcustom cr-flymake-ninja-executable "ninja"
|
|
||||||
"Ninja executable location; either in $PATH or explicitly given.")
|
|
||||||
|
|
||||||
(defun cr-flymake-absbufferpath ()
|
|
||||||
"Return the absolute path to the current buffer, or nil if the
|
|
||||||
current buffer has no path."
|
|
||||||
(when buffer-file-truename
|
|
||||||
(expand-file-name buffer-file-truename)))
|
|
||||||
|
|
||||||
(defun cr-flymake-chromium-src ()
|
|
||||||
"Return chromium's src/ directory, or nil on failure."
|
|
||||||
(let ((srcdir (locate-dominating-file
|
|
||||||
(cr-flymake-absbufferpath) cr-flymake-ninja-build-file)))
|
|
||||||
(when srcdir (expand-file-name srcdir))))
|
|
||||||
|
|
||||||
(defun cr-flymake-string-prefix-p (prefix str)
|
|
||||||
"Return non-nil if PREFIX is a prefix of STR (23.2 has string-prefix-p but
|
|
||||||
that's case insensitive and also 23.1 doesn't have it)."
|
|
||||||
(string= prefix (substring str 0 (length prefix))))
|
|
||||||
|
|
||||||
(defun cr-flymake-current-file-name ()
|
|
||||||
"Return the relative path from chromium's src/ directory to the
|
|
||||||
file backing the current buffer or nil if it doesn't look like
|
|
||||||
we're under chromium/src/."
|
|
||||||
(when (and (cr-flymake-chromium-src)
|
|
||||||
(cr-flymake-string-prefix-p
|
|
||||||
(cr-flymake-chromium-src) (cr-flymake-absbufferpath)))
|
|
||||||
(substring (cr-flymake-absbufferpath) (length (cr-flymake-chromium-src)))))
|
|
||||||
|
|
||||||
(defun cr-flymake-from-build-to-src-root ()
|
|
||||||
"Return a path fragment for getting from the build.ninja file to src/."
|
|
||||||
(replace-regexp-in-string
|
|
||||||
"[^/]+" ".."
|
|
||||||
(substring
|
|
||||||
(file-name-directory
|
|
||||||
(file-truename (or (and (cr-flymake-string-prefix-p
|
|
||||||
"/" cr-flymake-ninja-build-file)
|
|
||||||
cr-flymake-ninja-build-file)
|
|
||||||
(concat (cr-flymake-chromium-src)
|
|
||||||
cr-flymake-ninja-build-file))))
|
|
||||||
(length (cr-flymake-chromium-src)))))
|
|
||||||
|
|
||||||
(defun cr-flymake-getfname (file-name-from-error-message)
|
|
||||||
"Strip cruft from the passed-in filename to help flymake find the real file."
|
|
||||||
(file-name-nondirectory file-name-from-error-message))
|
|
||||||
|
|
||||||
(defun cr-flymake-ninja-command-line ()
|
|
||||||
"Return the command-line for running ninja, as a list of strings, or nil if
|
|
||||||
we're not during a save"
|
|
||||||
(unless (buffer-modified-p)
|
|
||||||
(list cr-flymake-ninja-executable
|
|
||||||
(list "-C"
|
|
||||||
(concat (cr-flymake-chromium-src)
|
|
||||||
(file-name-directory cr-flymake-ninja-build-file))
|
|
||||||
(concat (cr-flymake-from-build-to-src-root)
|
|
||||||
(cr-flymake-current-file-name) "^")))))
|
|
||||||
|
|
||||||
(defun cr-flymake-kick-off-check-after-save ()
|
|
||||||
"Kick off a syntax check after file save, if flymake-mode is on."
|
|
||||||
(when flymake-mode (flymake-start-syntax-check)))
|
|
||||||
|
|
||||||
(defadvice next-error (around cr-flymake-next-error activate)
|
|
||||||
"If flymake has something to say, let it say it; otherwise
|
|
||||||
revert to normal next-error behavior."
|
|
||||||
(if (not flymake-err-info)
|
|
||||||
(condition-case msg
|
|
||||||
ad-do-it
|
|
||||||
(error (message "%s" (prin1-to-string msg))))
|
|
||||||
(flymake-goto-next-error)
|
|
||||||
;; copy/pasted from flymake-display-err-menu-for-current-line because I
|
|
||||||
;; couldn't find a way to have it tell me what the relevant error for this
|
|
||||||
;; line was in a single call:
|
|
||||||
(let* ((line-no (flymake-current-line-no))
|
|
||||||
(line-err-info-list
|
|
||||||
(nth 0 (flymake-find-err-info flymake-err-info line-no)))
|
|
||||||
(menu-data (flymake-make-err-menu-data line-no line-err-info-list)))
|
|
||||||
(prin1 (car (car (car (cdr menu-data)))) t))))
|
|
||||||
|
|
||||||
(defun cr-flymake-find-file ()
|
|
||||||
"Enable flymake, but only if it makes sense, and immediately
|
|
||||||
disable timer-based execution."
|
|
||||||
(when (and (not flymake-mode)
|
|
||||||
(not buffer-read-only)
|
|
||||||
(cr-flymake-current-file-name))
|
|
||||||
;; Since flymake-allowed-file-name-masks requires static regexps to match
|
|
||||||
;; against, can't use cr-flymake-chromium-src here. Instead we add a
|
|
||||||
;; generic regexp, but only to a buffer-local version of the variable.
|
|
||||||
(set (make-local-variable 'flymake-allowed-file-name-masks)
|
|
||||||
(list (list "\\.c\\(\\|c\\|pp\\)"
|
|
||||||
'cr-flymake-ninja-command-line
|
|
||||||
'ignore
|
|
||||||
'cr-flymake-getfname)))
|
|
||||||
(flymake-find-file-hook)
|
|
||||||
(if flymake-mode
|
|
||||||
(cancel-timer flymake-timer)
|
|
||||||
(kill-local-variable 'flymake-allowed-file-name-masks))))
|
|
||||||
|
|
||||||
(add-hook 'find-file-hook 'cr-flymake-find-file 'append)
|
|
||||||
(add-hook 'after-save-hook 'cr-flymake-kick-off-check-after-save)
|
|
||||||
|
|
||||||
;; Show flymake infrastructure ERRORs in hopes of fixing them. Set to 3 for
|
|
||||||
;; DEBUG-level output from flymake.el.
|
|
||||||
(setq flymake-log-level 0)
|
|
||||||
|
|
||||||
(provide 'flymake-chromium)
|
|
|
@ -1,6 +0,0 @@
|
||||||
A snippet of Linux trybot output (note UTF-8 quotes).
|
|
||||||
|
|
||||||
AR(target) out/Debug/obj.target/printing/libprinting.a
|
|
||||||
app/l10n_util_unittest.cc: In member function ‘virtual void L10nUtilTest_TruncateString_Test::TestBody()’:
|
|
||||||
app/l10n_util_unittest.cc:67: error: invalid initialization of reference of type ‘const string16&’ from expression of type ‘std::wstring’
|
|
||||||
./app/l10n_util.h:166: error: in passing argument 1 of ‘string16 l10n_util::TruncateString(const string16&, size_t)’
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,72 +0,0 @@
|
||||||
This file contains sample trybot output from a Windows trybot run.
|
|
||||||
It contains a warning and an error but has otherwise been shortened
|
|
||||||
for length.
|
|
||||||
|
|
||||||
"C:\Program Files (x86)\Xoreax\IncrediBuild\BuildConsole.exe" e:\b\build\slave\win\build\src\build\all.sln "/Cfg=Debug|Win32"
|
|
||||||
|
|
||||||
-----------------------------------------------------------------
|
|
||||||
IncrediBuild Console 3.60 Internal (build 1156)
|
|
||||||
Copyright (C) 2001-2010 Xoreax Software Ltd. All rights reserved.
|
|
||||||
-----------------------------------------------------------------
|
|
||||||
--------------------Configuration: toolband_proxy_lib - Debug|Win32------------
|
|
||||||
Compiling...
|
|
||||||
toolband_p.c
|
|
||||||
toolband_proxy.cc
|
|
||||||
toolband_dlldata.c
|
|
||||||
Creating library...
|
|
||||||
|
|
||||||
toolband_proxy_lib - 0 error(s), 0 warning(s)
|
|
||||||
--------------------Configuration: webcore_bindings - Debug|Win32--------------
|
|
||||||
Compiling...
|
|
||||||
CSSGrammar.cpp
|
|
||||||
e:\b\build\slave\win\build\src\third_party\webkit\javascriptcore\wtf\text\StringImpl.h(90) : warning C4355: 'this' : used in base member initializer list with a gratuitous backslash \ for testing
|
|
||||||
e:\b\build\slave\win\build\src\third_party\webkit\webcore\dom\ViewportArguments.h(78) : warning C4305: 'initializing' : truncation from '' to 'bool'
|
|
||||||
e:\b\build\slave\win\build\src\build\Debug\obj\global_intermediate\webkit\CSSGrammar.cpp(1930) : warning C4065: switch statement contains 'default' but no 'case' labels
|
|
||||||
V8DerivedSources1.cpp
|
|
||||||
--------------------Configuration: run_testserver - Debug|Win32----------------
|
|
||||||
Compiling...
|
|
||||||
run_testserver.cc
|
|
||||||
Linking...
|
|
||||||
Embedding manifest...
|
|
||||||
Embedding manifest... (rc.exe)
|
|
||||||
Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
|
|
||||||
|
|
||||||
Copyright (C) Microsoft Corporation. All rights reserved.
|
|
||||||
|
|
||||||
Embedding manifest... (link.exe)
|
|
||||||
|
|
||||||
run_testserver - 0 error(s), 0 warning(s)
|
|
||||||
--------------------Configuration: browser - Debug|Win32-----------------------
|
|
||||||
Compiling...
|
|
||||||
bookmark_manager_resources_map.cc
|
|
||||||
theme_resources_map.cc
|
|
||||||
shared_resources_map.cc
|
|
||||||
process_singleton_win.cc
|
|
||||||
e:\b\build\slave\win\build\src\chrome\browser\process_singleton_win.cc(95) : error C2664: 'PathService::Get' : cannot convert parameter 2 from 'std::wstring *' to 'FilePath *'
|
|
||||||
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
|
|
||||||
gpu_process_host.cc
|
|
||||||
ntp_background_util.cc
|
|
||||||
|
|
||||||
browser - 6 error(s), 0 warning(s)
|
|
||||||
|
|
||||||
1 build system warning(s):
|
|
||||||
- PDB instance limit is enabled
|
|
||||||
|
|
||||||
---------------------- Done ----------------------
|
|
||||||
|
|
||||||
Build: 244 succeeded, 1 failed, 233 up-to-date, 42 skipped
|
|
||||||
|
|
||||||
|
|
||||||
We also see weird paths with mixed slashes like this:
|
|
||||||
|
|
||||||
--------------------Configuration: inspector_protocol_sources - Debug|Win32----
|
|
||||||
--------------------Configuration: installer_util_nacl_win64 - Debug|x64-------
|
|
||||||
Compiling...
|
|
||||||
google_chrome_distribution_dummy.cc
|
|
||||||
helper.cc
|
|
||||||
installation_state.cc
|
|
||||||
self_reg_work_item.cc
|
|
||||||
..\chrome/installer/util/work_item.h(67) : error C2514: 'FilePath' : class has no constructors
|
|
||||||
..\chrome/installer/util/work_item.h(26) : see declaration of 'FilePath'
|
|
||||||
delete_tree_work_item.cc
|
|
||||||
delete_reg_key_work_item.cc
|
|
|
@ -1,176 +0,0 @@
|
||||||
; To use this,
|
|
||||||
; 1) Add to init.el:
|
|
||||||
; (setq-default chrome-root "/path/to/chrome/src/")
|
|
||||||
; (add-to-list 'load-path (concat chrome-root "tools/emacs"))
|
|
||||||
; (require 'trybot)
|
|
||||||
; 2) Run on trybot output:
|
|
||||||
; M-x trybot
|
|
||||||
;
|
|
||||||
; To hack on this,
|
|
||||||
; M-x eval-buffer
|
|
||||||
; M-x trybot-test-win or M-x trybot-test-mac
|
|
||||||
|
|
||||||
(defvar chrome-root nil
|
|
||||||
"Path to the src/ directory of your Chrome checkout.")
|
|
||||||
|
|
||||||
(defun get-chrome-root ()
|
|
||||||
(or chrome-root default-directory))
|
|
||||||
|
|
||||||
; Hunt down from the top, case correcting each path component as needed.
|
|
||||||
; Currently does not keep a cache. Returns nil if no matching file can be
|
|
||||||
; figured out.
|
|
||||||
(defun case-corrected-filename (filename)
|
|
||||||
(save-match-data
|
|
||||||
(let ((path-components (split-string filename "/"))
|
|
||||||
(corrected-path (file-name-as-directory (get-chrome-root))))
|
|
||||||
(mapc
|
|
||||||
(function
|
|
||||||
(lambda (elt)
|
|
||||||
(if corrected-path
|
|
||||||
(let ((next-component
|
|
||||||
(car (member-ignore-case
|
|
||||||
elt (directory-files corrected-path)))))
|
|
||||||
(setq corrected-path
|
|
||||||
(and next-component
|
|
||||||
(file-name-as-directory
|
|
||||||
(concat corrected-path next-component))))))))
|
|
||||||
path-components)
|
|
||||||
(if corrected-path
|
|
||||||
(file-relative-name (directory-file-name corrected-path)
|
|
||||||
(get-chrome-root))
|
|
||||||
nil))))
|
|
||||||
|
|
||||||
(defun trybot-fixup-win ()
|
|
||||||
"Fix up Windows-specific output."
|
|
||||||
|
|
||||||
; Fix Windows paths ("d:\...\src\").
|
|
||||||
(save-excursion
|
|
||||||
; This regexp is subtle and rather hard to read. :~(
|
|
||||||
; Use regexp-builder when making changes to it.
|
|
||||||
(while (re-search-forward
|
|
||||||
(concat
|
|
||||||
; First part: path leader, either of the form
|
|
||||||
; e:\...src\ or ..\
|
|
||||||
"\\(^.:\\\\.*\\\\src\\\\\\|\\.\\.\\\\\\)"
|
|
||||||
; Second part: path, followed by error message marker.
|
|
||||||
"\\(.*?\\)[(:]") nil t)
|
|
||||||
(replace-match "" nil t nil 1)
|
|
||||||
; Line now looks like:
|
|
||||||
; foo\bar\baz.cc error message here
|
|
||||||
; We want to fixup backslashes in path into forward slashes,
|
|
||||||
; without modifying the error message - by matching up to the
|
|
||||||
; first colon above (which will be just beyond the end of the
|
|
||||||
; filename) we can use the end of the match as a limit.
|
|
||||||
(subst-char-in-region (point) (match-end 0) ?\\ ?/)
|
|
||||||
; See if we can correct the file name casing.
|
|
||||||
(let ((filename (buffer-substring (match-beginning 2) (match-end 2))))
|
|
||||||
(if (and (not (file-exists-p filename))
|
|
||||||
(setq filename (case-corrected-filename filename)))
|
|
||||||
(replace-match filename t t nil 2))))))
|
|
||||||
|
|
||||||
(defun trybot-fixup-maclin ()
|
|
||||||
"Fix up Mac/Linux output."
|
|
||||||
(save-excursion
|
|
||||||
(while (re-search-forward "^/b/build/[^ ]*/src/" nil t)
|
|
||||||
(replace-match ""))))
|
|
||||||
|
|
||||||
(defun trybot-fixup (type-hint)
|
|
||||||
"Parse and fixup the contents of the current buffer as trybot output."
|
|
||||||
|
|
||||||
; XXX is there something I should so so this stuff doesn't end up on the
|
|
||||||
; undo stack?
|
|
||||||
|
|
||||||
;; Fixup paths.
|
|
||||||
(cd (get-chrome-root))
|
|
||||||
|
|
||||||
(goto-char (point-min))
|
|
||||||
|
|
||||||
;; Fix up path references.
|
|
||||||
(cond ((eq type-hint 'win) (trybot-fixup-win))
|
|
||||||
((eq type-hint 'mac) (trybot-fixup-maclin))
|
|
||||||
((eq type-hint 'linux) (trybot-fixup-maclin))
|
|
||||||
(t (trybot-fixup-win) (trybot-fixup-maclin)))
|
|
||||||
|
|
||||||
(compilation-mode))
|
|
||||||
|
|
||||||
(defun trybot-get-new-buffer ()
|
|
||||||
"Get a new clean buffer for trybot output."
|
|
||||||
; Use trybot-buffer-name if available; otherwise, "*trybot*".
|
|
||||||
(let ((buffer-name (if (boundp 'trybot-buffer-name)
|
|
||||||
trybot-buffer-name
|
|
||||||
"*trybot*")))
|
|
||||||
(let ((old (get-buffer buffer-name)))
|
|
||||||
(when old (kill-buffer old)))
|
|
||||||
(get-buffer-create buffer-name)))
|
|
||||||
|
|
||||||
(defun trybot-fetch (type-hint url)
|
|
||||||
"Fetch a URL and postprocess it as trybot output."
|
|
||||||
|
|
||||||
(let ((on-fetch-completion
|
|
||||||
(lambda (process state)
|
|
||||||
(switch-to-buffer (process-buffer process))
|
|
||||||
(when (equal state "finished\n")
|
|
||||||
(trybot-fixup (process-get process 'type-hint)))))
|
|
||||||
(command (concat "curl -s " (shell-quote-argument url)
|
|
||||||
; Pipe it through the output shortener.
|
|
||||||
(cond
|
|
||||||
((eq type-hint 'win)
|
|
||||||
(concat " | " (get-chrome-root)
|
|
||||||
"build/sanitize-win-build-log.sh"))
|
|
||||||
((eq type-hint 'mac)
|
|
||||||
(concat " | " (get-chrome-root)
|
|
||||||
"build/sanitize-mac-build-log.sh"))))))
|
|
||||||
|
|
||||||
; Start up the subprocess.
|
|
||||||
(let* ((coding-system-for-read 'utf-8-dos)
|
|
||||||
(buffer (trybot-get-new-buffer))
|
|
||||||
(process (start-process-shell-command "curl" buffer command)))
|
|
||||||
; Attach the type hint to the process so we can get it back when
|
|
||||||
; the process completes.
|
|
||||||
(process-put process 'type-hint type-hint)
|
|
||||||
(set-process-query-on-exit-flag process nil)
|
|
||||||
(set-process-sentinel process on-fetch-completion))))
|
|
||||||
|
|
||||||
(defun trybot-test (type-hint filename)
|
|
||||||
"Load the given test data filename and do the trybot parse on it."
|
|
||||||
|
|
||||||
(let ((trybot-buffer-name "*trybot-test*")
|
|
||||||
(url (concat "file://" (get-chrome-root) "tools/emacs/" filename)))
|
|
||||||
(trybot-fetch type-hint url)))
|
|
||||||
|
|
||||||
(defun trybot-test-win ()
|
|
||||||
"Load the Windows test data and do the trybot parse on it."
|
|
||||||
(interactive)
|
|
||||||
(trybot-test 'win "trybot-windows.txt"))
|
|
||||||
(defun trybot-test-mac ()
|
|
||||||
"Load the Mac test data and do the trybot parse on it."
|
|
||||||
(interactive)
|
|
||||||
(trybot-test 'mac "trybot-mac.txt"))
|
|
||||||
(defun trybot-test-linux ()
|
|
||||||
"Load the Linux test data and do the trybot parse on it."
|
|
||||||
(interactive)
|
|
||||||
(trybot-test 'linux "trybot-linux.txt"))
|
|
||||||
|
|
||||||
(defun trybot (url)
|
|
||||||
"Fetch a trybot URL and fix up the output into a compilation-mode buffer."
|
|
||||||
(interactive "sURL to trybot stdout (leave empty to use clipboard): ")
|
|
||||||
|
|
||||||
;; Yank URL from clipboard if necessary.
|
|
||||||
(when (= (length url) 0)
|
|
||||||
(with-temp-buffer
|
|
||||||
(clipboard-yank)
|
|
||||||
(setq url (buffer-string))))
|
|
||||||
|
|
||||||
;; Append /text to the URL to get plain text output in the common
|
|
||||||
;; case of getting a URL to the HTML build log.
|
|
||||||
(when (equal "stdio" (car (last (split-string url "/"))))
|
|
||||||
(setq url (concat url "/text")))
|
|
||||||
|
|
||||||
(let ((type-hint (cond ((string-match "/[Ww]in" url) 'win)
|
|
||||||
((string-match "/mac/" url) 'mac)
|
|
||||||
; Match /linux, /linux_view, etc.
|
|
||||||
((string-match "/linux" url) 'linux)
|
|
||||||
(t 'unknown))))
|
|
||||||
(trybot-fetch type-hint url)))
|
|
||||||
|
|
||||||
(provide 'trybot)
|
|
|
@ -1,203 +0,0 @@
|
||||||
# Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
|
||||||
# found in the LICENSE file.
|
|
||||||
|
|
||||||
# Autocompletion config for YouCompleteMe in Chromium.
|
|
||||||
#
|
|
||||||
# USAGE:
|
|
||||||
#
|
|
||||||
# 1. Install YCM [https://github.com/Valloric/YouCompleteMe]
|
|
||||||
# (Googlers should check out [go/ycm])
|
|
||||||
#
|
|
||||||
# 2. Point to this config file in your .vimrc:
|
|
||||||
# let g:ycm_global_ycm_extra_conf =
|
|
||||||
# '<chrome_depot>/src/tools/vim/chromium.ycm_extra_conf.py'
|
|
||||||
#
|
|
||||||
# 3. Profit
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Usage notes:
|
|
||||||
#
|
|
||||||
# * You must use ninja & clang to build Chromium.
|
|
||||||
#
|
|
||||||
# * You must have run gyp_chromium and built Chromium recently.
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Hacking notes:
|
|
||||||
#
|
|
||||||
# * The purpose of this script is to construct an accurate enough command line
|
|
||||||
# for YCM to pass to clang so it can build and extract the symbols.
|
|
||||||
#
|
|
||||||
# * Right now, we only pull the -I and -D flags. That seems to be sufficient
|
|
||||||
# for everything I've used it for.
|
|
||||||
#
|
|
||||||
# * That whole ninja & clang thing? We could support other configs if someone
|
|
||||||
# were willing to write the correct commands and a parser.
|
|
||||||
#
|
|
||||||
# * This has only been tested on gPrecise.
|
|
||||||
|
|
||||||
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
|
|
||||||
|
|
||||||
# Flags from YCM's default config.
|
|
||||||
flags = [
|
|
||||||
'-DUSE_CLANG_COMPLETER',
|
|
||||||
'-std=c++11',
|
|
||||||
'-x',
|
|
||||||
'c++',
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
def PathExists(*args):
|
|
||||||
return os.path.exists(os.path.join(*args))
|
|
||||||
|
|
||||||
|
|
||||||
def FindChromeSrcFromFilename(filename):
|
|
||||||
"""Searches for the root of the Chromium checkout.
|
|
||||||
|
|
||||||
Simply checks parent directories until it finds .gclient and src/.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
filename: (String) Path to source file being edited.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
(String) Path of 'src/', or None if unable to find.
|
|
||||||
"""
|
|
||||||
curdir = os.path.normpath(os.path.dirname(filename))
|
|
||||||
while not (PathExists(curdir, 'src') and PathExists(curdir, 'src', 'DEPS')
|
|
||||||
and (PathExists(curdir, '.gclient')
|
|
||||||
or PathExists(curdir, 'src', '.git'))):
|
|
||||||
nextdir = os.path.normpath(os.path.join(curdir, '..'))
|
|
||||||
if nextdir == curdir:
|
|
||||||
return None
|
|
||||||
curdir = nextdir
|
|
||||||
return os.path.join(curdir, 'src')
|
|
||||||
|
|
||||||
|
|
||||||
# Largely copied from ninja-build.vim (guess_configuration)
|
|
||||||
def GetNinjaOutputDirectory(chrome_root):
|
|
||||||
"""Returns either <chrome_root>/out/Release or <chrome_root>/out/Debug.
|
|
||||||
|
|
||||||
The configuration chosen is the one most recently generated/built."""
|
|
||||||
root = os.path.join(chrome_root, 'out')
|
|
||||||
debug_path = os.path.join(root, 'Debug')
|
|
||||||
release_path = os.path.join(root, 'Release')
|
|
||||||
|
|
||||||
def is_release_15s_newer(test_path):
|
|
||||||
try:
|
|
||||||
debug_mtime = os.path.getmtime(os.path.join(debug_path, test_path))
|
|
||||||
except os.error:
|
|
||||||
debug_mtime = 0
|
|
||||||
try:
|
|
||||||
rel_mtime = os.path.getmtime(os.path.join(release_path, test_path))
|
|
||||||
except os.error:
|
|
||||||
rel_mtime = 0
|
|
||||||
return rel_mtime - debug_mtime >= 15
|
|
||||||
|
|
||||||
if is_release_15s_newer('build.ninja') or is_release_15s_newer('protoc'):
|
|
||||||
return release_path
|
|
||||||
return debug_path
|
|
||||||
|
|
||||||
|
|
||||||
def GetClangCommandFromNinjaForFilename(chrome_root, filename):
|
|
||||||
"""Returns the command line to build |filename|.
|
|
||||||
|
|
||||||
Asks ninja how it would build the source file. If the specified file is a
|
|
||||||
header, tries to find its companion source file first.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
chrome_root: (String) Path to src/.
|
|
||||||
filename: (String) Path to source file being edited.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
(List of Strings) Command line arguments for clang.
|
|
||||||
"""
|
|
||||||
if not chrome_root:
|
|
||||||
return []
|
|
||||||
|
|
||||||
# Generally, everyone benefits from including Chromium's src/, because all of
|
|
||||||
# Chromium's includes are relative to that.
|
|
||||||
chrome_flags = ['-I' + os.path.join(chrome_root)]
|
|
||||||
|
|
||||||
# Header files can't be built. Instead, try to match a header file to its
|
|
||||||
# corresponding source file.
|
|
||||||
if filename.endswith('.h'):
|
|
||||||
alternates = ['.cc', '.cpp']
|
|
||||||
for alt_extension in alternates:
|
|
||||||
alt_name = filename[:-2] + alt_extension
|
|
||||||
if os.path.exists(alt_name):
|
|
||||||
filename = alt_name
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
# If this is a standalone .h file with no source, the best we can do is
|
|
||||||
# try to use the default flags.
|
|
||||||
return chrome_flags
|
|
||||||
|
|
||||||
# Ninja needs the path to the source file from the output build directory.
|
|
||||||
# Cut off the common part and /.
|
|
||||||
subdir_filename = filename[len(chrome_root)+1:]
|
|
||||||
rel_filename = os.path.join('..', '..', subdir_filename)
|
|
||||||
|
|
||||||
out_dir = GetNinjaOutputDirectory(chrome_root)
|
|
||||||
|
|
||||||
# Ask ninja how it would build our source file.
|
|
||||||
p = subprocess.Popen(['ninja', '-v', '-C', out_dir, '-t',
|
|
||||||
'commands', rel_filename + '^'],
|
|
||||||
stdout=subprocess.PIPE)
|
|
||||||
stdout, stderr = p.communicate()
|
|
||||||
if p.returncode:
|
|
||||||
return chrome_flags
|
|
||||||
|
|
||||||
# Ninja might execute several commands to build something. We want the last
|
|
||||||
# clang command.
|
|
||||||
clang_line = None
|
|
||||||
for line in reversed(stdout.split('\n')):
|
|
||||||
if 'clang' in line:
|
|
||||||
clang_line = line
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
return chrome_flags
|
|
||||||
|
|
||||||
# Parse out the -I and -D flags. These seem to be the only ones that are
|
|
||||||
# important for YCM's purposes.
|
|
||||||
for flag in clang_line.split(' '):
|
|
||||||
if flag.startswith('-I'):
|
|
||||||
# Relative paths need to be resolved, because they're relative to the
|
|
||||||
# output dir, not the source.
|
|
||||||
if flag[2] == '/':
|
|
||||||
chrome_flags.append(flag)
|
|
||||||
else:
|
|
||||||
abs_path = os.path.normpath(os.path.join(out_dir, flag[2:]))
|
|
||||||
chrome_flags.append('-I' + abs_path)
|
|
||||||
elif flag.startswith('-') and flag[1] in 'DWFfmO':
|
|
||||||
if flag == '-Wno-deprecated-register' or flag == '-Wno-header-guard':
|
|
||||||
# These flags causes libclang (3.3) to crash. Remove it until things
|
|
||||||
# are fixed.
|
|
||||||
continue
|
|
||||||
chrome_flags.append(flag)
|
|
||||||
|
|
||||||
return chrome_flags
|
|
||||||
|
|
||||||
|
|
||||||
def FlagsForFile(filename):
|
|
||||||
"""This is the main entry point for YCM. Its interface is fixed.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
filename: (String) Path to source file being edited.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
(Dictionary)
|
|
||||||
'flags': (List of Strings) Command line flags.
|
|
||||||
'do_cache': (Boolean) True if the result should be cached.
|
|
||||||
"""
|
|
||||||
chrome_root = FindChromeSrcFromFilename(filename)
|
|
||||||
chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root,
|
|
||||||
filename)
|
|
||||||
final_flags = flags + chrome_flags
|
|
||||||
|
|
||||||
return {
|
|
||||||
'flags': final_flags,
|
|
||||||
'do_cache': True
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
" To get syntax highlighting and tab settings for gyp(i) and DEPS files,
|
|
||||||
" add the following to your .vimrc file:
|
|
||||||
" so /path/to/src/tools/vim/filetypes.vim
|
|
||||||
|
|
||||||
augroup filetype
|
|
||||||
au! BufRead,BufNewFile *.gyp set filetype=python expandtab tabstop=2 shiftwidth=2
|
|
||||||
au! BufRead,BufNewFile *.gypi set filetype=python expandtab tabstop=2 shiftwidth=2
|
|
||||||
au! BufRead,BufNewFile DEPS set filetype=python expandtab tabstop=2 shiftwidth=2
|
|
||||||
augroup END
|
|
|
@ -1,129 +0,0 @@
|
||||||
" Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
||||||
" Use of this source code is governed by a BSD-style license that can be
|
|
||||||
" found in the LICENSE file.
|
|
||||||
"
|
|
||||||
" Adds a "Compile this file" function, using ninja. On Mac, binds Cmd-k to
|
|
||||||
" this command. On Windows, Ctrl-F7 (which is the same as the VS default).
|
|
||||||
" On Linux, <Leader>o, which is \o by default ("o"=creates .o files)
|
|
||||||
"
|
|
||||||
" Adds a "Build this target" function, using ninja. This is not bound
|
|
||||||
" to any key by default, but can be used via the :CrBuild command.
|
|
||||||
" It builds 'chrome' by default, but :CrBuild target1 target2 etc works as well.
|
|
||||||
"
|
|
||||||
" Requires that gyp has already generated build.ninja files, and that ninja is
|
|
||||||
" in your path (which it is automatically if depot_tools is in your path).
|
|
||||||
"
|
|
||||||
" Add the following to your .vimrc file:
|
|
||||||
" so /path/to/src/tools/vim/ninja-build.vim
|
|
||||||
|
|
||||||
python << endpython
|
|
||||||
import os
|
|
||||||
import vim
|
|
||||||
|
|
||||||
|
|
||||||
def path_to_current_buffer():
|
|
||||||
"""Returns the absolute path of the current buffer."""
|
|
||||||
return vim.current.buffer.name
|
|
||||||
|
|
||||||
|
|
||||||
def path_to_source_root():
|
|
||||||
"""Returns the absolute path to the chromium source root."""
|
|
||||||
candidate = os.path.dirname(path_to_current_buffer())
|
|
||||||
# This is a list of files that need to identify the src directory. The shorter
|
|
||||||
# it is, the more likely it's wrong (checking for just "build/common.gypi"
|
|
||||||
# would find "src/v8" for files below "src/v8", as "src/v8/build/common.gypi"
|
|
||||||
# exists). The longer it is, the more likely it is to break when we rename
|
|
||||||
# directories.
|
|
||||||
fingerprints = ['chrome', 'net', 'v8', 'build', 'skia']
|
|
||||||
while candidate and not all(
|
|
||||||
[os.path.isdir(os.path.join(candidate, fp)) for fp in fingerprints]):
|
|
||||||
candidate = os.path.dirname(candidate)
|
|
||||||
return candidate
|
|
||||||
|
|
||||||
|
|
||||||
def guess_configuration():
|
|
||||||
"""Default to the configuration with either a newer build.ninja or a newer
|
|
||||||
protoc."""
|
|
||||||
root = os.path.join(path_to_source_root(), 'out')
|
|
||||||
def is_release_15s_newer(test_path):
|
|
||||||
try:
|
|
||||||
debug_mtime = os.path.getmtime(os.path.join(root, 'Debug', test_path))
|
|
||||||
except os.error:
|
|
||||||
debug_mtime = 0
|
|
||||||
try:
|
|
||||||
rel_mtime = os.path.getmtime(os.path.join(root, 'Release', test_path))
|
|
||||||
except os.error:
|
|
||||||
rel_mtime = 0
|
|
||||||
return rel_mtime - debug_mtime >= 15
|
|
||||||
configuration = 'Debug'
|
|
||||||
if is_release_15s_newer('build.ninja') or is_release_15s_newer('protoc'):
|
|
||||||
configuration = 'Release'
|
|
||||||
return configuration
|
|
||||||
|
|
||||||
|
|
||||||
def compute_ninja_command_for_current_buffer(configuration=None):
|
|
||||||
"""Returns the shell command to compile the file in the current buffer."""
|
|
||||||
if not configuration: configuration = guess_configuration()
|
|
||||||
build_dir = os.path.join(path_to_source_root(), 'out', configuration)
|
|
||||||
|
|
||||||
# ninja needs filepaths for the ^ syntax to be relative to the
|
|
||||||
# build directory.
|
|
||||||
file_to_build = path_to_current_buffer()
|
|
||||||
file_to_build = os.path.relpath(file_to_build, build_dir)
|
|
||||||
|
|
||||||
build_cmd = ' '.join(['ninja', '-C', build_dir, file_to_build + '^'])
|
|
||||||
if sys.platform == 'win32':
|
|
||||||
# Escape \ for Vim, and ^ for both Vim and shell.
|
|
||||||
build_cmd = build_cmd.replace('\\', '\\\\').replace('^', '^^^^')
|
|
||||||
vim.command('return "%s"' % build_cmd)
|
|
||||||
|
|
||||||
|
|
||||||
def compute_ninja_command_for_targets(targets='', configuration=None):
|
|
||||||
if not configuration: configuration = guess_configuration()
|
|
||||||
build_dir = os.path.join(path_to_source_root(), 'out', configuration)
|
|
||||||
build_cmd = ' '.join(['ninja', '-C', build_dir, targets])
|
|
||||||
vim.command('return "%s"' % build_cmd)
|
|
||||||
endpython
|
|
||||||
|
|
||||||
fun! s:MakeWithCustomCommand(build_cmd)
|
|
||||||
let l:oldmakepgr = &makeprg
|
|
||||||
let &makeprg=a:build_cmd
|
|
||||||
silent make | cwindow
|
|
||||||
if !has('gui_running')
|
|
||||||
redraw!
|
|
||||||
endif
|
|
||||||
let &makeprg = l:oldmakepgr
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! s:NinjaCommandForCurrentBuffer()
|
|
||||||
python compute_ninja_command_for_current_buffer()
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! s:NinjaCommandForTargets(targets)
|
|
||||||
python compute_ninja_command_for_targets(vim.eval('a:targets'))
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! CrCompileFile()
|
|
||||||
call s:MakeWithCustomCommand(s:NinjaCommandForCurrentBuffer())
|
|
||||||
endfun
|
|
||||||
|
|
||||||
fun! CrBuild(...)
|
|
||||||
let l:targets = a:0 > 0 ? join(a:000, ' ') : ''
|
|
||||||
if (l:targets !~ "\i")
|
|
||||||
let l:targets = 'chrome'
|
|
||||||
endif
|
|
||||||
call s:MakeWithCustomCommand(s:NinjaCommandForTargets(l:targets))
|
|
||||||
endfun
|
|
||||||
|
|
||||||
command! CrCompileFile call CrCompileFile()
|
|
||||||
command! -nargs=* CrBuild call CrBuild(<q-args>)
|
|
||||||
|
|
||||||
if has('mac')
|
|
||||||
map <D-k> :CrCompileFile<cr>
|
|
||||||
imap <D-k> <esc>:CrCompileFile<cr>
|
|
||||||
elseif has('win32')
|
|
||||||
map <C-F7> :CrCompileFile<cr>
|
|
||||||
imap <C-F7> <esc>:CrCompileFile<cr>
|
|
||||||
elseif has('unix')
|
|
||||||
map <Leader>o :CrCompileFile<cr>
|
|
||||||
endif
|
|
|
@ -1,115 +0,0 @@
|
||||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
||||||
// Use of this source code is governed by a BSD-style license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
//
|
|
||||||
// This is a small program that tries to connect to the X server. It
|
|
||||||
// continually retries until it connects or 30 seconds pass. If it fails
|
|
||||||
// to connect to the X server or fails to find needed functiona, it returns
|
|
||||||
// an error code of -1.
|
|
||||||
//
|
|
||||||
// This is to help verify that a useful X server is available before we start
|
|
||||||
// start running tests on the build bots.
|
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <X11/Xlib.h>
|
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
|
||||||
#include <X11/extensions/XInput2.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void Sleep(int duration_ms) {
|
|
||||||
struct timespec sleep_time, remaining;
|
|
||||||
|
|
||||||
// Contains the portion of duration_ms >= 1 sec.
|
|
||||||
sleep_time.tv_sec = duration_ms / 1000;
|
|
||||||
duration_ms -= sleep_time.tv_sec * 1000;
|
|
||||||
|
|
||||||
// Contains the portion of duration_ms < 1 sec.
|
|
||||||
sleep_time.tv_nsec = duration_ms * 1000 * 1000; // nanoseconds.
|
|
||||||
|
|
||||||
while (nanosleep(&sleep_time, &remaining) == -1 && errno == EINTR)
|
|
||||||
sleep_time = remaining;
|
|
||||||
}
|
|
||||||
|
|
||||||
class XScopedDisplay {
|
|
||||||
public:
|
|
||||||
XScopedDisplay() : display_(NULL) {}
|
|
||||||
~XScopedDisplay() {
|
|
||||||
if (display_) XCloseDisplay(display_);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set(Display* display) { display_ = display; }
|
|
||||||
Display* display() { return display_; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
Display* display_;
|
|
||||||
};
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
|
||||||
XScopedDisplay scoped_display;
|
|
||||||
if (argv[1] && strcmp(argv[1], "--noserver") == 0) {
|
|
||||||
scoped_display.set(XOpenDisplay(NULL));
|
|
||||||
if (scoped_display.display()) {
|
|
||||||
fprintf(stderr, "Found unexpected connectable display %s\n",
|
|
||||||
XDisplayName(NULL));
|
|
||||||
}
|
|
||||||
// Return success when we got an unexpected display so that the code
|
|
||||||
// without the --noserver is the same, but slow, rather than inverted.
|
|
||||||
return !scoped_display.display();
|
|
||||||
}
|
|
||||||
|
|
||||||
int kNumTries = 78; // 78*77/2 * 10 = 30s of waiting
|
|
||||||
int tries;
|
|
||||||
for (tries = 0; tries < kNumTries; ++tries) {
|
|
||||||
scoped_display.set(XOpenDisplay(NULL));
|
|
||||||
if (scoped_display.display())
|
|
||||||
break;
|
|
||||||
Sleep(10 * tries);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!scoped_display.display()) {
|
|
||||||
fprintf(stderr, "Failed to connect to %s\n", XDisplayName(NULL));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(stderr, "Connected after %d retries\n", tries);
|
|
||||||
|
|
||||||
#if defined(USE_AURA)
|
|
||||||
// Check for XInput2
|
|
||||||
int opcode, event, err;
|
|
||||||
if (!XQueryExtension(scoped_display.display(), "XInputExtension", &opcode,
|
|
||||||
&event, &err)) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Failed to get XInputExtension on %s.\n", XDisplayName(NULL));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int major = 2, minor = 0;
|
|
||||||
if (XIQueryVersion(scoped_display.display(), &major, &minor) == BadRequest) {
|
|
||||||
fprintf(stderr,
|
|
||||||
"Server does not have XInput2 on %s.\n", XDisplayName(NULL));
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ask for the list of devices. This can cause some Xvfb to crash.
|
|
||||||
int count = 0;
|
|
||||||
XIDeviceInfo* devices =
|
|
||||||
XIQueryDevice(scoped_display.display(), XIAllDevices, &count);
|
|
||||||
if (devices)
|
|
||||||
XIFreeDeviceInfo(devices);
|
|
||||||
|
|
||||||
fprintf(stderr,
|
|
||||||
"XInput2 verified initially sane on %s.\n", XDisplayName(NULL));
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(LEAK_SANITIZER)
|
|
||||||
// XOpenDisplay leaks memory if it takes more than one try to connect. This
|
|
||||||
// causes LSan bots to fail. We don't care about memory leaks in xdisplaycheck
|
|
||||||
// anyway, so just disable LSan completely.
|
|
||||||
extern "C" int __lsan_is_turned_off() { return 1; }
|
|
||||||
#endif
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
|
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
|
||||||
# found in the LICENSE file.
|
|
||||||
|
|
||||||
{
|
|
||||||
'targets': [
|
|
||||||
{
|
|
||||||
'target_name': 'xdisplaycheck',
|
|
||||||
'type': 'executable',
|
|
||||||
'dependencies': [
|
|
||||||
'../../build/linux/system.gyp:x11',
|
|
||||||
],
|
|
||||||
'sources': [
|
|
||||||
'xdisplaycheck.cc',
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
Loading…
Reference in New Issue