Skip to content

Commit

Permalink
(#12666) nuklear: add 4.10.1 + conan v2 support
Browse files Browse the repository at this point in the history
* conan v2 support

* add nuklear/4.10.1
  • Loading branch information
SpaceIm authored Sep 1, 2022
1 parent 252a309 commit 96aa8d9
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 27 deletions.
3 changes: 3 additions & 0 deletions recipes/nuklear/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
sources:
"4.10.1":
url: "https://github.com/Immediate-Mode-UI/Nuklear/archive/refs/tags/4.10.1.tar.gz"
sha256: "a7bd28477e00be6768e9b8cc3a406bc67b2d32d3a023b1e44868e8c566a7eb2f"
"4.06.1":
url: "https://github.com/Immediate-Mode-UI/Nuklear/archive/74a4df4eb965150ede86fefa6c147476541078a4.zip"
sha256: "d654b50b524f5f7db8cd742bff5ab6bcd42a9dd785d44429267cc3d5f5742b06"
Expand Down
39 changes: 26 additions & 13 deletions recipes/nuklear/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
from conan import ConanFile
from conan.tools.files import copy, get
from conan.tools.layout import basic_layout
import os

from conans import ConanFile, tools
required_conan_version = ">=1.50.0"


class NuklearConan(ConanFile):
name = "nuklear"
description = "A single-header ANSI C immediate mode cross-platform GUI library."
license = ["MIT", "Unlicense"]
topics = ("conan", "nuklear", "gui", "header-only")
topics = ("nuklear", "gui", "header-only")
homepage = "https://github.com/Immediate-Mode-UI/Nuklear"
url = "https://github.com/conan-io/conan-center-index"
settings = "os", "arch", "compiler", "build_type"
no_copy_source = True

@property
def _source_subfolder(self):
return "source_subfolder"
def package_id(self):
self.info.clear()

def layout(self):
basic_layout(self, src_folder="src")

def source(self):
tools.get(**self.conan_data["sources"][self.version])
url = self.conan_data["sources"][self.version]["url"]
extracted_dir = "Nuklear-" + os.path.splitext(os.path.basename(url))[0]
os.rename(extracted_dir, self._source_subfolder)
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def build(self):
pass

def package(self):
self.copy("LICENSE", dst="licenses", src=os.path.join(self._source_subfolder, "src"))
self.copy("nuklear.h", dst="include", src=self._source_subfolder)
copy(self, "LICENSE", src=os.path.join(self.source_folder, "src"), dst=os.path.join(self.package_folder, "licenses"))
copy(self, "nuklear.h", src=self.source_folder, dst=os.path.join(self.package_folder, "include"))

def package_id(self):
self.info.header_only()
def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.frameworkdirs = []
self.cpp_info.libdirs = []
self.cpp_info.resdirs = []
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
11 changes: 3 additions & 8 deletions recipes/nuklear/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
cmake_minimum_required(VERSION 3.1)
project(test_package C)
project(test_package LANGUAGES C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
find_package(nuklear REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.c)
target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS})
find_library(M_LIB m)
if(M_LIB)
target_link_libraries(${PROJECT_NAME} ${M_LIB})
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE nuklear::nuklear)
20 changes: 14 additions & 6 deletions recipes/nuklear/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import CMake, cmake_layout
import os

from conans import ConanFile, CMake, tools

class TestPackageConan(ConanFile):
settings = "os", "compiler", "build_type", "arch"
generators = "cmake"
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeToolchain", "CMakeDeps", "VirtualRunEnv"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

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")
self.run(bin_path, run_environment=True)
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
10 changes: 10 additions & 0 deletions recipes/nuklear/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.1)
project(test_package LANGUAGES C)

include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup(TARGETS)

find_package(nuklear REQUIRED CONFIG)

add_executable(${PROJECT_NAME} ../test_package/test_package.c)
target_link_libraries(${PROJECT_NAME} PRIVATE nuklear::nuklear)
17 changes: 17 additions & 0 deletions recipes/nuklear/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from conans import ConanFile, CMake, tools
import os


class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "cmake", "cmake_find_package_multi"

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if not tools.cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
2 changes: 2 additions & 0 deletions recipes/nuklear/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"4.10.1":
folder: all
"4.06.1":
folder: all
"4.03.1":
Expand Down

0 comments on commit 96aa8d9

Please sign in to comment.