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

miniscript: add recipe #15000

Merged
merged 5 commits into from
Jan 30, 2023
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
66 changes: 66 additions & 0 deletions recipes/miniscript/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a Makefile in the project, but I agree in adding this CMake file, as the original Makefile is very limited and it seems be compatible only Unix systems.

project(miniscript LANGUAGES CXX)

set(MINISCRIPT_SRC
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/Dictionary.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/List.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptInterpreter.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptIntrinsics.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptKeywords.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptLexer.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptParser.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptTAC.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptTypes.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/QA.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/SimpleString.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/SimpleVector.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/SplitJoin.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/UnicodeUtil.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/UnitTest.cpp
)

set(MINISCRIPT_INC
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/Dictionary.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/List.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptErrors.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptInterpreter.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptIntrinsics.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptKeywords.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptLexer.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptParser.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptTAC.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/MiniscriptTypes.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/QA.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/RefCountedStorage.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/SimpleString.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/SimpleVector.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/SplitJoin.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/UnicodeUtil.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/UnitTest.h
)


add_library(miniscript ${MINISCRIPT_SRC})
target_include_directories(miniscript PRIVATE ${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src)
set_target_properties(miniscript PROPERTIES
PUBLIC_HEADER "${MINISCRIPT_INC}"
WINDOWS_EXPORT_ALL_SYMBOLS ON
C_EXTENSIONS OFF
)
target_compile_features(miniscript PRIVATE cxx_std_11)

if(MSVC)
target_compile_options(miniscript PRIVATE /EHsc /wd4068)
endif()

find_library(LIBM m)
target_link_libraries(miniscript PRIVATE $<$<BOOL:${LIBM}>:${LIBM}>)

include(GNUInstallDirs)
install(
TARGETS miniscript
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/MiniScript
)
4 changes: 4 additions & 0 deletions recipes/miniscript/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"1.5.1":
url: "https://github.com/JoeStrout/miniscript/archive/172bea8e762c96b1b2a5ea743228ff6a58702cc3.tar.gz"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sha256: "a82ac634621657e14f046b6fd08dbc624e8e9890b646573edef454a2e540a1e2"
60 changes: 60 additions & 0 deletions recipes/miniscript/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from conan import ConanFile
from conan.tools.files import get, copy
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout

import os

required_conan_version = ">=1.53.0"

class MiniscriptConan(ConanFile):
name = "miniscript"
description = "modern, elegant, easy to learn, and easy to embed in your own C# or C++ projects."
license = "MIT"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/JoeStrout/miniscript"
topics = ("script", "embedded", "programming-language")
settings = "os", "arch", "compiler", "build_type"
options = {
"shared": [True, False],
"fPIC": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
}
exports_sources = ["CMakeLists.txt"]

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

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")

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

def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
tc = CMakeToolchain(self)
tc.variables["MINISCRIPT_SRC_DIR"] = self.source_folder.replace("\\", "/")
tc.generate()

def build(self):
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir))
cmake.build()

def package(self):
copy(self, pattern="LICENSE", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder)
cmake = CMake(self)
cmake.install()

def package_info(self):
self.cpp_info.libs = ["miniscript"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
self.cpp_info.system_libs.append("pthread")
8 changes: 8 additions & 0 deletions recipes/miniscript/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

find_package(miniscript REQUIRED CONFIG)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE miniscript::miniscript)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
26 changes: 26 additions & 0 deletions recipes/miniscript/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os


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

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 can_run(self):
bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package")
self.run(bin_path, env="conanrun")
25 changes: 25 additions & 0 deletions recipes/miniscript/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <iostream>
#include <fstream>

#include "MiniScript/SimpleString.h"
#include "MiniScript/UnicodeUtil.h"
#include "MiniScript/SimpleVector.h"
#include "MiniScript/List.h"
#include "MiniScript/Dictionary.h"
#include "MiniScript/MiniscriptParser.h"
#include "MiniScript/MiniscriptInterpreter.h"

int main() {
MiniScript::Interpreter interp;

interp.standardOutput = [](MiniScript::String s) { std::cout << s.c_str() << std::endl; };
interp.errorOutput = [](MiniScript::String s) { std::cerr << s.c_str() << std::endl; };
interp.implicitOutput = [](MiniScript::String s) { std::cout << s.c_str() << std::endl; };

interp.REPL("x = 5");
interp.REPL("print \"x = \" + x");
interp.REPL("y = 5 + x");
interp.REPL("print \"y = \" + y");

return 0;
}
8 changes: 8 additions & 0 deletions recipes/miniscript/all/test_v1_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.1)
project(test_package)

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

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../test_package/
${CMAKE_CURRENT_BINARY_DIR}/test_package/)
18 changes: 18 additions & 0 deletions recipes/miniscript/all/test_v1_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from conans import ConanFile, CMake
from conan.tools.build import cross_building
import os


class TestPackageV1Conan(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 cross_building(self):
bin_path = os.path.join("bin", "test_package")
self.run(bin_path, run_environment=True)
3 changes: 3 additions & 0 deletions recipes/miniscript/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
versions:
"1.5.1":
folder: all