Skip to content

Commit

Permalink
Merge pull request #400 from richardnorth3/pr/wrapper-help-msg
Browse files Browse the repository at this point in the history
Updated wrappers to catch -h and --help
  • Loading branch information
jdinan authored Jun 7, 2017
2 parents 4e7a95a + f924981 commit 6bcf56c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/shmem_compiler_script.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

use File::Basename;
use File::Basename qw(basename);
use File::Spec::Functions;

my $includedir = "@WRAPPER_COMPILER_INCLUDEDIR@";
Expand All @@ -118,6 +118,7 @@ my $include_flag = "-I";
my $libdir_flag = "-L";

my $comp = "";
my $wrapper = basename($0);
my $preproc_flags = $include_flag . $includedir;
my $comp_flags = "";
my $comp_flags_prefix = "";
Expand Down Expand Up @@ -161,6 +162,7 @@ my @args = @ARGV;
my $want_preproc = 1;
my $want_compile = 1;
my $want_link = 1;
my $want_help = 0;
my $dry_run = 0;
my $disable_flags = 1;
my $real_flag = 0;
Expand All @@ -169,7 +171,7 @@ my @appargs = ();
while (scalar(@args) > 0) {
my $arg = shift(@args);

if ($arg eq "-showme") {
if ($arg eq "-showme" || $arg eq "-show") {
$dry_run = 1;
} else {
if ($arg eq "-c") {
Expand All @@ -179,6 +181,9 @@ while (scalar(@args) > 0) {
$want_compile = 0;
$want_link = 0;
$real_flag = 1;
} elsif ($arg eq "--help") {
$want_help = 1;
$real_flag = 1;
} elsif ($arg eq "-S") {
$want_link = 0;
$real_flag = 1;
Expand Down Expand Up @@ -214,6 +219,19 @@ if ($want_link == 1) {
push(@exec_argv, split(' ', $linker_flags));
push(@exec_argv, split(' ', $libs));
}
if ($want_help == 1) {
print("== ",uc $wrapper," HELP ===================================\n");
print("usage: ",$wrapper," [",$wrapper,"_options] [compiler_arguments]\n\n");
print("COMPILER = $comp\n\n");
print($wrapper," options:\n");
print("\t--help Display this information\n");
print("\t-showme | -show Print the command that would be run without executing it\n");
print("\t-E | -M Disable compilation and linking\n");
print("\t-S Disable linking\n");
print("\t-c Compile and assemble. Disable linking\n\n");
print("Options provided by ",$comp," can also be used by ",$wrapper,".\n\n");
print("== ",uc $comp," HELP =====================================\n");
}

if ($dry_run == 1) {
print join(" ", @exec_argv) . "\n";
Expand Down
22 changes: 22 additions & 0 deletions src/shmem_launcher_script.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

SEARCH_LAUNCHERS="yod mpirun mpiexec srun"
LAUNCHER=""
SOS_LAUNCHER=`basename $0`

# Users can set the OSHRUN_LAUNCHER environment variable to specify the command
# that will be used by oshrun
Expand All @@ -29,6 +30,27 @@ else
done
fi

want_help=0;

if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
want_help=1
fi

if [ $want_help = 1 ]; then
printf "== OSHRUN HELP ====================================\n";
printf "usage: ${SOS_LAUNCHER} [oshrun_options] [launcher_arguments]\n\n";
if [ -z "${OSHRUN_LAUNCHER}" ]; then
printf "OSHRUN_LAUNCHER = (none)\n\n";
else
printf "OSHRUN_LAUNCHER = ${OSHRUN_LAUNCHER}\n\n";
fi
printf "Selected launcher: ${LAUNCHER}\n\n";
printf "${SOS_LAUNCHER} options:\n";
printf "\t--help | -h Display this information\n\n";
printf "Options provided by ${LAUNCHER} can also be used by ${SOS_LAUNCHER}.\n\n";
printf "== ${LAUNCHER} HELP ====================================\n" | tr [a-z] [A-Z];
fi

if [ -z "${LAUNCHER}" ]; then
echo "`basename $0`: Error, could not find a launcher. Aborting."
exit 1
Expand Down

0 comments on commit 6bcf56c

Please sign in to comment.