Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add chaiscript #828

Merged
merged 3 commits into from
Apr 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions recipes/chaiscript/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.4)
project(cmake_wrapper)

include(conanbuildinfo.cmake)
conan_basic_setup()

if (WIN32 AND BUILD_SHARED_LIBS)
Garcia6l20 marked this conversation as resolved.
Show resolved Hide resolved
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif(WIN32 AND BUILD_SHARED_LIBS)

add_subdirectory("source_subfolder")
4 changes: 4 additions & 0 deletions recipes/chaiscript/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"6.1.0":
sha256: 3ca9ba6434b4f0123b5ab56433e3383b01244d9666c85c06cc116d7c41e8f92a
url: https://github.com/ChaiScript/ChaiScript/archive/v6.1.0.tar.gz
80 changes: 80 additions & 0 deletions recipes/chaiscript/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
from conans import ConanFile, CMake, tools
import os


class ChaiScriptConan(ConanFile):
name = "chaiscript"
homepage = "https://github.com/ChaiScript/ChaiScript"
description = "Embedded Scripting Language Designed for C++."
topics = ("conan", "embedded-scripting-language", "language")
url = "https://github.com/conan-io/conan-center-index"
license = "BSD-3-Clause"
exports_sources = ["CMakeLists.txt"]
generators = "cmake"
settings = "os", "compiler", "build_type", "arch"
options = {"fPIC": [True, False], "dyn_load": [True, False], "use_std_make_shared": [True, False],
Garcia6l20 marked this conversation as resolved.
Show resolved Hide resolved
"multithread_support": [True, False],
"header_only": [True, False]}
default_options = {"fPIC": True, "dyn_load": True,
"use_std_make_shared": True,
"multithread_support": True,
"header_only": True}

@property
def _source_subfolder(self):
return "source_subfolder"

@property
def _build_subfolder(self):
return "build_subfolder"

def source(self):
tools.get(**self.conan_data["sources"][self.version])
extracted_dir = "ChaiScript-" + self.version
os.rename(extracted_dir, self._source_subfolder)

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC

def _configure_cmake(self):
cmake = CMake(self)
Garcia6l20 marked this conversation as resolved.
Show resolved Hide resolved
cmake.definitions["BUILD_TESTING"] = False
cmake.definitions["BUILD_SAMPLES"] = False
cmake.definitions["BUILD_MODULES"] = True
cmake.definitions["USE_STD_MAKE_SHARED"] = self.options.use_std_make_shared
cmake.definitions["DYNLOAD_ENABLED"] = self.options.dyn_load
cmake.definitions["MULTITHREAD_SUPPORT_ENABLED"] = self.options.multithread_support
cmake.configure(build_folder=self._build_subfolder)
return cmake

def build(self):
if not self.options.header_only:
cmake = self._configure_cmake()
cmake.build()

def package(self):
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
if self.options.header_only:
self.copy(pattern="*.hpp", dst="include",
src=os.path.join(self._source_subfolder, 'include'))
else:
cmake = self._configure_cmake()
cmake.install()
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
tools.rmdir(os.path.join(self.package_folder, "share"))

def package_id(self):
if self.options.header_only:
self.info.header_only()

def package_info(self):
if not self.options.header_only:
self.cpp_info.libs = tools.collect_libs(self)
if self.options.use_std_make_shared:
self.cpp_info.defines.append("CHAISCRIPT_USE_STD_MAKE_SHARED")
if self.settings.os == "Linux":
self.cpp_info.system_libs = ["dl"]
if self.options.multithread_support:
self.cpp_info.system_libs.append("pthread")
15 changes: 15 additions & 0 deletions recipes/chaiscript/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
project(test_package CXX)
cmake_minimum_required(VERSION 2.8.12)

set(CMAKE_VERBOSE_MAKEFILE ON)

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

find_package(chaiscript REQUIRED CONFIG)

# TEST_PACKAGE #################################################################

add_executable(${CMAKE_PROJECT_NAME} test_package.cpp)
target_link_libraries(${CMAKE_PROJECT_NAME} CONAN_PKG::chaiscript)
set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 14)
15 changes: 15 additions & 0 deletions recipes/chaiscript/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
from conans import ConanFile, CMake


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

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

def test(self):
self.run(os.path.join("bin", "test_package"), run_environment=True)
17 changes: 17 additions & 0 deletions recipes/chaiscript/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <chaiscript/chaiscript.hpp>
#include <iostream>
#include <cassert>

double chai_add(double i, double j)
{
return i + j;
}

int main()
{
chaiscript::ChaiScript chai;
chai.add(chaiscript::fun(&chai_add), "add");
const auto answer = chai.eval<double>("add(38.8, 3.2);");
assert(static_cast<int>(answer) == 42);
std::cout << "The answer is: " << answer << '\n';
}
4 changes: 4 additions & 0 deletions recipes/chaiscript/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
versions:
"6.1.0":
folder: all