Skip to content

Commit 117f6e6

Browse files
author
senmiao
committed
fix:Xcode8 Support
1 parent 0cf5353 commit 117f6e6

File tree

7 files changed

+397
-47
lines changed

7 files changed

+397
-47
lines changed

lcov-1.12/bin/copy_dates.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
#
3+
# Usage: copy_dates.sh SOURCE TARGET
4+
#
5+
# For each file found in SOURCE, set the modification time of the copy of that
6+
# file in TARGET to either the time of the latest Git commit (if SOURCE contains
7+
# a Git repository and the file was not modified after the last commit), or the
8+
# modification time of the original file.
9+
10+
SOURCE="$1"
11+
TARGET="$2"
12+
13+
if [ -z "$SOURCE" -o -z "$TARGET" ] ; then
14+
echo "Usage: $0 SOURCE TARGET" >&2
15+
exit 1
16+
fi
17+
18+
[ -d "$SOURCE/.git" ] ; NOGIT=$?
19+
20+
echo "Copying modification/commit times from $SOURCE to $TARGET"
21+
22+
cd "$SOURCE" || exit 1
23+
find * -type f | while read FILENAME ; do
24+
[ ! -e "$TARGET/$FILENAME" ] && continue
25+
26+
# Copy modification time
27+
touch -m "$TARGET/$FILENAME" -r "$FILENAME"
28+
29+
[ $NOGIT -eq 1 ] && continue # No Git
30+
git diff --quiet -- "$FILENAME" || continue # Modified
31+
git diff --quiet --cached -- "$FILENAME" || continue # Modified
32+
33+
# Apply modification time from Git commit time
34+
TIME=$(git log --pretty=format:%cd -n 1 --date=iso -- "$FILENAME")
35+
[ -n "$TIME" ] && touch -m "$TARGET/$FILENAME" --date "$TIME"
36+
done

lcov-1.12/bin/genhtml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ if (defined($opt_config_file)) {
350350
elsif (-r "/etc/lcovrc")
351351
{
352352
$config = read_config("/etc/lcovrc");
353+
} elsif (-r "/usr/local/etc/lcovrc")
354+
{
355+
$config = read_config("/usr/local/etc/lcovrc");
353356
}
354357

355358
if ($config || %opt_rc)
@@ -3848,8 +3851,8 @@ sub fmt_centered($$)
38483851
{
38493852
my ($width, $text) = @_;
38503853
my $w0 = length($text);
3851-
my $w1 = int(($width - $w0) / 2);
3852-
my $w2 = $width - $w0 - $w1;
3854+
my $w1 = $width > $w0 ? int(($width - $w0) / 2) : 0;
3855+
my $w2 = $width > $w0 ? $width - $w0 - $w1 : 0;
38533856

38543857
return (" "x$w1).$text.(" "x$w2);
38553858
}
@@ -5325,6 +5328,7 @@ sub demangle_list($)
53255328
my $tmpfile;
53265329
my $handle;
53275330
my %demangle;
5331+
my $demangle_arg = "";
53285332
my %versions;
53295333

53305334
# Write function names to file
@@ -5333,8 +5337,14 @@ sub demangle_list($)
53335337
print($handle join("\n", @$list));
53345338
close($handle);
53355339

5340+
# Extra flag necessary on OS X so that symbols listed by gcov get demangled
5341+
# properly.
5342+
if ($^O eq "darwin") {
5343+
$demangle_arg = "--no-strip-underscores";
5344+
}
5345+
53365346
# Build translation hash from c++filt output
5337-
open($handle, "-|", "c++filt < $tmpfile") or
5347+
open($handle, "-|", "c++filt $demangle_arg < $tmpfile") or
53385348
die("ERROR: could not run c++filt: $!\n");
53395349
foreach my $func (@$list) {
53405350
my $translated = <$handle>;

lcov-1.12/bin/geninfo

Lines changed: 67 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ sub solve_relative_path($$);
160160
sub read_gcov_header($);
161161
sub read_gcov_file($);
162162
sub info(@);
163+
sub map_llvm_version($);
164+
sub version_to_str($);
163165
sub get_gcov_version();
164166
sub system_no_output($@);
165167
sub read_config($);
@@ -304,6 +306,9 @@ if (defined($opt_config_file)) {
304306
elsif (-r "/etc/lcovrc")
305307
{
306308
$config = read_config("/etc/lcovrc");
309+
} elsif (-r "/usr/local/etc/lcovrc")
310+
{
311+
$config = read_config("/usr/local/etc/lcovrc");
307312
}
308313

309314
if ($config || %opt_rc)
@@ -1898,6 +1903,36 @@ sub read_gcov_file($)
18981903
}
18991904

19001905

1906+
# Map LLVM versions to the version of GCC gcov which they emulate.
1907+
1908+
sub map_llvm_version($)
1909+
{
1910+
my ($ver) = @_;
1911+
1912+
return 0x040200 if ($ver >= 0x030400);
1913+
1914+
warn("WARNING: This version of LLVM's gcov is unknown. ".
1915+
"Assuming it emulates GCC gcov version 4.2.\n");
1916+
1917+
return 0x040200;
1918+
}
1919+
1920+
1921+
# Return a readable version of encoded gcov version.
1922+
1923+
sub version_to_str($)
1924+
{
1925+
my ($ver) = @_;
1926+
my ($a, $b, $c);
1927+
1928+
$a = $ver >> 16 & 0xff;
1929+
$b = $ver >> 8 & 0xff;
1930+
$c = $ver & 0xff;
1931+
1932+
return "$a.$b.$c";
1933+
}
1934+
1935+
19011936
#
19021937
# Get the GCOV tool version. Return an integer number which represents the
19031938
# GCOV version. Version numbers can be compared using standard integer
@@ -1909,58 +1944,48 @@ sub get_gcov_version()
19091944
local *HANDLE;
19101945
my $version_string;
19111946
my $result;
1912-
my $pipe_next_line;
1947+
my ($a, $b, $c) = (4, 2, 0); # Fallback version
1948+
1949+
# Examples for gcov version output:
1950+
#
1951+
# gcov (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
1952+
#
1953+
# gcov (crosstool-NG 1.18.0) 4.7.2
1954+
#
1955+
# LLVM (http://llvm.org/):
1956+
# LLVM version 3.4svn
1957+
#
1958+
# Apple LLVM version 8.0.0 (clang-800.0.38)
1959+
# Optimized build.
1960+
# Default target: x86_64-apple-darwin16.0.0
1961+
# Host CPU: haswell
19131962

19141963
open(GCOV_PIPE, "-|", "$gcov_tool --version")
19151964
or die("ERROR: cannot retrieve gcov version!\n");
1965+
local $/;
19161966
$version_string = <GCOV_PIPE>;
1917-
# LLVM gcov keeps version information on the second line.
1918-
# For example, gcov --version yields:
1919-
# LLVM (http://llvm.org/):
1920-
# LLVM version 3.4svn
1921-
1922-
$pipe_next_line = <GCOV_PIPE>;
1923-
# In case version information is on first line.
1924-
# For example, with Xcode 7.0 gcov --version yields:
1925-
# Apple LLVM 7.0.0 (clang-700.0.65)
1926-
1927-
$version_string = $pipe_next_line if ($pipe_next_line && $version_string =~ /LLVM/);
19281967
close(GCOV_PIPE);
19291968

1930-
# Remove version information in parenthesis to cope with the following:
1931-
# - gcov (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3)
1932-
# - gcov (crosstool-NG 1.18.0) 4.7.2
1969+
# Remove all bracketed information
19331970
$version_string =~ s/\([^\)]*\)//g;
19341971

1935-
$result = 0;
1936-
if ($version_string =~ /(\d+)\.(\d+)(\.(\d+))?/)
1937-
{
1938-
if (defined($4))
1939-
{
1940-
info("Found gcov version: $1.$2.$4\n");
1941-
$result = $1 << 16 | $2 << 8 | $4;
1942-
}
1943-
else
1944-
{
1945-
info("Found gcov version: $1.$2\n");
1946-
$result = $1 << 16 | $2 << 8;
1947-
}
1972+
if ($version_string =~ /(\d+)\.(\d+)(\.(\d+))?/) {
1973+
($a, $b, $c) = ($1, $2, $4);
1974+
$c = 0 if (!defined($c));
1975+
} else {
1976+
warn("WARNING: cannot determine gcov version - ".
1977+
"assuming $a.$b.$c\n");
19481978
}
1949-
if ($version_string =~ /LLVM/)
1950-
{
1951-
# Map LLVM versions to the version of GCC gcov which
1952-
# they emulate
1953-
if ($result >= 0x030400)
1954-
{
1955-
info("Found LLVM gcov version 3.4, which emulates gcov version 4.2\n");
1956-
$result = 0x040200;
1957-
}
1958-
else
1959-
{
1960-
warn("This version of LLVM's gcov is unknown. Assuming it emulates GCC gcov version 4.2.\n");
1961-
$result = 0x040200;
1962-
}
1979+
$result = $a << 16 | $b << 8 | $c;
1980+
1981+
if ($version_string =~ /LLVM/) {
1982+
$result = map_llvm_version($result);
1983+
info("Found LLVM gcov version $a.$b.$c, which emulates gcov ".
1984+
"version ".version_to_str($result)."\n");
1985+
} else {
1986+
info("Found gcov version: ".version_to_str($result)."\n");
19631987
}
1988+
19641989
return ($result, $version_string);
19651990
}
19661991

lcov-1.12/bin/get_changes.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
#
3+
# Usage: get_changes.sh
4+
#
5+
# Print lcov change log information as provided by Git
6+
7+
TOOLDIR=$(cd $(dirname $0) ; pwd)
8+
9+
cd $TOOLDIR
10+
11+
if ! git --no-pager log --no-merges --decorate=short --color=never 2>/dev/null ; then
12+
cat "$TOOLDIR/../CHANGES" 2>/dev/null
13+
fi

lcov-1.12/bin/install.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
#
3+
# install.sh [--uninstall] sourcefile targetfile [install options]
4+
#
5+
6+
7+
# Check for uninstall option
8+
if test "x$1" == "x--uninstall" ; then
9+
UNINSTALL=true
10+
SOURCE=$2
11+
TARGET=$3
12+
shift 3
13+
else
14+
UNINSTALL=false
15+
SOURCE=$1
16+
TARGET=$2
17+
shift 2
18+
fi
19+
20+
# Check usage
21+
if test -z "$SOURCE" || test -z "$TARGET" ; then
22+
echo Usage: install.sh [--uninstall] source target [install options] >&2
23+
exit 1
24+
fi
25+
26+
27+
#
28+
# do_install(SOURCE_FILE, TARGET_FILE)
29+
#
30+
31+
do_install()
32+
{
33+
local SOURCE=$1
34+
local TARGET=$2
35+
local PARAMS=$3
36+
37+
install -p -D $PARAMS $SOURCE $TARGET
38+
}
39+
40+
41+
#
42+
# do_uninstall(SOURCE_FILE, TARGET_FILE)
43+
#
44+
45+
do_uninstall()
46+
{
47+
local SOURCE=$1
48+
local TARGET=$2
49+
50+
# Does target exist?
51+
if test -r $TARGET ; then
52+
# Is target of the same version as this package?
53+
if diff -I '^our \$lcov_version' -I '^\.TH ' $SOURCE $TARGET >/dev/null; then
54+
rm -f $TARGET
55+
else
56+
echo WARNING: Skipping uninstall for $TARGET - versions differ! >&2
57+
fi
58+
else
59+
echo WARNING: Skipping uninstall for $TARGET - not installed! >&2
60+
fi
61+
}
62+
63+
64+
# Call sub routine
65+
if $UNINSTALL ; then
66+
do_uninstall $SOURCE $TARGET
67+
else
68+
do_install $SOURCE $TARGET "$*"
69+
fi
70+
71+
exit 0

lcov-1.12/bin/lcov

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,9 @@ if (defined($opt_config_file)) {
243243
elsif (-r "/etc/lcovrc")
244244
{
245245
$config = read_config("/etc/lcovrc");
246+
} elsif (-r "/usr/local/etc/lcovrc")
247+
{
248+
$config = read_config("/usr/local/etc/lcovrc");
246249
}
247250

248251
if ($config || %opt_rc)
@@ -2915,7 +2918,7 @@ sub remove()
29152918

29162919
foreach $pattern (@pattern_list)
29172920
{
2918-
$match_found ||= ($filename =~ (/$pattern$/));
2921+
$match_found ||= ($filename =~ (/^$pattern$/));
29192922
}
29202923

29212924

@@ -4250,7 +4253,6 @@ sub warn_handler($)
42504253
{
42514254
my ($msg) = @_;
42524255

4253-
temp_cleanup();
42544256
warn("$tool_name: $msg");
42554257
}
42564258

0 commit comments

Comments
 (0)