1
0
Stephan Kulow 2019-02-05 10:18:44 +00:00 committed by Git OBS Bridge
commit 98d9e4f6fc
4 changed files with 235 additions and 43 deletions

View File

@ -0,0 +1,146 @@
From 2e80787bfadd3d02064d72f7d5374d07bc0225cc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <stefan.bruens@rwth-aachen.de>
Date: Sun, 13 Jan 2019 01:50:59 +0100
Subject: [PATCH] Generalize lookup of stdosl.h in install directory, allow
customization
Currently, shaders are installed in <PREFIX>/shaders, which does not
fit the needs of most Linux distributions, where <PREFIX> is typically
/usr/, and architecture independent data like the shaders should be
installed in e.g. /usr/share/OpenShadingLanguage/shaders/.
Typically, CMAKE_INSTALL_DATADIR is used for this case, but this would
break the current scheme. Introduce an OSL specific option instead,
OSL_INSTALL_SHADERDIR (default ""), which can be used to specify an
absolute or relative path for the shader installation.
Usage (relative to CMAKE_INSTALL_PREFIX):
$> cmake -DCMAKE_INSTALL_PREFIX=/usr/ \
-DOSL_INSTALL_SHADERDIR=share/OpenShadingLanguage
Same effect, using absolute paths:
$> cmake -DCMAKE_INSTALL_PREFIX=/usr/ \
-DOSL_INSTALL_SHADERDIR=/usr/share/OpenShadingLanguage
The configured path is added to the stdosl.h path lookup, i.e. for
the example above "/usr/share/OpenShadingLanguage/shaders/stdosl.h".
---
CMakeLists.txt | 9 +++++++++
src/liboslcomp/CMakeLists.txt | 2 ++
src/liboslcomp/oslcomp.cpp | 9 +++++++++
src/liboslcomp/oslcomp_shaders_dir.h.in | 7 +++++++
src/liboslexec/CMakeLists.txt | 1 +
src/shaders/CMakeLists.txt | 2 +-
src/shaders/MaterialX/CMakeLists.txt | 2 +-
7 files changed, 30 insertions(+), 2 deletions(-)
create mode 100644 src/liboslcomp/oslcomp_shaders_dir.h.in
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 02feab53..05d5e959 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -53,6 +53,15 @@ if (CMAKE_USE_FOLDERS)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
endif ()
+option (OSL_INSTALL_SHADERDIR "Shader install directory, absolute or relative (to CMAKE_INSTALL_PREFIX)" "")
+mark_as_advanced (OSL_INSTALL_SHADERDIR)
+if (IS_ABSOLUTE ${OSL_INSTALL_SHADERDIR})
+ set (INSTALL_FULL_SHADERDIR ${OSL_INSTALL_SHADERDIR})
+else()
+ set (INSTALL_FULL_SHADERDIR "${CMAKE_INSTALL_PREFIX}/${OSL_INSTALL_SHADERDIR}")
+endif()
+message (STATUS "Shader install dir = ${INSTALL_FULL_SHADERDIR}")
+
include (GNUInstallDirs)
set (CMAKE_MODULE_PATH
diff --git a/src/liboslcomp/CMakeLists.txt b/src/liboslcomp/CMakeLists.txt
index 549aa549..15d9d026 100644
--- a/src/liboslcomp/CMakeLists.txt
+++ b/src/liboslcomp/CMakeLists.txt
@@ -29,6 +29,8 @@ else ()
endif ()
+configure_file ( oslcomp_shaders_dir.h.in oslcomp_shaders_dir.h )
+
TARGET_LINK_LIBRARIES ( oslcomp ${OPENIMAGEIO_LIBRARIES} ${ILMBASE_LIBRARIES}
${Boost_LIBRARIES} ${CMAKE_DL_LIBS}
${CLANG_LIBRARIES} ${LLVM_LIBRARIES} ${LLVM_LDFLAGS}
diff --git a/src/liboslcomp/oslcomp.cpp b/src/liboslcomp/oslcomp.cpp
index a89212aa..d4deda70 100644
--- a/src/liboslcomp/oslcomp.cpp
+++ b/src/liboslcomp/oslcomp.cpp
@@ -36,6 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <cerrno>
#include "oslcomp_pvt.h"
+#include "oslcomp_shaders_dir.h"
#include <OpenImageIO/platform.h>
#include <OpenImageIO/sysutil.h>
@@ -478,6 +479,14 @@ find_stdoslpath (const std::vector<std::string>& includepaths)
}
}
+ // Try the regular install directory
+ std::string install_path = OSL_SHADERS_INSTALL_DIR;
+ if (OIIO::Filesystem::is_directory (install_path)) {
+ install_path = install_path + "/stdosl.h";
+ if (OIIO::Filesystem::exists (install_path))
+ return ustring(install_path);
+ }
+
// Try looking for "oslc" binary in the $PATH, and if so, look in
// ../../shaders/stdosl.h
std::vector<std::string> exec_path_dirs;
diff --git a/src/liboslcomp/oslcomp_shaders_dir.h.in b/src/liboslcomp/oslcomp_shaders_dir.h.in
new file mode 100644
index 00000000..0638252f
--- /dev/null
+++ b/src/liboslcomp/oslcomp_shaders_dir.h.in
@@ -0,0 +1,7 @@
+#ifndef OSL_SHADERS_INSTALL_DIR
+
+// Keep this in sync with the DESTINATION in shaders/CMakeLists.txt
+// and shaders/MaterialX/CMakeLists.txt
+#define OSL_SHADERS_INSTALL_DIR "@INSTALL_FULL_SHADERDIR@/shaders/"
+
+#endif // OSL_SHADERS_INSTALL_DIR
diff --git a/src/liboslexec/CMakeLists.txt b/src/liboslexec/CMakeLists.txt
index eb8f0fa9..ff5595cc 100644
--- a/src/liboslexec/CMakeLists.txt
+++ b/src/liboslexec/CMakeLists.txt
@@ -41,6 +41,7 @@ if (NOT BUILDSTATIC)
endif ()
include_directories ( "${CMAKE_SOURCE_DIR}/src/liboslcomp" )
+include_directories ( "${CMAKE_BINARY_DIR}/src/liboslcomp" )
FILE ( GLOB exec_headers "*.h" )
FILE ( GLOB compiler_headers "../liboslcomp/*.h" )
diff --git a/src/shaders/CMakeLists.txt b/src/shaders/CMakeLists.txt
index 9b263ffa..594c09cb 100644
--- a/src/shaders/CMakeLists.txt
+++ b/src/shaders/CMakeLists.txt
@@ -63,4 +63,4 @@ add_custom_target (shaders ALL
SOURCES ${shader_source} ${shader_headers})
install (FILES ${shader_headers} ${shader_source} ${shader_objs}
- DESTINATION shaders)
+ DESTINATION ${INSTALL_FULL_SHADERDIR}/shaders)
diff --git a/src/shaders/MaterialX/CMakeLists.txt b/src/shaders/MaterialX/CMakeLists.txt
index 98f54840..d134fcde 100644
--- a/src/shaders/MaterialX/CMakeLists.txt
+++ b/src/shaders/MaterialX/CMakeLists.txt
@@ -196,5 +196,5 @@ add_custom_target (mxshaders ALL
SOURCES ${shader_source} ${mx_shader_headers})
install (FILES ${mx_shader_headers} ${mx_shader_objs} ${mx_shader_osls}
- DESTINATION shaders/MaterialX)
+ DESTINATION ${INSTALL_FULL_SHADERDIR}/shaders/MaterialX)
--
2.20.1

View File

@ -1,21 +0,0 @@
Index: src/shaders/CMakeLists.txt
===================================================================
--- src/shaders/CMakeLists.txt.orig 2018-12-02 04:00:52.000000000 +0200
+++ src/shaders/CMakeLists.txt 2019-01-02 12:32:36.665656281 +0200
@@ -63,4 +63,4 @@ add_custom_target (shaders ALL
SOURCES ${shader_source} ${shader_headers})
install (FILES ${shader_headers} ${shader_source} ${shader_objs}
- DESTINATION shaders)
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/shaders)
Index: src/shaders/MaterialX/CMakeLists.txt
===================================================================
--- src/shaders/MaterialX/CMakeLists.txt.orig 2018-12-02 04:00:52.000000000 +0200
+++ src/shaders/MaterialX/CMakeLists.txt 2019-01-02 12:50:34.020012017 +0200
@@ -196,5 +196,5 @@ add_custom_target (mxshaders ALL
SOURCES ${shader_source} ${mx_shader_headers})
install (FILES ${mx_shader_headers} ${mx_shader_objs} ${mx_shader_osls}
- DESTINATION shaders/MaterialX)
+ DESTINATION ${CMAKE_INSTALL_DATADIR}/shaders/MaterialX)

View File

@ -1,3 +1,17 @@
-------------------------------------------------------------------
Sun Jan 13 02:21:24 UTC 2019 - Stefan Brüns <stefan.bruens@rwth-aachen.de>
- Fix lookup of stdosl.h from oslc (bnc#1123254):
Dropped OpenShadingLanguage-shaderinstalldir.patch
Added 0001-Generalize-lookup-of-stdosl.h-in-install-directory-a.patch
- Cleaned up spec file (defattr)
- Correct LLVM_MCJIT_LIBRARY value, add comment
- Use current LLVM for building (bnc#1123252)
- Split shaders in common-headers, MaterialX-shaders and example-shaders
subpackages. stdosl.h in common-headers is required by oslc in
the main package (bnc#1123254).
- Correct clang-devel package name for Leap 42.3
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Jan 8 16:39:15 UTC 2019 - Jan Engelhardt <jengelh@inai.de> Tue Jan 8 16:39:15 UTC 2019 - Jan Engelhardt <jengelh@inai.de>

View File

@ -1,7 +1,7 @@
# #
# spec file for package OpenShadingLanguage # spec file for package OpenShadingLanguage
# #
# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# #
# All modifications and additions to the file contributed by third parties # All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed # remain the property of their copyright owners, unless otherwise agreed
@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9) # license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative. # published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/ # Please submit bugfixes or comments via https://bugs.opensuse.org/
# #
# The library soname versions follow the package version major and minor numbers. # The library soname versions follow the package version major and minor numbers.
@ -32,31 +32,44 @@ Group: Productivity/Graphics/Other
Url: https://github.com/imageworks/OpenShadingLanguage Url: https://github.com/imageworks/OpenShadingLanguage
Source0: https://github.com/imageworks/OpenShadingLanguage/archive/Release-%{version}.tar.gz#/%{name}-Release-%{version}.tar.gz Source0: https://github.com/imageworks/OpenShadingLanguage/archive/Release-%{version}.tar.gz#/%{name}-Release-%{version}.tar.gz
Source1: https://creativecommons.org/licenses/by/3.0/legalcode.txt Source1: https://creativecommons.org/licenses/by/3.0/legalcode.txt
#PATCH-FIX-UPSTREAM OpenShadingLanguage-shaderinstalldir.patch - davejplater@gmail.com - shaders are installed directly under /usr #PATCH-FIX-UPSTREAM 0001-Generalize-lookup-of-stdosl.h-in-install-directory-a.patch
#https://github.com/imageworks/OpenShadingLanguage/issues/955 #https://github.com/imageworks/OpenShadingLanguage/issues/955
Patch0: OpenShadingLanguage-shaderinstalldir.patch Patch0: 0001-Generalize-lookup-of-stdosl.h-in-install-directory-a.patch
BuildRequires: bison BuildRequires: bison
BuildRequires: cmake BuildRequires: cmake
BuildRequires: cmake(pugixml) BuildRequires: cmake(pugixml)
BuildRequires: clang5-devel %if 0%{suse_version} >= 1500
BuildRequires: clang-devel
%else
BuildRequires: llvm-clang-devel >= 3.8
BuildRequires: ncurses-devel
%endif
BuildRequires: flex BuildRequires: flex
BuildRequires: gcc-c++ BuildRequires: gcc-c++
BuildRequires: libboost_atomic-devel %if 0%{suse_version} >= 1500
BuildRequires: libboost_filesystem-devel BuildRequires: libboost_filesystem-devel
BuildRequires: libboost_locale-devel BuildRequires: libboost_system-devel
BuildRequires: libboost_regex-devel
BuildRequires: libboost_thread-devel BuildRequires: libboost_thread-devel
BuildRequires: libboost_wave-devel BuildRequires: libboost_wave-devel
%else
# The default 1.54 is to old, 1.61 has unresolvable
# symbols in boost::wave (C++ ABI issue?)
BuildRequires: boost-devel >= 1.55.0
BuildConflicts: boost-devel >= 1.61.0
%endif
BuildRequires: OpenImageIO-devel BuildRequires: OpenImageIO-devel
BuildRequires: OpenEXR-devel BuildRequires: OpenEXR-devel
BuildRequires: python BuildRequires: python
Requires: %{name}-common-headers = %{version}
Recommends: %{name}-doc = %{version} Recommends: %{name}-doc = %{version}
%description %description
Open Shading Language (OSL) is a language for programmable shading Open Shading Language (OSL) is a language for programmable shading
in advanced renderers and other applications, ideal for describing in advanced renderers and other applications, ideal for describing
materials, lights, displacement, and pattern generation. materials, lights, displacement, and pattern generation.
This package contains binaries.
This package contains the standalone oslc compiler and some
utilities.
%package doc %package doc
Summary: Documentation for OpenShadingLanguage Summary: Documentation for OpenShadingLanguage
@ -70,16 +83,44 @@ in advanced renderers and other applications, ideal for describing
materials, lights, displacement, and pattern generation. materials, lights, displacement, and pattern generation.
This package contains documentation. This package contains documentation.
%package shaders-devel %package MaterialX-shaders-source
Summary: Headers for shading Summary: MaterialX shader nodes
Group: Development/Languages/Other Group: Development/Languages/Other
Requires: %{name} = %{version} Requires: %{name} = %{version}
Requires: %{name}-common-headers
%description shaders-devel %description MaterialX-shaders-source
Open Shading Language (OSL) is a language for programmable shading Open Shading Language (OSL) is a language for programmable shading
in advanced renderers and other applications, ideal for describing in advanced renderers and other applications, ideal for describing
materials, lights, displacement, and pattern generation. materials, lights, displacement, and pattern generation.
This package contains shaders and headers used by OSL.
This package contains the code for the MaterialX shader nodes.
%package example-shaders-source
Summary: OSL shader examples
Group: Development/Languages/Other
Requires: %{name} = %{version}
Requires: %{name}-common-headers
%description example-shaders-source
Open Shading Language (OSL) is a language for programmable shading
in advanced renderers and other applications, ideal for describing
materials, lights, displacement, and pattern generation.
This package contains some OSL example shaders.
%package common-headers
Summary: OSL standard library and auxiliary headers
Group: Development/Languages/Other
Requires: %{name} = %{version}
%description common-headers
Open Shading Language (OSL) is a language for programmable shading
in advanced renderers and other applications, ideal for describing
materials, lights, displacement, and pattern generation.
This package contains the OSL standard library headers, as well
as some additional headers useful for writing shaders.
%package -n liboslcomp%{sufx} %package -n liboslcomp%{sufx}
Summary: OpenShadingLanguage's compiler component library Summary: OpenShadingLanguage's compiler component library
@ -152,14 +193,20 @@ developing applications that use %{name}.
%prep %prep
%setup -q -n %{name}-Release-%{version} %setup -q -n %{name}-Release-%{version}
# Shaders and includes for OSL are installed in $PREFIX/shaders %patch0 -p1
%patch0
%build %build
# We use a combined LLVM on 15.0/TW, so libLLVMMCJIT is neither available nor needed
# On 42.3., we have to collect the split libraries ourselfs,
# as the supplied FindLLVM.cmake is broken
%if 0%{suse_version} < 1500
%define llvm_libs %(llvm-config --libfiles | tr ' ' ';')
%endif
%cmake \ %cmake \
-DLLVM_MCJIT_LIBRARY:FILEPATH=%{_libdir}/libLLVM.so \ %{?llvm_libs:-DLLVM_LIBRARY="%{llvm_libs}"} \
-DLLVM_MCJIT_LIBRARY="" \
-DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir}/%{name} \ -DCMAKE_INSTALL_DOCDIR:PATH=%{_docdir}/%{name} \
-DCMAKE_INSTALL_DATADIR:PATH=%{_datadir}/%{name} -DOSL_INSTALL_SHADERDIR:PATH=%{_datadir}/%{name}
make %{?_smp_mflags} make %{?_smp_mflags}
@ -191,16 +238,23 @@ find %{buildroot} -type f -name "*.la" -delete -print
%files %files
%defattr(-,root,root)
%{_bindir}/* %{_bindir}/*
%files doc %files doc
%license legalcode.txt %license legalcode.txt
%doc %{_docdir}/%{name}/ %doc %{_docdir}/%{name}/
%files shaders-devel %files MaterialX-shaders-source
%license LICENSE %_datadir/%{name}/shaders/MaterialX
%_datadir/%{name}/
%files example-shaders-source
%_datadir/%{name}/shaders/*.osl
%_datadir/%{name}/shaders/*.oso
%files common-headers
%dir %_datadir/%{name}
%dir %_datadir/%{name}/shaders
%_datadir/%{name}/shaders/*.h
%files -n liboslcomp%{sufx} %files -n liboslcomp%{sufx}
%license LICENSE %license LICENSE
@ -227,7 +281,6 @@ find %{buildroot} -type f -name "*.la" -delete -print
%{_libdir}/osl.imageio.so.%{sover}* %{_libdir}/osl.imageio.so.%{sover}*
%files devel %files devel
%defattr(-,root,root)
%license LICENSE %license LICENSE
%{_includedir}/* %{_includedir}/*
%{_libdir}/*.so %{_libdir}/*.so