On Mon, May 5, 2014 at 1:35 AM, Dylan Baker <[email protected]> wrote: > On Saturday, May 03, 2014 05:47:26 PM Jordan Justen wrote: >> On Fri, May 2, 2014 at 6:31 PM, Dylan Baker <[email protected]> wrote: >> > This uses the functions created by the last commit to create a >> > all-in-one piglit command. It uses argparse to parse partial commands >> > and provide help for those functions. >> > >> > It is also capable of handling all of the black magic for setting the >> > python sys.path and setting the PIGLIT_SOURCE_DIR environment variable. >> > >> > v2: - Allow the name of the program to not be piglit (example: >> > piglit-20140101) >> > >> > - Remove unused check from cmake >> > - Install piglit as piglit${PIGLIT_INSTALL_VERSION}; when this >> > >> > variable is unset piglit will be installed simply as 'piglit' >> > >> > Signed-off-by: Dylan Baker <[email protected]> >> > --- >> > >> > CMakeLists.txt | 17 ++++-------- >> > piglit | 88 >> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files >> > changed, 93 insertions(+), 12 deletions(-) >> > create mode 100755 piglit >> > >> > diff --git a/CMakeLists.txt b/CMakeLists.txt >> > index e3eddba..ff2038f 100644 >> > --- a/CMakeLists.txt >> > +++ b/CMakeLists.txt >> > @@ -426,18 +426,6 @@ install ( >> > >> > ) >> > >> > install ( >> > >> > - PROGRAMS >> > - piglit-merge-results.py >> > - piglit-print-commands.py >> > - piglit-run.py >> > - piglit-resume.py >> > - piglit-summary.py >> > - piglit-summary-html.py >> > - piglit-summary-junit.py >> > - DESTINATION ${PIGLIT_INSTALL_LIBDIR} >> > -) >> > - >> > -install ( >> > >> > DIRECTORY framework >> > DESTINATION ${PIGLIT_INSTALL_LIBDIR} >> > FILES_MATCHING PATTERN "*.py" >> > >> > @@ -462,6 +450,11 @@ install ( >> > >> > REGEX "CMakeFiles|CMakeLists" EXCLUDE >> > >> > ) >> > >> > +install ( >> > + PROGRAMS piglit RENAME piglit${PIGLIT_INSTALL_VERSION_SUFFIX} >> > + DESTINATION ${CMAKE_INSTALL_BINDIR} >> > +) >> > + >> > >> > set (CPACK_PACKAGE_VERSION_MAJOR "1") >> > set (CPACK_PACKAGE_VERSION_MINOR "0") >> > >> > diff --git a/piglit b/piglit >> > new file mode 100755 >> > index 0000000..9f3d349 >> > --- /dev/null >> > +++ b/piglit >> > @@ -0,0 +1,88 @@ >> > +#!/usr/bin/env python >> > + >> > +# Copyright (c) 2014 Intel Corporation >> > + >> > +# Permission is hereby granted, free of charge, to any person obtaining a >> > copy +# of this software and associated documentation files (the >> > "Software"), to deal +# in the Software without restriction, including >> > without limitation the rights +# to use, copy, modify, merge, publish, >> > distribute, sublicense, and/or sell +# copies of the Software, and to >> > permit persons to whom the Software is +# furnished to do so, subject to >> > the following conditions: >> > + >> > +# The above copyright notice and this permission notice shall be included >> > in +# all copies or substantial portions of the Software. >> > + >> > +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> > OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> > MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. >> > IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY >> > CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, >> > TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE >> > SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. >> > + >> > +""" Wrapper for piglit executables >> > + >> > +This imports functions from the framework and calls them with the >> > argument >> > +parts that the parser defined here doesn't konw how to parse. >> > + >> > +It is very important that the final parser not generate a help message >> > +(add_help=False in the constructor arguments), otherwise this parser will >> > +capture -h/--help and the results will not be useful. >> > + >> > +""" >> > + >> > +import os >> > +import os.path as path >> > +import sys >> > +import argparse >> > + >> > +# If running in the source directory there will be a HACKING file, don't >> > +# muck with things, if not we need to screw with the python path >> > +if not path.exists('HACKING'): >> > + _binpath, _bin = path.split(__file__) >> > + _libdir = path.abspath(path.join(_binpath, '../lib/', _bin)) >> >> '../lib/' => '..', 'lib' > > Doing that just produces unnecessary overhead and produces the same result, on > the three platforms we care about (windows, *nix, osx), the only platform > python supports that this wouldn't work on is classic macos (pre OSX macos). I > can make the change, but what does it buy us?
I was thinking about os.sep on windows, but, actually, abspath should handle that. I still think the separated version is better python code for os.path.join, and I don't think the performance overhead should be a concern for this once per invocation call. -Jordan _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
