-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add astc-codec 20190617 * astc-codec: prepend cci in version string * astc-codec: check C++11 * astc-codec: add bin folder to PATH env var
- Loading branch information
1 parent
712ba7c
commit 939d12a
Showing
8 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cmake_minimum_required(VERSION 2.8.12) | ||
project(cmake_wrapper) | ||
|
||
include("conanbuildinfo.cmake") | ||
conan_basic_setup() | ||
|
||
add_subdirectory(source_subfolder) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
sources: | ||
"cci.20190617": | ||
url: "https://github.com/google/astc-codec/archive/9757befb64db6662aad45de09ca87cd6f599ac02.tar.gz" | ||
sha256: "19034fed68401a612655b026e713c351df8caa768f55ce29a0f628378e988eac" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <iostream> | ||
#include <vector> | ||
#include <cstdint> | ||
#include <fstream> | ||
#include <string> | ||
|
||
#include <astc-codec/astc-codec.h> | ||
|
||
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<uint8_t> astc_data((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>()); | ||
|
||
const size_t width = std::stoi(argv[2]); | ||
const size_t height = std::stoi(argv[3]); | ||
|
||
std::vector<uint8_t> 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
versions: | ||
"cci.20190617": | ||
folder: all |