[win32] Make cairo-perf-diff run on win32

This commit is contained in:
Frederic Plourde 2008-07-17 13:56:22 -07:00 committed by Vladimir Vukicevic
parent d61c7df1c0
commit 5284f8cab4
4 changed files with 84 additions and 3 deletions

View file

@ -41,6 +41,10 @@ $(CFG)/cairo-perf.exe: $(OBJECTS)
@mkdir -p $(CFG)
@$(CC) $(CFLAGS) -Fe"$@" $^ -link $(LDFLAGS)
cairo-perf-diff-files:
@mkdir -p $(CFG)
@$(CC) $(CFLAGS) -Fe"$@" cairo-perf-diff-files.c cairo-stats.c -link $(LDFLAGS)
clean:
@rm -f $(CFG)/*.obj $(CFG)/*.exe $(CFG)/*.dll $(CFG)/*.lib $(CFG)/*.pdb $(CFG)/*.ilk || exit 0

View file

@ -179,4 +179,25 @@ added:
above, three tests would be performed at sizes of 16x16, 32x32 and
64x64.
How to run cairo-perf-diff on WINDOWS
-------------------------------------
This section explains the specifics of running cairo-perf-diff under
win32 plateforms. It assumes that you have installed a UNIX-like shell
environment such as MSYS (distributed as part of MinGW).
1. From your Mingw32 window, be sure to have all of your MSVC environ-
ment variables set up for proper compilation using 'make'
2. Add the %GitBaseDir%/Git/bin path to your environment, replacing the
%GitBaseDir% by whatever directory your Git version is installed to.
3. Comment out the "UNSET CDPATH" line in the git-sh-setup script
(located inside the ...Git/bin directory) by putting a "#" at the
beginning of the line.
you should be ready to go !
From your mingw32 window, go to your cairo/perf directory and run the
cairo-perf-diff script with the right arguments.
Thanks for your contributions and have fun with cairo!

View file

@ -189,7 +189,11 @@ git_setup
# Build cairo-perf-diff-files if not available
if [ ! -e $CAIRO_DIR/perf/cairo-perf-diff-files ]; then
echo "Building cairo-perf-diff-files"
make -C $CAIRO_DIR/perf/ cairo-perf-diff-files
if [ $OS = "Windows_NT" ]; then
make -f Makefile.win32 -C $CAIRO_DIR/perf/ cairo-perf-diff-files CFG=debug
else
make -C $CAIRO_DIR/perf/ cairo-perf-diff-files
fi
fi
if [ ! -e $old ]; then

View file

@ -96,6 +96,12 @@ typedef struct _cairo_perf_diff_files_args {
cairo_perf_report_options_t options;
} cairo_perf_diff_files_args_t;
/* 'ssize_t' does not exist in the C standard on win32.
* We use 'ptrdiff_t', which is nearly equivalent. */
#ifdef _MSC_VER
typedef ptrdiff_t ssize_t;
#endif
#ifndef __USE_GNU
static ssize_t
getline (char **lineptr, size_t *n, FILE *stream);
@ -104,6 +110,14 @@ static char *
strndup (const char *s, size_t n);
#endif
#ifdef _MSC_VER
static long long
strtoll(const char *nptr, char **endptr, int base);
static char *
basename(char *path);
#endif
/* Ad-hoc parsing, macros with a strong dependence on the calling
* context, and plenty of other ugliness is here. But at least it's
* not perl... */
@ -304,6 +318,40 @@ strndup (const char *s, size_t n)
}
#endif /* ifndef __USE_GNU */
/* We provide hereafter a win32 implementation of the basename
* and strtoll functions which are not available otherwise.
* The basename function is fully compliant to its GNU specs.
*/
#ifdef _MSC_VER
long long
strtoll(const char *nptr, char **endptr, int base)
{
return _atoi64(nptr);
}
static char *
basename(char *path)
{
char *end, *s;
end = (path + strlen(path) - 1);
while (end && (end >= path + 1) && (*end == '/')) {
*end = '\0';
end--;
}
s = strrchr(path, '/');
if (s) {
if (s == end) {
return s;
} else {
return s+1;
}
} else {
return path;
}
}
#endif /* ifndef _MSC_VER */
static int
test_report_cmp_backend_then_name (const void *a, const void *b)
@ -397,9 +445,13 @@ cairo_perf_report_load (cairo_perf_report_t *report, const char *filename)
size_t line_size = 0;
char *configuration;
char *dot;
char *baseName;
configuration = strdup (filename);
report->configuration = strdup (basename (configuration));
configuration = xmalloc (strlen (filename) * sizeof (char) + 1);
strcpy (configuration, filename);
baseName = strdup (basename (configuration));
report->configuration = xmalloc (strlen (filename) * sizeof (char) + 1);
strcpy(report->configuration, baseName);
free (configuration);
dot = strrchr (report->configuration, '.');
if (dot)