Skip to content

Commit 150b7ab

Browse files
committed
add chaiscript
1 parent eea2f70 commit 150b7ab

File tree

7 files changed

+130
-0
lines changed

7 files changed

+130
-0
lines changed

recipes/chaiscript/all/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_minimum_required(VERSION 3.4)
2+
project(cmake_wrapper)
3+
4+
include(conanbuildinfo.cmake)
5+
conan_basic_setup()
6+
7+
if (WIN32 AND BUILD_SHARED_LIBS)
8+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
9+
endif(WIN32 AND BUILD_SHARED_LIBS)
10+
11+
add_subdirectory("source_subfolder")

recipes/chaiscript/all/conandata.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
sources:
2+
"6.1.0":
3+
sha256: 3ca9ba6434b4f0123b5ab56433e3383b01244d9666c85c06cc116d7c41e8f92a
4+
url: https://github.com/ChaiScript/ChaiScript/archive/v6.1.0.tar.gz

recipes/chaiscript/all/conanfile.py

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
from conans import ConanFile, CMake, tools
2+
import os
3+
4+
5+
class ChaiScriptConan(ConanFile):
6+
name = "chaiscript"
7+
homepage = "https://github.com/ChaiScript/ChaiScript"
8+
description = "Embedded Scripting Language Designed for C++."
9+
topics = ("conan", "embedded-scripting-language", "language")
10+
url = "https://github.com/conan-io/conan-center-index"
11+
license = "BSD-3-Clause"
12+
exports_sources = ["CMakeLists.txt"]
13+
generators = "cmake"
14+
settings = "os", "compiler", "build_type", "arch"
15+
options = {"shared": [True, False], "fPIC": [True, False], "dyn_load": [True, False], "use_std_make_shared": [True, False],
16+
"multithread_support": [True, False]}
17+
default_options = {"shared": False, "fPIC": True, "dyn_load": True, "use_std_make_shared": True,
18+
"multithread_support": True}
19+
20+
@property
21+
def _source_subfolder(self):
22+
return "source_subfolder"
23+
24+
@property
25+
def _build_subfolder(self):
26+
return "build_subfolder"
27+
28+
def source(self):
29+
tools.get(**self.conan_data["sources"][self.version])
30+
extracted_dir = "ChaiScript-" + self.version
31+
os.rename(extracted_dir, self._source_subfolder)
32+
33+
def config_options(self):
34+
if self.settings.os == "Windows":
35+
del self.options.fPIC
36+
37+
def _configure_cmake(self):
38+
cmake = CMake(self)
39+
cmake.definitions["USE_STD_MAKE_SHARED"] = self.options.use_std_make_shared
40+
cmake.definitions["DYNLOAD_ENABLED"] = self.options.dyn_load
41+
cmake.definitions["MULTITHREAD_SUPPORT_ENABLED"] = self.options.multithread_support
42+
cmake.configure(build_folder=self._build_subfolder)
43+
return cmake
44+
45+
def build(self):
46+
cmake = self._configure_cmake()
47+
cmake.build()
48+
49+
def package(self):
50+
self.copy("LICENSE", dst="licenses", src=self._source_subfolder)
51+
cmake = self._configure_cmake()
52+
cmake.install()
53+
tools.rmdir(os.path.join(self.package_folder, "lib", "cmake"))
54+
tools.rmdir(os.path.join(self.package_folder, "lib", "pkgconfig"))
55+
tools.rmdir(os.path.join(self.package_folder, "share"))
56+
57+
def package_info(self):
58+
self.cpp_info.libs = tools.collect_libs(self)
59+
if self.options.use_std_make_shared:
60+
self.cpp_info.defines.append("CHAISCRIPT_USE_STD_MAKE_SHARED")
61+
if self.settings.os == "Linux":
62+
self.cpp_info.system_libs = ["dl"]
63+
if self.options.multithread_support:
64+
self.cpp_info.system_libs.append("pthread")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
project(test_package CXX)
2+
cmake_minimum_required(VERSION 2.8.12)
3+
4+
set(CMAKE_VERBOSE_MAKEFILE ON)
5+
6+
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
7+
conan_basic_setup(TARGETS)
8+
9+
find_package(chaiscript REQUIRED CONFIG)
10+
11+
# TEST_PACKAGE #################################################################
12+
13+
add_executable(${CMAKE_PROJECT_NAME} test_package.cpp)
14+
target_link_libraries(${CMAKE_PROJECT_NAME} CONAN_PKG::chaiscript)
15+
set_property(TARGET ${CMAKE_PROJECT_NAME} PROPERTY CXX_STANDARD 14)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
from conans import ConanFile, CMake
3+
4+
5+
class TestPackageConan(ConanFile):
6+
settings = "os", "compiler", "build_type", "arch"
7+
generators = "cmake_find_package_multi", "cmake"
8+
9+
def build(self):
10+
cmake = CMake(self)
11+
cmake.configure()
12+
cmake.build()
13+
14+
def test(self):
15+
self.run(os.path.join("bin", "test_package"), run_environment=True)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <chaiscript/chaiscript.hpp>
2+
#include <iostream>
3+
#include <cassert>
4+
5+
double chai_add(double i, double j)
6+
{
7+
return i + j;
8+
}
9+
10+
int main()
11+
{
12+
chaiscript::ChaiScript chai;
13+
chai.add(chaiscript::fun(&chai_add), "add");
14+
const auto answer = chai.eval<double>("add(38.8, 3.2);");
15+
assert(static_cast<int>(answer) == 42);
16+
std::cout << "The answer is: " << answer << '\n';
17+
}

recipes/chaiscript/config.yml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
versions:
3+
"6.1.0":
4+
folder: all

0 commit comments

Comments
 (0)