option(GMX_USE_TNG "Use the TNG library for trajectory I/O" ON)
-if(UNIX)
- option(GMX_SYMLINK_OLD_BINARY_NAMES "Create symbolic links for pre-5.0 binary names" ON)
-endif()
option(GMX_BUILD_MDRUN_ONLY "Build and install only the mdrun binary" OFF)
option(GMX_CYCLE_SUBCOUNTERS "Enable cycle subcounters to get a more detailed cycle timings" OFF)
The core of the wrapper binary is the gmx::CommandLineModuleManager::run()
method. This method:
- 1. Checks whether the binary is invoked through a symlink. If it is, it
- searches the registered modules for names matching the name of the symlink
- (with certain prefixes in the symlink name ignored). If a match is found,
- it continues as if the command was invoked as `gmx` _module_ `...`, where
- _module_ is the name of the found module and `...` are the rest of the
- arguments.
- 2. Parses the command line arguments before the module name as arguments to
+ 1. Parses the command line arguments before the module name as arguments to
the wrapper binary. Some arguments such as `-h` and `-version` cause rest
of the command (the module name and all that follows) to be ignored.
- 3. If a module is specified, also checks the command line arguments after the
+ 2. If a module is specified, also checks the command line arguments after the
module name for the options understood by the wrapper binary, such as `-h`
and `-version` (see below for details of how `-h` works). Any such options
are handled by the manager and removed from the command line for further
processing.
- 4. Print the startup header (contents of which can be controlled by the
+ 3. Print the startup header (contents of which can be controlled by the
command line options).
- 5. If a command line option requests termination after the startup header
+ 4. If a command line option requests termination after the startup header
(such as `-version`), return.
- 6. Passes control to the selected module. If there is no module specified,
+ 5. Passes control to the selected module. If there is no module specified,
the help module is invoked (see below).
- 7. Print a quote at the end, and return the exit code from the module.
+ 6. Print a quote at the end, and return the exit code from the module.
Command line help
-----------------
CMakeLists.txt.
`bin/`
- : The standard location for executables, some scripts, and some symlinks.
+ : The standard location for executables and some scripts.
Some of the scripts hardcode the absolute installation prefix, which needs
to be changed if the scripts are relocated.
`include/gromacs/`
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
#include "cmdlinemodulemanager.h"
-#include "config.h"
-
#include <cstdio>
#include <string>
*/
CommandLineModuleMap::const_iterator
findModuleByName(const std::string &name) const;
- /*! \brief
- * Finds a module that the name of the binary.
- *
- * \param[in] invokedName Name by which the program was invoked.
- * \throws std::bad_alloc if out of memory.
- * \returns Iterator to the found module, or
- * \c modules_.end() if not found.
- *
- * Checks whether the program is invoked through a symlink whose name
- * is different from \a binaryName_, and if so, checks
- * if a module name matches the name of the symlink.
- *
- * Note that the \p invokedName parameter is currently not necessary
- * (as the program context object is also available and provides this
- * value), but it clarifies the control flow.
- */
- CommandLineModuleMap::const_iterator
- findModuleFromBinaryName(const char *invokedName) const;
/*! \brief
* Processes command-line options for the wrapper binary.
return modules_.find(name);
}
-CommandLineModuleMap::const_iterator
-CommandLineModuleManager::Impl::findModuleFromBinaryName(
- const char *invokedName) const
-{
- std::string moduleName = invokedName;
-#ifdef GMX_BINARY_SUFFIX
- moduleName = stripSuffixIfPresent(moduleName, GMX_BINARY_SUFFIX);
-#endif
- if (moduleName == binaryName_)
- {
- return modules_.end();
- }
- if (startsWith(moduleName, "g_"))
- {
- moduleName.erase(0, 2);
- }
- if (startsWith(moduleName, "gmx"))
- {
- moduleName.erase(0, 3);
- }
- return findModuleByName(moduleName);
-}
-
CommandLineModuleInterface *
CommandLineModuleManager::Impl::processCommonOptions(
CommandLineCommonOptionsHolder *optionsHolder, int *argc, char ***argv)
{
// Check if we are directly invoking a certain module.
CommandLineModuleInterface *module = singleModule_;
- if (module == NULL)
- {
- // Also check for invokation through named symlinks.
- CommandLineModuleMap::const_iterator moduleIter
- = findModuleFromBinaryName(programContext_.programName());
- if (moduleIter != modules_.end())
- {
- module = moduleIter->second.get();
- }
- }
// TODO: It would be nice to propagate at least the -quiet option to
// the modules so that they can also be quiet in response to this.
/*
* This file is part of the GROMACS molecular simulation package.
*
- * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Copyright (c) 2012,2013,2014,2015, by the GROMACS development team, led by
* Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
* and including many others, as listed in the AUTHORS file in the
* top-level source directory and at http://www.gromacs.org.
ASSERT_EQ(0, rc);
}
-TEST_F(CommandLineModuleManagerTest, RunsModuleHelpWithDashHWithSymLink)
-{
- const char *const cmdline[] = {
- "g_module", "-h"
- };
- CommandLine args(cmdline);
- initManager(args, "test");
- MockModule &mod1 = addModule("module", "First module");
- addModule("other", "Second module");
- using ::testing::_;
- EXPECT_CALL(mod1, writeHelp(_));
- mod1.setExpectedDisplayName("test module");
- int rc = 0;
- ASSERT_NO_THROW_GMX(rc = manager().run(args.argc(), args.argv()));
- ASSERT_EQ(0, rc);
-}
-
TEST_F(CommandLineModuleManagerTest, RunsModuleHelpWithDashHWithSingleModule)
{
const char *const cmdline[] = {
ASSERT_EQ(0, rc);
}
-TEST_F(CommandLineModuleManagerTest, RunsModuleBasedOnBinaryName)
-{
- const char *const cmdline[] = {
- "g_module", "-flag", "yes"
- };
- CommandLine args(cmdline);
- initManager(args, "test");
- MockModule &mod1 = addModule("module", "First module");
- addModule("other", "Second module");
- using ::testing::_;
- using ::testing::Args;
- using ::testing::ElementsAreArray;
- EXPECT_CALL(mod1, init(_));
- EXPECT_CALL(mod1, run(_, _))
- .With(Args<1, 0>(ElementsAreArray(args.argv(), args.argc())));
- int rc = 0;
- ASSERT_NO_THROW_GMX(rc = manager().run(args.argc(), args.argv()));
- ASSERT_EQ(0, rc);
-}
-
-TEST_F(CommandLineModuleManagerTest, RunsModuleBasedOnBinaryNameWithPathAndSuffix)
-{
- const char *const cmdline[] = {
- "/usr/local/gromacs/bin/g_module" GMX_BINARY_SUFFIX ".exe", "-flag", "yes"
- };
- CommandLine args(cmdline);
- initManager(args, "test");
- MockModule &mod1 = addModule("module", "First module");
- addModule("other", "Second module");
- using ::testing::_;
- using ::testing::Args;
- using ::testing::ElementsAreArray;
- EXPECT_CALL(mod1, init(_));
- EXPECT_CALL(mod1, run(_, _))
- .With(Args<1, 0>(ElementsAreArray(args.argv(), args.argc())));
- int rc = 0;
- ASSERT_NO_THROW_GMX(rc = manager().run(args.argc(), args.argv()));
- ASSERT_EQ(0, rc);
-}
-
TEST_F(CommandLineModuleManagerTest, HandlesConflictingBinaryAndModuleNames)
{
const char *const cmdline[] = {
#
# This file is part of the GROMACS molecular simulation package.
#
-# Copyright (c) 2010,2011,2012,2013,2014, by the GROMACS development team, led by
+# Copyright (c) 2010,2011,2012,2013,2014,2015, by the GROMACS development team, led by
# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
# and including many others, as listed in the AUTHORS file in the
# top-level source directory and at http://www.gromacs.org.
endif()
gmx_cpack_add_generated_source_directory(completion)
- if (GMX_SYMLINK_OLD_BINARY_NAMES)
- configure_file(CreateLinks.cmake.cmakein CreateLinks.cmake @ONLY)
- set(CREATE_LINKS_SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/CreateLinks.cmake)
- install(SCRIPT ${CREATE_LINKS_SCRIPT} COMPONENT links)
- endif()
-
if(BUILD_TESTING)
add_subdirectory(mdrun/tests)
endif()
+++ /dev/null
-#
-# This file is part of the GROMACS molecular simulation package.
-#
-# Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
-# Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
-# and including many others, as listed in the AUTHORS file in the
-# top-level source directory and at http://www.gromacs.org.
-#
-# GROMACS 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.
-#
-# GROMACS 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 GROMACS; if not, see
-# http://www.gnu.org/licenses, or write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# If you want to redistribute modifications to GROMACS, please
-# consider that scientific software is very special. Version
-# control is crucial - bugs must be traceable. We will be happy to
-# consider code for inclusion in the official distribution, but
-# derived work must not be called official GROMACS. Details are found
-# in the README & COPYING files - if they are missing, get the
-# official version at http://www.gromacs.org.
-#
-# To help us fund GROMACS development, we humbly ask that you cite
-# the research papers on the package. Check out http://www.gromacs.org.
-
-# TODO: It would be nicer to have the list generated from the binary,
-# but this has some complications. As the same list is also needed for
-# man page generation, this can wait for now.
-set(SYMLINK_NAMES
- mdrun
- gmxcheck
- gmxdump
- grompp
- pdb2gmx
- tpbconv
- g_protonate
- g_x2top
- do_dssp
- editconf
- eneconv
- genbox
- genconf
- genion
- genrestr
- make_edi
- make_ndx
- mk_angndx
- trjcat
- trjconv
- trjorder
- xpm2ps
- g_anadock
- g_anaeig
- g_analyze
- g_angle
- g_bar
- g_bond
- g_bundle
- g_chi
- g_cluster
- g_clustsize
- g_confrms
- g_covar
- g_current
- g_density
- g_densmap
- g_densorder
- g_dielectric
- g_dipoles
- g_disre
- g_dist
- g_dos
- g_dyecoupl
- g_dyndom
- g_enemat
- g_energy
- g_filter
- g_gyrate
- g_h2order
- g_hbond
- g_helix
- g_helixorient
- g_hydorder
- g_lie
- g_mdmat
- g_mindist
- g_morph
- g_msd
- g_nmeig
- g_nmens
- g_nmtraj
- g_options
- g_order
- g_pme_error
- g_polystat
- g_potential
- g_principal
- g_rama
- g_rms
- g_rmsdist
- g_rmsf
- g_rotacf
- g_rotmat
- g_saltbr
- g_sans
- g_sas
- g_saxs
- g_select
- g_sgangle
- g_sham
- g_sigeps
- g_sorient
- g_spatial
- g_spol
- g_tcaf
- g_traj
- g_tune_pme
- g_vanhove
- g_velacc
- g_wham
- g_wheel
- )
-
-if (NOT DEFINED BINARY_DIRECTORY)
- set(BINARY_DIRECTORY "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@BIN_INSTALL_DIR@")
-endif ()
-set(BINARY_SUFFIX "@GMX_BINARY_SUFFIX@@CMAKE_EXECUTABLE_SUFFIX@")
-set(GMX_NATIVE_WINDOWS "@GMX_NATIVE_WINDOWS@")
-
-foreach (linkname ${SYMLINK_NAMES})
- set(linkpath ${BINARY_DIRECTORY}/${linkname}${BINARY_SUFFIX})
- # Based on documentation, CMake only supports symbolic links on Unix,
- # although NTFS also has those (since Windows Vista; they require admin
- # permissions to create).
- if (GMX_NATIVE_WINDOWS)
- if (NOT QUIETLY)
- message(STATUS "Installing: Creating alias binary ${linkpath}")
- endif ()
- execute_process(
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${BINARY_DIRECTORY}/gmx${BINARY_SUFFIX} ${linkpath})
- else()
- if (NOT QUIETLY)
- message(STATUS "Installing: Creating symbolic link ${linkpath}")
- endif ()
- if (EXISTS ${linkpath})
- FILE(REMOVE ${linkpath})
- endif ()
- execute_process(
- COMMAND ${CMAKE_COMMAND} -E create_symlink
- gmx${BINARY_SUFFIX} ${linkpath})
- endif()
-endforeach ()