diff --git a/recipes/astc-codec/all/CMakeLists.txt b/recipes/astc-codec/all/CMakeLists.txt new file mode 100644 index 0000000000000..d32836cbae4aa --- /dev/null +++ b/recipes/astc-codec/all/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12) +project(cmake_wrapper) + +include("conanbuildinfo.cmake") +conan_basic_setup() + +add_subdirectory(source_subfolder) diff --git a/recipes/astc-codec/all/conandata.yml b/recipes/astc-codec/all/conandata.yml new file mode 100644 index 0000000000000..5ae510b14b461 --- /dev/null +++ b/recipes/astc-codec/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "cci.20190617": + url: "https://github.com/google/astc-codec/archive/9757befb64db6662aad45de09ca87cd6f599ac02.tar.gz" + sha256: "19034fed68401a612655b026e713c351df8caa768f55ce29a0f628378e988eac" diff --git a/recipes/astc-codec/all/conanfile.py b/recipes/astc-codec/all/conanfile.py new file mode 100644 index 0000000000000..de86c00f0acc4 --- /dev/null +++ b/recipes/astc-codec/all/conanfile.py @@ -0,0 +1,73 @@ +import os +import glob +from conans import ConanFile, CMake, tools + + +class AstcCodecConan(ConanFile): + name = "astc-codec" + description = " A software ASTC decoder implementation which supports the ASTC LDR profile" + homepage = "https://github.com/google/astc-codec" + url = "https://github.com/conan-io/conan-center-index" + license = "Apache-2.0" + topics = ("conan", "astc", "codec") + settings = "os", "compiler", "arch", "build_type" + options = { + "fPIC": [True, False], + } + default_options = { + "fPIC": True, + } + exports_sources = "CMakeLists.txt" + generators = "cmake" + + _cmake = None + + @property + def _source_subfolder(self): + return "source_subfolder" + + @property + def _build_subfolder(self): + return "build_subfolder" + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if self.settings.compiler.cppstd: + tools.check_min_cppstd(self, "11") + + def source(self): + tools.get(**self.conan_data["sources"][self.version]) + extracted_dir = glob.glob("astc-codec-*")[0] + os.rename(extracted_dir, self._source_subfolder) + + def _configure_cmake(self): + if self._cmake: + return self._cmake + self._cmake = CMake(self) + self._cmake.definitions["OPTION_ASTC_TESTS"] = False + self._cmake.configure(build_folder=self._build_subfolder) + return self._cmake + + def build(self): + cmake = self._configure_cmake() + cmake.build() + + def package(self): + self.copy("LICENSE", src=self._source_subfolder, dst="licenses") + self.copy("*.h", dst="include", src=os.path.join(self._source_subfolder, "include")) + self.copy("*.lib", src=os.path.join(self._build_subfolder, "lib"), dst="lib", keep_path=False) + self.copy("*.dll", src=os.path.join(self._build_subfolder, "bin"), dst="bin", keep_path=False) + self.copy("*.exe", src=os.path.join(self._build_subfolder, "bin"), dst="bin", keep_path=False) + self.copy("*.so*", src=os.path.join(self._build_subfolder, "lib"), dst="lib", keep_path=False, symlinks=True) + self.copy("*.dylib", src=os.path.join(self._build_subfolder, "lib"), dst="lib", keep_path=False) + self.copy("*.a", src=os.path.join(self._build_subfolder, "lib"), dst="lib", keep_path=False) + + def package_info(self): + self.cpp_info.libs = tools.collect_libs(self) + + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH environment variable: {}".format(bindir)) + self.env_info.PATH.append(bindir) diff --git a/recipes/astc-codec/all/test_package/CMakeLists.txt b/recipes/astc-codec/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..1baaed448aea7 --- /dev/null +++ b/recipes/astc-codec/all/test_package/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.1) +project(test_package CXX) + +include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) +conan_basic_setup() + +add_executable(${CMAKE_PROJECT_NAME} test_package.cpp) +target_link_libraries(${CMAKE_PROJECT_NAME} ${CONAN_LIBS}) +set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 11) diff --git a/recipes/astc-codec/all/test_package/atlas_small_4x4.astc b/recipes/astc-codec/all/test_package/atlas_small_4x4.astc new file mode 100644 index 0000000000000..0dd080b12d23f Binary files /dev/null and b/recipes/astc-codec/all/test_package/atlas_small_4x4.astc differ diff --git a/recipes/astc-codec/all/test_package/conanfile.py b/recipes/astc-codec/all/test_package/conanfile.py new file mode 100644 index 0000000000000..0616bc5a57142 --- /dev/null +++ b/recipes/astc-codec/all/test_package/conanfile.py @@ -0,0 +1,18 @@ +from conans import ConanFile, CMake, tools +import os + + +class TestPackageConan(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "cmake" + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if not tools.cross_building(self.settings): + bin_path = os.path.join("bin", "test_package") + bees = os.path.join(self.source_folder, "atlas_small_4x4.astc") + self.run("{} {} 256 256".format(bin_path, bees), run_environment=True) diff --git a/recipes/astc-codec/all/test_package/test_package.cpp b/recipes/astc-codec/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..ec0a2e3ad6195 --- /dev/null +++ b/recipes/astc-codec/all/test_package/test_package.cpp @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include + +#include + +int main(int argc, char **argv) +{ + if (argc < 4) { + std::cerr << "Need at least three argument\n"; + } + std::ifstream stream(argv[1], std::ios::in | std::ios::binary); + std::vector astc_data((std::istreambuf_iterator(stream)), std::istreambuf_iterator()); + + const size_t width = std::stoi(argv[2]); + const size_t height = std::stoi(argv[3]); + + std::vector result; + result.resize(width * height * 4); + + bool success = astc_codec::ASTCDecompressToRGBA( + astc_data.data(), astc_data.size(), width, height, astc_codec::FootprintType::k4x4, + result.data(), result.size(), /* stride */ width * 4); + + stream.close(); + + return 0; +} diff --git a/recipes/astc-codec/config.yml b/recipes/astc-codec/config.yml new file mode 100644 index 0000000000000..dc12e222a3828 --- /dev/null +++ b/recipes/astc-codec/config.yml @@ -0,0 +1,3 @@ +versions: + "cci.20190617": + folder: all