Skip to content

Commit

Permalink
Merge pull request #2 from madebr/pr_lodepng
Browse files Browse the repository at this point in the history
lodepng: change version + fix shared + test_package
  • Loading branch information
intelligide authored Aug 4, 2020
2 parents 3b01548 + de78913 commit 4870bc3
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 8 deletions.
6 changes: 5 additions & 1 deletion recipes/lodepng/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.4)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

if(BUILD_SHARED_LIBS)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()

add_library(lodepng "source_subfolder/lodepng.h" "source_subfolder/lodepng.cpp")

include(GNUInstallDirs)
Expand Down
2 changes: 1 addition & 1 deletion recipes/lodepng/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sources:
"20200615":
"cci.20200615":
url: "https://github.com/lvandeve/lodepng/archive/34628e89e80cd007179b25b0b2695e6af0f57fac.tar.gz"
sha256: "486ece0b661e83e509f1c6c9a05ca8dd1dd0008eec47d2aad9359e3609ab44a9"
3 changes: 2 additions & 1 deletion recipes/lodepng/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import glob
from conans import ConanFile, CMake, tools


class LodepngConan(ConanFile):
name = "lodepng"
description = "PNG encoder and decoder in C and C++, without dependencies."
Expand Down Expand Up @@ -61,4 +62,4 @@ def package(self):
self.copy(pattern="LICENSE", dst="licenses", src=self._source_subfolder)

def package_info(self):
self.cpp_info.libs = tools.collect_libs(self)
self.cpp_info.libs = ["lodepng"]
4 changes: 3 additions & 1 deletion recipes/lodepng/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
Expand All @@ -13,4 +14,5 @@ def build(self):
def test(self):
if not tools.cross_building(self.settings):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
bees = os.path.join(self.source_folder, "bees.png")
self.run("{} {}".format(bin_path, bees), run_environment=True)
18 changes: 15 additions & 3 deletions recipes/lodepng/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@

#include "lodepng.h"

int main()
int main(int argc, const char *argv[])
{
std::ifstream stream("bees.png", std::ios::in | std::ios::binary);
if (argc < 2) {
std::cerr << "Need at least one argument\n";
}
std::ifstream stream(argv[1], std::ios::in | std::ios::binary);
std::vector<uint8_t> data((std::istreambuf_iterator<char>(stream)), std::istreambuf_iterator<char>());

std::cout << "file name " << argv[1] << "\n";
std::cout << "file size " << data.size() << " bytes\n";

std::vector<uint8_t> decoded;
unsigned width = 0, height = 0;
lodepng::decode(decoded, width, height, data);
unsigned error = lodepng::decode(decoded, width, height, data);
if (error != 0) {
std::cerr << "lodepng::decode returned with error code " << error << "\n";
return 1;
}
std::cout << "image size: " << width << " x " << height << " pixels.\n";

stream.close();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion recipes/lodepng/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
versions:
"20200615":
"cci.20200615":
folder: all

0 comments on commit 4870bc3

Please sign in to comment.