Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

h5 compiler wrappers now pass all arguments passed to it to the compile line #3954

Merged
merged 4 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions bin/h5cc.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ host_os="@host_os@"

prog_name="`basename $0`"

allargs=""
misc_args=""
compile_args=""
libraries=""
link_args=""
Expand Down Expand Up @@ -202,7 +202,6 @@ for arg in $@ ; do

case "$arg" in
-c)
allargs="$allargs $arg"
compile_args="$compile_args $arg"

if test "x$do_link" = "xyes" -a -n "$output_file"; then
Expand All @@ -213,7 +212,6 @@ for arg in $@ ; do
dash_c="yes"
;;
-o)
allargs="$allargs $arg"
dash_o="yes"

if test "x$dash_c" = "xyes"; then
Expand All @@ -225,14 +223,12 @@ for arg in $@ ; do
fi
;;
-E|-M|-MT)
allargs="$allargs $arg"
compile_args="$compile_args $arg"
dash_c="yes"
do_link="no"
;;
-l*)
libraries=" $libraries $arg "
allargs="$allargs $arg"
;;
-prefix=*)
prefix="`expr "$arg" : '-prefix=\(.*\)'`"
Expand Down Expand Up @@ -264,14 +260,14 @@ for arg in $@ ; do
;;
*\"*)
qarg="'"$arg"'"
allargs="$allargs $qarg"
misc_args="$misc_args $qarg"
;;
*\'*)
qarg='\"'"$arg"'\"'
allargs="$allargs $qarg"
qarg='"'"$arg"'"'
misc_args="$misc_args $qarg"
;;
*)
allargs="$allargs $qarg"
misc_args="$misc_args $qarg"

if test -s "$arg"; then
ext=`expr "$arg" : '.*\(\..*\)'`
Expand Down Expand Up @@ -313,7 +309,7 @@ if test "x$do_compile" = "xyes"; then
compile_args="-c $compile_args"
fi

$SHOW $CC -I$includedir $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CFLAGS $CFLAGS $compile_args
$SHOW $CC -I$includedir $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CFLAGS $CFLAGS $misc_args $compile_args
status=$?

if test "$status" != "0"; then
Expand Down
32 changes: 30 additions & 2 deletions c++/examples/testh5c++.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ prog1_o=${H5TOOL}_prog1.o
prog2=${H5TOOL}_prog2.$suffix
prog2_o=${H5TOOL}_prog2.o
applib=libapp${H5TOOL}.a
args=${H5TOOL}_args.$suffix
args_o=${H5TOOL}_args.o

# short hands
# Caution: if some *.h5 files must be cleaned here, list them by names.
Expand Down Expand Up @@ -134,16 +136,38 @@ int main (void)
}
EOF

# Generate args:
# An application main that test misc command line arguments being passed.
cat > $args <<EOF
#include <string>
#include <iostream>
#include "H5Cpp.h"
#ifndef H5_NO_NAMESPACE
using namespace H5;
#endif

const H5std_string FILE_NAME( "args.h5" );

int main (void)
{
char c = SGL_QUOTE; // 'H'
char *s = DBL_QUOTE; // "HDF"
int val = MISC; // 42

H5File file( FILE_NAME, H5F_ACC_TRUNC );
return 0;
}
EOF

# Parse option
# None

# Print a line-line message left justified in a field of 70 characters
# Print a line-line message left justified in a field of 74 characters
# beginning with the word "Testing".
#
TESTING() {
SPACES=" "
echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
echo "Testing $* $SPACES" | cut -c1-74 | tr -d '\012'
}


Expand Down Expand Up @@ -231,6 +255,10 @@ echo "***"Just preprocess, no compile, no link.
TOOLTEST -E $hdf5main
TOOLTEST -E $appmain $prog1 $prog2

# HDF5 program that depends on input args.
echo "***"Simple Compile and Link in one step with user-supplied arguments.
TOOLTEST -DSGL_QUOTE=\'H\' -DDBL_QUOTE=\"HDF\" -DMISC=42 $args

##############################################################################
# END
##############################################################################
Expand Down
16 changes: 6 additions & 10 deletions c++/src/h5c++.in
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ host_os="@host_os@"

prog_name="`basename $0`"

allargs=""
misc_args=""
compile_args=""
libraries=""
link_args=""
Expand Down Expand Up @@ -198,7 +198,6 @@ for arg in $@ ; do

case "$arg" in
-c)
allargs="$allargs $arg"
compile_args="$compile_args $arg"

if test "x$do_link" = "xyes" -a -n "$output_file"; then
Expand All @@ -209,7 +208,6 @@ for arg in $@ ; do
dash_c="yes"
;;
-o)
allargs="$allargs $arg"
dash_o="yes"

if test "x$dash_c" = "xyes"; then
Expand All @@ -221,14 +219,12 @@ for arg in $@ ; do
fi
;;
-E|-M|-MT)
allargs="$allargs $arg"
compile_args="$compile_args $arg"
dash_c="yes"
do_link="no"
;;
-l*)
libraries=" $libraries $arg "
allargs="$allargs $arg"
;;
-prefix=*)
prefix="`expr "$arg" : '-prefix=\(.*\)'`"
Expand All @@ -254,15 +250,15 @@ for arg in $@ ; do
;;
*\"*)
qarg="'"$arg"'"
allargs="$allargs $qarg"
misc_args="$misc_args $qarg"
;;
*\'*)
qarg='\"'"$arg"'\"'
allargs="$allargs $qarg"
qarg='"'"$arg"'"'
misc_args="$misc_args $qarg"
;;

*)
allargs="$allargs $qarg"
misc_args="$misc_args $qarg"

if [ -s "$arg" ] ; then
ext=`expr "$arg" : '.*\(\..*\)'`
Expand Down Expand Up @@ -300,7 +296,7 @@ if test "x$do_compile" = "xyes"; then
compile_args="-c $compile_args"
fi

$SHOW $CXX -I$includedir $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS $compile_args
$SHOW $CXX -I$includedir $H5BLD_CPPFLAGS $CPPFLAGS $H5BLD_CXXFLAGS $CXXFLAGS $misc_args $compile_args
status=$?

if test "$status" != "0"; then
Expand Down
32 changes: 30 additions & 2 deletions examples/testh5cc.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ prog1=${H5TOOL}_prog1.$suffix
prog1_o=${H5TOOL}_prog1.o
prog2=${H5TOOL}_prog2.$suffix
prog2_o=${H5TOOL}_prog2.o
args=${H5TOOL}_args.$suffix
args_o=${H5TOOL}_args.o
applib=libapp${H5TOOL}.a

# short hands
Expand Down Expand Up @@ -327,16 +329,38 @@ main (void)
}
EOF

# Generate args:
# An application main that test misc command line arguments being passed.
cat > $args <<EOF
#include "hdf5.h"
#define H5FILE_NAME "check_args.h5"
int
main (void)
{
char c = SGL_QUOTE; /* 'H' */
char *s = DBL_QUOTE; /* "HDF" */
int val = MISC; /* 42 */
hid_t file; /* file and dataset handles */

file = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
H5Fclose(file);

printf("HDF5 C Sample program ran successfully. File %s generated.\n", H5FILE_NAME);
remove(H5FILE_NAME);

return 0;
}
EOF

# Parse option
# None

# Print a line-line message left justified in a field of 70 characters
# Print a line-line message left justified in a field of 71 characters
# beginning with the word "Testing".
#
TESTING() {
SPACES=" "
echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
echo "Testing $* $SPACES" | cut -c1-71 | tr -d '\012'
}


Expand Down Expand Up @@ -512,6 +536,10 @@ else
TOOLTEST $v114main
fi

# Group 6: # HDF5 program that depends on input args.
echo "***"Simple Compile and Link in one step with user-supplied arguments.
TOOLTEST -DSGL_QUOTE=\'H\' -DDBL_QUOTE=\"HDF\" -DMISC=42 $args

##############################################################################
# END
##############################################################################
Expand Down
35 changes: 31 additions & 4 deletions fortran/examples/testh5fc.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ myos=`uname -s`
myhostnama=`uname -n`

# Generate some source files and library for tests.
suffix=f90 # source file suffix
suffix=F90 # source file suffix
hdf5main=${H5TOOL}_hdf5main.$suffix
hdf5main_o=${H5TOOL}_hdf5main.o
appmain=${H5TOOL}_appmain.$suffix
appmain_o=${H5TOOL}_appmain.o
args=${H5TOOL}_args.$suffix
args_o=${H5TOOL}_args.o
prog1=${H5TOOL}_prog1.$suffix
prog1_o=${H5TOOL}_prog1.o
prog2=${H5TOOL}_prog2.$suffix
Expand Down Expand Up @@ -106,7 +108,7 @@ cat > $hdf5main <<EOF

IMPLICIT NONE

CHARACTER(LEN=8), PARAMETER :: filename = "apptmp.h5" ! File name
CHARACTER(LEN=9), PARAMETER :: filename = "apptmp.h5" ! File name
INTEGER(HID_T) :: file_id ! File identifier

INTEGER :: error ! Error flag
Expand All @@ -118,17 +120,38 @@ cat > $hdf5main <<EOF
END PROGRAM FILEEXAMPLE
EOF

# Generate an args Main Program:
# An application main that test misc command line arguments being passed.
cat > $args <<EOF
PROGRAM ARGS
USE HDF5 ! This module contains all necessary modules

IMPLICIT NONE
CHARACTER(LEN=1), PARAMETER :: chr1 = SGL_QUOTE ! 'H'
CHARACTER(LEN=3), PARAMETER :: chr3 = DBL_QUOTE ! "HDF"
INTEGER, PARAMETER :: val = MISC ! 42

CHARACTER(LEN=9), PARAMETER :: filename = "argtmp.h5" ! File name
INTEGER(HID_T) :: file_id ! File identifier

INTEGER :: error ! Error flag

CALL h5open_f (error)
CALL h5fcreate_f(filename, H5F_ACC_TRUNC_F, file_id, error)
CALL h5fclose_f(file_id, error)
CALL h5close_f(error)
END PROGRAM ARGS
EOF

# Parse option
# None

# Print a line-line message left justified in a field of 70 characters
# Print a line-line message left justified in a field of 73 characters
# beginning with the word "Testing".
#
TESTING() {
SPACES=" "
echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012'
echo "Testing $* $SPACES" | cut -c1-73 | tr -d '\012'
}


Expand Down Expand Up @@ -199,6 +222,10 @@ $RANLIB $applib
TOOLTEST $appmain $applib
TOOLTEST $appmain_o $applib

# HDF5 program that depends on input args.
echo "***"Simple Compile and Link in one step with user-supplied arguments.
TOOLTEST -DSGL_QUOTE=\'H\' -DDBL_QUOTE=\"HDF\" -DMISC=42 $args

# No preprocess test since -E is not a common option for Fortran compilers.

##############################################################################
Expand Down
Loading
Loading