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 version 1.6.2 #22861

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
42 changes: 34 additions & 8 deletions recipes/miniscript/all/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.8)
project(miniscript LANGUAGES CXX)
project(Miniscript LANGUAGES C CXX)

set(MINISCRIPT_SRC
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/MiniScript/Dictionary.cpp
Expand Down Expand Up @@ -40,25 +40,51 @@ set(MINISCRIPT_INC
)


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

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

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

set(MINICMD_HEADERS
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/OstreamSupport.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/ShellIntrinsics.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/editline/editline.h
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/editline/unix.h
)

if(NOT WIN32)
set(EDITLINE_SRC
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/editline/complete.c
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/editline/editline.c
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/editline/sysunix.c
)
endif()

add_executable(minicmd
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/main.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/OstreamSupport.cpp
${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/ShellIntrinsics.cpp
${EDITLINE_SRC}
${MINICMD_HEADERS}
)
target_include_directories(minicmd PRIVATE ${MINISCRIPT_SRC_DIR}/MiniScript-cpp/src/editline)
target_link_libraries(minicmd PRIVATE miniscript-cpp)
target_compile_features(minicmd PRIVATE cxx_std_11)

include(GNUInstallDirs)
install(
TARGETS miniscript
TARGETS miniscript-cpp minicmd
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
Expand Down
13 changes: 13 additions & 0 deletions recipes/miniscript/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
sources:
"1.6.2":
url: "https://github.com/JoeStrout/miniscript/archive/refs/tags/v1.6.2.tar.gz"
sha256: "62df0ce8faca21db588ed5f0abe020a41602c8fc02376f6b2385869863acbefd"
"1.5.1":
url: "https://github.com/JoeStrout/miniscript/archive/172bea8e762c96b1b2a5ea743228ff6a58702cc3.tar.gz"
sha256: "a82ac634621657e14f046b6fd08dbc624e8e9890b646573edef454a2e540a1e2"
patches:
"1.6.2":
- patch_file: "patches/1.6.2-0001-fix-install.patch"
patch_description: "fix install destinations"
patch_type: "portability"
toge marked this conversation as resolved.
Show resolved Hide resolved
patch_source: "https://github.com/JoeStrout/miniscript/pull/184"
- patch_file: "patches/1.6.2-0002-remove-bit.patch"
patch_description: "remove unused bit header"
patch_type: "portability"
patch_source: "https://github.com/JoeStrout/miniscript/pull/145"
53 changes: 48 additions & 5 deletions recipes/miniscript/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from conan import ConanFile
from conan.tools.files import get, copy
from conan.tools.files import get, copy, apply_conandata_patches, export_conandata_patches
from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout

from conan.errors import ConanInvalidConfiguration
from conan.tools.build import check_min_cppstd
from conan.tools.scm import Version
from conan.tools.microsoft import is_msvc
import os

required_conan_version = ">=1.53.0"
Expand All @@ -14,6 +17,7 @@ class MiniscriptConan(ConanFile):
homepage = "https://github.com/JoeStrout/miniscript"
topics = ("script", "embedded", "programming-language")
settings = "os", "arch", "compiler", "build_type"
package_type = "library"
options = {
"shared": [True, False],
"fPIC": [True, False],
Expand All @@ -24,6 +28,25 @@ class MiniscriptConan(ConanFile):
}
exports_sources = ["CMakeLists.txt"]

@property
def _min_cppstd(self):
return "11" if Version(self.version) < "1.6.2" else "17"

@property
def _compilers_minimum_version(self):
return {
"17": {
"gcc": "8",
"clang": "7",
"apple-clang": "12",
"Visual Studio": "16",
"msvc": "192",
},
}.get(self._min_cppstd, {})

def export_sources(self):
export_conandata_patches(self)

def config_options(self):
if self.settings.os == 'Windows':
del self.options.fPIC
Expand All @@ -35,17 +58,37 @@ def configure(self):
def layout(self):
cmake_layout(self, src_folder="src")

def validate(self):
# miniscript doesn't declare export symbols with __declspec.
if is_msvc(self) and self.options.shared:
raise ConanInvalidConfiguration(
f"{self.ref} doesn't support msvc shared build.(yet)"
)

if self.settings.compiler.get_safe("cppstd"):
check_min_cppstd(self, self._min_cppstd)
minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support."
)

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("\\", "/")
if Version(self.version) < "1.6.2":
tc.variables["MINISCRIPT_SRC_DIR"] = self.source_folder.replace("\\", "/")
tc.generate()

def build(self):
apply_conandata_patches(self)
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir))
if Version(self.version) >= "1.6.2":
toge marked this conversation as resolved.
Show resolved Hide resolved
cmake.configure()
else:
cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir))
cmake.build()

def package(self):
Expand All @@ -54,7 +97,7 @@ def package(self):
cmake.install()

def package_info(self):
self.cpp_info.libs = ["miniscript"]
self.cpp_info.libs = ["miniscript-cpp"]
if self.settings.os in ["Linux", "FreeBSD"]:
self.cpp_info.system_libs.append("m")
self.cpp_info.system_libs.append("pthread")
21 changes: 21 additions & 0 deletions recipes/miniscript/all/patches/1.6.2-0001-fix-install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0d00a90..5984c15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -131,4 +131,14 @@ if(MINISCRIPT_BUILD_TESTING)
endif()
endif()

-install(TARGETS miniscript-cpp minicmd)
+include(GNUInstallDirs)
+install(
+ TARGETS miniscript-cpp minicmd
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+install(
+ FILES ${MINISCRIPT_HEADERS}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/MiniScript
+)
\ No newline at end of file
13 changes: 13 additions & 0 deletions recipes/miniscript/all/patches/1.6.2-0002-remove-bit.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/MiniScript-cpp/src/MiniScript/MiniscriptTypes.cpp b/MiniScript-cpp/src/MiniScript/MiniscriptTypes.cpp
index c406663..696dacf 100644
--- a/MiniScript-cpp/src/MiniScript/MiniscriptTypes.cpp
+++ b/MiniScript-cpp/src/MiniScript/MiniscriptTypes.cpp
@@ -15,7 +15,7 @@

#include <iostream>
#include <math.h>
-#include <bit>
+

namespace MiniScript {

7 changes: 6 additions & 1 deletion recipes/miniscript/all/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ 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)
if(miniscript_VERSION VERSION_GREATER_EQUAL "1.6.2")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
target_compile_definitions(${PROJECT_NAME} PRIVATE MINISCRIPT_1_6)
else()
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11)
endif()
21 changes: 21 additions & 0 deletions recipes/miniscript/all/test_package/test_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@
#include "MiniScript/MiniscriptParser.h"
#include "MiniScript/MiniscriptInterpreter.h"

#ifdef MINISCRIPT_1_6

int main() {
MiniScript::Interpreter interp;

interp.standardOutput = [](MiniScript::String s, bool lineBreak=true) { std::cout << s.c_str() << std::endl; };
interp.errorOutput = [](MiniScript::String s, bool lineBreak=true) { std::cerr << s.c_str() << std::endl; };
interp.implicitOutput = [](MiniScript::String s, bool lineBreak=true) { 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;
}

#else

int main() {
MiniScript::Interpreter interp;

Expand All @@ -23,3 +42,5 @@ int main() {

return 0;
}

#endif
2 changes: 2 additions & 0 deletions recipes/miniscript/config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
versions:
"1.6.2":
folder: all
"1.5.1":
folder: all
Loading