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 (retry) #26368

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
44 changes: 34 additions & 10 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 @@ -39,26 +39,50 @@ set(MINISCRIPT_INC
${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
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"
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"
39 changes: 26 additions & 13 deletions recipes/miniscript/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
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"
required_conan_version = ">=2.0.9"

class MiniscriptConan(ConanFile):
name = "miniscript"
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 @@ -23,29 +27,38 @@ class MiniscriptConan(ConanFile):
"fPIC": True,
}
exports_sources = ["CMakeLists.txt"]
implements = ["auto_shared_fpic"]

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 export_sources(self):
export_conandata_patches(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)"
)
check_min_cppstd(self, 11 if Version(self.version) < "1.6.2" else 17)

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

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):
cmake = CMake(self)
cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir))
if Version(self.version) < "1.6.2":
cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir))
else:
cmake.configure()
cmake.build()

def package(self):
Expand All @@ -54,7 +67,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 {

4 changes: 3 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,6 @@ 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_definitions(${PROJECT_NAME} PRIVATE MINISCRIPT_1_6)
endif()
9 changes: 4 additions & 5 deletions recipes/miniscript/all/test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
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 requirements(self):
self.requires(self.tested_reference_str)

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")
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
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
8 changes: 0 additions & 8 deletions recipes/miniscript/all/test_v1_package/CMakeLists.txt

This file was deleted.

18 changes: 0 additions & 18 deletions recipes/miniscript/all/test_v1_package/conanfile.py

This file was deleted.

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