diff --git a/doc/binary_c2.lyx b/doc/binary_c2.lyx index ebf54e58877ce6290f9ec91458755b7f194ff064..b8dd8dc163c1ca3f31af7502c6a0b50e45f864dd 100644 --- a/doc/binary_c2.lyx +++ b/doc/binary_c2.lyx @@ -4678,18 +4678,8 @@ Meson \end_inset +. -\begin_inset Flex URL -status open - -\begin_layout Plain Layout - -https://github.com/ninja-build/ninja/blob/master/misc/bash-completion -\end_layout - -\end_inset - - \end_layout \end_inset @@ -4718,12 +4708,46 @@ and now you should go to that directory to build the code using status open \begin_layout Plain Layout -ninja, +ninja \end_layout +\end_inset + + (see section +\begin_inset space ~ \end_inset +\begin_inset CommandInset ref +LatexCommand ref +reference "subsec:Ninja-autocompletion" +plural "false" +caps "false" +noprefix "false" + +\end_inset + + for +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +ninja +\end_layout + +\end_inset + +- +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +bash +\end_layout + +\end_inset + + autocompletion instructions). \end_layout \begin_layout Standard @@ -4756,11 +4780,10 @@ The code will now build, assuming everything worked ok. not \emph default work then please try to fix it (using, e.g. - -\emph on -Google -\emph default -) before running to me with complaints. +\begin_inset space ~ +\end_inset + + your favourite search engine) before running to me with complaints. It works fine on \begin_inset Flex OS status open @@ -20005,6 +20028,99 @@ git_url () \end_layout +\begin_layout Subsection +Ninja autocompletion +\end_layout + +\begin_layout Standard +\begin_inset CommandInset label +LatexCommand label +name "subsec:Ninja-autocompletion" + +\end_inset + +Copy the file +\begin_inset Flex File +status open + +\begin_layout Plain Layout +meson/bash_ninja_autocomplete.sh +\end_layout + +\end_inset + + (in the +\begin_inset Formula $\binaryc$ +\end_inset + + root directory) to wherever you keep your +\begin_inset Flex Software +status open + +\begin_layout Plain Layout +bash +\end_layout + +\end_inset + + autocompletion scripts. + Make it executable with +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +chmod +x bash_ninja_autocomplete.sh +\end_layout + +\end_inset + + and add the following to your +\begin_inset Flex File +status open + +\begin_layout Plain Layout +.bashrc +\end_layout + +\end_inset + + file: +\begin_inset listings +inline false +status open + +\begin_layout Plain Layout + +# autocomplete for ninja source +\end_layout + +\begin_layout Plain Layout + +<path to file>/bash_ninja_autocomplete.sh +\end_layout + +\end_inset + + +\end_layout + +\begin_layout Standard +The autocompletion script is based on an original from +\begin_inset Flex URL +status open + +\begin_layout Plain Layout + +https://github.com/ninja-build/ninja/blob/master/misc/bash-completion +\end_layout + +\end_inset + +, distributed under an Apache 2.0 licence. +\end_layout + \begin_layout Section Changelog \end_layout diff --git a/meson.build b/meson.build index 6a2c9d6329605b7058cba8133e33760b8dbcb6c2..8964106084c6e990c379d366c2bbb7c88141da6a 100644 --- a/meson.build +++ b/meson.build @@ -24,12 +24,12 @@ # ############################################################ # -# A typical clean build with gcc and "time make" gives -# 95.23user 21.08system 0:34.64elapsed 335%CPU (0avgtext+0avgdata 425420maxresident)k +# A typical clean build with gcc and "time make" (without ccache) gives # -# While with ninja (no ccache) we get -# 54.94user 17.08system 0:20.95elapsed 343%CPU (0avgtext+0avgdata 327256maxresident)k +# 82.20user 19.66system 0:30.18elapsed 337%CPU (0avgtext+0avgdata 330368maxresident)k # +# While with ninja (no ccache) we get +# 55.83user 15.86system 0:20.14elapsed 355%CPU (0avgtext+0avgdata 327448maxresident)k ############################################################ # define the binary_c project project( @@ -51,7 +51,7 @@ cpufreq = run_command('meson/cpu_frequency.sh').stdout().strip() homedir = run_command('sh','-c','echo $HOME').stdout().strip() ############################################################ -# get binary_c root location +# get binary_c root and src locations binary_c = meson.source_root() binary_c_src = meson.source_root() + '/src' @@ -71,22 +71,49 @@ absolute_incdirs = [ binary_c, binary_c_src ] absolute_libdirs = [ ] ############################################################ -# determine whether we're a debug or generic build -have_gnu99 = compiler.has_argument('-std=gnu99') -have_avx = compiler.has_argument('-mavx') +# default C flags +# +cflags = [ + '-DALIGNSIZE=16' +] ############################################################ -# default C flags +# cflags required for generic builds and other builds # -cflags = ['-DALIGNSIZE=16'] +_other_cflags = [ + '-std=gnu99', # required for PCH (and cannot hurt if specified twice) +] + +foreach cflag : _other_cflags + if compiler.has_argument(cflag) + cflags += [ cflag ] + endif +endforeach -if have_gnu99 - cflags += [ '-std=gnu99' ] -endif -if have_avx and get_option('generic') == false - cflags += [ '-mavx' ] -endif +############################################################ +# C flags that are non-generic, i.e. machine-specific. +# +if get_option('generic') == false + _non_generic_cflags = [ + 'mmx', + 'sse', + 'sse2', + 'sse3', + 'ssse3', + 'sse4.1', + 'sse4.2', + 'sse4', + 'avx', + 'avx2', + ] + foreach cflag : _non_generic_cflags + __cflag = '-m' + cflag + if compiler.has_argument( __cflag ) + cflags += [ __cflag ] + endif + endforeach +endif ############################################################ # optional C flags diff --git a/meson/bash_ninja_autocomplete.sh b/meson/bash_ninja_autocomplete.sh new file mode 100755 index 0000000000000000000000000000000000000000..2466bd1b12443480a3a01b1d18ca32001858c5f4 --- /dev/null +++ b/meson/bash_ninja_autocomplete.sh @@ -0,0 +1,64 @@ +# Copyright 2011 Google Inc. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Add the following to your .bashrc to tab-complete ninja targets +# . path/to/ninja/misc/bash-completion + +_ninja_target() { + local cur prev targets dir line targets_command OPTIND + + # When available, use bash_completion to: + # 1) Complete words when the cursor is in the middle of the word + # 2) Complete paths with files or directories, as appropriate + if _get_comp_words_by_ref cur prev &>/dev/null ; then + case $prev in + -f) + _filedir + return 0 + ;; + -C) + _filedir -d + return 0 + ;; + esac + else + cur="${COMP_WORDS[COMP_CWORD]}" + fi + + if [[ "$cur" == "--"* ]]; then + # there is currently only one argument that takes -- + COMPREPLY=($(compgen -P '--' -W 'version' -- "${cur:2}")) + else + dir="." + line=$(echo ${COMP_LINE} | cut -d" " -f 2-) + # filter out all non relevant arguments but keep C for dirs + while getopts :C:f:j:l:k:nvd:t: opt $line; do + case $opt in + # eval for tilde expansion + C) eval dir="$OPTARG" ;; + esac + done; + + #orignal + #targets_command="eval ninja -C \"${dir}\" -t targets all 2>/dev/null | cut -d: -f1" + + # RGI autocomplete list : bit of trial and error here! + targets_command="eval ninja -C \"${dir}\" -t targets all |grep '\(LINKER\|COMMAND\|SHSYM\)'| cut -d: -f1" + #echo "Targets: $targets_command" + COMPREPLY=($(compgen -W '`${targets_command}`' -- "$cur")) + #echo "COMPREPLY $COMPREPLY" + fi + return +} +complete -F _ninja_target ninja