1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 cmake,
6 clang,
7 libclang,
8 libxml2,
9 zlib,
10 openexr,
11 openimageio,
12 llvm,
13 boost,
14 flex,
15 bison,
16 partio,
17 pugixml,
18 robin-map,
19 util-linux,
20 python3,
21}:
22
23let
24 boost_static = boost.override { enableStatic = true; };
25in
26stdenv.mkDerivation (finalAttrs: {
27 pname = "openshadinglanguage";
28 version = "1.14.7.0";
29
30 src = fetchFromGitHub {
31 owner = "AcademySoftwareFoundation";
32 repo = "OpenShadingLanguage";
33 rev = "v${finalAttrs.version}";
34 hash = "sha256-w78x0e9T0lYCAPDPkx6T/4TzAs/mpJ/24uQ+yH5gB5I=";
35 };
36
37 cmakeFlags = [
38 "-DBoost_ROOT=${boost}"
39 "-DUSE_BOOST_WAVE=ON"
40 "-DENABLE_RTTI=ON"
41
42 # Build system implies llvm-config and llvm-as are in the same directory.
43 # Override defaults.
44 "-DLLVM_DIRECTORY=${llvm}"
45 "-DLLVM_CONFIG=${llvm.dev}/bin/llvm-config"
46 "-DLLVM_BC_GENERATOR=${clang}/bin/clang++"
47 ];
48
49 prePatch = ''
50 substituteInPlace src/cmake/modules/FindLLVM.cmake \
51 --replace-fail "NO_DEFAULT_PATH" ""
52 '';
53
54 preConfigure = ''
55 patchShebangs src/liboslexec/serialize-bc.bash
56 '';
57
58 nativeBuildInputs = [
59 bison
60 clang
61 cmake
62 flex
63 ];
64
65 buildInputs = [
66 boost_static
67 libclang
68 llvm
69 openexr
70 openimageio
71 partio
72 pugixml
73 python3.pkgs.pybind11
74 robin-map
75 util-linux # needed just for hexdump
76 zlib
77 ]
78 ++ lib.optionals stdenv.hostPlatform.isDarwin [
79 libxml2
80 ];
81
82 postFixup = ''
83 substituteInPlace "$out"/lib/pkgconfig/*.pc \
84 --replace '=''${exec_prefix}//' '=/'
85 '';
86
87 meta = {
88 description = "Advanced shading language for production GI renderers";
89 homepage = "https://opensource.imageworks.com/osl.html";
90 maintainers = with lib.maintainers; [ hodapp ];
91 license = lib.licenses.bsd3;
92 platforms = lib.platforms.unix;
93 };
94})