config-list.h: generate-configlist.sh
config-list.h: Documentation/*config.txt Documentation/config/*.txt
- $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh >$@
+ $(QUIET_GEN)$(SHELL_PATH) ./generate-configlist.sh . $@
command-list.h: generate-cmdlist.sh command-list.txt
command-list.h: $(wildcard Documentation/git*.txt)
$(QUIET_GEN)$(SHELL_PATH) ./generate-cmdlist.sh \
$(patsubst %,--exclude-program %,$(EXCLUDED_PROGRAMS)) \
- command-list.txt >$@
+ . $@
hook-list.h: generate-hooklist.sh Documentation/githooks.txt
- $(QUIET_GEN)$(SHELL_PATH) ./generate-hooklist.sh >$@
+ $(QUIET_GEN)$(SHELL_PATH) ./generate-hooklist.sh . $@
SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):\
$(localedir_SQ):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
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 ${EXCLUSION_PROGS} command-list.txt
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
+ execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/generate-cmdlist.sh"
+ ${EXCLUSION_PROGS}
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_BINARY_DIR}/command-list.h")
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
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
+ execute_process(COMMAND "${SH_EXE}" "${CMAKE_SOURCE_DIR}/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
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- OUTPUT_FILE ${CMAKE_BINARY_DIR}/hook-list.h)
+ execute_process(COMMAND "${SH_EXE}" ${CMAKE_SOURCE_DIR}/generate-hooklist.sh
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_BINARY_DIR}/hook-list.h")
endif()
include_directories(${CMAKE_BINARY_DIR})
print_command_list () {
echo "static struct cmdname_help command_list[] = {"
- echo "$1" |
+ echo "$2" |
while read cmd rest
do
synopsis=
break
;;
esac
- done <"Documentation/$cmd.txt"
+ done <"$1/Documentation/$cmd.txt"
printf '\t{ "%s", N_("%s"), 0' "$cmd" "$synopsis"
printf " | CAT_%s" $rest
shift
done
-commands="$(command_list "$1")"
-categories="$(category_list "$commands")"
+if test "$#" -ne 2
+then
+ die "USAGE: $0 <SOURCE_DIR> <OUTPUT>"
+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 "$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"
#!/bin/sh
-echo "/* Automatically generated by generate-configlist.sh */"
-echo
+SOURCE_DIR="$1"
+OUTPUT="$2"
+
+if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT"
+then
+ echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT>"
+ exit 1
+fi
print_config_list () {
cat <<EOF
static const char *config_name_list[] = {
EOF
- grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
+ grep -h '^[a-zA-Z].*\..*::$' "$SOURCE_DIR"/Documentation/*config.txt "$SOURCE_DIR"/Documentation/config/*.txt |
sed '/deprecated/d; s/::$//; s/, */\n/g' |
sort |
sed 's/^.*$/ "&",/'
EOF
}
-echo
-print_config_list
+{
+ echo "/* Automatically generated by generate-configlist.sh */"
+ echo
+ echo
+ print_config_list
+} >"$OUTPUT"
#
# 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 <SOURCE_DIR> <OUTPUT>"
+ exit 1
+fi
+
+{
+
cat <<EOF
/* Automatically generated by generate-hooklist.sh */
sed -n \
-e '/^~~~~*$/ {x; s/^.*$/ "&",/; p;}' \
-e 'x' \
- <Documentation/githooks.txt |
+ <"$SOURCE_DIR"/Documentation/githooks.txt |
LC_ALL=C sort
cat <<EOF
NULL,
};
EOF
+
+} >"$OUTPUT"