Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
e69278eb
Commit
e69278eb
authored
15 years ago
by
mh17
Browse files
Options
Downloads
Patches
Plain Diff
script to report header modularity violations
parent
237440af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/includes.php
+124
-0
124 additions, 0 deletions
scripts/includes.php
with
124 additions
and
0 deletions
scripts/includes.php
0 → 100755
+
124
−
0
View file @
e69278eb
#!/usr/bin/php
<?php
/*
includes.php, mh17 Feb 2010
Copyright (c) 2010 Genome research Ltd
Check the source tree for C files that include headers they should not
use find to get all the header files and note nested includes using grep
process header path name to get file and path
use find to get all the C files and list included headers using grep
ignore file names not beginning with zmap
report:
files included more than once
*_I.h and *_P.h included from another directory
NB: Only deals with include as <file> not "file"
We assume the file names are unique
-> they must be as they are included without directory names (except for include/ZMap)
*/
// NB: run from the ZMap source directory
/*
$strict = FALSE;
for($i = 1;$i < $argc;$i++)
{
$arg = $argv[$i];
if($arg == "-strict")
$strict = TRUE;
else
{
print ("error in arg $arg\n");
exit;
}
}
*/
$headers
=
array
();
function
get_includes
(
$file
)
{
$inc
=
array
();
$cmd
=
"grep
\"
#include
\"
$file
"
;
exec
(
$cmd
,
$ifiles
=
array
());
foreach
(
$ifiles
as
$f
)
{
$name
=
explode
(
'>'
,
$f
);
$name
=
explode
(
'<'
,
$name
[
0
]);
$name
=
$name
[
1
];
$name
=
explode
(
'/'
,
$name
);
$name
=
array_pop
(
$name
);
if
(
!
strncmp
(
$name
,
"zmap"
,
4
))
{
$inc
[
$name
]
=
1
;
}
}
return
(
$inc
);
}
// check that included files do not violate design modularity
// private headers are not to be included from other directories
function
vet
(
$file
,
$dir
,
$inc
)
{
global
$headers
;
foreach
(
$inc
as
$f
=>
$x
)
{
if
(
strpos
(
$f
,
"_I"
)
!==
FALSE
||
strpos
(
$f
,
"_P"
)
!==
FALSE
)
// private header
{
$head
=
$headers
[
$f
];
$hd
=
$head
[
'dir'
];
if
(
strcmp
(
$hd
,
$dir
))
{
print
(
"
$dir
/
$file
includes
$hd
/
$f
\n
"
);
}
}
}
}
// find all the headers and the files they include
exec
(
'find . -name "*.h"'
,
$h_path
=
array
());
foreach
(
$h_path
as
$h
)
{
$names
=
explode
(
"/"
,
$h
);
$file
=
array_pop
(
$names
);
$dir
=
implode
(
"/"
,
$names
);
if
(
!
strncmp
(
$file
,
"zmap"
,
4
))
{
$headers
[
$file
]
=
array
(
'dir'
=>
$dir
);
$headers
[
$file
][
'includes'
]
=
get_includes
(
$h
);
}
}
// find the nested headers in each header
foreach
(
$headers
as
$file
=>
$head
)
{
vet
(
$file
,
$head
[
'dir'
],
$head
[
'includes'
]);
}
// find all the source files and the headers they include
exec
(
'find . -name "*.c"'
,
$c_path
=
array
());
foreach
(
$c_path
as
$c
)
{
$names
=
explode
(
"/"
,
$c
);
$file
=
array_pop
(
$names
);
$dir
=
implode
(
"/"
,
$names
);
$inc
=
get_includes
(
$c
);
vet
(
$file
,
$dir
,
$inc
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment