[Piglit] [PATCH 1/2] cmake: Install piglit as piglit.py on Windows.

Ken Phillis Jr kphillisjr at gmail.com
Wed Jun 4 17:01:14 PDT 2014


I think it would be a good solution to use piglit.py as the file name
to begin with to avoid platform issues ( Mainly windows ) related to
files that lack extensions.

On Wed, Jun 4, 2014 at 3:15 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> On Wednesday, June 04, 2014 02:09:14 AM Jose Fonseca wrote:
>> ----- Original Message -----
>>
>> > On Tuesday, June 03, 2014 06:58:37 PM jfonseca at vmware.com wrote:
>> > > From: José Fonseca <jfonseca at vmware.com>
>> > >
>> > > Windows doesn't support #!.  Instead it knows how to invoke scripts
>> > > based off the file extension.
>> > > ---
>> > >
>> > >  CMakeLists.txt | 7 ++++++-
>> > >  piglit         | 4 ++++
>> > >  2 files changed, 10 insertions(+), 1 deletion(-)
>> > >
>> > > diff --git a/CMakeLists.txt b/CMakeLists.txt
>> > > index a77a2a8..fed58bb 100644
>> > > --- a/CMakeLists.txt
>> > > +++ b/CMakeLists.txt
>> > > @@ -450,8 +450,13 @@ install (
>> > >
>> > >   REGEX "CMakeFiles|CMakeLists" EXCLUDE
>> > >
>> > >  )
>> > >
>> > > +if (WIN32)
>> > > + set (PYTHON_SUFFIX ".py")
>> > > +else ()
>> > > + set (PYTHON_SUFFIX "")
>> > > +endif ()
>> > >
>> > >  install (
>> > >
>> > > - PROGRAMS piglit RENAME piglit${PIGLIT_INSTALL_VERSION_SUFFIX}
>> > > + PROGRAMS piglit RENAME
>> > > piglit${PIGLIT_INSTALL_VERSION_SUFFIX}${PYTHON_SUFFIX} DESTINATION
>> > > ${CMAKE_INSTALL_BINDIR}
>> > >
>> > >  )
>> > >
>> > > diff --git a/piglit b/piglit
>> > > index dcb51db..bf53876 100755
>> > > --- a/piglit
>> > > +++ b/piglit
>> > > @@ -40,6 +40,10 @@ import argparse
>> > >
>> > >  # muck with things, if not we need to screw with the python path
>> > >
>> > >  if not path.exists('HACKING'):
>> > >      _binpath, _bin = path.split(__file__)
>> > >
>> > > +    _binname, _binext = path.splitext(_bin)
>> > > +    if _binext == '.py':
>> > > +        # Drop .py extension (used on Windows)
>> > > +        _bin = _binname
>> >
>> > This is to allow the sys.path manipulation to work on windows, correct?
>>
>> Yes, sys.path and  PIGLIT_SOURCE_DIR.  Otherwise it will search tests in
>> .../lib/piglit.py/bin/*.exe instead of .../lib/piglit/bin/*.exe
>> > In that case could we wrap this in an obvious windows specific check,
>>
>> > something like:
>> This might be useful if one uses native windows binaries on cygwin (as Brian
>> Paul seems to do). So instead of trying to white-list platforms, just
>> looking at the file extension seems more robust. Unless you plan to produce
>> a piglit version with like "1.0.py" ;-)
>> > if sys.platform == 'win32':
>> >     _bin = path.splitext(_bin)[0]  # remove '.py' from name
>> >
>> > >      _libdir = path.abspath(path.join(_binpath, '..', 'lib', _bin))
>> > >      sys.path.append(_libdir)
>>
>> > >      if 'PIGLIT_SOURCE_DIR' not in os.environ:
>> Jose
>
> I guess my concern is that if something is wrapped in a nice 'if windows' tag,
> that gives me and other linux-only developers a warning of 'hands off' or,
> 'please ask a windows developer if this works'. But obviously that isn't going
> to make things easier, so I will retract my comment.
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>


More information about the Piglit mailing list