mirror of
https://github.com/reactos/CMake.git
synced 2025-02-24 14:00:38 +00:00
ENH: Added dump of more files. Improved robustness of dump.
This commit is contained in:
parent
f47b9d01ce
commit
c2b98959c5
@ -1,49 +1,71 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include "DumpInformation.h"
|
#include "DumpInformation.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
int DumpFile(char* filename, char* comment)
|
void cmDumpInformationPrintFile(const char* name, FILE* fout)
|
||||||
{
|
{
|
||||||
FILE* file = fopen(filename, "r");
|
fprintf(fout,
|
||||||
if(!file)
|
"================================================================\n");
|
||||||
|
struct stat fs;
|
||||||
|
if(stat(name, &fs) != 0)
|
||||||
{
|
{
|
||||||
printf("Error, could not open file %s\n", filename);
|
fprintf(fout, "The file \"%s\" does not exist.\n", name);
|
||||||
return 1;
|
fflush(fout);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
printf("%s", comment);
|
|
||||||
while(!feof(file))
|
FILE* fin = fopen(name, "rb");
|
||||||
|
if(fin)
|
||||||
{
|
{
|
||||||
int ch = fgetc(file);
|
fprintf(fout,
|
||||||
if(ch != EOF)
|
"Contents of \"%s\":\n"
|
||||||
|
"----------------------------------------------------------------\n",
|
||||||
|
name);
|
||||||
|
const int bufferSize = 4096;
|
||||||
|
char buffer[bufferSize];
|
||||||
|
int n;
|
||||||
|
while((n = fread(buffer, 1, bufferSize, fin)) > 0)
|
||||||
{
|
{
|
||||||
if(ch == '<')
|
for(char* c = buffer; c < buffer+n; ++c)
|
||||||
{
|
{
|
||||||
printf("<");
|
switch(*c)
|
||||||
}
|
{
|
||||||
else if(ch == '>')
|
case '<': fprintf(fout, "<"); break;
|
||||||
{
|
case '>': fprintf(fout, ">"); break;
|
||||||
printf(">");
|
case '&': fprintf(fout, "&"); break;
|
||||||
}
|
default: putc(*c, fout); break;
|
||||||
else if(ch == '&')
|
}
|
||||||
{
|
|
||||||
printf("&");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
putc(ch, stdout);
|
|
||||||
}
|
}
|
||||||
|
fflush(fout);
|
||||||
}
|
}
|
||||||
|
fclose(fin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(fout, "Error opening \"%s\" for reading.\n", name);
|
||||||
|
fflush(fout);
|
||||||
}
|
}
|
||||||
printf("\n");
|
|
||||||
fclose(file);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int,char *[])
|
||||||
int main(int, char*[])
|
|
||||||
{
|
{
|
||||||
int res = 0;
|
const char* files[] =
|
||||||
res += DumpFile(CMAKE_DUMP_FILE, "#CMake System Variables are:");
|
{
|
||||||
res += DumpFile(CMAKE_CACHE_FILE, "#CMake Cache is:");
|
DumpInformation_BINARY_DIR "/SystemInformation.out",
|
||||||
res += DumpFile(CMAKE_ALL_VARIABLES, "#CMake Variables are:");
|
DumpInformation_BINARY_DIR "/AllVariables.txt",
|
||||||
return res;
|
DumpInformation_BINARY_DIR "/../../Source/cmConfigure.h",
|
||||||
}
|
DumpInformation_BINARY_DIR "/../../CMakeCache.txt",
|
||||||
|
DumpInformation_BINARY_DIR "/../../CMakeOutput.log",
|
||||||
|
DumpInformation_BINARY_DIR "/../../CMakeError.log",
|
||||||
|
DumpInformation_BINARY_DIR "/../../Bootstrap.cmk/cmake_bootstrap.log",
|
||||||
|
0
|
||||||
|
};
|
||||||
|
|
||||||
|
const char** f;
|
||||||
|
for(f = files; *f; ++f)
|
||||||
|
{
|
||||||
|
cmDumpInformationPrintFile(*f, stdout);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
#define CMAKE_DUMP_FILE "${DumpInformation_BINARY_DIR}/SystemInformation.out"
|
#ifndef _DumpInformation_h
|
||||||
#define CMAKE_CACHE_FILE "${CMAKE_BINARY_DIR}/../../CMakeCache.txt"
|
#define _DumpInformation_h
|
||||||
#define CMAKE_ALL_VARIABLES "${CMAKE_BINARY_DIR}/AllVariables.txt"
|
|
||||||
|
#define DumpInformation_BINARY_DIR "@DumpInformation_BINARY_DIR@"
|
||||||
|
|
||||||
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user