Makefile: add check-headers target
RFC PATCH 1/2 Makefile: add check-headers target
This allows us to ensure that each header can be included individually without needing to include other headers first.
---
This patch demonstrates how to verify PATCH 2/2.
Makefile | 6 ++++++ check-headers.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 check-headers.sh
Makefile +6 -0
@@ -2591,6 +2591,12 @@ check-docs:: check-builtins:: ./check-builtins.sh +### Make sure headers include their dependencies +# +check-headers:: + ./check-headers.sh $(CC) $(ALL_CFLAGS) + + ### Test suite coverage testing # .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-report
check-headers.sh new file +26 -0
@@ -0,0 +1,26 @@ +#!/bin/sh + +exit_code=0 + +maybe_exit () { + status="$1" + if test "$status" != 0 + then + exit_code="$status" + if test -n "$CHECK_HEADERS_STOP" + then + exit "$status" + fi + fi +} + +git ls-files *.h | +while read header +do + echo "HEADER $header" && + "$@" -Wno-unused -x c -c -o "$header".bin - <"$header" && + rm "$header".bin || + maybe_exit $? +done + +exit $exit_code
Signature · 1 line
2.1.0.62.g7dc6c49
RFC PATCH 2/2 headers: include dependent headers
Add dependent headers so that including a header does not require including additional headers.
This makes it so that "gcc -c $header" succeeds for each header.
---
This patch was prepared by using the "check-headers" target introduced by PATCH 1/2 to find headers that were not including their dependencies.
The only significant code movement was the movement of a struct defined in utf8.c to utf8.h so that it can be included by unicode_width.h.
archive.h | 1 + argv-array.h | 2 ++ attr.h | 2 ++ branch.h | 3 +++ cache-tree.h | 1 + color.h | 3 ++- column.h | 2 ++ commit.h | 1 + convert.h | 3 +++ credential.h | 1 + csum-file.h | 2 ++ delta.h | 2 ++ diff.h | 2 +- diffcore.h | 2 ++ dir.h | 2 ++ ewah/ewok.h | 2 ++ exec_cmd.h | 2 ++ fsck.h | 2 ++ gpg-interface.h | 2 ++ graph.h | 2 ++ hashmap.h | 2 ++ help.h | 2 ++ khash.h | 3 +++ kwset.h | 2 ++ line-log.h | 1 + list-objects.h | 2 ++ ll-merge.h | 2 ++ mailmap.h | 3 +++ merge-recursive.h | 2 ++ notes-cache.h | 1 + notes-merge.h | 3 +++ notes-utils.h | 1 + notes.h | 1 + object.h | 2 ++ pack-bitmap.h | 2 ++ pack-objects.h | 2 ++ pack-revindex.h | 2 ++ parse-options.h | 2 ++ patch-ids.h | 3 +++ pathspec.h | 2 ++ progress.h | 2 ++ quote.h | 3 ++- reachable.h | 2 ++ reflog-walk.h | 1 + refs.h | 4 ++++ remote.h | 1 + resolve-undo.h | 2 ++ send-pack.h | 4 ++++ sequencer.h | 3 +++ sha1-lookup.h | 2 ++ shortlog.h | 2 ++ sideband.h | 2 ++ strbuf.h | 2 ++ submodule.h | 6 ++++-- tag.h | 1 + tree-walk.h | 2 ++ tree.h | 1 + unicode_width.h | 3 +++ unpack-trees.h | 2 ++ url.h | 2 ++ urlmatch.h | 2 ++ utf8.c | 7 ------- utf8.h | 9 +++++++++ wt-status.h | 1 + 64 files changed, 133 insertions(+), 12 deletions(-)
archive.h +1 -0
@@ -1,6 +1,7 @@#ifndef ARCHIVE_H #define ARCHIVE_H +#include "cache.h" #include "pathspec.h" struct archiver_args {
argv-array.h +2 -0
@@ -1,6 +1,8 @@#ifndef ARGV_ARRAY_H #define ARGV_ARRAY_H +#include "git-compat-util.h" +extern const char *empty_argv[]; struct argv_array {
attr.h +2 -0
@@ -1,6 +1,8 @@#ifndef ATTR_H #define ATTR_H +#include "cache.h" +/* An attribute is a pointer to this opaque structure */ struct git_attr ;
branch.h +3 -0
@@ -3,6 +3,9 @@/* Functions for acting on the information about branches. */ +#include "cache.h" +#include "strbuf.h" +/* * Creates a new branch, where head is the branch currently checked * out, name is the new branch name, start_name is the name of the
cache-tree.h +1 -0
@@ -3,6 +3,7 @@#include "tree.h" #include "tree-walk.h" +#include "cache.h" struct cache_tree ;struct cache_tree_sub {
color.h +2 -1
@@ -1,7 +1,8 @@#ifndef COLOR_H #define COLOR_H -struct strbuf ; +#include "git-compat-util.h" +#include "strbuf.h" /* 2 + (2 * num_attrs) + 8 + 1 + 8 + 'm' + NUL */ /* "\033[1;2;4;5;7;38;5;2xx;48;5;2xxm\0" */
column.h +2 -0
@@ -1,6 +1,8 @@#ifndef COLUMN_H #define COLUMN_H +#include "string-list.h" +#define COL_LAYOUT_MASK 0x000F#define COL_ENABLE_MASK 0x0030/* always, never or auto */ #define COL_PARSEOPT 0x0040/* --column is given from cmdline */
commit.h +1 -0
@@ -7,6 +7,7 @@#include "decorate.h" #include "gpg-interface.h" #include "string-list.h" +#include "cache.h" struct commit_list {struct commit *item;
convert.h +3 -0
@@ -4,6 +4,9 @@#ifndef CONVERT_H #define CONVERT_H +#include "git-compat-util.h" +#include "strbuf.h" +enum safe_crlf {SAFE_CRLF_FALSE =0 , SAFE_CRLF_FAIL = 1,
credential.h +1 -0
@@ -1,6 +1,7 @@#ifndef CREDENTIAL_H #define CREDENTIAL_H +#include "git-compat-util.h" #include "string-list.h" struct credential {
csum-file.h +2 -0
@@ -1,6 +1,8 @@#ifndef CSUM_FILE_H #define CSUM_FILE_H +#include "cache.h" +struct progress ;/* A SHA1-protected file */
delta.h +2 -0
@@ -1,6 +1,8 @@#ifndef DELTA_H #define DELTA_H +#include "git-compat-util.h" +/* opaque object for delta index */ struct delta_index ;
diff.h +1 -1
@@ -6,11 +6,11 @@#include "tree-walk.h" #include "pathspec.h" +#include "strbuf.h" struct rev_info ;struct diff_options ;struct diff_queue_struct ; -struct strbuf ;struct diff_filespec ;struct userdiff_driver ;struct sha1_array ;
diffcore.h +2 -0
@@ -4,6 +4,8 @@#ifndef DIFFCORE_H #define DIFFCORE_H +#include "diff.h" +/* This header file is internal between diff.c and its diff transformers * (e.g. diffcore-rename, diffcore-pickaxe). Never include this header * in anything else.
dir.h +2 -0
@@ -4,6 +4,8 @@/* See Documentation/technical/api-directory-listing.txt */ #include "strbuf.h" +#include "pathspec.h" +#include "cache.h" struct dir_entry {unsigned int len;
ewah/ewok.h +2 -0
@@ -20,6 +20,8 @@#ifndef __EWOK_BITMAP_H__#define __EWOK_BITMAP_H__ +#include "git-compat-util.h" +#ifndef ewah_malloc# define ewah_malloc xmalloc#endif
exec_cmd.h +2 -0
@@ -1,6 +1,8 @@#ifndef GIT_EXEC_CMD_H #define GIT_EXEC_CMD_H +#include "git-compat-util.h" +extern void git_set_argv_exec_path (const char *exec_path);extern const char *git_extract_argv0_path (const char *path);extern const char *git_exec_path (void );
fsck.h +2 -0
@@ -1,6 +1,8 @@#ifndef GIT_FSCK_H #define GIT_FSCK_H +#include "object.h" +#define FSCK_ERROR 1#define FSCK_WARN 2
gpg-interface.h +2 -0
@@ -1,6 +1,8 @@ #ifndef GPG_INTERFACE_H #define GPG_INTERFACE_H +#include "strbuf.h" + struct signature_check { char *payload; char *gpg_output;
graph.h +2 -0
@@ -1,6 +1,8 @@#ifndef GRAPH_H #define GRAPH_H +#include "revision.h" +/* A graph is a pointer to this opaque structure */ struct git_graph ;
hashmap.h +2 -0
@@ -1,6 +1,8 @@#ifndef HASHMAP_H #define HASHMAP_H +#include "git-compat-util.h" +/* * Generic implementation of hash-based key-value mappings. * See Documentation/technical/api-hashmap.txt.
help.h +2 -0
@@ -1,6 +1,8 @@ #ifndef HELP_H #define HELP_H +#include "git-compat-util.h" + struct cmdnames { int alloc; int cnt;
khash.h +3 -0
@@ -26,6 +26,9 @@#ifndef __AC_KHASH_H#define __AC_KHASH_H +#include "git-compat-util.h" +#include "cache.h" +#define AC_VERSION_KHASH_H "0.2.8"typedef uint32_t khint32_t ;
kwset.h +2 -0
@@ -25,6 +25,8 @@The author may be reached (Email) at the address [email protected], or (US mail) as Mike Haertel c/o Free Software Foundation. */ +#include "git-compat-util.h" +struct kwsmatch {int index;/* Index number of matching keyword. */
line-log.h +1 -0
@@ -2,6 +2,7 @@#define LINE_LOG_H #include "diffcore.h" +#include "string-list.h" struct rev_info ;struct commit ;
list-objects.h +2 -0
@@ -1,6 +1,8 @@#ifndef LIST_OBJECTS_H #define LIST_OBJECTS_H +#include "revision.h" +typedef void (*show_commit_fn )(struct commit *,void *);typedef void (*show_object_fn )(struct object *,const struct name_path *,const char *,void *);void traverse_commit_list (struct rev_info *,show_commit_fn ,show_object_fn ,void *);
ll-merge.h +2 -0
@@ -5,6 +5,8 @@ #ifndef LL_MERGE_H #define LL_MERGE_H +#include "xdiff/xdiff.h" + struct ll_merge_options { unsigned virtual_ancestor : 1; unsigned variant : 2; /* favor ours, favor theirs, or union merge */
mailmap.h +3 -0
@@ -1,6 +1,9 @@#ifndef MAILMAP_H #define MAILMAP_H +#include "git-compat-util.h" +#include "string-list.h" +int read_mailmap (struct string_list *map,char **repo_abbrev);void clear_mailmap (struct string_list *map);
merge-recursive.h +2 -0
@@ -1,7 +1,9 @@ #ifndef MERGE_RECURSIVE_H #define MERGE_RECURSIVE_H +#include "strbuf.h" #include "string-list.h" +#include "commit.h" struct merge_options { const char *ancestor;
notes-cache.h +1 -0
@@ -1,6 +1,7 @@#ifndef NOTES_CACHE_H #define NOTES_CACHE_H +#include "git-compat-util.h" #include "notes.h" struct notes_cache {
notes-merge.h +3 -0
@@ -1,6 +1,9 @@#ifndef NOTES_MERGE_H #define NOTES_MERGE_H +#include "notes.h" +#include "commit.h" +#define NOTES_MERGE_WORKTREE "NOTES_MERGE_WORKTREE" enum notes_merge_verbosity {
notes-utils.h +1 -0
@@ -2,6 +2,7 @@#define NOTES_UTILS_H #include "notes.h" +#include "commit.h" /* * Create new notes commit from the given notes tree
notes.h +1 -0
@@ -1,6 +1,7 @@#ifndef NOTES_H #define NOTES_H +#include "strbuf.h" #include "string-list.h" /*
object.h +2 -0
@@ -1,6 +1,8 @@ #ifndef OBJECT_H #define OBJECT_H +#include "cache.h" + struct object_list { struct object *item; struct object_list *next;
pack-bitmap.h +2 -0
@@ -1,9 +1,11 @@ #ifndef PACK_BITMAP_H #define PACK_BITMAP_H +#include "git-compat-util.h" #include "ewah/ewok.h" #include "khash.h" #include "pack-objects.h" +#include "revision.h" struct bitmap_disk_entry { uint32_t object_pos;
pack-objects.h +2 -0
@@ -1,6 +1,8 @@ #ifndef PACK_OBJECTS_H #define PACK_OBJECTS_H +#include "pack.h" + struct object_entry { struct pack_idx_entry idx; unsigned long size; /* uncompressed size */
pack-revindex.h +2 -0
@@ -1,6 +1,8 @@ #ifndef PACK_REVINDEX_H #define PACK_REVINDEX_H +#include "git-compat-util.h" + struct revindex_entry { off_t offset; unsigned int nr;
parse-options.h +2 -0
@@ -1,6 +1,8 @@#ifndef PARSE_OPTIONS_H #define PARSE_OPTIONS_H +#include "git-compat-util.h" +enum parse_opt_type {/* special types */ OPTION_END,
patch-ids.h +3 -0
@@ -1,6 +1,9 @@ #ifndef PATCH_IDS_H #define PATCH_IDS_H +#include "commit.h" +#include "diff.h" + struct patch_id { unsigned char patch_id[20]; char seen;
pathspec.h +2 -0
@@ -1,6 +1,8 @@#ifndef PATHSPEC_H #define PATHSPEC_H +#include "git-compat-util.h" +/* Pathspec magic */ #define PATHSPEC_FROMTOP (1<<0)#define PATHSPEC_MAXDEPTH (1<<1)
progress.h +2 -0
@@ -1,6 +1,8 @@#ifndef PROGRESS_H #define PROGRESS_H +#include "git-compat-util.h" +struct progress ;void display_throughput (struct progress *progress,off_t total);
quote.h +2 -1
@@ -1,7 +1,8 @@#ifndef QUOTE_H #define QUOTE_H -struct strbuf ; +#include "git-compat-util.h" +#include "strbuf.h" /* Help to copy the thing properly quoted for the shell safety. * any single quote is replaced with '\'', any exclamation point
reachable.h +2 -0
@@ -1,6 +1,8 @@#ifndef REACHEABLE_H #define REACHEABLE_H +#include "revision.h" +struct progress ;extern void mark_reachable_objects (struct rev_info *revs,int mark_reflog,struct progress *);
reflog-walk.h +1 -0
@@ -2,6 +2,7 @@#define REFLOG_WALK_H #include "cache.h" +#include "commit.h" struct reflog_walk_info ;
refs.h +4 -0
@@ -1,6 +1,10 @@ #ifndef REFS_H #define REFS_H +#include "git-compat-util.h" +#include "strbuf.h" +#include "string-list.h" + struct ref_lock { char *ref_name; char *orig_ref_name;
remote.h +1 -0
@@ -3,6 +3,7 @@#include "parse-options.h" #include "hashmap.h" +#include "strbuf.h" enum {REMOTE_CONFIG ,
resolve-undo.h +2 -0
@@ -1,6 +1,8 @@ #ifndef RESOLVE_UNDO_H #define RESOLVE_UNDO_H +#include "cache.h" + struct resolve_undo_info { unsigned int mode[3]; unsigned char sha1[3][20];
send-pack.h +4 -0
@@ -1,6 +1,10 @@ #ifndef SEND_PACK_H #define SEND_PACK_H +#include "git-compat-util.h" +#include "run-command.h" +#include "remote.h" + struct send_pack_args { unsigned verbose:1, quiet:1,
sequencer.h +3 -0
@@ -1,6 +1,9 @@#ifndef SEQUENCER_H #define SEQUENCER_H +#include "git-compat-util.h" +#include "strbuf.h" +#define SEQ_DIR "sequencer"#define SEQ_HEAD_FILE "sequencer/head"#define SEQ_TODO_FILE "sequencer/todo"
sha1-lookup.h +2 -0
@@ -1,6 +1,8 @@#ifndef SHA1_LOOKUP_H #define SHA1_LOOKUP_H +#include "git-compat-util.h" +typedef const unsigned char *sha1_access_fn (size_t index,void *table); extern int sha1_pos(const unsigned char *sha1,
shortlog.h +2 -0
@@ -1,6 +1,8 @@#ifndef SHORTLOG_H #define SHORTLOG_H +#include "git-compat-util.h" +#include "commit.h" #include "string-list.h" struct shortlog {
sideband.h +2 -0
@@ -1,6 +1,8 @@#ifndef SIDEBAND_H #define SIDEBAND_H +#include "git-compat-util.h" +#define SIDEBAND_PROTOCOL_ERROR -2#define SIDEBAND_REMOTE_ERROR -1
strbuf.h +2 -0
@@ -1,6 +1,8 @@#ifndef STRBUF_H #define STRBUF_H +#include "git-compat-util.h" +/* See Documentation/technical/api-strbuf.txt */ extern char strbuf_slopbuf[];
submodule.h +4 -2
@@ -1,8 +1,10 @@#ifndef SUBMODULE_H #define SUBMODULE_H -struct diff_options ; -struct argv_array ; +#include "git-compat-util.h" +#include "diff.h" +#include "argv-array.h" +#include "string-list.h" enum { RECURSE_SUBMODULES_ON_DEMAND = -1,
tag.h +1 -0
@@ -1,6 +1,7 @@#ifndef TAG_H #define TAG_H +#include "git-compat-util.h" #include "object.h" extern const char *tag_type;
tree-walk.h +2 -0
@@ -1,6 +1,8 @@ #ifndef TREE_WALK_H #define TREE_WALK_H +#include "strbuf.h" + struct name_entry { const unsigned char *sha1; const char *path;
tree.h +1 -0
@@ -2,6 +2,7 @@#define TREE_H #include "object.h" +#include "pathspec.h" extern const char *tree_type;
unicode_width.h +3 -0
@@ -1,3 +1,6 @@ +#include "git-compat-util.h" +#include "utf8.h" +static const struct interval zero_width[] = { {0x0300 ,0x036F }, {0x0483 ,0x0489 },
unpack-trees.h +2 -0
@@ -1,7 +1,9 @@#ifndef UNPACK_TREES_H #define UNPACK_TREES_H +#include "cache.h" #include "string-list.h" +#include "tree-walk.h" #define MAX_UNPACK_TREES 8
url.h +2 -0
@@ -1,6 +1,8 @@#ifndef URL_H #define URL_H +#include "strbuf.h" +extern int is_url (const char *url);extern int is_urlschemechar (int first_flag,int ch);extern char *url_decode (const char *url);
urlmatch.h +2 -0
@@ -1,4 +1,6 @@#ifndef URL_MATCH_H + +#include "git-compat-util.h" #include "string-list.h" struct url_info {
utf8.c +0 -7
@@ -2,13 +2,6 @@#include "strbuf.h" #include "utf8.h" -/* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */ - -struct interval { -ucs_char_t first; -ucs_char_t last; -}; -size_t display_mode_esc_sequence_len (const char *s) {const char *p = s;
utf8.h +9 -0
@@ -1,8 +1,17 @@#ifndef GIT_UTF8_H #define GIT_UTF8_H +#include "strbuf.h" +typedef unsigned int ucs_char_t ;/* assuming 32bit int */ +/* This code is originally from http://www.cl.cam.ac.uk/~mgk25/ucs/ */ + +struct interval { +ucs_char_t first; +ucs_char_t last; +}; +size_t display_mode_esc_sequence_len (const char *s);int utf8_width (const char **start,size_t *remainder_p);int utf8_strnwidth (const char *string,int len,int skip_ansi);
wt-status.h +1 -0
@@ -4,6 +4,7 @@#include <stdio.h> #include "string-list.h" #include "color.h" +#include "pathspec.h" enum color_wt_status {WT_STATUS_HEADER =0 ,
Signature · 1 line
2.1.0.62.g7dc6c49
Re: [RFC PATCH 2/2] headers: include dependent headers
Am 06.09.2014 um 21:20 schrieb David Aguilar:
Quoted 13 lines
Add dependent headers so that including a header does not require including additional headers.
This makes it so that "gcc -c $header" succeeds for each header.
Signed-off-by David Aguilar <[email protected]>---
branch.h +0
-0
branch.h line 7
Quoted 5 lines
branch.h +2
-0@@ -3,6 +3,9 @@/* Functions for acting on the information about branches. */ +#include "cache.h" +#include "strbuf.h"
cache.h includes strbuf.h, so the line above isn't necessary.
Re: [RFC PATCH 2/2] headers: include dependent headers
Quoted 15 lines · René Scharfe
Am 06.09.2014 um 21:20 schrieb David Aguilar:
Quoted 14 lines
Add dependent headers so that including a header does not require including additional headers.
This makes it so that "gcc -c $header" succeeds for each header.
Signed-off-by David Aguilar <[email protected]>---
branch.h +0
-0@@ -3,6 +3,9 @@
Quoted 6 lines
branch.h line 7
Quoted 4 lines
branch.h +2
-0/* Functions for acting on the information about branches. */ +#include "cache.h" +#include "strbuf.h"
cache.hincludesstrbuf.h, so the line above isn't necessary.
I think the primary objective of these two patches is to allow anybody who wants to use a feature X to include the header H that is about that feature without having to know what other header F and G are required by the implementation of header H.
And I think that cuts both ways. Somebody who wants to use a feature defined in the header H shouldn't have to know that other headers I and J he includes to use other features from happen to already include H for their own use.
Here, branch.h does want to see "struct strbuf" for its own use, so including "strbuf.h" is the right thing to do and in line with the primary objective, no? It shouldn't have to know that "cache.h" happens to include "strbuf.h".
While assessing these two patches, we would need to decide what to do with the "include git-compat-util.h first in any C source" rule in the coding guidelines. I think it is still a good practical exception (in the sense that even if you do not use FLEX_ARRAY, signed_add_overflows(), etc. yourself, you should follow the rule), even if we choose to adopt "One that wants to use features from a header only needs to include that header".
Re: [RFC PATCH 2/2] headers: include dependent headers
In reply to René ScharfeQuoted 15 lines · René Scharfe
Am 06.09.2014 um 21:20 schrieb David Aguilar:
Quoted 14 lines
Add dependent headers so that including a header does not require including additional headers.
This makes it so that "gcc -c $header" succeeds for each header.
Signed-off-by David Aguilar <[email protected]>---
branch.h +0
-0@@ -3,6 +3,9 @@
Quoted 6 lines
branch.h line 7
Quoted 4 lines
branch.h +2
-0/* Functions for acting on the information about branches. */ +#include "cache.h" +#include "strbuf.h"
cache.hincludesstrbuf.h, so the line above isn't necessary.
True, but is "gcc -c $header" something we want to please in the first place (not an objection, but request for opinions)?
Re: [RFC PATCH 2/2] headers: include dependent headers
Am 08.09.2014 um 19:50 schrieb Junio C Hamano:
Quoted 19 lines
Quoted 17 lines · René Scharfe
Am 06.09.2014 um 21:20 schrieb David Aguilar:
Quoted 16 lines
Add dependent headers so that including a header does not require including additional headers.
This makes it so that "gcc -c $header" succeeds for each header.
Signed-off-by David Aguilar <[email protected]>---
branch.h +0
-0@@ -3,6 +3,9 @@/* Functions for acting on the information about branches. */
Quoted 7 lines
Quoted 4 lines
branch.h line 7
Quoted 2 lines
branch.h +2
-0+#include "cache.h" +#include "strbuf.h"
cache.hincludesstrbuf.h, so the line above isn't necessary.True, but is "gcc -c $header" something we want to please in the first place (not an objection, but request for opinions)?
It *sounds* useful, but we did without that feature so far. Hmm. It would make it easier to use headers -- any dependency to other files are already taken care of. Since we have less .h files than .c files this seems to make sense.
Would it perhaps also make using precompiled headers easier (or possible in the first place)? Do we care?
René
Am 06.09.2014 um 21:20 schrieb David Aguilar:
Quoted 2 lines
This allows us to ensure that each header can be included individually without needing to include other headers first.
Sounds like a good objective.
Quoted 39 lines
Signed-off-by David Aguilar <[email protected]>---
This patch demonstrates how to verify PATCH 2/2.Makefile | 6 ++++++ check-headers.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+)create mode 100755
check-headers.shMakefile +6
-0@@ -2591,6 +2591,12 @@ check-docs:: check-builtins:: ./check-builtins.sh +### Make sure headers include their dependencies +# +check-headers:: + ./check-headers.sh $(CC) $(ALL_CFLAGS) + + ### Test suite coverage testing # .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-reportcheck-headers.sh new file +7
-0@@ -0,0 +1,26 @@ +#!/bin/sh + +exit_code=0 + +maybe_exit () { + status="$1" + if test "$status" != 0
check-headers.sh line 17
Quoted 10 lines
check-headers.sh new file +10
-0+ then + exit_code="$status" + if test -n "$CHECK_HEADERS_STOP" + then + exit "$status" + fi + fi +} + +git ls-files *.h |
This checks all .h files in the top directory. Would it be better to check all files in LIB_H instead? Or even all .h files in the tree (using "git ls-files '*.h'")? The latter might be difficult because some of the files in compat/ #include system-specific headers.
Quoted 10 lines
check-headers.sh new file +9
-0+while read header +do + echo "HEADER $header" && + "$@" -Wno-unused -x c -c -o "$header".bin - <"$header" && + rm "$header".bin || + maybe_exit $? +done + +exit $exit_code
Quoted 53 lines · René Scharfe
Am 06.09.2014 um 21:20 schrieb David Aguilar:
Quoted 2 lines
This allows us to ensure that each header can be included individually without needing to include other headers first.
Sounds like a good objective.
Quoted 47 lines
Signed-off-by David Aguilar <[email protected]>---
This patch demonstrates how to verify PATCH 2/2.Makefile | 6 ++++++ check-headers.sh | 26 ++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 check-headers.shMakefile +6
-0@@ -2591,6 +2591,12 @@ check-docs:: check-builtins:: ./check-builtins.sh +### Make sure headers include their dependencies +# +check-headers:: + ./check-headers.sh $(CC) $(ALL_CFLAGS) + + ### Test suite coverage testing # .PHONY: coverage coverage-clean coverage-compile coverage-test coverage-reportcheck-headers.sh new file +15
-0@@ -0,0 +1,26 @@ +#!/bin/sh + +exit_code=0 + +maybe_exit () { + status="$1" + if test "$status" != 0 + then + exit_code="$status" + if test -n "$CHECK_HEADERS_STOP" + then + exit "$status" + fi + fi +}
Quoted 8 lines
check-headers.sh line 17
Quoted 2 lines
check-headers.sh new file +2
-0+ +git ls-files *.h |This checks all .h files in the top directory. Would it be better to check all files in
LIB_Hinstead? Or even all .h files in the tree (using "git ls-files '*.h'")? The latter might be difficult because some of the files in compat/ #include system-specific headers.
Ah, I hadn't thought of using LIB_H; that might be the most practical solution.
Changing it to quoted '*.h' finds compat/ files which seemed like too much trouble. OTOH blindly using all *.h files (i.e. not using git ls-files) picks up the generated common-cmds.h which would require changing generate-cmdlist.h, and that seemed like it might be out of scope for this patch.
I'd certainly be interested in improving this part, so I'll see if we can reformulate this patch to use LIB_H.
I'll also fixup the unneeded strbuf.h addition in the reroll.
Quoted 12 lines
Quoted 11 lines
check-headers.sh new file +9
-0+while read header +do + echo "HEADER $header" && + "$@" -Wno-unused -x c -c -o "$header".bin - <"$header" && + rm "$header".bin || + maybe_exit $? +done + +exit $exit_code
Signature · 1 line
David
Quoted 8 lines · David Aguilar
Quoted 5 lines
This checks all .h files in the top directory. Would it be better to check all files in
LIB_Hinstead? Or even all .h files in the tree (using "git ls-files '*.h'")? The latter might be difficult because some of the files in compat/ #include system-specific headers.Ah, I hadn't thought of using
LIB_H; that might be the most practical solution.
Maybe not; see d85b0dff7297fb43a57a0c1e697417bb7723247c, which is in 'next'.
-Peff
Quoted 8 lines · Jeff King
Quoted 6 lines · David Aguilar
Quoted 5 lines
This checks all .h files in the top directory. Would it be better to check all files in
LIB_Hinstead? Or even all .h files in the tree (using "git ls-files '*.h'")? The latter might be difficult because some of the files in compat/ #include system-specific headers.
Quoted 5 lines
Quoted 2 lines
Ah, I hadn't thought of using
LIB_H; that might be the most practical solution.Maybe not; see
d85b0dff7297fb43a57a0c1e697417bb7723247c, which is in 'next'.
Thanks for the heads-up. I'll send v2 now which will basically use the original approach plus a few extra paths so that we catch xdiff/, vcs-svn, and ewah/.
Widening any more (e.g. it would be nice to say compat/*.h too) breaks it due to platform-specific includes so it seems good enough for catching the main cross-platform headers.
Signature · 1 line
David