-
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.
Merge pull request #828 from Garcia6l20/master
add chaiscript
- Loading branch information
Showing
7 changed files
with
146 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,11 @@ | ||
cmake_minimum_required(VERSION 3.4) | ||
project(cmake_wrapper) | ||
|
||
include(conanbuildinfo.cmake) | ||
conan_basic_setup() | ||
|
||
if (WIN32 AND BUILD_SHARED_LIBS) | ||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) | ||
endif(WIN32 AND BUILD_SHARED_LIBS) | ||
|
||
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: | ||
"6.1.0": | ||
sha256: 3ca9ba6434b4f0123b5ab56433e3383b01244d9666c85c06cc116d7c41e8f92a | ||
url: https://github.com/ChaiScript/ChaiScript/archive/v6.1.0.tar.gz |
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,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], | ||
"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) | ||
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") |
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,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) |
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,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) |
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,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'; | ||
} |
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 @@ | ||
--- | ||
versions: | ||
"6.1.0": | ||
folder: all |