makefiles: Generate the testlist.c files at make depend time.
This commit is contained in:
parent
fd9c9a6d03
commit
3bae3c6514
|
@ -302,6 +302,9 @@ wine_fn_clean_rules ()
|
|||
ac_clean=$[@]
|
||||
ac_extraclean="$ac_dir/Makefile"
|
||||
test "$srcdir" = . && ac_extraclean="$ac_extraclean $ac_dir/.gitignore"
|
||||
case $ac_dir in
|
||||
*/tests) ac_extraclean="$ac_extraclean $ac_dir/testlist.c" ;;
|
||||
esac
|
||||
|
||||
if wine_fn_has_flag clean
|
||||
then
|
||||
|
@ -587,7 +590,6 @@ wine_fn_config_test ()
|
|||
ac_clean=
|
||||
test -n "$CROSSTARGET" && ac_clean=`expr $ac_dir/${ac_name} : "\\(.*\\)_test"`_crosstest.exe
|
||||
test -n "$DLLEXT" || ac_clean="$ac_dir/${ac_name}.exe $ac_dir/${ac_name}-stripped.exe"
|
||||
ac_clean="$ac_clean $ac_dir/testlist.c"
|
||||
|
||||
AS_VAR_IF([enable_tests],[no],[wine_fn_disabled_rules $ac_clean; return])
|
||||
|
||||
|
|
|
@ -7144,6 +7144,9 @@ wine_fn_clean_rules ()
|
|||
ac_clean=$@
|
||||
ac_extraclean="$ac_dir/Makefile"
|
||||
test "$srcdir" = . && ac_extraclean="$ac_extraclean $ac_dir/.gitignore"
|
||||
case $ac_dir in
|
||||
*/tests) ac_extraclean="$ac_extraclean $ac_dir/testlist.c" ;;
|
||||
esac
|
||||
|
||||
if wine_fn_has_flag clean
|
||||
then
|
||||
|
@ -7441,7 +7444,6 @@ wine_fn_config_test ()
|
|||
ac_clean=
|
||||
test -n "$CROSSTARGET" && ac_clean=`expr $ac_dir/${ac_name} : "\\(.*\\)_test"`_crosstest.exe
|
||||
test -n "$DLLEXT" || ac_clean="$ac_dir/${ac_name}.exe $ac_dir/${ac_name}-stripped.exe"
|
||||
ac_clean="$ac_clean $ac_dir/testlist.c"
|
||||
|
||||
if test "x$enable_tests" = xno; then :
|
||||
wine_fn_disabled_rules $ac_clean; return
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
PROGRAMS = \
|
||||
make_ctests$(EXEEXT) \
|
||||
make_xftmpl$(EXEEXT)
|
||||
|
||||
MANPAGES = \
|
||||
|
@ -8,7 +7,6 @@ MANPAGES = \
|
|||
winemaker.man.in
|
||||
|
||||
C_SRCS = \
|
||||
make_ctests.c \
|
||||
make_xftmpl.c \
|
||||
makedep.c
|
||||
|
||||
|
@ -19,9 +17,6 @@ UPDATE_DESKTOP_DATABASE = update-desktop-database
|
|||
|
||||
all: wineapploader
|
||||
|
||||
make_ctests$(EXEEXT): make_ctests.o
|
||||
$(CC) $(CFLAGS) -o $@ make_ctests.o $(LDFLAGS)
|
||||
|
||||
make_xftmpl$(EXEEXT): make_xftmpl.o
|
||||
$(CC) $(CFLAGS) -o $@ make_xftmpl.o $(LIBPORT) $(LDFLAGS)
|
||||
|
||||
|
|
|
@ -1,160 +0,0 @@
|
|||
/*
|
||||
* Generate a C file containing a list of tests
|
||||
*
|
||||
* Copyright 2002, 2005 Alexandre Julliard
|
||||
* Copyright 2002 Dimitrie O. Paun
|
||||
* Copyright 2005 Royce Mitchell III for the ReactOS Project
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
****** Keep in sync with tools/winapi/msvcmaker:_generate_testlist_c *****
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
static const char *output_file;
|
||||
|
||||
static void cleanup_files(void)
|
||||
{
|
||||
if (output_file) unlink( output_file );
|
||||
}
|
||||
|
||||
static void exit_on_signal( int sig )
|
||||
{
|
||||
exit(1); /* this will call the atexit functions */
|
||||
}
|
||||
|
||||
static void fatal_error( const char *msg, ... )
|
||||
{
|
||||
va_list valist;
|
||||
va_start( valist, msg );
|
||||
fprintf( stderr, "make_ctests: " );
|
||||
vfprintf( stderr, msg, valist );
|
||||
va_end( valist );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void fatal_perror( const char *msg, ... )
|
||||
{
|
||||
va_list valist;
|
||||
va_start( valist, msg );
|
||||
fprintf( stderr, "make_ctests: " );
|
||||
vfprintf( stderr, msg, valist );
|
||||
perror( " " );
|
||||
va_end( valist );
|
||||
exit(1);
|
||||
}
|
||||
|
||||
static void *xmalloc( size_t size )
|
||||
{
|
||||
void *res = malloc (size ? size : 1);
|
||||
if (!res) fatal_error( "virtual memory exhausted.\n" );
|
||||
return res;
|
||||
}
|
||||
|
||||
static char* basename( const char* filename )
|
||||
{
|
||||
const char *p, *p2;
|
||||
char *out;
|
||||
size_t out_len;
|
||||
|
||||
p = strrchr ( filename, '/' );
|
||||
if ( !p )
|
||||
p = filename;
|
||||
else
|
||||
++p;
|
||||
|
||||
/* look for backslashes, too... */
|
||||
p2 = strrchr ( p, '\\' );
|
||||
if ( p2 ) p = p2 + 1;
|
||||
|
||||
/* find extension... */
|
||||
p2 = strrchr ( p, '.' );
|
||||
if ( !p2 )
|
||||
p2 = p + strlen(p);
|
||||
|
||||
/* malloc a copy */
|
||||
out_len = p2-p;
|
||||
out = xmalloc ( out_len+1 );
|
||||
memcpy ( out, p, out_len );
|
||||
out[out_len] = '\0';
|
||||
return out;
|
||||
}
|
||||
|
||||
int main( int argc, const char** argv )
|
||||
{
|
||||
int i, count = 0;
|
||||
FILE *out = stdout;
|
||||
char **tests = xmalloc( argc * sizeof(*tests) );
|
||||
|
||||
for (i = 1; i < argc; i++)
|
||||
{
|
||||
if (!strcmp( argv[i], "-o" ) && i < argc-1)
|
||||
{
|
||||
output_file = argv[++i];
|
||||
continue;
|
||||
}
|
||||
tests[count++] = basename( argv[i] );
|
||||
}
|
||||
|
||||
atexit( cleanup_files );
|
||||
signal( SIGTERM, exit_on_signal );
|
||||
signal( SIGINT, exit_on_signal );
|
||||
#ifdef SIGHUP
|
||||
signal( SIGHUP, exit_on_signal );
|
||||
#endif
|
||||
|
||||
if (output_file)
|
||||
{
|
||||
if (!(out = fopen( output_file, "w" )))
|
||||
fatal_perror( "cannot create %s", output_file );
|
||||
}
|
||||
|
||||
fprintf( out,
|
||||
"/* Automatically generated file; DO NOT EDIT!! */\n"
|
||||
"\n"
|
||||
"#define WIN32_LEAN_AND_MEAN\n"
|
||||
"#include <windows.h>\n\n"
|
||||
"#define STANDALONE\n"
|
||||
"#include \"wine/test.h\"\n\n" );
|
||||
|
||||
for (i = 0; i < count; i++) fprintf( out, "extern void func_%s(void);\n", tests[i] );
|
||||
|
||||
fprintf( out,
|
||||
"\n"
|
||||
"const struct test winetest_testlist[] =\n"
|
||||
"{\n" );
|
||||
|
||||
for (i = 0; i < count; i++) fprintf( out, " { \"%s\", func_%s },\n", tests[i], tests[i] );
|
||||
|
||||
fprintf( out,
|
||||
" { 0, 0 }\n"
|
||||
"};\n" );
|
||||
|
||||
if (output_file && fclose( out ))
|
||||
fatal_perror( "error writing to %s", output_file );
|
||||
|
||||
output_file = NULL;
|
||||
return 0;
|
||||
}
|
108
tools/makedep.c
108
tools/makedep.c
|
@ -100,6 +100,7 @@ static struct strarray dllflags;
|
|||
static struct strarray imports;
|
||||
static struct strarray make_vars;
|
||||
static struct strarray cmdline_vars;
|
||||
static struct strarray testlist_files;
|
||||
|
||||
static const char *base_dir;
|
||||
static const char *src_dir;
|
||||
|
@ -1453,7 +1454,7 @@ static struct strarray output_sources(void)
|
|||
struct strarray po_files = empty_strarray;
|
||||
struct strarray mo_files = empty_strarray;
|
||||
struct strarray mc_files = empty_strarray;
|
||||
struct strarray test_files = empty_strarray;
|
||||
struct strarray ok_files = empty_strarray;
|
||||
struct strarray dlldata_files = empty_strarray;
|
||||
struct strarray c2man_files = empty_strarray;
|
||||
struct strarray implib_objs = empty_strarray;
|
||||
|
@ -1693,7 +1694,8 @@ static struct strarray output_sources(void)
|
|||
{
|
||||
int need_cross = testdll || (source->flags & FLAG_C_IMPLIB) || (module && staticlib);
|
||||
|
||||
if (source->flags & FLAG_GENERATED) strarray_add( &clean_files, source->filename );
|
||||
if ((source->flags & FLAG_GENERATED) && (!testdll || strcmp( source->filename, "testlist.c" )))
|
||||
strarray_add( &clean_files, source->filename );
|
||||
if (source->flags & FLAG_C_IMPLIB) strarray_add( &implib_objs, strmake( "%s.o", obj ));
|
||||
strarray_add( &object_files, strmake( "%s.o", obj ));
|
||||
output( "%s.o: %s\n", obj, source->filename );
|
||||
|
@ -1721,7 +1723,7 @@ static struct strarray output_sources(void)
|
|||
}
|
||||
if (testdll && !strcmp( ext, "c" ) && !(source->flags & FLAG_GENERATED))
|
||||
{
|
||||
strarray_add( &test_files, source->name );
|
||||
strarray_add( &ok_files, strmake( "%s.ok", obj ));
|
||||
output( "%s.ok:\n", obj );
|
||||
output( "\t%s $(RUNTESTFLAGS) -T %s -M %s -p %s%s %s && touch $@\n",
|
||||
top_dir_path( "tools/runtest" ), top_obj_dir,
|
||||
|
@ -1938,7 +1940,6 @@ static struct strarray output_sources(void)
|
|||
|
||||
if (testdll)
|
||||
{
|
||||
struct strarray ok_files = strarray_replace_extension( &test_files, ".c", ".ok" );
|
||||
char *testmodule = replace_extension( testdll, ".dll", "_test.exe" );
|
||||
char *stripped = replace_extension( testdll, ".dll", "_test-stripped.exe" );
|
||||
struct strarray all_libs = empty_strarray;
|
||||
|
@ -2009,11 +2010,6 @@ static struct strarray output_sources(void)
|
|||
strarray_add( &phony_targets, "crosstest" );
|
||||
}
|
||||
|
||||
output( "testlist.c: %s%s %s\n",
|
||||
tools_dir_path( "make_ctests" ), tools_ext, src_dir_path( "Makefile.in" ));
|
||||
output( "\t%s%s -o $@", tools_dir_path( "make_ctests" ), tools_ext );
|
||||
output_filenames( test_files );
|
||||
output( "\n" );
|
||||
output_filenames( ok_files );
|
||||
output( ": %s%s ../%s%s\n", testmodule, dllext, testdll, dllext );
|
||||
output( "check test:" );
|
||||
|
@ -2027,6 +2023,7 @@ static struct strarray output_sources(void)
|
|||
strarray_add( &phony_targets, "check" );
|
||||
strarray_add( &phony_targets, "test" );
|
||||
strarray_add( &phony_targets, "testclean" );
|
||||
testlist_files = strarray_replace_extension( &ok_files, ".ok", "" );
|
||||
}
|
||||
|
||||
if (all_targets.count)
|
||||
|
@ -2115,22 +2112,92 @@ static void rename_temp_file( const char *dest )
|
|||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* are_files_identical
|
||||
*/
|
||||
static int are_files_identical( FILE *file1, FILE *file2 )
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
char buffer1[8192], buffer2[8192];
|
||||
int size1 = fread( buffer1, 1, sizeof(buffer1), file1 );
|
||||
int size2 = fread( buffer2, 1, sizeof(buffer2), file2 );
|
||||
if (size1 != size2) return 0;
|
||||
if (!size1) return feof( file1 ) && feof( file2 );
|
||||
if (memcmp( buffer1, buffer2, size1 )) return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* rename_temp_file_if_changed
|
||||
*/
|
||||
static void rename_temp_file_if_changed( const char *dest )
|
||||
{
|
||||
FILE *file1, *file2;
|
||||
int do_rename = 1;
|
||||
|
||||
if ((file1 = fopen( dest, "r" )))
|
||||
{
|
||||
if ((file2 = fopen( temp_file_name, "r" )))
|
||||
{
|
||||
do_rename = !are_files_identical( file1, file2 );
|
||||
fclose( file2 );
|
||||
}
|
||||
fclose( file1 );
|
||||
}
|
||||
if (!do_rename)
|
||||
{
|
||||
unlink( temp_file_name );
|
||||
temp_file_name = NULL;
|
||||
}
|
||||
else rename_temp_file( dest );
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* output_testlist
|
||||
*/
|
||||
static void output_testlist( const char *dest, struct strarray files )
|
||||
{
|
||||
int i;
|
||||
|
||||
output_file = create_temp_file( dest );
|
||||
|
||||
output( "/* Automatically generated by make depend; DO NOT EDIT!! */\n\n" );
|
||||
output( "#define WIN32_LEAN_AND_MEAN\n" );
|
||||
output( "#include <windows.h>\n\n" );
|
||||
output( "#define STANDALONE\n" );
|
||||
output( "#include \"wine/test.h\"\n\n" );
|
||||
|
||||
for (i = 0; i < files.count; i++) output( "extern void func_%s(void);\n", files.str[i] );
|
||||
output( "\n" );
|
||||
output( "const struct test winetest_testlist[] =\n" );
|
||||
output( "{\n" );
|
||||
for (i = 0; i < files.count; i++) output( " { \"%s\", func_%s },\n", files.str[i], files.str[i] );
|
||||
output( " { 0, 0 }\n" );
|
||||
output( "};\n" );
|
||||
|
||||
if (fclose( output_file )) fatal_perror( "write" );
|
||||
output_file = NULL;
|
||||
rename_temp_file_if_changed( dest );
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************
|
||||
* output_gitignore
|
||||
*/
|
||||
static void output_gitignore( const char *dest, const struct strarray *files )
|
||||
static void output_gitignore( const char *dest, struct strarray files )
|
||||
{
|
||||
int i;
|
||||
|
||||
output_file = create_temp_file( dest );
|
||||
|
||||
output( "# Automatically generated by make depend; DO NOT EDIT!!\n" );
|
||||
output( "/.gitignore\n" );
|
||||
output( "/Makefile\n" );
|
||||
for (i = 0; i < files->count; i++)
|
||||
for (i = 0; i < files.count; i++)
|
||||
{
|
||||
if (!strchr( files->str[i], '/' )) output( "/" );
|
||||
output( "%s\n", files->str[i] );
|
||||
if (!strchr( files.str[i], '/' )) output( "/" );
|
||||
output( "%s\n", files.str[i] );
|
||||
}
|
||||
|
||||
if (fclose( output_file )) fatal_perror( "write" );
|
||||
|
@ -2144,7 +2211,7 @@ static void output_gitignore( const char *dest, const struct strarray *files )
|
|||
*/
|
||||
static void output_dependencies( const char *path )
|
||||
{
|
||||
struct strarray targets = empty_strarray;
|
||||
struct strarray targets, ignore_files = empty_strarray;
|
||||
|
||||
if (Separator && ((output_file = fopen( path, "r" ))))
|
||||
{
|
||||
|
@ -2167,13 +2234,20 @@ static void output_dependencies( const char *path )
|
|||
fatal_perror( "%s", path );
|
||||
}
|
||||
|
||||
testlist_files = empty_strarray;
|
||||
targets = output_sources();
|
||||
|
||||
fclose( output_file );
|
||||
output_file = NULL;
|
||||
if (temp_file_name) rename_temp_file( path );
|
||||
|
||||
if (!src_dir && base_dir) output_gitignore( base_dir_path( ".gitignore" ), &targets );
|
||||
strarray_add( &ignore_files, ".gitignore" );
|
||||
strarray_add( &ignore_files, "Makefile" );
|
||||
if (testlist_files.count) strarray_add( &ignore_files, "testlist.c" );
|
||||
strarray_addall( &ignore_files, targets );
|
||||
|
||||
if (testlist_files.count) output_testlist( base_dir_path( "testlist.c" ), testlist_files );
|
||||
if (!src_dir && base_dir) output_gitignore( base_dir_path( ".gitignore" ), ignore_files );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue