From a767f2fd6c5a6104ff32a35a27f0c15aec546957 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 19 Mar 2026 06:33:24 +0100 Subject: builds: move build scripts into "tools/" We have a bunch of scripts used by our different build systems that are all located in the top-level directory. Now that we have introduced the new "tools/" directory though we have a better home for them. Move the scripts into the "tools/" directory. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- Makefile | 34 +++++----- check-builtins.sh | 34 ---------- config.mak.dev | 2 +- contrib/buildsystems/CMakeLists.txt | 18 +++--- contrib/subtree/meson.build | 2 +- detect-compiler | 58 ----------------- generate-cmdlist.sh | 120 ------------------------------------ generate-configlist.sh | 52 ---------------- generate-hooklist.sh | 33 ---------- generate-perl.sh | 37 ----------- generate-python.sh | 20 ------ generate-script.sh | 34 ---------- meson.build | 14 ++--- tools/check-builtins.sh | 34 ++++++++++ tools/detect-compiler | 58 +++++++++++++++++ tools/generate-cmdlist.sh | 120 ++++++++++++++++++++++++++++++++++++ tools/generate-configlist.sh | 52 ++++++++++++++++ tools/generate-hooklist.sh | 33 ++++++++++ tools/generate-perl.sh | 37 +++++++++++ tools/generate-python.sh | 20 ++++++ tools/generate-script.sh | 34 ++++++++++ 21 files changed, 423 insertions(+), 423 deletions(-) delete mode 100755 check-builtins.sh delete mode 100755 detect-compiler delete mode 100755 generate-cmdlist.sh delete mode 100755 generate-configlist.sh delete mode 100755 generate-hooklist.sh delete mode 100755 generate-perl.sh delete mode 100755 generate-python.sh delete mode 100755 generate-script.sh create mode 100755 tools/check-builtins.sh create mode 100755 tools/detect-compiler create mode 100755 tools/generate-cmdlist.sh create mode 100755 tools/generate-configlist.sh create mode 100755 tools/generate-hooklist.sh create mode 100755 tools/generate-perl.sh create mode 100755 tools/generate-python.sh create mode 100755 tools/generate-script.sh diff --git a/Makefile b/Makefile index 8564b1be36..322f5940e3 100644 --- a/Makefile +++ b/Makefile @@ -2689,21 +2689,21 @@ $(BUILT_INS): git$X ln -s $< $@ 2>/dev/null || \ cp $< $@ -config-list.h: generate-configlist.sh +config-list.h: tools/generate-configlist.sh @mkdir -p .depend - $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@ .depend/config-list.h.d + $(QUIET_GEN)$(SHELL_PATH) ./tools/generate-configlist.sh . $@ .depend/config-list.h.d -include .depend/config-list.h.d -command-list.h: generate-cmdlist.sh command-list.txt +command-list.h: tools/generate-cmdlist.sh command-list.txt command-list.h: $(wildcard Documentation/git*.adoc) - $(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \ + $(QUIET_GEN)$(SHELL_PATH) ./tools/generate-cmdlist.sh \ $(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \ . $@ -hook-list.h: generate-hooklist.sh Documentation/githooks.adoc - $(QUIET_GEN)$(SHELL_PATH) ./generate-hooklist.sh . $@ +hook-list.h: tools/generate-hooklist.sh Documentation/githooks.adoc + $(QUIET_GEN)$(SHELL_PATH) ./tools/generate-hooklist.sh . $@ SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):\ $(localedir_SQ):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\ @@ -2716,8 +2716,8 @@ GIT-SCRIPT-DEFINES: FORCE echo "$$FLAGS" >$@; \ fi -$(SCRIPT_SH_GEN) $(SCRIPT_LIB) : % : %.sh generate-script.sh GIT-BUILD-OPTIONS GIT-SCRIPT-DEFINES - $(QUIET_GEN)./generate-script.sh "$<" "$@+" ./GIT-BUILD-OPTIONS && \ +$(SCRIPT_SH_GEN) $(SCRIPT_LIB) : % : %.sh tools/generate-script.sh GIT-BUILD-OPTIONS GIT-SCRIPT-DEFINES + $(QUIET_GEN)./tools/generate-script.sh "$<" "$@+" ./GIT-BUILD-OPTIONS && \ mv $@+ $@ git.rc: git.rc.in GIT-VERSION-GEN GIT-VERSION-FILE @@ -2757,8 +2757,8 @@ endif PERL_DEFINES += $(gitexecdir) $(perllibdir) $(localedir) -$(SCRIPT_PERL_GEN): % : %.perl generate-perl.sh GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE - $(QUIET_GEN)$(SHELL_PATH) generate-perl.sh ./GIT-BUILD-OPTIONS ./GIT-VERSION-FILE GIT-PERL-HEADER "$<" "$@+" && \ +$(SCRIPT_PERL_GEN): % : %.perl tools/generate-perl.sh GIT-PERL-DEFINES GIT-PERL-HEADER GIT-VERSION-FILE + $(QUIET_GEN)$(SHELL_PATH) tools/generate-perl.sh ./GIT-BUILD-OPTIONS ./GIT-VERSION-FILE GIT-PERL-HEADER "$<" "$@+" && \ mv $@+ $@ PERL_DEFINES := $(subst $(space),:,$(PERL_DEFINES)) @@ -2786,8 +2786,8 @@ GIT-PERL-HEADER: $(PERL_HEADER_TEMPLATE) GIT-PERL-DEFINES Makefile perllibdir: @echo '$(perllibdir_SQ)' -git-instaweb: git-instaweb.sh generate-script.sh GIT-BUILD-OPTIONS GIT-SCRIPT-DEFINES - $(QUIET_GEN)./generate-script.sh "$<" "$@+" ./GIT-BUILD-OPTIONS && \ +git-instaweb: git-instaweb.sh tools/generate-script.sh GIT-BUILD-OPTIONS GIT-SCRIPT-DEFINES + $(QUIET_GEN)./tools/generate-script.sh "$<" "$@+" ./GIT-BUILD-OPTIONS && \ chmod +x $@+ && \ mv $@+ $@ else # NO_PERL @@ -2804,9 +2804,9 @@ endif # NO_PERL $(SCRIPT_PYTHON_GEN): GIT-BUILD-OPTIONS ifndef NO_PYTHON -$(SCRIPT_PYTHON_GEN): generate-python.sh +$(SCRIPT_PYTHON_GEN): tools/generate-python.sh $(SCRIPT_PYTHON_GEN): % : %.py - $(QUIET_GEN)$(SHELL_PATH) generate-python.sh ./GIT-BUILD-OPTIONS "$<" "$@" + $(QUIET_GEN)$(SHELL_PATH) tools/generate-python.sh ./GIT-BUILD-OPTIONS "$<" "$@" else # NO_PYTHON $(SCRIPT_PYTHON_GEN): % : unimplemented.sh $(QUIET_GEN) \ @@ -3226,9 +3226,9 @@ endif NO_PERL_CPAN_FALLBACKS_SQ = $(subst ','\'',$(NO_PERL_CPAN_FALLBACKS)) endif -perl/build/lib/%.pm: perl/%.pm generate-perl.sh GIT-BUILD-OPTIONS GIT-VERSION-FILE GIT-PERL-DEFINES +perl/build/lib/%.pm: perl/%.pm tools/generate-perl.sh GIT-BUILD-OPTIONS GIT-VERSION-FILE GIT-PERL-DEFINES $(call mkdir_p_parent_template) - $(QUIET_GEN)$(SHELL_PATH) generate-perl.sh ./GIT-BUILD-OPTIONS ./GIT-VERSION-FILE GIT-PERL-HEADER "$<" "$@" + $(QUIET_GEN)$(SHELL_PATH) tools/generate-perl.sh ./GIT-BUILD-OPTIONS ./GIT-VERSION-FILE GIT-PERL-HEADER "$<" "$@" perl/build/man/man3/Git.3pm: perl/Git.pm $(call mkdir_p_parent_template) @@ -3936,7 +3936,7 @@ check-docs:: ### Make sure built-ins do not have dups and listed in git.c # check-builtins:: - ./check-builtins.sh + ./tools/check-builtins.sh ### Test suite coverage testing # diff --git a/check-builtins.sh b/check-builtins.sh deleted file mode 100755 index a0aaf3a347..0000000000 --- a/check-builtins.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -{ - cat <<\EOF -sayIt: - $(foreach b,$(BUILT_INS),echo XXX $(b:$X=) YYY;) -EOF - cat Makefile -} | -make -f - sayIt 2>/dev/null | -sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p' | -sort | -{ - bad=0 - while read builtin - do - base=$(expr "$builtin" : 'git-\(.*\)') - x=$(sed -ne 's/.*{ "'$base'", \(cmd_[^, ]*\).*/'$base' \1/p' git.c) - if test -z "$x" - then - echo "$base is builtin but not listed in git.c command list" - bad=1 - fi - for sfx in sh perl py - do - if test -f "$builtin.$sfx" - then - echo "$base is builtin but $builtin.$sfx still exists" - bad=1 - fi - done - done - exit $bad -} diff --git a/config.mak.dev b/config.mak.dev index e86b6e1b34..c8dcf78779 100644 --- a/config.mak.dev +++ b/config.mak.dev @@ -1,5 +1,5 @@ ifndef COMPILER_FEATURES -COMPILER_FEATURES := $(shell ./detect-compiler $(CC)) +COMPILER_FEATURES := $(shell ./tools/detect-compiler $(CC)) endif ifeq ($(filter no-error,$(DEVOPTS)),) diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt index c6cfb874ef..81b4306e72 100644 --- a/contrib/buildsystems/CMakeLists.txt +++ b/contrib/buildsystems/CMakeLists.txt @@ -636,7 +636,7 @@ set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" F if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS) list(REMOVE_ITEM EXCLUSION_PROGS empty) message("Generating command-list.h") - execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-cmdlist.sh" + execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/tools/generate-cmdlist.sh" ${EXCLUSION_PROGS} "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/command-list.h") @@ -644,14 +644,14 @@ endif() if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h) message("Generating config-list.h") - execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-configlist.sh" + execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/tools/generate-configlist.sh" "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/config-list.h") endif() if(NOT EXISTS ${CMAKE_BINARY_DIR}/hook-list.h) message("Generating hook-list.h") - execute_process(COMMAND "${SH_EXE}" ${CMAKE_SOURCE_DIR}/generate-hooklist.sh + execute_process(COMMAND "${SH_EXE}" ${CMAKE_SOURCE_DIR}/tools/generate-hooklist.sh "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/hook-list.h") endif() @@ -832,11 +832,11 @@ foreach(script ${git_shell_scripts}) endif() add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${shell_gen_path}" - COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-script.sh" + COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/tools/generate-script.sh" "${CMAKE_SOURCE_DIR}/${script}.sh" "${CMAKE_BINARY_DIR}/${shell_gen_path}" "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS" - DEPENDS "${CMAKE_SOURCE_DIR}/generate-script.sh" + DEPENDS "${CMAKE_SOURCE_DIR}/tools/generate-script.sh" "${CMAKE_SOURCE_DIR}/${script}.sh" VERBATIM) list(APPEND shell_gen ${CMAKE_BINARY_DIR}/${shell_gen_path}) @@ -875,13 +875,13 @@ foreach(script ${git_perl_scripts} ${perl_modules}) file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/${perl_gen_dir}") add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/${perl_gen_path}" - COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-perl.sh" + COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/tools/generate-perl.sh" "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS" "${CMAKE_BINARY_DIR}/GIT-VERSION-FILE" "${CMAKE_BINARY_DIR}/GIT-PERL-HEADER" "${CMAKE_SOURCE_DIR}/${script}" "${CMAKE_BINARY_DIR}/${perl_gen_path}" - DEPENDS "${CMAKE_SOURCE_DIR}/generate-perl.sh" + DEPENDS "${CMAKE_SOURCE_DIR}/tools/generate-perl.sh" "${CMAKE_SOURCE_DIR}/${script}" "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS" "${CMAKE_BINARY_DIR}/GIT-VERSION-FILE" @@ -892,11 +892,11 @@ add_custom_target(perl-gen ALL DEPENDS ${perl_gen}) # Python script add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/git-p4" - COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-python.sh" + COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/tools/generate-python.sh" "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS" "${CMAKE_SOURCE_DIR}/git-p4.py" "${CMAKE_BINARY_DIR}/git-p4" - DEPENDS "${CMAKE_SOURCE_DIR}/generate-python.sh" + DEPENDS "${CMAKE_SOURCE_DIR}/tools/generate-python.sh" "${CMAKE_SOURCE_DIR}/git-p4.py" "${CMAKE_BINARY_DIR}/GIT-BUILD-OPTIONS" VERBATIM) diff --git a/contrib/subtree/meson.build b/contrib/subtree/meson.build index 161435abeb..804c315894 100644 --- a/contrib/subtree/meson.build +++ b/contrib/subtree/meson.build @@ -3,7 +3,7 @@ git_subtree = custom_target( output: 'git-subtree', command: [ shell, - meson.project_source_root() / 'generate-script.sh', + meson.project_source_root() / 'tools/generate-script.sh', '@INPUT@', '@OUTPUT@', meson.project_build_root() / 'GIT-BUILD-OPTIONS', diff --git a/detect-compiler b/detect-compiler deleted file mode 100755 index 124ebdd4c9..0000000000 --- a/detect-compiler +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -# -# Probe the compiler for vintage, version, etc. This is used for setting -# optional make knobs under the DEVELOPER knob. - -CC="$*" - -# we get something like (this is at least true for gcc and clang) -# -# FreeBSD clang version 3.4.1 (tags/RELEASE...) -get_version_line() { - LANG=C LC_ALL=C $CC -v 2>&1 | sed -n '/ version /{p;q;}' -} - -get_family() { - get_version_line | sed 's/^\(.*\) version [0-9].*/\1/' -} - -get_version() { - # A string that begins with a digit up to the next SP - ver=$(get_version_line | sed 's/^.* version \([0-9][^ ]*\).*/\1/') - - # There are known -variant suffixes that do not affect the - # meaning of the main version number. Strip them. - ver=${ver%-win32} - ver=${ver%-posix} - - echo "$ver" -} - -print_flags() { - family=$1 - version=$(get_version | cut -f 1 -d .) - - # Print a feature flag not only for the current version, but also - # for any prior versions we encompass. This avoids needing to do - # numeric comparisons in make, which are awkward. - while test "$version" -gt 0 - do - echo $family$version - version=$((version - 1)) - done -} - -case "$(get_family)" in -gcc) - print_flags gcc - ;; -clang | *" clang") - print_flags clang - ;; -"Apple LLVM") - print_flags clang - ;; -*) - : unknown compiler family - ;; -esac diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh deleted file mode 100755 index 0ed39c4c5d..0000000000 --- a/generate-cmdlist.sh +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh - -die () { - echo "$@" >&2 - exit 1 -} - -command_list () { - while read cmd rest - do - case "$cmd" in - "#"* | '') - # Ignore comments and allow empty lines - continue - ;; - *) - case "$exclude_programs" in - *":$cmd:"*) - ;; - *) - echo "$cmd $rest" - ;; - esac - esac - done <"$1" -} - -category_list () { - echo "$1" | - cut -d' ' -f2- | - tr ' ' '\012' | - grep -v '^$' | - LC_ALL=C sort -u -} - -define_categories () { - echo - echo "/* Command categories */" - bit=0 - echo "$1" | - while read cat - do - echo "#define CAT_$cat (1UL << $bit)" - bit=$(($bit+1)) - done - test "$bit" -gt 32 && die "Urgh.. too many categories?" -} - -define_category_names () { - echo - echo "/* Category names */" - echo "static const char *category_names[] = {" - bit=0 - echo "$1" | - while read cat - do - echo " \"$cat\", /* (1UL << $bit) */" - bit=$(($bit+1)) - done - echo " NULL" - echo "};" -} - -print_command_list () { - echo "static struct cmdname_help command_list[] = {" - - echo "$2" | - while read cmd rest - do - synopsis= - while read line - do - case "$line" in - "$cmd - "*) - synopsis=${line#$cmd - } - break - ;; - esac - done <"$1/Documentation/$cmd.adoc" - - printf '\t{ "%s", N_("%s"), 0' "$cmd" "$synopsis" - printf " | CAT_%s" $rest - echo " }," - done - echo "};" -} - -exclude_programs=: -while test "--exclude-program" = "$1" -do - shift - exclude_programs="$exclude_programs$1:" - shift -done - -if test "$#" -ne 2 -then - die "USAGE: $0 " -fi - -SOURCE_DIR="$1" -OUTPUT="$2" - -{ - commands="$(command_list "$SOURCE_DIR"/command-list.txt)" - categories="$(category_list "$commands")" - - echo "/* Automatically generated by generate-cmdlist.sh */ - struct cmdname_help { - const char *name; - const char *help; - uint32_t category; - }; - " - define_categories "$categories" - echo - define_category_names "$categories" - echo - print_command_list "$SOURCE_DIR" "$commands" -} >"$OUTPUT" diff --git a/generate-configlist.sh b/generate-configlist.sh deleted file mode 100755 index e28054f9e0..0000000000 --- a/generate-configlist.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh - -SOURCE_DIR="$1" -OUTPUT="$2" -DEPFILE="$3" - -if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" -then - echo >&2 "USAGE: $0 []" - exit 1 -fi - -print_config_list () { - cat <"$OUTPUT" - -if test -n "$DEPFILE" -then - QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" - { - printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ - "$SOURCE_DIR"/Documentation/config/*.adoc | - sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" - printf '%s:\n' "$SOURCE_DIR"/Documentation/*config.adoc \ - "$SOURCE_DIR"/Documentation/config/*.adoc | - sed -e 's/[# ]/\\&/g' - } >"$DEPFILE" -fi diff --git a/generate-hooklist.sh b/generate-hooklist.sh deleted file mode 100755 index e0cdf26944..0000000000 --- a/generate-hooklist.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# Usage: ./generate-hooklist.sh >hook-list.h - -SOURCE_DIR="$1" -OUTPUT="$2" - -if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" -then - echo >&2 "USAGE: $0 " - exit 1 -fi - -{ - -cat <"$OUTPUT" diff --git a/generate-perl.sh b/generate-perl.sh deleted file mode 100755 index 796d835932..0000000000 --- a/generate-perl.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -set -e - -if test $# -ne 5 -then - echo >&2 "USAGE: $0 " - exit 1 -fi - -GIT_BUILD_OPTIONS="$1" -GIT_VERSION_FILE="$2" -PERL_HEADER="$3" -INPUT="$4" -OUTPUT="$5" - -. "$GIT_BUILD_OPTIONS" -. "$GIT_VERSION_FILE" - -sed -e '1{' \ - -e " /^#!.*perl/!b" \ - -e " s|#!.*perl|#!$PERL_PATH|" \ - -e " r $PERL_HEADER" \ - -e ' G' \ - -e '}' \ - -e "s|@GIT_VERSION@|$GIT_VERSION|g" \ - -e "s|@LOCALEDIR@|$PERL_LOCALEDIR|g" \ - -e "s|@NO_GETTEXT@|$NO_GETTEXT|g" \ - -e "s|@NO_PERL_CPAN_FALLBACKS@|$NO_PERL_CPAN_FALLBACKS|g" \ - "$INPUT" >"$OUTPUT" - -case "$INPUT" in -*.perl|*git-contacts) - chmod a+x "$OUTPUT";; -*) - ;; -esac diff --git a/generate-python.sh b/generate-python.sh deleted file mode 100755 index 31ac115689..0000000000 --- a/generate-python.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -set -e - -if test $# -ne 3 -then - echo >&2 "USAGE: $0 " - exit 1 -fi - -GIT_BUILD_OPTIONS="$1" -INPUT="$2" -OUTPUT="$3" - -. "$GIT_BUILD_OPTIONS" - -sed -e "1s|#!.*python|#!$PYTHON_PATH|" \ - "$INPUT" >"$OUTPUT+" -chmod a+x "$OUTPUT+" -mv "$OUTPUT+" "$OUTPUT" diff --git a/generate-script.sh b/generate-script.sh deleted file mode 100755 index a149e4f0ba..0000000000 --- a/generate-script.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh - -set -e - -if test $# -ne 3 -then - echo >&2 "USAGE: $0 " - exit 1 -fi - -INPUT="$1" -OUTPUT="$2" -BUILD_OPTIONS="$3" - -. "$BUILD_OPTIONS" - -sed -e "1s|#!.*/sh|#!$SHELL_PATH|" \ - -e "s|@SHELL_PATH@|$SHELL_PATH|" \ - -e "s|@DIFF@|$DIFF|" \ - -e "s|@LOCALEDIR@|$LOCALEDIR|g" \ - -e "s/@USE_GETTEXT_SCHEME@/$USE_GETTEXT_SCHEME/g" \ - -e "$BROKEN_PATH_FIX" \ - -e "s|@GITWEBDIR@|$GITWEBDIR|g" \ - -e "s|@PERL_PATH@|$PERL_PATH|g" \ - -e "s|@PAGER_ENV@|$PAGER_ENV|g" \ - "$INPUT" >"$OUTPUT" - -case "$(basename "$INPUT")" in -git-mergetool--lib.sh|git-sh-i18n.sh|git-sh-setup.sh) - ;; -*) - chmod a+x "$OUTPUT" - ;; -esac diff --git a/meson.build b/meson.build index 1d66b5181e..604fe89d2d 100644 --- a/meson.build +++ b/meson.build @@ -554,7 +554,7 @@ libgit_sources = [ libgit_sources += custom_target( input: 'command-list.txt', output: 'command-list.h', - command: [shell, meson.current_source_dir() + '/generate-cmdlist.sh', meson.current_source_dir(), '@OUTPUT@'], + command: [shell, meson.current_source_dir() + '/tools/generate-cmdlist.sh', meson.current_source_dir(), '@OUTPUT@'], env: script_environment, ) @@ -723,10 +723,10 @@ endif builtin_sources += custom_target( output: 'config-list.h', depfile: 'config-list.h.d', - depend_files: [ 'generate-configlist.sh' ], + depend_files: [ 'tools/generate-configlist.sh' ], command: [ shell, - meson.current_source_dir() / 'generate-configlist.sh', + meson.current_source_dir() / 'tools/generate-configlist.sh', meson.current_source_dir(), '@OUTPUT@', '@DEPFILE@', @@ -739,7 +739,7 @@ builtin_sources += custom_target( output: 'hook-list.h', command: [ shell, - meson.current_source_dir() + '/generate-hooklist.sh', + meson.current_source_dir() + '/tools/generate-hooklist.sh', meson.current_source_dir(), '@OUTPUT@', ], @@ -1959,7 +1959,7 @@ foreach script : scripts_sh output: fs.stem(script), command: [ shell, - meson.project_source_root() / 'generate-script.sh', + meson.project_source_root() / 'tools/generate-script.sh', '@INPUT@', '@OUTPUT@', meson.project_build_root() / 'GIT-BUILD-OPTIONS', @@ -2008,7 +2008,7 @@ if perl_features_enabled generate_perl_command = [ shell, - meson.project_source_root() / 'generate-perl.sh', + meson.project_source_root() / 'tools/generate-perl.sh', meson.project_build_root() / 'GIT-BUILD-OPTIONS', git_version_file.full_path(), perl_header, @@ -2057,7 +2057,7 @@ if target_python.found() output: fs.stem(script), command: [ shell, - meson.project_source_root() / 'generate-python.sh', + meson.project_source_root() / 'tools/generate-python.sh', meson.project_build_root() / 'GIT-BUILD-OPTIONS', '@INPUT@', '@OUTPUT@', diff --git a/tools/check-builtins.sh b/tools/check-builtins.sh new file mode 100755 index 0000000000..a0aaf3a347 --- /dev/null +++ b/tools/check-builtins.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +{ + cat <<\EOF +sayIt: + $(foreach b,$(BUILT_INS),echo XXX $(b:$X=) YYY;) +EOF + cat Makefile +} | +make -f - sayIt 2>/dev/null | +sed -n -e 's/.*XXX \(.*\) YYY.*/\1/p' | +sort | +{ + bad=0 + while read builtin + do + base=$(expr "$builtin" : 'git-\(.*\)') + x=$(sed -ne 's/.*{ "'$base'", \(cmd_[^, ]*\).*/'$base' \1/p' git.c) + if test -z "$x" + then + echo "$base is builtin but not listed in git.c command list" + bad=1 + fi + for sfx in sh perl py + do + if test -f "$builtin.$sfx" + then + echo "$base is builtin but $builtin.$sfx still exists" + bad=1 + fi + done + done + exit $bad +} diff --git a/tools/detect-compiler b/tools/detect-compiler new file mode 100755 index 0000000000..124ebdd4c9 --- /dev/null +++ b/tools/detect-compiler @@ -0,0 +1,58 @@ +#!/bin/sh +# +# Probe the compiler for vintage, version, etc. This is used for setting +# optional make knobs under the DEVELOPER knob. + +CC="$*" + +# we get something like (this is at least true for gcc and clang) +# +# FreeBSD clang version 3.4.1 (tags/RELEASE...) +get_version_line() { + LANG=C LC_ALL=C $CC -v 2>&1 | sed -n '/ version /{p;q;}' +} + +get_family() { + get_version_line | sed 's/^\(.*\) version [0-9].*/\1/' +} + +get_version() { + # A string that begins with a digit up to the next SP + ver=$(get_version_line | sed 's/^.* version \([0-9][^ ]*\).*/\1/') + + # There are known -variant suffixes that do not affect the + # meaning of the main version number. Strip them. + ver=${ver%-win32} + ver=${ver%-posix} + + echo "$ver" +} + +print_flags() { + family=$1 + version=$(get_version | cut -f 1 -d .) + + # Print a feature flag not only for the current version, but also + # for any prior versions we encompass. This avoids needing to do + # numeric comparisons in make, which are awkward. + while test "$version" -gt 0 + do + echo $family$version + version=$((version - 1)) + done +} + +case "$(get_family)" in +gcc) + print_flags gcc + ;; +clang | *" clang") + print_flags clang + ;; +"Apple LLVM") + print_flags clang + ;; +*) + : unknown compiler family + ;; +esac diff --git a/tools/generate-cmdlist.sh b/tools/generate-cmdlist.sh new file mode 100755 index 0000000000..0ed39c4c5d --- /dev/null +++ b/tools/generate-cmdlist.sh @@ -0,0 +1,120 @@ +#!/bin/sh + +die () { + echo "$@" >&2 + exit 1 +} + +command_list () { + while read cmd rest + do + case "$cmd" in + "#"* | '') + # Ignore comments and allow empty lines + continue + ;; + *) + case "$exclude_programs" in + *":$cmd:"*) + ;; + *) + echo "$cmd $rest" + ;; + esac + esac + done <"$1" +} + +category_list () { + echo "$1" | + cut -d' ' -f2- | + tr ' ' '\012' | + grep -v '^$' | + LC_ALL=C sort -u +} + +define_categories () { + echo + echo "/* Command categories */" + bit=0 + echo "$1" | + while read cat + do + echo "#define CAT_$cat (1UL << $bit)" + bit=$(($bit+1)) + done + test "$bit" -gt 32 && die "Urgh.. too many categories?" +} + +define_category_names () { + echo + echo "/* Category names */" + echo "static const char *category_names[] = {" + bit=0 + echo "$1" | + while read cat + do + echo " \"$cat\", /* (1UL << $bit) */" + bit=$(($bit+1)) + done + echo " NULL" + echo "};" +} + +print_command_list () { + echo "static struct cmdname_help command_list[] = {" + + echo "$2" | + while read cmd rest + do + synopsis= + while read line + do + case "$line" in + "$cmd - "*) + synopsis=${line#$cmd - } + break + ;; + esac + done <"$1/Documentation/$cmd.adoc" + + printf '\t{ "%s", N_("%s"), 0' "$cmd" "$synopsis" + printf " | CAT_%s" $rest + echo " }," + done + echo "};" +} + +exclude_programs=: +while test "--exclude-program" = "$1" +do + shift + exclude_programs="$exclude_programs$1:" + shift +done + +if test "$#" -ne 2 +then + die "USAGE: $0 " +fi + +SOURCE_DIR="$1" +OUTPUT="$2" + +{ + commands="$(command_list "$SOURCE_DIR"/command-list.txt)" + categories="$(category_list "$commands")" + + echo "/* Automatically generated by generate-cmdlist.sh */ + struct cmdname_help { + const char *name; + const char *help; + uint32_t category; + }; + " + define_categories "$categories" + echo + define_category_names "$categories" + echo + print_command_list "$SOURCE_DIR" "$commands" +} >"$OUTPUT" diff --git a/tools/generate-configlist.sh b/tools/generate-configlist.sh new file mode 100755 index 0000000000..e28054f9e0 --- /dev/null +++ b/tools/generate-configlist.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +SOURCE_DIR="$1" +OUTPUT="$2" +DEPFILE="$3" + +if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" +then + echo >&2 "USAGE: $0 []" + exit 1 +fi + +print_config_list () { + cat <"$OUTPUT" + +if test -n "$DEPFILE" +then + QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" + { + printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | + sed -e 's/[# ]/\\&/g' -e "s/^/$QUOTED_OUTPUT: /" + printf '%s:\n' "$SOURCE_DIR"/Documentation/*config.adoc \ + "$SOURCE_DIR"/Documentation/config/*.adoc | + sed -e 's/[# ]/\\&/g' + } >"$DEPFILE" +fi diff --git a/tools/generate-hooklist.sh b/tools/generate-hooklist.sh new file mode 100755 index 0000000000..e0cdf26944 --- /dev/null +++ b/tools/generate-hooklist.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# +# Usage: ./generate-hooklist.sh >hook-list.h + +SOURCE_DIR="$1" +OUTPUT="$2" + +if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" +then + echo >&2 "USAGE: $0 " + exit 1 +fi + +{ + +cat <"$OUTPUT" diff --git a/tools/generate-perl.sh b/tools/generate-perl.sh new file mode 100755 index 0000000000..796d835932 --- /dev/null +++ b/tools/generate-perl.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +set -e + +if test $# -ne 5 +then + echo >&2 "USAGE: $0 " + exit 1 +fi + +GIT_BUILD_OPTIONS="$1" +GIT_VERSION_FILE="$2" +PERL_HEADER="$3" +INPUT="$4" +OUTPUT="$5" + +. "$GIT_BUILD_OPTIONS" +. "$GIT_VERSION_FILE" + +sed -e '1{' \ + -e " /^#!.*perl/!b" \ + -e " s|#!.*perl|#!$PERL_PATH|" \ + -e " r $PERL_HEADER" \ + -e ' G' \ + -e '}' \ + -e "s|@GIT_VERSION@|$GIT_VERSION|g" \ + -e "s|@LOCALEDIR@|$PERL_LOCALEDIR|g" \ + -e "s|@NO_GETTEXT@|$NO_GETTEXT|g" \ + -e "s|@NO_PERL_CPAN_FALLBACKS@|$NO_PERL_CPAN_FALLBACKS|g" \ + "$INPUT" >"$OUTPUT" + +case "$INPUT" in +*.perl|*git-contacts) + chmod a+x "$OUTPUT";; +*) + ;; +esac diff --git a/tools/generate-python.sh b/tools/generate-python.sh new file mode 100755 index 0000000000..31ac115689 --- /dev/null +++ b/tools/generate-python.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +set -e + +if test $# -ne 3 +then + echo >&2 "USAGE: $0 " + exit 1 +fi + +GIT_BUILD_OPTIONS="$1" +INPUT="$2" +OUTPUT="$3" + +. "$GIT_BUILD_OPTIONS" + +sed -e "1s|#!.*python|#!$PYTHON_PATH|" \ + "$INPUT" >"$OUTPUT+" +chmod a+x "$OUTPUT+" +mv "$OUTPUT+" "$OUTPUT" diff --git a/tools/generate-script.sh b/tools/generate-script.sh new file mode 100755 index 0000000000..a149e4f0ba --- /dev/null +++ b/tools/generate-script.sh @@ -0,0 +1,34 @@ +#!/bin/sh + +set -e + +if test $# -ne 3 +then + echo >&2 "USAGE: $0 " + exit 1 +fi + +INPUT="$1" +OUTPUT="$2" +BUILD_OPTIONS="$3" + +. "$BUILD_OPTIONS" + +sed -e "1s|#!.*/sh|#!$SHELL_PATH|" \ + -e "s|@SHELL_PATH@|$SHELL_PATH|" \ + -e "s|@DIFF@|$DIFF|" \ + -e "s|@LOCALEDIR@|$LOCALEDIR|g" \ + -e "s/@USE_GETTEXT_SCHEME@/$USE_GETTEXT_SCHEME/g" \ + -e "$BROKEN_PATH_FIX" \ + -e "s|@GITWEBDIR@|$GITWEBDIR|g" \ + -e "s|@PERL_PATH@|$PERL_PATH|g" \ + -e "s|@PAGER_ENV@|$PAGER_ENV|g" \ + "$INPUT" >"$OUTPUT" + +case "$(basename "$INPUT")" in +git-mergetool--lib.sh|git-sh-i18n.sh|git-sh-setup.sh) + ;; +*) + chmod a+x "$OUTPUT" + ;; +esac -- cgit v1.3-5-g45d5