Skip to content

Commit

Permalink
NEW: Add recipe for libnvimgcodec
Browse files Browse the repository at this point in the history
  • Loading branch information
carterbox committed Sep 11, 2024
1 parent 8d2e5e3 commit ec1eb15
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 0 deletions.
43 changes: 43 additions & 0 deletions recipes/libnvimagecodec/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#! bash
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

mkdir build
cd build

cmake ${CMAKE_ARGS} -GNinja \
-DBUILD_LIBRARY:BOOL=ON \
-DBUILD_DOCS:BOOL=OFF \
-DBUILD_EXTENSIONS:BOOL=OFF \
-DBUILD_PYTHON:BOOL=OFF \
-DBUILD_SAMPLES:BOOL=OFF \
-DBUILD_SHARED_LIBS:BOOL=ON \
-DBUILD_STATIC_LIBS:BOOL=OFF \
-DBUILD_TEST:BOOL=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_LIBDIR=lib \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DBUILD_NVJPEG2K_EXT:BOOL=OFF \
-DBUILD_NVJPEG_EXT:BOOL=ON \
${SRC_DIR}

cmake --build .

cmake --install . --strip

# Move cmake configure files to the more-common lib directory
mkdir -p ${PREFIX}/lib/cmake
mv ${PREFIX}/cmake/* ${PREFIX}/lib/cmake
121 changes: 121 additions & 0 deletions recipes/libnvimagecodec/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
# Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
{% set version = "0.3.0" %}

package:
name: libnvimgcodec-split
version: {{ version }}

source:
url: https://github.com/NVIDIA/nvImageCodec/archive/refs/tags/v{{ version }}.tar.gz
sha256: 4bba949d6cf4e88fcd6b2d86bff960c9ed68eb25b6c4dde3b7772615480ab9fb
patches:
- missing-includes.patch
- no-overwrite-libdir.patch

build:
skip: true # [not linux]
skip: true # [ppc64le]
skip: true # [cuda_compiler_version in (None, "None")]

requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cuda') }}
- {{ compiler('cxx')}}
- {{ stdlib('c') }}
- cmake >=3.18
- ninja
- python-clang
host:
- cuda-version {{ cuda_compiler_version }}
- libboost-devel
- libjpeg-turbo
- libnvjpeg-dev
- libopencv
- libtiff
- nvtx-c
- zlib
- zstd

outputs:

- name: libnvimgcodec-dev
build:
run_exports:
- {{ pin_subpackage('libnvimgcodec') }}
files:
# This recipe requires conda-build 24.7 or later
include:
- include/**
- lib/libnvimgcodec.so
- lib/cmake/nvimgcodec
# ld config contains wrong path (lib64 instead of lib)
# - etc/**
exclude:
- lib/libnvimgcodec_static.a
- lib/libnvimgcodec.so.*
requirements:
host:
- {{ pin_subpackage('libnvimgcodec', exact=True) }}
run:
- {{ pin_subpackage('libnvimgcodec', exact=True) }}
test:
commands:
- test -f ${PREFIX}/include/nvimgcodec.h # [unix]
- test -f ${PREFIX}/lib/libnvimgcodec.so.0 # [linux]
- test -f ${PREFIX}/lib/libnvimgcodec.so.{{ version }}.0 # [linux]
- test ! -f ${PREFIX}/etc/ld.so.conf.d/nvimgcodec.conf # [unix]
- test -f ${PREFIX}/lib/cmake/nvimgcodec/nvimgcodecConfig.cmake # [unix]
- test ! -f ${PREFIX}/lib/libnvimgcodec_static.a # [unix]

- name: libnvimgcodec
build:
run_exports:
- {{ pin_subpackage('libnvimgcodec') }}
files:
- lib/libnvimgcodec.so.*
requirements:
build:
- {{ compiler('c') }}
- {{ compiler('cuda') }}
- {{ compiler('cxx')}}
- {{ stdlib('c') }}
host:
- cuda-version {{ cuda_compiler_version }}
- libboost-devel
- libjpeg-turbo
- libnvjpeg-dev
- libopencv
- libtiff
- nvtx-c
- zlib
- zstd
test:
commands:
- test -f ${PREFIX}/lib/libnvimgcodec.so.0 # [linux]
- test -f ${PREFIX}/lib/libnvimgcodec.so.{{ version }}.0 # [linux]

about:
home: https://github.com/NVIDIA/nvImageCodec
description: >
The nvImageCodec is an open-source library of accelerated codecs with
unified interface. This package is the C-API only. See nvimagecodec for the
Python-API.
license: Apache-2.0 license
license_family: APACHE
license_file:
- LICENSE.txt
- Acknowledgements.txt
feedstock_name: libnvimgcodec
85 changes: 85 additions & 0 deletions recipes/libnvimagecodec/missing-includes.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
diff --git a/extensions/libjpeg_turbo/jpeg_handle.h b/extensions/libjpeg_turbo/jpeg_handle.h
index bc24173..6da1652 100644
--- a/extensions/libjpeg_turbo/jpeg_handle.h
+++ b/extensions/libjpeg_turbo/jpeg_handle.h
@@ -1,16 +1,16 @@
-/*
+/*
* SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
* Copyright 2019-2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@

#pragma once

+#include <cstdint>
#include <string>
#include "jpeg_utils.h"

diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
index 50685ce..9778dbf 100644
--- a/external/CMakeLists.txt
+++ b/external/CMakeLists.txt
@@ -1,2 +1,4 @@
-add_subdirectory(pybind11 EXCLUDE_FROM_ALL)
-add_subdirectory(dlpack EXCLUDE_FROM_ALL)
\ No newline at end of file
+if(BUILD_PYTHON)
+ add_subdirectory(pybind11 EXCLUDE_FROM_ALL)
+ add_subdirectory(dlpack EXCLUDE_FROM_ALL)
+endif(BUILD_PYTHON)
diff --git a/src/logger.h b/src/logger.h
index 4b75869..3264a95 100644
--- a/src/logger.h
+++ b/src/logger.h
@@ -17,6 +17,7 @@

#pragma once

+#include <algorithm>
#include <nvimgcodec.h>
#include <string>
#include <vector>
@@ -46,7 +47,7 @@ class Logger : public ILogger
}

void log(const nvimgcodecDebugMessageSeverity_t message_severity,
- const nvimgcodecDebugMessageCategory_t message_category, const std::string& message) override
+ const nvimgcodecDebugMessageCategory_t message_category, const std::string& message) override
{
nvimgcodecDebugMessageData_t data{NVIMGCODEC_STRUCTURE_TYPE_DEBUG_MESSAGE_DATA, sizeof(nvimgcodecDebugMessageData_t), nullptr,
message.c_str(), 0, nullptr, name_.c_str(), 0};
@@ -85,4 +86,4 @@ class Logger : public ILogger
std::string name_;
};

-} //namespace nvimgcodec
\ No newline at end of file
+} //namespace nvimgcodec
diff --git a/src/parsers/exif.h b/src/parsers/exif.h
index aff554c..d996317 100644
--- a/src/parsers/exif.h
+++ b/src/parsers/exif.h
@@ -42,6 +42,7 @@

#pragma once

+#include <cstdint>
#include <cstdio>
#include <map>
#include <utility>
23 changes: 23 additions & 0 deletions recipes/libnvimagecodec/no-overwrite-libdir.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5d8aeb0..0b084af 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -114,11 +114,6 @@ endif()
# * CMAKE_INSTALL_BINDIR
# * CMAKE_INSTALL_INCLUDEDIR
include(GNUInstallDirs)
-if(UNIX)
- set(CMAKE_INSTALL_LIBDIR "lib64") # use lib64 instead of lib
-else()
- set(CMAKE_INSTALL_LIBDIR "lib")
-endif()
set(CMAKE_INSTALL_FULL_LIBDIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") # adjust accordingly

# Layout. This works for all platforms:
@@ -190,4 +185,4 @@ install(
COMPONENT lib
)

-# }
\ No newline at end of file
+# }

0 comments on commit ec1eb15

Please sign in to comment.