Skip to content

Commit

Permalink
Fix Windows Python binding builds. Does not address PyImath runtime i…
Browse files Browse the repository at this point in the history
…ssues, but does allow build to succeed
  • Loading branch information
meshula authored and nickrasmussen committed Aug 8, 2018
1 parent 7376f9b commit 15ce54c
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 117 deletions.
18 changes: 18 additions & 0 deletions IlmBase/IexMath/IexMathFloatExc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,24 @@ getMathExcOn ()
return when;
}

MathExcOn::MathExcOn (int when)
: _changed (false)
{
_saved = getMathExcOn();

if (_saved != when)
{
_changed = true;
mathExcOn (when);
}
}

MathExcOn::~MathExcOn ()
{
if (_changed)
mathExcOn (_saved);
}

void
MathExcOn::handleOutstandingExceptions()
{
Expand Down
36 changes: 10 additions & 26 deletions IlmBase/IexMath/IexMathFloatExc.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//
// Copyright (c) 2002, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
Expand All @@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Expand All @@ -41,7 +41,7 @@
#define IEXMATH_EXPORT_H

#if defined(OPENEXR_DLL)
#if defined(IEX_EXPORTS)
#if defined(IEXMATH_EXPORTS)
#define IEXMATH_EXPORT __declspec(dllexport)
#else
#define IEXMATH_EXPORT __declspec(dllimport)
Expand Down Expand Up @@ -100,28 +100,12 @@ int getMathExcOn();
// // point exception settings
//------------------------------------------------------------------------

class IEXMATH_EXPORT MathExcOn
class MathExcOn
{
public:

MathExcOn (int when)
:
_changed (false)
{
_saved = getMathExcOn();

if (_saved != when)
{
_changed = true;
mathExcOn (when);
}
}

~MathExcOn ()
{
if (_changed)
mathExcOn (_saved);
}
IEXMATH_EXPORT MathExcOn (int when);
IEXMATH_EXPORT ~MathExcOn ();

// It is possible for functions to set the exception registers
// yet not trigger a SIGFPE. Specifically, the implementation
Expand All @@ -132,12 +116,12 @@ class IEXMATH_EXPORT MathExcOn
// It should be called wherever this class is commonly used where it has
// been found that certain floating point exceptions are not being thrown.

void handleOutstandingExceptions();
IEXMATH_EXPORT void handleOutstandingExceptions();

private:

bool _changed;
int _saved;
int _saved;
};


Expand Down
1 change: 1 addition & 0 deletions IlmBase/config.windows/IlmBaseConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#undef HAVE_POSIX_SEMAPHORES

// Required for system-specific debug trap code in IexBaseExc.cpp
// and DLL export macros

#define PLATFORM_WINDOWS 1

17 changes: 13 additions & 4 deletions PyIlmBase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SET(ILMBASE_VERSION_API ${ILMBASE_VERSION_MAJOR}_${ILMBASE_VERSION_MINOR})
ENABLE_TESTING()


# distro building
# distro building
SET(CPACK_PACKAGE_VERSION_MAJOR "${ILMBASE_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${ILMBASE_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${ILMBASE_VERSION_PATCH}")
Expand All @@ -29,12 +29,20 @@ INCLUDE ( CPack )
# Set this option to find the C++ libs with their namespaced versions
# The python modules themselves are built without versioning
OPTION (NAMESPACE_VERSIONING "Use Namespace Versioning" ON)
# Allow the developer to select if Dynamic or Static libraries are built
OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON)

# Setup osx rpathing
SET (CMAKE_MACOSX_RPATH 1)
SET (BUILD_WITH_INSTALL_RPATH 1)

SET (LIB_TYPE SHARED)
IF (BUILD_SHARED_LIBS)
# User wants to build Dynamic Libraries, so change the LIB_TYPE variable to CMake keyword 'SHARED'
SET (LIB_TYPE SHARED)
IF (WIN32)
ADD_DEFINITIONS(-DOPENEXR_DLL)
ENDIF ()
ENDIF (BUILD_SHARED_LIBS)

FIND_PACKAGE ( PythonLibs REQUIRED )
FIND_PACKAGE ( PythonInterp REQUIRED )
Expand All @@ -48,7 +56,8 @@ INCLUDE_DIRECTORIES (
PyIex
PyImath
PyImathNumpy
${PYTHON_INCLUDE_PATH}
${PYTHON_INCLUDE_PATH}
${Boost_INCLUDE_DIRS}
)

LINK_DIRECTORIES ( ${ILMBASE_PACKAGE_PREFIX}/lib )
Expand All @@ -68,7 +77,7 @@ IF (NUMPY_FOUND)
ADD_SUBDIRECTORY ( PyImathNumpy )
ADD_SUBDIRECTORY ( PyImathNumpyTest )
ENDIF ()

##########################
# Tests
##########################
Expand Down
7 changes: 7 additions & 0 deletions PyIlmBase/PyIex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@ ADD_LIBRARY ( PyIex ${LIB_TYPE}
PyIex.cpp
)

IF(BUILD_SHARED_LIBS)
target_compile_definitions( PyIex PRIVATE -DPYIEX_EXPORTS )
ENDIF()

target_compile_definitions( PyIex PRIVATE PYIEX_BUILD )

TARGET_LINK_LIBRARIES ( PyIex
${PYTHON_LIBRARIES}
${Boost_LIBRARIES}
)

INSTALL ( TARGETS PyIex
Expand Down
45 changes: 19 additions & 26 deletions PyIlmBase/PyIex/PyIexExport.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
//
// Copyright (c) 2001-2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
Expand All @@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Expand All @@ -35,28 +35,21 @@
#ifndef PYIEXEXPORT_H
#define PYIEXEXPORT_H

#if defined(PLATFORM_WINDOWS)
# if defined(PLATFORM_BUILD_STATIC)
# define PYIEX_EXPORT_DEFINITION
# define PYIEX_IMPORT_DEFINITION
# else
# define PYIEX_EXPORT_DEFINITION __declspec(dllexport)
# define PYIEX_IMPORT_DEFINITION __declspec(dllimport)
# endif
#else // linux/macos
# if defined(PLATFORM_VISIBILITY_AVAILABLE)
# define PYIEX_EXPORT_DEFINITION __attribute__((visibility("default")))
# define PYIEX_IMPORT_DEFINITION
# else
# define PYIEX_EXPORT_DEFINITION
# define PYIEX_IMPORT_DEFINITION
# endif
#endif

#if defined(PYIEX_EXPORTS) // create library
# define PYIEX_EXPORT PYIEX_EXPORT_DEFINITION
#else // use library
# define PYIEX_EXPORT PYIEX_IMPORT_DEFINITION
#if defined(OPENEXR_DLL)
#if defined(PLATFORM_VISIBILITY_AVAILABLE)
#define PYIEX_EXPORT __attribute__((visibility("default")))
#define PYIEX_IMPORT __attribute__((visibility("default")))
#elif defined(_MSC_VER)
#if defined(PYIEX_BUILD)
#define PYIEX_EXPORT __declspec(dllexport)
#else
#define PYIEX_EXPORT __declspec(dllimport)
#endif
#else
#define PYIEX_EXPORT
#endif
#else
#define PYIEX_EXPORT
#endif

#endif // #ifndef PYIEXEXPORT_H
Expand Down
10 changes: 8 additions & 2 deletions PyIlmBase/PyImath/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ ADD_LIBRARY ( PyImath ${LIB_TYPE}
PyImathVec4fd.cpp
PyImathVec4siArray.cpp
PyImathVec4si.cpp

)

IF(BUILD_SHARED_LIBS)
target_compile_definitions( PyImath PRIVATE -DPYIMATH_EXPORTS )
ENDIF()

target_compile_definitions( PyImath PRIVATE -DPYIMATH_BUILD )


TARGET_LINK_LIBRARIES ( PyImath
Iex${ILMBASE_LIBSUFFIX}
IexMath${ILMBASE_LIBSUFFIX}
Expand All @@ -49,7 +55,7 @@ INSTALL ( TARGETS PyImath
ADD_LIBRARY ( imathmodule ${LIB_TYPE}
imathmodule.cpp
PyImathFun.cpp
PyImathBasicTypes.cpp
PyImathBasicTypes.cpp
)

SET_TARGET_PROPERTIES ( imathmodule
Expand Down
1 change: 1 addition & 0 deletions PyIlmBase/PyImath/PyImath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <PyIex.h>
#include <PyImathExport.h>


namespace PyImath {

template <> PYIMATH_EXPORT const char * BoolArray::name() { return "BoolArray"; }
Expand Down
1 change: 1 addition & 0 deletions PyIlmBase/PyImath/PyImathBasicTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <Python.h>
#include <boost/python.hpp>
#include <PyImath.h>
#include <PyImathExport.h>
#include <PyImathFixedArray.h>
#include <PyImathFixedVArray.h>

Expand Down
4 changes: 1 addition & 3 deletions PyIlmBase/PyImath/PyImathBasicTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@
#ifndef _PyImathBasicTypes_h_
#define _PyImathBasicTypes_h_

#include <PyImathExport.h>

namespace PyImath {

PYIMATH_EXPORT void register_basicTypes();
void register_basicTypes();

}

Expand Down
52 changes: 22 additions & 30 deletions PyIlmBase/PyImath/PyImathExport.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
///////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2007-2011, Industrial Light & Magic, a division of Lucas
// Copyright (c) 2001-2012, Industrial Light & Magic, a division of Lucas
// Digital Ltd. LLC
//
//
// All rights reserved.
//
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
Expand All @@ -16,8 +16,8 @@
// distribution.
// * Neither the name of Industrial Light & Magic nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
Expand All @@ -32,32 +32,24 @@
//
///////////////////////////////////////////////////////////////////////////

#ifndef PYIMATH_EXPORT_H
#define PYIMATH_EXPORT_H
#ifndef PYIMATHEXPORT_H
#define PYIMATHEXPORT_H

#if defined(PLATFORM_WINDOWS)
# if defined(PLATFORM_BUILD_STATIC)
# define PYIMATH_EXPORT_DEFINITION
# define PYIMATH_IMPORT_DEFINITION
# else
# define PYIMATH_EXPORT_DEFINITION __declspec(dllexport)
# define PYIMATH_IMPORT_DEFINITION __declspec(dllimport)
# endif
#else // linux/macos
# if defined(PLATFORM_VISIBILITY_AVAILABLE)
# define PYIMATH_EXPORT_DEFINITION __attribute__((visibility("default")))
# define PYIMATH_IMPORT_DEFINITION
# else
# define PYIMATH_EXPORT_DEFINITION
# define PYIMATH_IMPORT_DEFINITION
# endif
#endif

#if defined(PYIMATH_EXPORTS) // create library
# define PYIMATH_EXPORT PYIMATH_EXPORT_DEFINITION
#else // use library
# define PYIMATH_EXPORT PYIMATH_IMPORT_DEFINITION
#if defined(OPENEXR_DLL)
#if defined(PLATFORM_VISIBILITY_AVAILABLE)
#define PYIMATH_EXPORT __attribute__((visibility("default")))
#define PYIMATH_EXPORT __attribute__((visibility("default")))
#elif defined(_MSC_VER)
#if defined(PYIMATH_BUILD)
#define PYIMATH_EXPORT __declspec(dllexport)
#else
#define PYIMATH_EXPORT __declspec(dllimport)
#endif
#else
#define PYIMATH_EXPORT
#endif
#else
#define PYIMATH_EXPORT
#endif

#endif // #ifndef PYIMATHEXPORT_H

2 changes: 2 additions & 0 deletions PyIlmBase/PyImath/PyImathRandom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ solidSphereRand(Rand &rand, int num)
return retval;
}

PYIMATH_EXPORT
class_<IMATH_NAMESPACE::Rand32>
register_Rand32()
{
Expand Down Expand Up @@ -241,6 +242,7 @@ register_Rand32()
return rand32_class;
}

PYIMATH_EXPORT
class_<IMATH_NAMESPACE::Rand48>
register_Rand48()
{
Expand Down
Loading

0 comments on commit 15ce54c

Please sign in to comment.