mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-23 16:20:57 +08:00
HDFFV-9059 Allow detect to take a file as an argument
This commit is contained in:
parent
fbf837eac3
commit
99f743ed1a
@ -148,7 +148,7 @@ New Features
|
||||
Java Library:
|
||||
----------------
|
||||
- JNI native library dependencies
|
||||
|
||||
|
||||
The build for the hdf5_java native library used the wrong
|
||||
hdf5 target library for CMake builds. Correcting the hdf5_java
|
||||
library to build with the shared hdf5 library required testing
|
||||
@ -209,6 +209,15 @@ Bug Fixes since HDF5-1.10.3 release
|
||||
|
||||
Library
|
||||
-------
|
||||
- Allow H5detect and H5make_libsettings to take a file as an argument.
|
||||
|
||||
Rather than only writing to stdout, add a command argument to name
|
||||
the file that H5detect and H5make_libsettings will use for output.
|
||||
Without an argument, stdout is still used, so backwards compatibility
|
||||
is maintained.
|
||||
|
||||
(ADB - 2018/09/05, HDFFV-9059)
|
||||
|
||||
- A bug was discovered in the parallel library where an application
|
||||
would hang if a collective read/write of a chunked dataset occurred
|
||||
when collective metadata reads were enabled and some of the ranks
|
||||
|
@ -854,7 +854,7 @@ endif ()
|
||||
# specific type checks inside
|
||||
#-----------------------------------------------------------------------------
|
||||
add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c)
|
||||
target_include_directories(H5detect PRIVATE "${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
|
||||
target_include_directories(H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
|
||||
target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
|
||||
TARGET_C_PROPERTIES (H5detect STATIC)
|
||||
target_link_libraries (H5detect
|
||||
@ -865,12 +865,12 @@ target_link_libraries (H5detect
|
||||
add_custom_command (
|
||||
OUTPUT ${HDF5_BINARY_DIR}/H5Tinit.c
|
||||
COMMAND $<TARGET_FILE:H5detect>
|
||||
ARGS > ${HDF5_BINARY_DIR}/H5Tinit.c
|
||||
ARGS ${HDF5_BINARY_DIR}/H5Tinit.c
|
||||
DEPENDS H5detect
|
||||
)
|
||||
|
||||
add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c)
|
||||
target_include_directories(H5make_libsettings PRIVATE "${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
|
||||
target_include_directories(H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
|
||||
target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
|
||||
TARGET_C_PROPERTIES (H5make_libsettings STATIC)
|
||||
target_link_libraries (H5make_libsettings
|
||||
@ -881,7 +881,7 @@ target_link_libraries (H5make_libsettings
|
||||
add_custom_command (
|
||||
OUTPUT ${HDF5_BINARY_DIR}/H5lib_settings.c
|
||||
COMMAND $<TARGET_FILE:H5make_libsettings>
|
||||
ARGS > ${HDF5_BINARY_DIR}/H5lib_settings.c
|
||||
ARGS ${HDF5_BINARY_DIR}/H5lib_settings.c
|
||||
DEPENDS H5make_libsettings
|
||||
WORKING_DIRECTORY ${HDF5_BINARY_DIR}
|
||||
)
|
||||
@ -925,14 +925,14 @@ if (BUILD_SHARED_LIBS)
|
||||
add_custom_command (
|
||||
OUTPUT ${HDF5_BINARY_DIR}/shared/H5Tinit.c
|
||||
COMMAND $<TARGET_FILE:H5detect>
|
||||
ARGS > ${HDF5_BINARY_DIR}/shared/H5Tinit.c
|
||||
ARGS ${HDF5_BINARY_DIR}/shared/H5Tinit.c
|
||||
DEPENDS H5detect
|
||||
WORKING_DIRECTORY ${HDF5_BINARY_DIR}/shared
|
||||
)
|
||||
add_custom_command (
|
||||
OUTPUT ${HDF5_BINARY_DIR}/shared/H5lib_settings.c
|
||||
COMMAND $<TARGET_FILE:H5make_libsettings>
|
||||
ARGS > ${HDF5_BINARY_DIR}/shared/H5lib_settings.c
|
||||
ARGS ${HDF5_BINARY_DIR}/shared/H5lib_settings.c
|
||||
DEPENDS H5make_libsettings
|
||||
WORKING_DIRECTORY ${HDF5_BINARY_DIR}
|
||||
)
|
||||
|
705
src/H5detect.c
705
src/H5detect.c
File diff suppressed because it is too large
Load Diff
@ -27,12 +27,12 @@ static const char *FileHeader = "\n\
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *";
|
||||
/*
|
||||
*
|
||||
* Created: H5make_libsettings.c
|
||||
* 17 Mar 2010
|
||||
* Quincey Koziol
|
||||
* Created: H5make_libsettings.c
|
||||
* 17 Mar 2010
|
||||
* Quincey Koziol
|
||||
*
|
||||
* Purpose: Generate the H5libsettings.c file from the
|
||||
* libhdf5.settings file.
|
||||
* Purpose: Generate the H5libsettings.c file from the
|
||||
* libhdf5.settings file.
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -43,19 +43,18 @@ static const char *FileHeader = "\n\
|
||||
|
||||
#define LIBSETTINGSFNAME "libhdf5.settings"
|
||||
|
||||
|
||||
FILE *rawoutstream = NULL;
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: insert_libhdf5_settings
|
||||
* Function: insert_libhdf5_settings
|
||||
*
|
||||
* Purpose: insert the contents of libhdf5.settings into a file
|
||||
* represented by flibinfo.
|
||||
* Make it an empty string if H5_HAVE_EMBEDDED_LIBINFO is not
|
||||
* defined, i.e., not enabled.
|
||||
* Purpose: insert the contents of libhdf5.settings into a file
|
||||
* represented by flibinfo.
|
||||
* Make it an empty string if H5_HAVE_EMBEDDED_LIBINFO is not
|
||||
* defined, i.e., not enabled.
|
||||
*
|
||||
* Return: void
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* Apr 20, 2009
|
||||
* Return: void
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -63,9 +62,9 @@ static void
|
||||
insert_libhdf5_settings(FILE *flibinfo)
|
||||
{
|
||||
#ifdef H5_HAVE_EMBEDDED_LIBINFO
|
||||
FILE *fsettings; /* for files libhdf5.settings */
|
||||
FILE *fsettings; /* for files libhdf5.settings */
|
||||
int inchar;
|
||||
int bol = 0; /* indicates the beginning of a new line */
|
||||
int bol = 0; /* indicates the beginning of a new line */
|
||||
|
||||
if(NULL == (fsettings = HDfopen(LIBSETTINGSFNAME, "r"))) {
|
||||
HDperror(LIBSETTINGSFNAME);
|
||||
@ -77,33 +76,33 @@ insert_libhdf5_settings(FILE *flibinfo)
|
||||
fprintf(flibinfo, "char H5libhdf5_settings[]=\n");
|
||||
bol++;
|
||||
while(EOF != (inchar = HDgetc(fsettings))) {
|
||||
if(bol) {
|
||||
/* Start a new line */
|
||||
fprintf(flibinfo, "\t\"");
|
||||
bol = 0;
|
||||
} /* end if */
|
||||
if(inchar == '\n') {
|
||||
/* end of a line */
|
||||
fprintf(flibinfo, "\\n\"\n");
|
||||
bol++;
|
||||
if(bol) {
|
||||
/* Start a new line */
|
||||
fprintf(flibinfo, "\t\"");
|
||||
bol = 0;
|
||||
} /* end if */
|
||||
else
|
||||
HDputc(inchar, flibinfo);
|
||||
if(inchar == '\n') {
|
||||
/* end of a line */
|
||||
fprintf(flibinfo, "\\n\"\n");
|
||||
bol++;
|
||||
} /* end if */
|
||||
else
|
||||
HDputc(inchar, flibinfo);
|
||||
} /* end while */
|
||||
if(HDfeof(fsettings)) {
|
||||
/* wrap up */
|
||||
if(!bol)
|
||||
/* EOF found without a new line */
|
||||
fprintf(flibinfo, "\\n\"\n");
|
||||
fprintf(flibinfo, ";\n\n");
|
||||
/* wrap up */
|
||||
if(!bol)
|
||||
/* EOF found without a new line */
|
||||
fprintf(flibinfo, "\\n\"\n");
|
||||
fprintf(flibinfo, ";\n\n");
|
||||
} /* end if */
|
||||
else {
|
||||
fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME);
|
||||
HDexit(1);
|
||||
fprintf(stderr, "Read errors encountered with %s\n", LIBSETTINGSFNAME);
|
||||
HDexit(1);
|
||||
} /* end else */
|
||||
if(0 != HDfclose(fsettings)) {
|
||||
HDperror(LIBSETTINGSFNAME);
|
||||
HDexit(1);
|
||||
HDperror(LIBSETTINGSFNAME);
|
||||
HDexit(1);
|
||||
} /* end if */
|
||||
#else
|
||||
/* print variable definition and an empty string */
|
||||
@ -112,18 +111,15 @@ insert_libhdf5_settings(FILE *flibinfo)
|
||||
#endif
|
||||
} /* insert_libhdf5_settings() */
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: make_libinfo
|
||||
* Function: make_libinfo
|
||||
*
|
||||
* Purpose: Create the embedded library information definition.
|
||||
* This sets up for a potential extension that the declaration
|
||||
* is printed to a file different from stdout.
|
||||
* Purpose: Create the embedded library information definition.
|
||||
* This sets up for a potential extension that the declaration
|
||||
* is printed to a file different from stdout.
|
||||
*
|
||||
* Return: void
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* Sep 15, 2009
|
||||
* Return: void
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -131,42 +127,38 @@ static void
|
||||
make_libinfo(void)
|
||||
{
|
||||
/* print variable definition and then the string as a macro. */
|
||||
insert_libhdf5_settings(stdout);
|
||||
insert_libhdf5_settings(rawoutstream);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: print_header
|
||||
* Function: print_header
|
||||
*
|
||||
* Purpose: Prints the header for the generated file.
|
||||
* Purpose: Prints the header for the generated file.
|
||||
*
|
||||
* Return: void
|
||||
*
|
||||
* Programmer: Robb Matzke
|
||||
* matzke@llnl.gov
|
||||
* Mar 12 1997
|
||||
* Return: void
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void
|
||||
print_header(void)
|
||||
{
|
||||
time_t now = HDtime(NULL);
|
||||
struct tm *tm = HDlocaltime(&now);
|
||||
char real_name[30];
|
||||
char host_name[256];
|
||||
int i;
|
||||
const char *s;
|
||||
time_t now = HDtime(NULL);
|
||||
struct tm *tm = HDlocaltime(&now);
|
||||
char real_name[30];
|
||||
char host_name[256];
|
||||
int i;
|
||||
const char *s;
|
||||
#ifdef H5_HAVE_GETPWUID
|
||||
struct passwd *pwd = NULL;
|
||||
struct passwd *pwd = NULL;
|
||||
#else
|
||||
int pwd = 1;
|
||||
int pwd = 1;
|
||||
#endif
|
||||
static const char *month_name[] =
|
||||
static const char *month_name[] =
|
||||
{
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
static const char *purpose = "\
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
||||
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
static const char *purpose = "\
|
||||
This machine-generated source code contains\n\
|
||||
information about the library build configuration\n";
|
||||
|
||||
@ -175,22 +167,22 @@ information about the library build configuration\n";
|
||||
*/
|
||||
#ifdef H5_HAVE_GETPWUID
|
||||
{
|
||||
size_t n;
|
||||
char *comma;
|
||||
size_t n;
|
||||
char *comma;
|
||||
|
||||
if((pwd = HDgetpwuid(HDgetuid()))) {
|
||||
if((comma = HDstrchr(pwd->pw_gecos, ','))) {
|
||||
n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos));
|
||||
HDstrncpy(real_name, pwd->pw_gecos, n);
|
||||
real_name[n] = '\0';
|
||||
} /* end if */
|
||||
if((pwd = HDgetpwuid(HDgetuid()))) {
|
||||
if((comma = HDstrchr(pwd->pw_gecos, ','))) {
|
||||
n = MIN(sizeof(real_name) - 1, (unsigned)(comma - pwd->pw_gecos));
|
||||
HDstrncpy(real_name, pwd->pw_gecos, n);
|
||||
real_name[n] = '\0';
|
||||
} /* end if */
|
||||
else {
|
||||
HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name));
|
||||
real_name[sizeof(real_name) - 1] = '\0';
|
||||
} /* end else */
|
||||
} /* end if */
|
||||
HDstrncpy(real_name, pwd->pw_gecos, sizeof(real_name));
|
||||
real_name[sizeof(real_name) - 1] = '\0';
|
||||
} /* end else */
|
||||
} /* end if */
|
||||
else
|
||||
real_name[0] = '\0';
|
||||
real_name[0] = '\0';
|
||||
}
|
||||
#else
|
||||
real_name[0] = '\0';
|
||||
@ -201,7 +193,7 @@ information about the library build configuration\n";
|
||||
*/
|
||||
#ifdef H5_HAVE_GETHOSTNAME
|
||||
if(HDgethostname(host_name, sizeof(host_name)) < 0)
|
||||
host_name[0] = '\0';
|
||||
host_name[0] = '\0';
|
||||
#else
|
||||
host_name[0] = '\0';
|
||||
#endif
|
||||
@ -209,53 +201,49 @@ information about the library build configuration\n";
|
||||
/*
|
||||
* The file header: warning, copyright notice, build information.
|
||||
*/
|
||||
printf("/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n");
|
||||
HDputs(FileHeader); /*the copyright notice--see top of this file */
|
||||
fprintf(rawoutstream, "/* Generated automatically by H5make_libsettings -- do not edit */\n\n\n");
|
||||
HDfputs(FileHeader, rawoutstream); /*the copyright notice--see top of this file */
|
||||
|
||||
printf(" *\n * Created:\t\t%s %2d, %4d\n",
|
||||
month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year);
|
||||
fprintf(rawoutstream, " *\n * Created:\t\t%s %2d, %4d\n",
|
||||
month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year);
|
||||
if(pwd || real_name[0] || host_name[0]) {
|
||||
printf(" *\t\t\t");
|
||||
if(real_name[0])
|
||||
printf("%s <", real_name);
|
||||
fprintf(rawoutstream, " *\t\t\t");
|
||||
if(real_name[0])
|
||||
fprintf(rawoutstream, "%s <", real_name);
|
||||
#ifdef H5_HAVE_GETPWUID
|
||||
if(pwd)
|
||||
HDfputs(pwd->pw_name, stdout);
|
||||
if(pwd)
|
||||
HDfputs(pwd->pw_name, rawoutstream);
|
||||
#endif
|
||||
if(host_name[0])
|
||||
printf("@%s", host_name);
|
||||
if(real_name[0])
|
||||
printf(">");
|
||||
HDputchar('\n');
|
||||
if(host_name[0])
|
||||
fprintf(rawoutstream, "@%s", host_name);
|
||||
if(real_name[0])
|
||||
fprintf(rawoutstream, ">");
|
||||
HDfputc('\n', rawoutstream);
|
||||
} /* end if */
|
||||
printf(" *\n * Purpose:\t\t");
|
||||
fprintf(rawoutstream, " *\n * Purpose:\t\t");
|
||||
for(s = purpose; *s; s++) {
|
||||
HDputchar(*s);
|
||||
if('\n' == *s && s[1])
|
||||
printf(" *\t\t\t");
|
||||
HDfputc(*s, rawoutstream);
|
||||
if('\n' == *s && s[1])
|
||||
fprintf(rawoutstream, " *\t\t\t");
|
||||
} /* end for */
|
||||
|
||||
printf(" *\n * Modifications:\n *\n");
|
||||
printf(" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
|
||||
printf(" *\tIt was generated by code in `H5make_libsettings.c'.\n");
|
||||
fprintf(rawoutstream, " *\n * Modifications:\n *\n");
|
||||
fprintf(rawoutstream, " *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
|
||||
fprintf(rawoutstream, " *\tIt was generated by code in `H5make_libsettings.c'.\n");
|
||||
|
||||
printf(" *\n *");
|
||||
fprintf(rawoutstream, " *\n *");
|
||||
for(i = 0; i < 73; i++)
|
||||
HDputchar('-');
|
||||
printf("\n */\n\n");
|
||||
HDfputc('-', rawoutstream);
|
||||
fprintf(rawoutstream, "\n */\n\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: print_footer
|
||||
* Function: print_footer
|
||||
*
|
||||
* Purpose: Prints the file footer for the generated file.
|
||||
* Purpose: Prints the file footer for the generated file.
|
||||
*
|
||||
* Return: void
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* koziol@hdfgroup.org
|
||||
* Mar 31 2010
|
||||
* Return: void
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -265,24 +253,37 @@ print_footer(void)
|
||||
/* nothing */
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: main
|
||||
* Function: main
|
||||
*
|
||||
* Purpose: Main entry point.
|
||||
* Purpose: Main entry point.
|
||||
*
|
||||
* Return: Success: exit(0)
|
||||
*
|
||||
* Failure: exit(1)
|
||||
*
|
||||
* Programmer: Albert Cheng
|
||||
* 2010/4/1
|
||||
* Return: Success: exit(0)
|
||||
* Failure: exit(1)
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
main(void)
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *fname = NULL;
|
||||
FILE *f; /* temporary holding place for the stream pointer
|
||||
* so that rawoutstream is changed only when succeeded */
|
||||
|
||||
if (argc > 1) {
|
||||
fname = argv[1];
|
||||
}
|
||||
/* First check if filename is string "NULL" */
|
||||
if (fname != NULL) {
|
||||
/* binary output */
|
||||
if ((f = HDfopen(fname, "w")) != NULL) {
|
||||
rawoutstream = f;
|
||||
}
|
||||
}
|
||||
if (!rawoutstream)
|
||||
rawoutstream = stdout;
|
||||
|
||||
print_header();
|
||||
|
||||
/* Generate embedded library information variable definition */
|
||||
@ -290,5 +291,12 @@ main(void)
|
||||
|
||||
print_footer();
|
||||
|
||||
if (rawoutstream && rawoutstream != stdout) {
|
||||
if (HDfclose(rawoutstream))
|
||||
fprintf(stderr, "closing rawoutstream");
|
||||
else
|
||||
rawoutstream = NULL;
|
||||
}
|
||||
|
||||
HDexit(0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user