Updated
This commit is contained in:
parent
5821f20967
commit
d39fa4697a
105
cava/.config/cava/config
Normal file
105
cava/.config/cava/config
Normal file
|
@ -0,0 +1,105 @@
|
|||
## Configuration file for CAVA. Default values are commented out. Use either ; or # for commenting.
|
||||
|
||||
|
||||
[general]
|
||||
|
||||
# smoothing mode, can be normal, scientific or waves.
|
||||
; mode = waves
|
||||
|
||||
# Framerate Default: 60. Accepts only non-negative values.
|
||||
; framerate = 60
|
||||
|
||||
# Sensitivity in %. If you think the bars are to low/response is to littei, try
|
||||
# increasing this value 200 means double height. Accepts only non-negative values.
|
||||
sensitivity = 1.5
|
||||
|
||||
# Autosens will atempt to decrease sensitivity if cava peaks. 1 = on, 0 = off
|
||||
autosens = 0
|
||||
|
||||
# The number of bars. 0 (default) sets it to auto (fil upp console).
|
||||
# width of bras and space between bars in number of characters. Default witdth 3 and space 1.
|
||||
; bars = 0
|
||||
bar_width = 2
|
||||
bar_spacing = 1
|
||||
|
||||
|
||||
# Lower cutoff freq for lowest bar and higheset for highest bar
|
||||
# the bandwith of the visualizer, defaults to 50 - 10000 Hz
|
||||
# Note: there is a minimum total bandwith of 43Mhz x number of bars.
|
||||
# Cava will automaticly increase the higher cuttoff if a too low band is specified.
|
||||
lower_cutoff_freq = 50
|
||||
higher_cutoff_freq = 10000
|
||||
|
||||
|
||||
|
||||
[input]
|
||||
|
||||
# method of capturing audio, supported input methods are: 'pulse', 'alsa' or 'fifo'.
|
||||
# Defaults to 'alsa'
|
||||
#
|
||||
# for pulseaudio 'source' wil be the source. Default: 'NULL', which uses system default source
|
||||
# all pulseaudio sinks(outputs) have 'monitor' sources(inputs) associated with them
|
||||
# but the default, might be your microphone, try the command 'pacmd list-sources' to find the right one
|
||||
# you can change source here to the name of your prefered device, or cahnge your default pulseaudio source by running
|
||||
# 'pacmd set-default-source NAME|#N'
|
||||
#
|
||||
# for alsa 'source' will be the capture device. Default: 'hw:Loopback,1'
|
||||
# for fifo 'source' will be the path to fifo-file. Default: '/tmp/mpd.fifo'
|
||||
; method = alsa
|
||||
; source = hw:Loopback,1
|
||||
|
||||
; method = fifo
|
||||
; source = /tmp/mpd.fifo
|
||||
|
||||
; method = pulse
|
||||
; source = NULL
|
||||
|
||||
|
||||
|
||||
|
||||
[output]
|
||||
|
||||
# method used to draw output may be ncurses, noncurses.
|
||||
; method = ncurses
|
||||
|
||||
# visual styles, may be 'stereo' or 'mono'.
|
||||
# Stereo mirrors both channels with low frequencies in center.
|
||||
# Mono avrages both channels and outputs left to right lowest to highest frequencies
|
||||
style = mono
|
||||
|
||||
|
||||
[color]
|
||||
|
||||
# supported colors are: red, green, yellow, magenta, cyan, white, blue, black.
|
||||
; background = black
|
||||
foreground = red
|
||||
|
||||
|
||||
[smoothing]
|
||||
|
||||
# multiplier for the integral smoothing calculations. Takes values from 0 - 0.99.
|
||||
# Higher values means smoother, but less precise. 0 to disable.
|
||||
; integral = 0.7
|
||||
|
||||
# disables or enables the so-called "Monstercat smoothing". Default: 1. Set to 0 to disable.
|
||||
; monstercat = 1
|
||||
|
||||
# Set gravity multiplier for "drop off". Higher values means bars will drop faster.
|
||||
# Accepts only non-negative values. 0.5 means half gravity, 2 means double. Set to 0 to disable "drop off".
|
||||
gravity = 3
|
||||
|
||||
|
||||
# In bar height, bars that whould have been lower that this will not be drawn.
|
||||
; ignore = 0
|
||||
|
||||
|
||||
[eq]
|
||||
|
||||
# This one is tricky. You can have as much keys as you want.
|
||||
# remember to uncomment more then one key! More keys = more precision.
|
||||
# Look at readme.md on github for further explanations and examples.
|
||||
; 1 = 1 # bass
|
||||
; 2 = 1
|
||||
; 3 = 1 # midtone
|
||||
; 4 = 1
|
||||
; 5 = 1 # treble
|
|
@ -1,12 +1,12 @@
|
|||
.header-bar.default-decoration {
|
||||
padding-top: 3px;
|
||||
padding-bottom: 3px;
|
||||
}
|
||||
|
||||
.header-bar.default-decoration .button.titlebutton {
|
||||
padding-top: 2px;
|
||||
padding-bottom: 2px;
|
||||
}
|
||||
/* .header-bar.default-decoration { */
|
||||
/* padding-top: 3px; */
|
||||
/* padding-bottom: 3px; */
|
||||
/* } */
|
||||
/* */
|
||||
/* .header-bar.default-decoration .button.titlebutton { */
|
||||
/* padding-top: 2px; */
|
||||
/* padding-bottom: 2px; */
|
||||
/* } */
|
||||
|
||||
/* .window-frame:backdrop, */
|
||||
/* .window-frame, */
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
let g:netrw_dirhistmax =10
|
||||
let g:netrw_dirhist_cnt =2
|
||||
let g:netrw_dirhist_cnt =4
|
||||
let g:netrw_dirhist_1='/home/tim/.nvim'
|
||||
let g:netrw_dirhist_2='/home/tim/.dotfiles/nvim/.nvim'
|
||||
let g:netrw_dirhist_3='/home/tim/Projects/cpp/arena'
|
||||
let g:netrw_dirhist_4='/home/tim/Projects/cpp/stdany'
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@ Plug 'morhetz/gruvbox'
|
|||
Plug 'Yggdroot/indentLine'
|
||||
Plug 'scrooloose/nerdtree'
|
||||
Plug 'godlygeek/tabular'
|
||||
Plug 'majutsushi/tagbar'
|
||||
" Plug 'majutsushi/tagbar'
|
||||
Plug 'tomtom/tcomment_vim'
|
||||
Plug 'bling/vim-airline'
|
||||
Plug 'tommcdo/vim-exchange'
|
||||
|
@ -17,15 +17,21 @@ Plug 'MarcWeber/vim-addon-mw-utils'
|
|||
Plug 'tomtom/tlib_vim'
|
||||
Plug 'SirVer/ultisnips'
|
||||
Plug 'honza/vim-snippets'
|
||||
Plug 'beyondmarc/glsl.vim'
|
||||
" Plug 'beyondmarc/glsl.vim'
|
||||
Plug 'tpope/vim-dispatch'
|
||||
Plug 'freitass/todo.txt-vim'
|
||||
" Plug 'freitass/todo.txt-vim'
|
||||
Plug 'tpope/vim-unimpaired'
|
||||
Plug 'milkypostman/vim-togglelist'
|
||||
Plug 'Valloric/YouCompleteMe'
|
||||
" Plug 'Shougo/deoplete.nvim'
|
||||
" Plug 'vim-scripts/LanguageTool'
|
||||
" Plug 'pangloss/vim-javascript'
|
||||
Plug 'moll/vim-bbye'
|
||||
Plug 'tpope/vim-fugitive'
|
||||
Plug 'tikhomirov/vim-glsl'
|
||||
call plug#end()
|
||||
|
||||
let g:ctrlp_custom_ignore = '\v[\/](bin|obj)$'
|
||||
let g:ctrlp_custom_ignore = '\v[\/](bin|docs)$'
|
||||
|
||||
let delimitMate_expand_cr = 1
|
||||
|
||||
|
@ -35,14 +41,15 @@ set t_ZH=[3m
|
|||
set t_ZR=[23m
|
||||
set background=dark
|
||||
|
||||
let g:indentLine_char = '│'
|
||||
let g:indentLine_color_term = 239
|
||||
" let g:indentLine_char = '│'
|
||||
" let g:indentLine_color_term = 239
|
||||
set list lcs=tab:\│\
|
||||
|
||||
" map <silent> <M-a> :NERDTreeToggle<cr>
|
||||
map <silent> <F2> :NERDTreeToggle<cr>
|
||||
|
||||
" map <silent> <M-2> :TagbarToggle<cr>
|
||||
map <silent> <F3> :TagbarToggle<cr>
|
||||
" map <silent> <F3> :TagbarToggle<cr>
|
||||
|
||||
let g:airline_powerline_fonts = 1
|
||||
let g:airline#extensions#tabline#enabled = 1
|
||||
|
@ -76,6 +83,7 @@ set number
|
|||
set relativenumber
|
||||
set laststatus=2
|
||||
set softtabstop=4
|
||||
set tabstop=4
|
||||
set shiftwidth=4
|
||||
set noexpandtab
|
||||
set completeopt-=preview
|
||||
|
@ -83,6 +91,9 @@ set completeopt-=preview
|
|||
" I do not remember what this is for
|
||||
" set cinkeys=0{,0},0),:,!^F,o,O,e
|
||||
|
||||
let g:languagetool_jar='$HOME/.local/bin/LanguageTool-3.2/languagetool-commandline.jar'
|
||||
let g:languagetool_lang="nl"
|
||||
|
||||
map <silent> <tab> :bn<cr>
|
||||
map <silent> <S-tab> :bp<cr>
|
||||
|
||||
|
@ -93,13 +104,19 @@ autocmd FileType cpp map <F9> :Make<cr>
|
|||
autocmd FileType cpp map <F10> :Make debug<cr>
|
||||
autocmd FileType cpp map <F12> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR>
|
||||
|
||||
autocmd FileType go let &makeprg="go run %:p:h/*.go"
|
||||
autocmd FileType go map <F10> :Make<cr>
|
||||
|
||||
autocmd FileType tex map <F9> :!arara %<cr>
|
||||
|
||||
if !filereadable(expand("%:p:h")."/Makefile")
|
||||
let &makeprg="cd CMake/default && make"
|
||||
endif
|
||||
map <silent> <F4> :call ToggleQuickfixList()<cr>
|
||||
map <silent> <F5> :e ./todo/todo.txt<cr>
|
||||
map <silent> <F6> :e ./todo/done.txt<cr>
|
||||
map <silent> <F7> :grep -F TODO -R ./src/**/*.cpp ./include/**/*.h<cr> :cw<cr>
|
||||
map <silent> <F8> :grep -F NOTE -R ./src/**/*.cpp ./include/**/*.h<cr> :cw<cr>
|
||||
" map <silent> <F7> :grep -F TODO -R ./src/**/*.cpp ./include/**/*.h<cr> :cw<cr>
|
||||
" map <silent> <F8> :grep -F NOTE -R ./src/**/*.cpp ./include/**/*.h<cr> :cw<cr>
|
||||
|
||||
function! NeatFoldText()
|
||||
let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
|
||||
|
@ -112,7 +129,45 @@ function! NeatFoldText()
|
|||
return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
|
||||
endfunction
|
||||
|
||||
set foldtext=NeatFoldText()
|
||||
function! MyFoldText() " {{{
|
||||
let line = getline(v:foldstart)
|
||||
|
||||
let nucolwidth = &fdc + &number * &numberwidth
|
||||
let windowwidth = winwidth(0) - nucolwidth - 3
|
||||
let foldedlinecount = v:foldend - v:foldstart
|
||||
|
||||
" expand tabs into spaces
|
||||
let onetab = strpart(' ', 0, &tabstop)
|
||||
let line = substitute(line, '\t', onetab, 'g')
|
||||
|
||||
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
|
||||
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
|
||||
return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
|
||||
endfunction " }}}
|
||||
|
||||
fu! CustomFoldText()
|
||||
"get first non-blank line
|
||||
let fs = v:foldstart
|
||||
while getline(fs) =~ '^\s*$' | let fs = nextnonblank(fs + 1)
|
||||
endwhile
|
||||
if fs > v:foldend
|
||||
let line = getline(v:foldstart)
|
||||
else
|
||||
let line = substitute(getline(fs), '\t', repeat(' ', &tabstop), 'g')
|
||||
endif
|
||||
|
||||
let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
|
||||
let foldSize = 1 + v:foldend - v:foldstart
|
||||
let foldSizeStr = " " . foldSize . " lines "
|
||||
let foldLevelStr = repeat("+--", v:foldlevel)
|
||||
let lineCount = line("$")
|
||||
let foldPercentage = printf("[%.1f", (foldSize*1.0)/lineCount*100) . "%] "
|
||||
let expansionString = repeat(".", w - strwidth(foldSizeStr.line.foldLevelStr.foldPercentage))
|
||||
return line . expansionString . foldSizeStr . foldPercentage . foldLevelStr
|
||||
endf
|
||||
|
||||
" set foldtext=NeatFoldText()
|
||||
set foldtext=CustomFoldText()
|
||||
set foldcolumn=1
|
||||
au BufRead *.cpp setlocal foldmethod=syntax
|
||||
au BufRead *.cpp setlocal foldnestmax=1
|
||||
au BufRead *.cpp,*.go,*.js setlocal foldmethod=syntax
|
||||
au BufRead *.cpp,*go,*.js setlocal foldnestmax=1
|
||||
|
|
1
nvim/.config/nvim/plugged/LanguageTool
Submodule
1
nvim/.config/nvim/plugged/LanguageTool
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit e4f234b8a06e2d855e3ddcee1e9d81d203830c63
|
|
@ -1 +1 @@
|
|||
Subproject commit 0352ed9b1f8f6bb4b9cdc1c164b564573243aecc
|
||||
Subproject commit cb5756943fdd3ba062f101a5aba34acdd34d1356
|
|
@ -1 +1 @@
|
|||
Subproject commit 9e84cf8072866b92faf5082cb93a554b75e35fd0
|
||||
Subproject commit 8a803267a741cff3d6147650745f83c8f2125578
|
|
@ -1 +1 @@
|
|||
Subproject commit b5d3fe66a58a13d2ff8b6391f4387608496a030f
|
||||
Subproject commit 564176f01d7f3f7f8ab452ff4e1f5314de7b0981
|
1
nvim/.config/nvim/plugged/deoplete.nvim
Submodule
1
nvim/.config/nvim/plugged/deoplete.nvim
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 816bea3a9a0c5a1cc53488256d452edea04cb70a
|
|
@ -1 +1 @@
|
|||
Subproject commit 9bc625e4d5fc8cee40dfa9e811aa210e5dba945f
|
||||
Subproject commit 245c52580408e8eaae178ce11735498034c0dab7
|
|
@ -1 +1 @@
|
|||
Subproject commit e4ba7abe5ccccc0ebea0e33a4e045f96311020d8
|
||||
Subproject commit 91bae6876031ececf151cc4f28aa5fb8c93681e4
|
|
@ -1 +1 @@
|
|||
Subproject commit 6011a6132c40d7f8fecadd7b44677f539289ea4c
|
||||
Subproject commit 2a2617310b0fb4c0daf02be2ba465fada257f2d0
|
|
@ -1 +1 @@
|
|||
Subproject commit 0b44415a3302030b56755cc1135ca9ca57dc1ada
|
||||
Subproject commit 35c859179da4ad4f96eb8255e428904436a0b4b4
|
|
@ -1 +1 @@
|
|||
Subproject commit c067932263fbb8add3c330485b14f31f791418f0
|
||||
Subproject commit 7c4277754b6b77fb80b47cd4a7384d1e2d6c1538
|
|
@ -1 +1 @@
|
|||
Subproject commit 04b1b1de812f521a88e42df387695c5c6378eac2
|
||||
Subproject commit 34b13299b5da7ad66ea387027d458bd54127687c
|
|
@ -1 +1 @@
|
|||
Subproject commit b3d9e18b081bfdfeec50af58fa7eb5a353a10675
|
||||
Subproject commit 1e3a5e58aeb4aa508ce2e36bcb5230452812c4c3
|
|
@ -1 +1 @@
|
|||
Subproject commit c9699feed1cc301826fdb36ad3bb37e14be1d4ea
|
||||
Subproject commit 3c420ed63f54a3359d5bc4e500cb9abd0c9177c5
|
|
@ -1 +1 @@
|
|||
Subproject commit 14d14cf951c08fc88ca6c3e6f28fe47b99421e23
|
||||
Subproject commit eaf2034163b9b9dab2217d10c48ae0d52e90d07b
|
1
nvim/.config/nvim/plugged/vim-bbye
Submodule
1
nvim/.config/nvim/plugged/vim-bbye
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit a018cbc1ba63b1a8b86b7c468645e7642637ec4a
|
|
@ -1 +1 @@
|
|||
Subproject commit 69fea418692f76058d5cd95f0a17ed6b0f5bbb77
|
||||
Subproject commit fc8d1e68cd58fb3ffdd56109bf855cda92b10b70
|
1
nvim/.config/nvim/plugged/vim-fugitive
Submodule
1
nvim/.config/nvim/plugged/vim-fugitive
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit bdd216827ae53cdf70d933bb30762da9bf42cad4
|
1
nvim/.config/nvim/plugged/vim-glsl
Submodule
1
nvim/.config/nvim/plugged/vim-glsl
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 6ea4e1983b18cf440c8f800a3e94b57338a3e99f
|
1
nvim/.config/nvim/plugged/vim-javascript
Submodule
1
nvim/.config/nvim/plugged/vim-javascript
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 1d8c2677d26d6b3950b90dc1636e63334c8efc3b
|
1
nvim/.config/nvim/plugged/vim-javascript-syntax
Submodule
1
nvim/.config/nvim/plugged/vim-javascript-syntax
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 9e019fccd738ba73713268a327ac3765646a4edd
|
|
@ -1 +1 @@
|
|||
Subproject commit 8cb1d88e475ac3c109f56ebd5379c07d3ed83a9f
|
||||
Subproject commit 042aec6f06e958d74f072855bfd365a671aaf49b
|
|
@ -1 +1 @@
|
|||
Subproject commit 754871fc6e523133921cb4f72b26111ff61cd7dd
|
||||
Subproject commit eaa5289b5161ef2c24fb66364ad563ea4ef5b170
|
|
@ -1 +1 @@
|
|||
Subproject commit 23f471ad0f00e2fab097f9d67ffd770881d4b35a
|
||||
Subproject commit 11dc568dbfd7a56866a4354c737515769f08e9fe
|
1
nvim/.config/nvim/plugged/vim-z80
Submodule
1
nvim/.config/nvim/plugged/vim-z80
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 3b9e2b28582fbad167100e950602ccbc67cbdf39
|
456
scripts/config_gen.py
Executable file
456
scripts/config_gen.py
Executable file
|
@ -0,0 +1,456 @@
|
|||
#!/usr/bin/env python2
|
||||
|
||||
import sys
|
||||
import os
|
||||
import os.path
|
||||
import re
|
||||
import argparse
|
||||
import datetime
|
||||
import multiprocessing
|
||||
import shlex
|
||||
import shutil
|
||||
import tempfile
|
||||
import time
|
||||
import subprocess
|
||||
import glob
|
||||
|
||||
|
||||
# Default flags for make
|
||||
default_make_flags = ["-i", "-j" + str(multiprocessing.cpu_count())]
|
||||
|
||||
# Set YCM-Generator directory
|
||||
# Always obtain the real path to the directory where 'config_gen.py' lives as,
|
||||
# in some cases, it will be a symlink placed in '/usr/bin' (as is the case
|
||||
# with the Arch Linux AUR package) and it won't
|
||||
# be able to find the plugin directory.
|
||||
ycm_generator_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
|
||||
def main():
|
||||
# parse command-line args
|
||||
parser = argparse.ArgumentParser(description="Automatically generates config files for YouCompleteMe")
|
||||
parser.add_argument("-v", "--verbose", action="store_true", help="Show output from build process")
|
||||
parser.add_argument("-m", "--make", default="make", help="Use the specified executable for make.")
|
||||
parser.add_argument("-c", "--compiler", help="Use the specified executable for clang. It should be the same version as the libclang used by YCM. The executable for clang++ will be inferred from this.")
|
||||
parser.add_argument("-C", "--configure_opts", default="", help="Additional flags to pass to configure/cmake/etc. e.g. --configure_opts=\"--enable-FEATURE\"")
|
||||
parser.add_argument("-F", "--format", choices=["ycm", "cc"], default="ycm", help="Format of output file (YouCompleteMe or color_coded). Default: ycm")
|
||||
parser.add_argument("-M", "--make-flags", help="Flags to pass to make when fake-building. Default: -M=\"{}\"".format(" ".join(default_make_flags)))
|
||||
parser.add_argument("-o", "--output", help="Save the config file as OUTPUT. Default: .ycm_extra_conf.py, or .color_coded if --format=cc.")
|
||||
parser.add_argument("-x", "--language", choices=["c", "c++"], help="Only output flags for the given language. This defaults to whichever language has its compiler invoked the most.")
|
||||
parser.add_argument("--out-of-tree", action="store_true", help="Build autotools projects out-of-tree. This is a no-op for other project types.")
|
||||
parser.add_argument("--qt-version", choices=["4", "5"], default="5", help="Use the given Qt version for qmake. (Default: 5)")
|
||||
parser.add_argument("-e", "--preserve-environment", action="store_true", help="Pass environment variables to build processes.")
|
||||
parser.add_argument("PROJECT_DIR", help="The root directory of the project.")
|
||||
args = vars(parser.parse_args())
|
||||
project_dir = os.path.abspath(args["PROJECT_DIR"])
|
||||
|
||||
# verify that project_dir exists
|
||||
if(not os.path.exists(project_dir)):
|
||||
print("ERROR: '{}' does not exist".format(project_dir))
|
||||
return 1
|
||||
|
||||
# verify the clang is installed, and infer the correct name for both the C and C++ compilers
|
||||
try:
|
||||
cc = args["compiler"] or "clang"
|
||||
args["cc"] = subprocess.check_output(["which", cc]).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
print("ERROR: Could not find clang at '{}'. Please make sure it is installed and is either in your path, or specified with --compiler.".format(cc))
|
||||
return 1
|
||||
|
||||
try:
|
||||
h, t = os.path.split(args["compiler"] or "clang")
|
||||
cxx = os.path.join(h, t.replace("clang", "clang++"))
|
||||
args["cxx"] = subprocess.check_output(["which", cxx]).strip()
|
||||
except subprocess.CalledProcessError:
|
||||
print("ERROR: Could not find clang++ at '{}'. Please make sure it is installed and specified appropriately.".format(cxx))
|
||||
return 1
|
||||
|
||||
# sanity check - remove this after we add Windows support
|
||||
if(sys.platform.startswith("win32")):
|
||||
print("ERROR: Windows is not supported")
|
||||
|
||||
# prompt user to overwrite existing file (if necessary)
|
||||
config_file = {
|
||||
None: args["output"],
|
||||
"cc": os.path.join(project_dir, ".color_coded"),
|
||||
"ycm": os.path.join(project_dir, ".ycm_extra_conf.py"),
|
||||
}[args["format"] if args["output"] is None else None]
|
||||
|
||||
if(os.path.exists(config_file)):
|
||||
print("'{}' already exists. Overwrite? [y/N] ".format(config_file)),
|
||||
response = sys.stdin.readline().strip().lower()
|
||||
|
||||
if(response != "y" and response != "yes"):
|
||||
return 1
|
||||
|
||||
# command-line args to pass to fake_build() using kwargs
|
||||
args["make_cmd"] = args.pop("make")
|
||||
args["configure_opts"] = shlex.split(args["configure_opts"])
|
||||
args["make_flags"] = default_make_flags if args["make_flags"] is None else shlex.split(args["make_flags"])
|
||||
force_lang = args.pop("language")
|
||||
output_format = args.pop("format")
|
||||
del args["compiler"]
|
||||
del args["output"]
|
||||
del args["PROJECT_DIR"]
|
||||
|
||||
generate_conf = {
|
||||
"ycm": generate_ycm_conf,
|
||||
"cc": generate_cc_conf,
|
||||
}[output_format]
|
||||
|
||||
# temporary files to hold build logs
|
||||
with tempfile.NamedTemporaryFile(mode="rw") as c_build_log:
|
||||
with tempfile.NamedTemporaryFile(mode="rw") as cxx_build_log:
|
||||
# perform the actual compilation of flags
|
||||
fake_build(project_dir, c_build_log.name, cxx_build_log.name, **args)
|
||||
(c_count, c_skip, c_flags) = parse_flags(c_build_log)
|
||||
(cxx_count, cxx_skip, cxx_flags) = parse_flags(cxx_build_log)
|
||||
|
||||
print("Collected {} relevant entries for C compilation ({} discarded).".format(c_count, c_skip))
|
||||
print("Collected {} relevant entries for C++ compilation ({} discarded).".format(cxx_count, cxx_skip))
|
||||
|
||||
# select the language to compile for. If -x was used, zero all other options (so we don't need to repeat the error code)
|
||||
if(force_lang == "c"):
|
||||
cxx_count = 0
|
||||
elif(force_lang == "c++"):
|
||||
c_count = 0
|
||||
|
||||
if(c_count == 0 and cxx_count == 0):
|
||||
print()
|
||||
print("ERROR: No commands were logged to the build logs (C: {}, C++: {}).".format(c_build_log.name, cxx_build_log.name))
|
||||
print("Your build system may not be compatible.")
|
||||
c_build_log.delete = False
|
||||
cxx_build_log.delete = False
|
||||
return 3
|
||||
|
||||
elif(c_count > cxx_count):
|
||||
lang, flags = ("c", c_flags)
|
||||
else:
|
||||
lang, flags = ("c++", cxx_flags)
|
||||
|
||||
generate_conf(["-x", lang] + flags, config_file)
|
||||
print("Created {} config file with {} {} flags".format(output_format.upper(), len(flags), lang.upper()))
|
||||
|
||||
|
||||
def fake_build(project_dir, c_build_log_path, cxx_build_log_path, verbose, make_cmd, cc, cxx, out_of_tree, configure_opts, make_flags, preserve_environment, qt_version):
|
||||
'''Builds the project using the fake toolchain, to collect the compiler flags.
|
||||
|
||||
project_dir: the directory containing the source files
|
||||
build_log_path: the file to log commands to
|
||||
verbose: show the build process output
|
||||
make_cmd: the path of the make executable
|
||||
cc: the path of the clang executable
|
||||
cxx: the path of the clang++ executable
|
||||
out_of_tree: perform an out-of-tree build (autotools only)
|
||||
configure_opts: additional flags for configure stage
|
||||
make_flags: additional flags for make
|
||||
preserve_environment: pass environment variables to build processes
|
||||
qt_version: The Qt version to use when building with qmake.
|
||||
'''
|
||||
|
||||
# TODO: add Windows support
|
||||
assert(not sys.platform.startswith("win32"))
|
||||
fake_path = os.path.join(ycm_generator_dir, "fake-toolchain", "Unix")
|
||||
|
||||
# environment variables and arguments for build process
|
||||
started = time.time()
|
||||
FNULL = open(os.devnull, "w")
|
||||
proc_opts = {} if verbose else {
|
||||
"stdin": FNULL,
|
||||
"stdout": FNULL,
|
||||
"stderr": FNULL
|
||||
}
|
||||
proc_opts["cwd"] = project_dir
|
||||
|
||||
if(preserve_environment):
|
||||
env = os.environ
|
||||
else:
|
||||
# Preserve HOME, since Cmake needs it to find some packages and it's
|
||||
# normally there anyway. See #26.
|
||||
env = dict(map(lambda x: (x, os.environ[x]), ["HOME"]))
|
||||
|
||||
env["PATH"] = "{}:{}".format(fake_path, os.environ["PATH"])
|
||||
env["CC"] = "clang"
|
||||
env["CXX"] = "clang++"
|
||||
env["YCM_CONFIG_GEN_CC_LOG"] = c_build_log_path
|
||||
env["YCM_CONFIG_GEN_CXX_LOG"] = cxx_build_log_path
|
||||
|
||||
# used during configuration stage, so that cmake, etc. can verify what the compiler supports
|
||||
env_config = env.copy()
|
||||
env_config["YCM_CONFIG_GEN_CC_PASSTHROUGH"] = cc
|
||||
env_config["YCM_CONFIG_GEN_CXX_PASSTHROUGH"] = cxx
|
||||
|
||||
# use -i (ignore errors), since the makefile may include scripts which
|
||||
# depend upon the existence of various output files
|
||||
make_args = [make_cmd] + make_flags
|
||||
|
||||
# Used for the qmake build system below
|
||||
pro_files = glob.glob(os.path.join(project_dir, "*.pro"))
|
||||
|
||||
# sanity check - make sure the toolchain is available
|
||||
assert os.path.exists(fake_path), "Could not find toolchain at '{}'".format(fake_path)
|
||||
|
||||
# helper function to display exact commands used
|
||||
def run(cmd, *args, **kwargs):
|
||||
print("$ " + " ".join(cmd))
|
||||
subprocess.call(cmd, *args, **kwargs)
|
||||
|
||||
# execute the build system
|
||||
if(os.path.exists(os.path.join(project_dir, "CMakeLists.txt"))):
|
||||
# cmake
|
||||
# run cmake in a temporary directory, then compile the project as usual
|
||||
build_dir = tempfile.mkdtemp()
|
||||
proc_opts["cwd"] = build_dir
|
||||
|
||||
# if the project was built in-tree, we need to hide the cache file so that cmake
|
||||
# populates the build dir instead of just re-generating the existing files
|
||||
cache_path = os.path.join(project_dir, "CMakeCache.txt")
|
||||
|
||||
if(os.path.exists(cache_path)):
|
||||
fd, cache_tmp = tempfile.mkstemp()
|
||||
os.close(fd)
|
||||
shutil.move(cache_path, cache_tmp)
|
||||
else:
|
||||
cache_tmp = None
|
||||
|
||||
print("Running cmake in '{}'...".format(build_dir))
|
||||
run(["cmake", project_dir] + configure_opts, env=env_config, **proc_opts)
|
||||
|
||||
print("\nRunning make...")
|
||||
run(make_args, env=env, **proc_opts)
|
||||
|
||||
print("\nCleaning up...")
|
||||
print("")
|
||||
shutil.rmtree(build_dir)
|
||||
|
||||
if(cache_tmp):
|
||||
shutil.move(cache_tmp, cache_path)
|
||||
|
||||
elif(os.path.exists(os.path.join(project_dir, "configure"))):
|
||||
# autotools
|
||||
# perform build in-tree, since not all projects handle out-of-tree builds correctly
|
||||
|
||||
if(out_of_tree):
|
||||
build_dir = tempfile.mkdtemp()
|
||||
proc_opts["cwd"] = build_dir
|
||||
print("Configuring autotools in '{}'...".format(build_dir))
|
||||
else:
|
||||
print("Configuring autotools...")
|
||||
|
||||
run([os.path.join(project_dir, "configure")] + configure_opts, env=env_config, **proc_opts)
|
||||
|
||||
print("\nRunning make...")
|
||||
run(make_args, env=env, **proc_opts)
|
||||
|
||||
print("\nCleaning up...")
|
||||
|
||||
if(out_of_tree):
|
||||
print("")
|
||||
shutil.rmtree(build_dir)
|
||||
else:
|
||||
run([make_cmd, "maintainer-clean"], env=env, **proc_opts)
|
||||
|
||||
elif(pro_files):
|
||||
# qmake
|
||||
# make sure there is only one .pro file
|
||||
if len(pro_files) != 1:
|
||||
print("ERROR: Found {} .pro files (expected one): {}.".format(
|
||||
len(pro_files), ', '.join(pro_files)))
|
||||
sys.exit(1)
|
||||
|
||||
# run qmake in a temporary directory, then compile the project as usual
|
||||
build_dir = tempfile.mkdtemp()
|
||||
proc_opts["cwd"] = build_dir
|
||||
env_config["QT_SELECT"] = qt_version
|
||||
env_config["QMAKESPEC"] = "unsupported/linux-clang" if qt_version == "4" else "linux-clang"
|
||||
|
||||
print("Running qmake in '{}' with Qt {}...".format(build_dir, qt_version))
|
||||
run(["qmake"] + configure_opts + [pro_files[0]], env=env_config,
|
||||
**proc_opts)
|
||||
|
||||
print("\nRunning make...")
|
||||
run(make_args, env=env, **proc_opts)
|
||||
|
||||
print("\nCleaning up...")
|
||||
print("")
|
||||
shutil.rmtree(build_dir)
|
||||
|
||||
elif(any([os.path.exists(os.path.join(project_dir, x)) for x in ["GNUmakefile", "makefile", "Makefile"]])):
|
||||
# make
|
||||
# needs to be handled last, since other build systems can generate Makefiles
|
||||
print("Preparing build directory...")
|
||||
run([make_cmd, "clean"], env=env, **proc_opts)
|
||||
|
||||
print("\nRunning make...")
|
||||
run(make_args, env=env, **proc_opts)
|
||||
|
||||
else:
|
||||
print("ERROR: Unknown build system")
|
||||
sys.exit(2)
|
||||
|
||||
print("Build completed in {} sec".format(round(time.time() - started, 2)))
|
||||
print("")
|
||||
|
||||
|
||||
def parse_flags(build_log):
|
||||
'''Creates a list of compiler flags from the build log.
|
||||
|
||||
build_log: an iterator of lines
|
||||
Returns: (line_count, skip_count, flags)
|
||||
flags is a list, and the counts are integers
|
||||
'''
|
||||
|
||||
# Used to ignore entries which result in temporary files, or don't fully
|
||||
# compile the file
|
||||
temp_output = re.compile("(-x assembler)|(-o ([a-zA-Z0-9._].tmp))|(/dev/null)")
|
||||
skip_count = 0
|
||||
|
||||
# Flags we want:
|
||||
# -includes (-i, -I)
|
||||
# -defines (-D)
|
||||
# -warnings (-Werror), but no assembler, etc. flags (-Wa,-option)
|
||||
# -language (-std=gnu99) and standard library (-nostdlib)
|
||||
# -word size (-m64)
|
||||
flags_whitelist = ["-[iID].*", "-W[^,]*", "-std=[a-z0-9+]+", "-(no)?std(lib|inc)", "-m[0-9]+"]
|
||||
flags_whitelist = re.compile("|".join(map("^{}$".format, flags_whitelist)))
|
||||
flags = set()
|
||||
line_count = 0
|
||||
|
||||
# macro definitions should be handled separately, so we can resolve duplicates
|
||||
define_flags = dict()
|
||||
define_regex = re.compile("-D([a-zA-Z0-9_]+)=(.*)")
|
||||
|
||||
# Used to only bundle filenames with applicable arguments
|
||||
filename_flags = ["-o", "-I", "-isystem", "-include", "-imacros"]
|
||||
|
||||
# Process build log
|
||||
for line in build_log:
|
||||
if(temp_output.search(line)):
|
||||
skip_count += 1
|
||||
continue
|
||||
|
||||
line_count += 1
|
||||
words = split_flags(line)
|
||||
|
||||
for (i, word) in enumerate(words):
|
||||
if(word[0] != '-' or not flags_whitelist.match(word)):
|
||||
continue
|
||||
|
||||
# handle macro definitions
|
||||
m = define_regex.match(word)
|
||||
if(m):
|
||||
if(m.group(1) not in define_flags):
|
||||
define_flags[m.group(1)] = [m.group(2)]
|
||||
elif(m.group(2) not in define_flags[m.group(1)]):
|
||||
define_flags[m.group(1)].append(m.group(2))
|
||||
|
||||
continue
|
||||
|
||||
# include arguments for this option, if there are any, as a tuple
|
||||
if(i != len(words) - 1 and word in filename_flags and words[i + 1][0] != '-'):
|
||||
flags.add((word, words[i + 1]))
|
||||
else:
|
||||
flags.add(word)
|
||||
|
||||
# Only specify one word size (the largest)
|
||||
# (Different sizes are used for different files in the linux kernel.)
|
||||
mRegex = re.compile("^-m[0-9]+$")
|
||||
word_flags = list([f for f in flags if isinstance(f, basestring) and mRegex.match(f)])
|
||||
|
||||
if(len(word_flags) > 1):
|
||||
for flag in word_flags:
|
||||
flags.remove(flag)
|
||||
|
||||
flags.add(max(word_flags))
|
||||
|
||||
# Resolve duplicate macro definitions (always choose the last value for consistency)
|
||||
for name, values in define_flags.iteritems():
|
||||
if(len(values) > 1):
|
||||
print("WARNING: {} distinct definitions of macro {} found".format(len(values), name))
|
||||
values.sort()
|
||||
|
||||
flags.add("-D{}={}".format(name, values[0]))
|
||||
|
||||
return (line_count, skip_count, sorted(flags))
|
||||
|
||||
|
||||
def generate_cc_conf(flags, config_file):
|
||||
'''Generates the .color_coded file
|
||||
|
||||
flags: the list of flags
|
||||
config_file: the path to save the configuration file at'''
|
||||
|
||||
with open(config_file, "w") as output:
|
||||
for flag in flags:
|
||||
if(isinstance(flag, basestring)):
|
||||
output.write(flag + "\n")
|
||||
else: # is tuple
|
||||
for f in flag:
|
||||
output.write(f + "\n")
|
||||
|
||||
|
||||
def generate_ycm_conf(flags, config_file):
|
||||
'''Generates the .ycm_extra_conf.py.
|
||||
|
||||
flags: the list of flags
|
||||
config_file: the path to save the configuration file at'''
|
||||
|
||||
template_file = os.path.join(ycm_generator_dir, "template.py")
|
||||
|
||||
with open(template_file, "r") as template:
|
||||
with open(config_file, "w") as output:
|
||||
output.write("# Generated by YCM Generator at {}\n\n".format(str(datetime.datetime.today())))
|
||||
|
||||
for line in template:
|
||||
if(line == " # INSERT FLAGS HERE\n"):
|
||||
# insert generated code
|
||||
for flag in flags:
|
||||
if(isinstance(flag, basestring)):
|
||||
output.write(" '{}',\n".format(flag))
|
||||
else: # is tuple
|
||||
output.write(" '{}', '{}',\n".format(*flag))
|
||||
|
||||
else:
|
||||
# copy template
|
||||
output.write(line)
|
||||
|
||||
|
||||
def split_flags(line):
|
||||
'''Helper method that splits a string into flags.
|
||||
Flags are space-seperated, except for spaces enclosed in quotes.
|
||||
Returns a list of flags'''
|
||||
|
||||
# Pass 1: split line using whitespace
|
||||
words = line.strip().split()
|
||||
|
||||
# Pass 2: merge words so that the no. of quotes is balanced
|
||||
res = []
|
||||
|
||||
for w in words:
|
||||
if(len(res) > 0 and unbalanced_quotes(res[-1])):
|
||||
res[-1] += " " + w
|
||||
else:
|
||||
res.append(w)
|
||||
|
||||
return res
|
||||
|
||||
|
||||
def unbalanced_quotes(s):
|
||||
'''Helper method that returns True if the no. of single or double quotes in s is odd.'''
|
||||
|
||||
single = 0
|
||||
double = 0
|
||||
|
||||
for c in s:
|
||||
if(c == "'"):
|
||||
single += 1
|
||||
elif(c == '"'):
|
||||
double += 1
|
||||
|
||||
return (single % 2 == 1 or double % 2 == 1)
|
||||
|
||||
|
||||
if(__name__ == "__main__"):
|
||||
# Note that sys.exit() lets us use None and 0 interchangably
|
||||
sys.exit(main())
|
||||
|
1
scripts/fake-toolchain/Unix/ar
Symbolic link
1
scripts/fake-toolchain/Unix/ar
Symbolic link
|
@ -0,0 +1 @@
|
|||
true
|
1
scripts/fake-toolchain/Unix/as
Symbolic link
1
scripts/fake-toolchain/Unix/as
Symbolic link
|
@ -0,0 +1 @@
|
|||
true
|
14
scripts/fake-toolchain/Unix/cc
Executable file
14
scripts/fake-toolchain/Unix/cc
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then
|
||||
# Cmake determines compiler properties by compiling a test file, so call clang for this case
|
||||
$YCM_CONFIG_GEN_CC_PASSTHROUGH $@
|
||||
|
||||
elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
|
||||
# Needed to enable clang-specific options for certain build systems (e.g. linux)
|
||||
$YCM_CONFIG_GEN_CC_PASSTHROUGH $@
|
||||
|
||||
else
|
||||
echo "$@" >> $YCM_CONFIG_GEN_CC_LOG
|
||||
fi
|
||||
|
1
scripts/fake-toolchain/Unix/clang
Symbolic link
1
scripts/fake-toolchain/Unix/clang
Symbolic link
|
@ -0,0 +1 @@
|
|||
cc
|
1
scripts/fake-toolchain/Unix/clang++
Symbolic link
1
scripts/fake-toolchain/Unix/clang++
Symbolic link
|
@ -0,0 +1 @@
|
|||
cxx
|
14
scripts/fake-toolchain/Unix/cxx
Executable file
14
scripts/fake-toolchain/Unix/cxx
Executable file
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ ! -z "$YCM_CONFIG_GEN_CC_PASSTHROUGH" ]; then
|
||||
# Cmake determines compiler properties by compiling a test file, so call clang for this case
|
||||
$YCM_CONFIG_GEN_CXX_PASSTHROUGH $@
|
||||
|
||||
elif [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
|
||||
# Needed to enable clang-specific options for certain build systems (e.g. linux)
|
||||
$YCM_CONFIG_GEN_CC_PASSTHROUGH $@
|
||||
|
||||
else
|
||||
echo "$@" >> $YCM_CONFIG_GEN_CXX_LOG
|
||||
fi
|
||||
|
1
scripts/fake-toolchain/Unix/g++
Symbolic link
1
scripts/fake-toolchain/Unix/g++
Symbolic link
|
@ -0,0 +1 @@
|
|||
cxx
|
1
scripts/fake-toolchain/Unix/gcc
Symbolic link
1
scripts/fake-toolchain/Unix/gcc
Symbolic link
|
@ -0,0 +1 @@
|
|||
cc
|
1
scripts/fake-toolchain/Unix/gcc++
Symbolic link
1
scripts/fake-toolchain/Unix/gcc++
Symbolic link
|
@ -0,0 +1 @@
|
|||
cxx
|
1
scripts/fake-toolchain/Unix/ld
Symbolic link
1
scripts/fake-toolchain/Unix/ld
Symbolic link
|
@ -0,0 +1 @@
|
|||
true
|
1
scripts/fake-toolchain/Unix/nm
Symbolic link
1
scripts/fake-toolchain/Unix/nm
Symbolic link
|
@ -0,0 +1 @@
|
|||
true
|
4
scripts/fake-toolchain/Unix/true
Executable file
4
scripts/fake-toolchain/Unix/true
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/sh
|
||||
# This script is needed because /bin/true does not exist on non-FHS-compliant distros. e.g. NixOS
|
||||
exit 0
|
||||
|
|
@ -35,5 +35,4 @@ cat << EOF
|
|||
$f7 ▄█▄ $rst
|
||||
$f7▄█████████▄$rst
|
||||
$f7▀▀▀▀▀▀▀▀▀▀▀$rst
|
||||
|
||||
EOF
|
||||
|
|
134
scripts/template.py
Normal file
134
scripts/template.py
Normal file
|
@ -0,0 +1,134 @@
|
|||
# This file is NOT licensed under the GPLv3, which is the license for the rest
|
||||
# of YouCompleteMe.
|
||||
#
|
||||
# Here's the license text for this file:
|
||||
#
|
||||
# This is free and unencumbered software released into the public domain.
|
||||
#
|
||||
# Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
# distribute this software, either in source code form or as a compiled
|
||||
# binary, for any purpose, commercial or non-commercial, and by any
|
||||
# means.
|
||||
#
|
||||
# In jurisdictions that recognize copyright laws, the author or authors
|
||||
# of this software dedicate any and all copyright interest in the
|
||||
# software to the public domain. We make this dedication for the benefit
|
||||
# of the public at large and to the detriment of our heirs and
|
||||
# successors. We intend this dedication to be an overt act of
|
||||
# relinquishment in perpetuity of all present and future rights to this
|
||||
# software under copyright law.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# For more information, please refer to <http://unlicense.org/>
|
||||
|
||||
import os
|
||||
import ycm_core
|
||||
|
||||
flags = [
|
||||
# INSERT FLAGS HERE
|
||||
]
|
||||
|
||||
|
||||
# Set this to the absolute path to the folder (NOT the file!) containing the
|
||||
# compile_commands.json file to use that instead of 'flags'. See here for
|
||||
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
|
||||
#
|
||||
# You can get CMake to generate this file for you by adding:
|
||||
# set( CMAKE_EXPORT_COMPILE_COMMANDS 1 )
|
||||
# to your CMakeLists.txt file.
|
||||
#
|
||||
# Most projects will NOT need to set this to anything; you can just change the
|
||||
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
|
||||
compilation_database_folder = ''
|
||||
|
||||
if os.path.exists( compilation_database_folder ):
|
||||
database = ycm_core.CompilationDatabase( compilation_database_folder )
|
||||
else:
|
||||
database = None
|
||||
|
||||
SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
|
||||
|
||||
def DirectoryOfThisScript():
|
||||
return os.path.dirname( os.path.abspath( __file__ ) )
|
||||
|
||||
|
||||
def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
|
||||
if not working_directory:
|
||||
return list( flags )
|
||||
new_flags = []
|
||||
make_next_absolute = False
|
||||
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
|
||||
for flag in flags:
|
||||
new_flag = flag
|
||||
|
||||
if make_next_absolute:
|
||||
make_next_absolute = False
|
||||
if not flag.startswith( '/' ):
|
||||
new_flag = os.path.join( working_directory, flag )
|
||||
|
||||
for path_flag in path_flags:
|
||||
if flag == path_flag:
|
||||
make_next_absolute = True
|
||||
break
|
||||
|
||||
if flag.startswith( path_flag ):
|
||||
path = flag[ len( path_flag ): ]
|
||||
new_flag = path_flag + os.path.join( working_directory, path )
|
||||
break
|
||||
|
||||
if new_flag:
|
||||
new_flags.append( new_flag )
|
||||
return new_flags
|
||||
|
||||
|
||||
def IsHeaderFile( filename ):
|
||||
extension = os.path.splitext( filename )[ 1 ]
|
||||
return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
|
||||
|
||||
|
||||
def GetCompilationInfoForFile( filename ):
|
||||
# The compilation_commands.json file generated by CMake does not have entries
|
||||
# for header files. So we do our best by asking the db for flags for a
|
||||
# corresponding source file, if any. If one exists, the flags for that file
|
||||
# should be good enough.
|
||||
if IsHeaderFile( filename ):
|
||||
basename = os.path.splitext( filename )[ 0 ]
|
||||
for extension in SOURCE_EXTENSIONS:
|
||||
replacement_file = basename + extension
|
||||
if os.path.exists( replacement_file ):
|
||||
compilation_info = database.GetCompilationInfoForFile(
|
||||
replacement_file )
|
||||
if compilation_info.compiler_flags_:
|
||||
return compilation_info
|
||||
return None
|
||||
return database.GetCompilationInfoForFile( filename )
|
||||
|
||||
|
||||
def FlagsForFile( filename, **kwargs ):
|
||||
if database:
|
||||
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
|
||||
# python list, but a "list-like" StringVec object
|
||||
compilation_info = GetCompilationInfoForFile( filename )
|
||||
if not compilation_info:
|
||||
return None
|
||||
|
||||
final_flags = MakeRelativePathsInFlagsAbsolute(
|
||||
compilation_info.compiler_flags_,
|
||||
compilation_info.compiler_working_dir_ )
|
||||
|
||||
else:
|
||||
relative_to = DirectoryOfThisScript()
|
||||
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
|
||||
|
||||
return {
|
||||
'flags': final_flags,
|
||||
'do_cache': True
|
||||
}
|
||||
|
206
scripts/watchfile
Executable file
206
scripts/watchfile
Executable file
|
@ -0,0 +1,206 @@
|
|||
#!/bin/bash
|
||||
|
||||
version=1.0.1
|
||||
versionDate="2014-02-14"
|
||||
|
||||
function showHelp() {
|
||||
echo "watchfile - monitor file(s)/command and perform action when changed
|
||||
|
||||
Possible ways of usage
|
||||
----------------------------------------
|
||||
Monitor FILE, when modified execute FILE
|
||||
\$ watchfile [options] FILE
|
||||
|
||||
Monitor FILE, when modified execute CMND [PARAM_1 ..PARAM_N]
|
||||
\$ watchfile [options] FILE CMND [PARAM_1 .. PARAM_N]
|
||||
|
||||
Monitor FILE_1 .. FILE_N, when modified execute CMND [PARAM_1 ..PARAM_N]
|
||||
\$ watchfile [options] -i FILE_1 .. FILE_N -e CMND [PARAM_1 .. PARAM_N]
|
||||
|
||||
Monitor output of CMND1, when modified execute CMND2 [PARAM_1 .. PARAM_N]
|
||||
\$ watchfile [options] -s \"CMND1\" -e CMND [PARAM_1 .. PARAM_N]
|
||||
|
||||
|
||||
options:
|
||||
-h, --help Show help
|
||||
-d, --delay=N Specify the delay between each monitor update. Default 0.5.
|
||||
--check-content If set it checks file content, instead of just the timestamp.
|
||||
Has no effect with the -s flag set.
|
||||
--no-clear If set, it doesn't clear the screen before executing CMND.
|
||||
-v, --version Outputs version information
|
||||
|
||||
flags:
|
||||
-s, Next argument specifies monitor command. Requires -e flag.
|
||||
-i, Start listing files to monitor. Requires -e flag.
|
||||
-e, Start listing command to execute. Requires -s or -i or flag.
|
||||
Must be the last flag used (CMND can thus use flags as parameters)
|
||||
|
||||
Note: If CMND isn't found, and ./CMND is, it automatically uses this command.
|
||||
Note: If the command uses ampersands (&, &&), these must be escaped (\&, \&\&).
|
||||
|
||||
|
||||
Examples
|
||||
----------------------------------------
|
||||
Monitor executable foo.sh, and execute on change
|
||||
$ watchfile foo.sh
|
||||
|
||||
Monitor python file foo.py, and execute it on change
|
||||
$ watchfile foo.py python foo.py
|
||||
|
||||
As above, but monitor content (not just timestamp):
|
||||
$ watchfile --check-content foo.py python foo.py
|
||||
|
||||
Compiling main.cpp file on change:
|
||||
$ watchfile main.cpp g++ -Wall main.cpp -o main
|
||||
|
||||
Compiling main.cpp file on change, running when compilation succeedes:
|
||||
$ watchfile main.cpp g++ -Wall main.cpp -o main \&\& ./main
|
||||
|
||||
Compiling project whenever source files changes, and running if it succeedes:
|
||||
$ watchfile -s \"find . -name '*.cpp' -or -name '*.h' | xargs cat\" \\
|
||||
-e make \&\& ./main
|
||||
|
||||
See: http://swarminglogic.com/jotting/2014_02_watchfile for more examples
|
||||
|
||||
Mainted at: https://gist.github.com/swarminglogic/8963507
|
||||
Author: Roald Fernandez (github@swarminglogic.com)
|
||||
Version: $version ($versionDate)
|
||||
License: CC-zero (public domain)
|
||||
"
|
||||
exit $1
|
||||
}
|
||||
|
||||
function parseParameters() {
|
||||
tmp=$@
|
||||
leftovers=""
|
||||
while test $# -gt 0; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
showHelp 0
|
||||
;;
|
||||
--no-clear)
|
||||
shift
|
||||
flagNoClear=true
|
||||
;;
|
||||
--check-content)
|
||||
shift
|
||||
flagCheckContent=true
|
||||
;;
|
||||
-d)
|
||||
shift
|
||||
delay=$1
|
||||
shift
|
||||
;;
|
||||
--delay*)
|
||||
delay=`echo $1 | sed -e 's/^[^=]*=//g'`
|
||||
shift
|
||||
;;
|
||||
-v|--version)
|
||||
shift
|
||||
echo "watchfile $version"
|
||||
exit 0
|
||||
;;
|
||||
-s)
|
||||
shift
|
||||
flagS=true
|
||||
watchcmnd=$1
|
||||
shift
|
||||
;;
|
||||
-i)
|
||||
shift
|
||||
flagI=true
|
||||
nI=0
|
||||
for i in `seq 1 $#`; do
|
||||
if [[ ${!i} == -* ]] ; then
|
||||
break;
|
||||
else
|
||||
((++nI))
|
||||
fi
|
||||
done
|
||||
watchfiles=${@:1:$nI}
|
||||
shift $nI
|
||||
;;
|
||||
-e)
|
||||
shift
|
||||
flagE=true
|
||||
execcmnd=${@:1}
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
leftovers="$leftovers "$1
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
leftovers="$leftovers "$1
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
if [[ $flagE && (! $flagS) && (! $flagI) ]] ; then
|
||||
echo "Error: If -e flag is set, -s or -i flags are required."
|
||||
exit 1
|
||||
elif [[ ($flagS || $flagI) && ! $flagE ]] ; then
|
||||
echo "Error: If -s or -i flags are set, the -e flags is required."
|
||||
exit 1
|
||||
elif [[ $flagS && $flagI ]]; then
|
||||
echo "Error: Both -s and -i flags cannot be used simultaneously."
|
||||
exit 1
|
||||
elif [[ (! $flagE) && (! $flagS) && (! $flagI) ]] ; then
|
||||
set -- $leftovers
|
||||
watchfiles=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
execcmnd=${@:2}
|
||||
else
|
||||
execcmnd=$watchfiles
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Exit with help if no parameters
|
||||
if [[ ! $@ ]] ; then showHelp 1; fi
|
||||
|
||||
# Defaults
|
||||
delay=0.5
|
||||
|
||||
# Parse parameters into $watch and $execcmnd variables
|
||||
parseParameters "$@"
|
||||
|
||||
# Sanitize executable
|
||||
set -- $execcmnd
|
||||
if [[ ! `which $1` ]] && [[ -x ./$1 ]] ; then
|
||||
execcmnd=./$execcmnd
|
||||
elif [[ ! `which $1` ]] && [[ ! -x ./$1 ]] ; then
|
||||
echo "Error: No executable $1 or ./$1 found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Main monitoring loop.
|
||||
if [[ -z $watchcmnd ]] ; then
|
||||
if [[ ! $flagCheckContent ]] ; then
|
||||
watchcmnd="stat -c %Y $watchfiles | md5sum"
|
||||
else
|
||||
watchcmnd="cat $watchfiles | md5sum"
|
||||
fi
|
||||
else
|
||||
watchcmnd="$watchcmnd | md5sum"
|
||||
fi
|
||||
|
||||
md5sum=`eval $watchcmnd`
|
||||
md5sumNow=$md5sum
|
||||
while [[ true ]]
|
||||
do
|
||||
# Loop until some files have changed
|
||||
while [[ "$md5sumNow" = "$md5sum" ]]
|
||||
do
|
||||
sleep $delay
|
||||
md5sumNow=`eval $watchcmnd`
|
||||
done
|
||||
|
||||
# Execute the file, as it has changed.
|
||||
if [[ ! $flagNoClear ]] ; then
|
||||
clear
|
||||
fi
|
||||
eval $execcmnd
|
||||
|
||||
md5sum=$md5sumNow
|
||||
done
|
|
@ -35,7 +35,6 @@ set -g status-right-attr "none"
|
|||
set -g message-fg "colour246"
|
||||
set -g message-command-bg "colour239"
|
||||
set -g status-attr "none"
|
||||
set -g status-utf8 "on"
|
||||
set -g pane-border-fg "colour239"
|
||||
set -g status-left-attr "none"
|
||||
setw -g window-status-fg "colour246"
|
||||
|
|
|
@ -7,11 +7,11 @@ setopt correct
|
|||
source $ZSH/oh-my-zsh.sh
|
||||
|
||||
#setting environment variables
|
||||
export EDITOR=vim
|
||||
export EDITOR=nvim
|
||||
export ABSROOT=$HOME/Projects/abs
|
||||
export PATH="/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
export PATH="$HOME/.local/bin/scripts:$PATH"
|
||||
export PATH="$HOME/.local/bin/scripts:$PATH:/usr/bin/core_perl"
|
||||
export TERM="screen-256color"
|
||||
export SAL_USE_VCLPLUGIN="gtk"
|
||||
export GOPATH="$HOME/.local/go"
|
||||
|
@ -22,7 +22,7 @@ alias cl="clear"
|
|||
alias vim="nvim"
|
||||
alias tmux="tmux -2"
|
||||
alias attach="tmux a"
|
||||
alias wcp="wc -l src/**/*.cpp include/**/*.h"
|
||||
alias wcp="wc -l **/src/**/*.cpp **/include/**/*.h"
|
||||
|
||||
#start tmux
|
||||
if [ -z "$TMUX" ]; then tmux; exit; fi
|
||||
|
|
Loading…
Reference in New Issue
Block a user