From fddc425020ff82775a7110f6781ea01b7cc5207e Mon Sep 17 00:00:00 2001 From: Firefly35 Date: Sat, 23 Nov 2024 23:25:59 +0100 Subject: [PATCH 1/3] feat[meson]: WIP. add meson build. Start MesonBackendGenerator implementation. --- README.md | 22 +++ meson.build | 102 ++++++++++ remaken.pro | 1 + src/Constants.cpp | 11 ++ src/Constants.h | 5 +- src/backends/BackendGeneratorFactory.cpp | 3 + src/backends/MesonGeneratorBackend.cpp | 203 ++++++++++++++++++++ src/backends/MesonGeneratorBackend.h | 37 ++++ src/managers/BundleManager.cpp | 4 +- src/retrievers/CredentialsFileRetriever.cpp | 2 +- src/utils/DepUtils.cpp | 2 +- src/utils/OsUtils.cpp | 2 +- 12 files changed, 388 insertions(+), 6 deletions(-) create mode 100644 meson.build create mode 100755 src/Constants.cpp create mode 100644 src/backends/MesonGeneratorBackend.cpp create mode 100644 src/backends/MesonGeneratorBackend.h diff --git a/README.md b/README.md index 45b491d..136b67f 100644 --- a/README.md +++ b/README.md @@ -492,6 +492,28 @@ Where: ### Linux build from the ```scripts/unixes``` folder, run ```./build_remaken.sh``` +### Meson build (on linux so far) +from the repository root folder, run +``` +pushd libs +git clone --recurse-submodules https://github.com/boostorg/boost +pushd boost +mkdir cmake-build +pushd cmake-build +cmake -DCMAKE_INSTALL_PREFIX=../../boost_install .. +make +make install +popd +popd +popd +meson setup meson-builddir +pushd meson-builddir +meson compile +popd +``` +The remaken binary is in the meson-builddir folder +Note: this build depends on system openssl for now. + ### Windows build from the ```scripts/win``` folder, run ```./build_remaken.bat``` diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..1d99442 --- /dev/null +++ b/meson.build @@ -0,0 +1,102 @@ +project('remaken', 'cpp') +#NOTE: BOOST_OS_LINUX_AVAILABLE is defined hardcoded : must figure out why os detection doesn't work within boost/predef ? +add_project_arguments('-DMYVERSIONSTRING="1.10.1"', '-DBOOST_OS_LINUX_AVAILABLE', language : 'cpp') +cc = meson.get_compiler('cpp') +incdir = include_directories('libs/CLI11/include', 'libs/nlohmann-json/single_include', 'src') +openssl_dep = dependency('openssl') +boost_lib_dir = meson.project_source_root() / 'libs/boost_install/lib' +boost_dep = declare_dependency( + dependencies : [cc.find_library('boost_atomic', dirs : [boost_lib_dir]), \ + cc.find_library('boost_charconv', dirs : [boost_lib_dir]), \ + cc.find_library('boost_chrono', dirs : [boost_lib_dir]), \ + cc.find_library('boost_cobalt', dirs : [boost_lib_dir]), \ + cc.find_library('boost_container', dirs : [boost_lib_dir]), \ + cc.find_library('boost_context', dirs : [boost_lib_dir]), \ + cc.find_library('boost_contract', dirs : [boost_lib_dir]), \ + cc.find_library('boost_coroutine', dirs : [boost_lib_dir]), \ + cc.find_library('boost_date_time', dirs : [boost_lib_dir]), \ + cc.find_library('boost_fiber', dirs : [boost_lib_dir]), \ + cc.find_library('boost_fiber_numa', dirs : [boost_lib_dir]), \ + cc.find_library('boost_filesystem', dirs : [boost_lib_dir]), \ + cc.find_library('boost_graph', dirs : [boost_lib_dir]), \ + cc.find_library('boost_iostreams', dirs : [boost_lib_dir]), \ + cc.find_library('boost_json', dirs : [boost_lib_dir]), \ + cc.find_library('boost_locale', dirs : [boost_lib_dir]), \ + cc.find_library('boost_log', dirs : [boost_lib_dir]), \ + cc.find_library('boost_log_setup', dirs : [boost_lib_dir]), \ + cc.find_library('boost_nowide', dirs : [boost_lib_dir]), \ + cc.find_library('boost_prg_exec_monitor', dirs : [boost_lib_dir]), \ + cc.find_library('boost_process', dirs : [boost_lib_dir]), \ + cc.find_library('boost_program_options', dirs : [boost_lib_dir]), \ + cc.find_library('boost_random', dirs : [boost_lib_dir]), \ + cc.find_library('boost_serialization', dirs : [boost_lib_dir]), \ + cc.find_library('boost_stacktrace_addr2line', dirs : [boost_lib_dir]), \ + cc.find_library('boost_stacktrace_backtrace', dirs : [boost_lib_dir]), \ + cc.find_library('boost_stacktrace_basic', dirs : [boost_lib_dir]), \ + cc.find_library('boost_stacktrace_from_exception', dirs : [boost_lib_dir]), \ + cc.find_library('boost_stacktrace_noop', dirs : [boost_lib_dir]), \ + cc.find_library('boost_test_exec_monitor', dirs : [boost_lib_dir]), \ + cc.find_library('boost_thread', dirs : [boost_lib_dir]), \ + cc.find_library('boost_timer', dirs : [boost_lib_dir]), \ + cc.find_library('boost_type_erasure', dirs : [boost_lib_dir]), \ + cc.find_library('boost_unit_test_framework', dirs : [boost_lib_dir]), \ + cc.find_library('boost_url', dirs : [boost_lib_dir]), \ + cc.find_library('boost_wave', dirs : [boost_lib_dir]), \ + cc.find_library('boost_wserialization', dirs : [boost_lib_dir])], \ + include_directories : include_directories('libs/boost_install/include/boost') +) + +#boost_dep = dependency('boost', modules : ['DLL', 'Filesystem', 'Fiber']) +remaken = executable('remaken', 'src/backends/BackendGeneratorFactory.cpp', \ + 'src/backends/BazelGeneratorBackend.cpp', \ + 'src/backends/CMakeGeneratorBackend.cpp', \ + 'src/backends/JSONGeneratorBackend.cpp', \ + 'src/backends/QMakeGeneratorBackend.cpp', \ + 'src/backends/MesonGeneratorBackend.cpp', \ + 'src/commands/RemoteCommand.cpp', \ + 'src/commands/SearchCommand.cpp', \ + 'src/managers/BundleManager.cpp', \ + 'src/commands/BundleXpcfCommand.cpp', \ + 'src/commands/CleanCommand.cpp', \ + 'src/commands/ConfigureCommand.cpp', \ + 'src/commands/ListCommand.cpp', \ + 'src/managers/XpcfXmlManager.cpp', \ + 'src/tools/BrewSystemTool.cpp', \ + 'src/tools/ConanSystemTool.cpp', \ + 'src/tools/GitTool.cpp', \ + 'src/commands/InfoCommand.cpp', \ + 'src/commands/PackageCommand.cpp', \ + 'src/commands/InitCommand.cpp', \ + 'src/tools/NativeSystemTools.cpp', \ + 'src/tools/PkgConfigTool.cpp', \ + 'src/utils/DepUtils.cpp', \ + 'src/utils/OsUtils.cpp', \ + 'src/utils/PathBuilder.cpp', \ + 'src/commands/ProfileCommand.cpp', \ + 'src/commands/RunCommand.cpp', \ + 'src/tools/VCPKGSystemTool.cpp', \ + 'src/tools/ZipTool.cpp', \ + 'src/main.cpp', \ + 'src/Dependency.cpp', \ + 'src/managers/DependencyManager.cpp', \ + 'src/Constants.cpp', \ + 'src/CmdOptions.cpp', \ + 'src/Cache.cpp', \ + 'src/commands/InstallCommand.cpp', \ + 'src/commands/VersionCommand.cpp', \ + 'src/commands/AbstractCommand.cpp', \ + 'src/FileHandlerFactory.cpp', \ + 'src/retrievers/CredentialsFileRetriever.cpp', \ + 'src/retrievers/FSFileRetriever.cpp', \ + 'src/retrievers/HttpFileRetriever.cpp', \ + 'src/retrievers/AbstractFileRetriever.cpp', \ + 'src/HttpHandlerFactory.cpp', \ + 'src/retrievers/ConanFileRetriever.cpp', \ + 'src/retrievers/SystemFileRetriever.cpp', \ + 'src/tools/SystemTools.cpp', \ + 'src/commands/ParseCommand.cpp', \ + 'src/commands/BundleCommand.cpp', \ + 'src/tinyxml2.cpp', \ + 'src/tinyxmlhelper.cpp', + include_directories : incdir, + dependencies : [boost_dep, openssl_dep]) diff --git a/remaken.pro b/remaken.pro index e848d2e..86f9e71 100755 --- a/remaken.pro +++ b/remaken.pro @@ -118,6 +118,7 @@ SOURCES += \ src/main.cpp \ src/Dependency.cpp \ src/managers/DependencyManager.cpp \ + src/Constants.cpp \ src/CmdOptions.cpp \ src/Cache.cpp \ src/commands/InstallCommand.cpp \ diff --git a/src/Constants.cpp b/src/Constants.cpp new file mode 100755 index 0000000..1ad45ed --- /dev/null +++ b/src/Constants.cpp @@ -0,0 +1,11 @@ +#include "Constants.h" + +bool copy_file_overwrite(fs::path const& from, fs::path const& to, boost::system::error_code* ec) +{ + #if BOOST_VERSION >= 107400 + fs::copy_file(from , to, fs::copy_options::overwrite_existing); + #else /* BOOST_VERSION */ + fs::copy_file(from , to, fs::copy_option::overwrite_if_exists); + #endif /* BOOST_VERSION */ +} + diff --git a/src/Constants.h b/src/Constants.h index a0aa084..7fe8067 100755 --- a/src/Constants.h +++ b/src/Constants.h @@ -50,7 +50,8 @@ typedef enum { pkg_config = 0x04, json = 0x08, make = 0x10, - bazel = 0x20 + bazel = 0x20, + meson = 0x40 } GeneratorType; typedef enum { @@ -94,4 +95,6 @@ typename Range::const_iterator find(Range const& range, Value const& value) return std::find(begin(range), end(range), value); } +bool copy_file_overwrite(fs::path const& from, fs::path const& to, boost::system::error_code* ec = nullptr); + #endif // CONSTANTS_H diff --git a/src/backends/BackendGeneratorFactory.cpp b/src/backends/BackendGeneratorFactory.cpp index 2459604..04a96e1 100644 --- a/src/backends/BackendGeneratorFactory.cpp +++ b/src/backends/BackendGeneratorFactory.cpp @@ -25,6 +25,7 @@ #include "backends/CMakeGeneratorBackend.h" #include "backends/JSONGeneratorBackend.h" #include "backends/QMakeGeneratorBackend.h" +#include "backends/MesonGeneratorBackend.h" namespace BackendGeneratorFactory { std::shared_ptr getGenerator(const CmdOptions & options) @@ -38,6 +39,8 @@ std::shared_ptr getGenerator(const CmdOptions & options) break; case GeneratorType::json: return std::make_shared(options); break; + case GeneratorType::meson: return std::make_shared(options); + break; default: throw std::runtime_error("Generator not imnplemented - generator support coming in future releases"); break; diff --git a/src/backends/MesonGeneratorBackend.cpp b/src/backends/MesonGeneratorBackend.cpp new file mode 100644 index 0000000..e601b6c --- /dev/null +++ b/src/backends/MesonGeneratorBackend.cpp @@ -0,0 +1,203 @@ +/** + * @copyright Copyright (c) 2019 B-com http://www.b-com.com/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @author Loïc Touraine + * + * @file + * @brief description of file + * @date 2019-11-15 + */ + +#include "backends/MesonGeneratorBackend.h" +#include +#include +#include + +static const std::map type2prefixMap = { + {Dependency::Type::BREW,"BREW"}, + {Dependency::Type::REMAKEN,"REMAKEN"}, + {Dependency::Type::CONAN,"CONAN"}, + {Dependency::Type::CHOCO,"CHOCO"}, + {Dependency::Type::SYSTEM,"SYSTEM"}, + {Dependency::Type::SCOOP,"SCOOP"}, + {Dependency::Type::VCPKG,"VCPKG"} +}; + +std::pair MesonGeneratorBackend::generate(const std::vector & deps, Dependency::Type depType) +{ + fs::detail::utf8_codecvt_facet utf8; + if (!mapContains(type2prefixMap,depType)) { + throw std::runtime_error("Error dependency type " + std::to_string(static_cast(depType)) + " no supported"); + } + std::string prefix = type2prefixMap.at(depType); + std::string filename = boost::to_lower_copy(prefix) + getGeneratorFileName("buildinfo"); + fs::path filePath = DepUtils::getProjectBuildSubFolder(m_options)/filename; + std::ofstream fos(filePath.generic_string(utf8),std::ios::out); + std::string libdirs, libsStr, defines, cflags; + for (auto & dep : deps ) { + for (auto & cflagInfos : dep.cflags()) { + std::vector cflagsVect; + boost::split_regex(cflagsVect, cflagInfos, boost::regex( " -" )); + for (auto & cflag: cflagsVect) { + if (cflag[0] == '-') { + cflag.erase(0,1); + } + std::string cflagPrefix = cflag.substr(0,1); + if (cflagPrefix == "I") { + // remove -I + cflag.erase(0,1); + boost::trim(cflag); + if (!cflags.empty()) { + cflags += ", "; + } + cflags += "'" + cflag + "'"; + } + else if (cflagPrefix == "D") { + // remove -D + cflag.erase(0,1); + boost::trim(cflag); + defines += " " + cflag; + } + } + } + for (auto & define : dep.defines()) { + defines += " " + define; + } + + for (auto & libInfos : dep.libs()) { + std::vector optionsVect; + boost::split_regex(optionsVect, libInfos, boost::regex( " -" )); + for (auto & option: optionsVect) { + if (option[0] == '-') { + option.erase(0,1); + } + std::string optionPrefix = option.substr(0,1); + if (optionPrefix == "L") { + option.erase(0,1); + libdirs += " -L\"" + option + "\""; + } + //TODO : extract lib paths from libdefs and put quotes around libs path + else { + boost::trim(option); + libsStr += " -" + option; + } + } + } + for (auto & libdir : dep.libdirs()) { + libdirs += " -L\"" + libdir + "\""; + } + } + fos< setupInfos) +{ + fs::detail::utf8_codecvt_facet utf8; + fs::path buildProjectSubFolderPath = DepUtils::getProjectBuildSubFolder(m_options); + fs::path depsInfoFilePath = buildProjectSubFolderPath / getGeneratorFileName("dependenciesBuildInfo"); // extension should later depend on generator type + std::ofstream depsOstream(depsInfoFilePath.generic_string(utf8),std::ios::out); + for (auto & kv : setupInfos) { + depsOstream<<"CONFIG += "< & deps) +{ + fs::detail::utf8_codecvt_facet utf8; + fs::path buildFolderPath = rootFolderPath/DepUtils::getBuildPlatformFolder(m_options); + fs::path configureFilePath = buildFolderPath / getGeneratorFileName("configure_conditions"); + if (fs::exists(configureFilePath) ) { + fs::remove(configureFilePath); + } + + if (deps.empty()) { + return; + } + + if (!fs::exists(buildFolderPath)) { + fs::create_directories(buildFolderPath); + } + std::ofstream configureFile(configureFilePath.generic_string(utf8).c_str(), std::ios::out); + for (auto & dep : deps) { + for (auto & condition : dep.getConditions()) { + configureFile << "DEFINES += " << condition; + configureFile << "\n"; + } + } + configureFile.close(); +} + +void MesonGeneratorBackend::parseConditionsFile(const fs::path & rootFolderPath, std::map & conditionsMap) +{ + fs::detail::utf8_codecvt_facet utf8; + fs::path configureFilePath = rootFolderPath / getGeneratorFileName("configure_conditions"); + //std::map conditionsMap; + + if (!fs::exists(configureFilePath)) { + return; + } + + std::ifstream configureFile(configureFilePath.generic_string(utf8).c_str(), std::ios::in); + while (!configureFile.eof()) { + std::vector results; + std::string curStr; + getline(configureFile,curStr); + //std::string formatRegexStr = "^[\t\s]*DEFINES[\t\s]*+=[\t\s]*[a-zA-Z0-9_-]*"; + //std::regex formatRegexr(formatRegexStr, std::regex_constants::extended); + std::smatch sm; + //check string format is ^[\t\s]*DEFINES[\t\s]*+=[\t\s]*[a-zA-Z0-9_-]* + // if (std::regex_search(curStr, sm, formatRegexr, std::regex_constants::match_any)) { + boost::split(results, curStr, [](char c){return c == '=';}); + if (results.size() == 2) { + std::string definesValue = results[0]; + std::string conditionValue = results[1]; + boost::algorithm::erase_all(definesValue, " "); + boost::trim(conditionValue); + if (definesValue == "DEFINES+") { + conditionsMap.insert_or_assign(conditionValue, true); + } + if (definesValue == "DEFINES-") { + conditionsMap.insert_or_assign(conditionValue, false); + } + } + // } + } + configureFile.close(); +} diff --git a/src/backends/MesonGeneratorBackend.h b/src/backends/MesonGeneratorBackend.h new file mode 100644 index 0000000..c942bc6 --- /dev/null +++ b/src/backends/MesonGeneratorBackend.h @@ -0,0 +1,37 @@ +/** + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * @author Loïc Touraine + * + * @file + * @brief description of file + * @date 2024-11-21 + */ + +#ifndef MESONGENERATORBACKEND_H +#define MESONGENERATORBACKEND_H +#include "backends/IGeneratorBackend.h" + +class MesonGeneratorBackend : virtual public AbstractGeneratorBackend +{ +public: + MesonGeneratorBackend(const CmdOptions & options):AbstractGeneratorBackend(options,".options") {} + ~MesonGeneratorBackend() override = default; + std::pair generate(const std::vector & deps, Dependency::Type depType) override; + void generateIndex(std::map setupInfos) override; + void generateConfigureConditionsFile(const fs::path & rootFolderPath, const std::vector & deps) override; + void parseConditionsFile(const fs::path & rootFolderPath, std::map & conditionsMap) override; +}; + +#endif // MESONGENERATORBACKEND_H diff --git a/src/managers/BundleManager.cpp b/src/managers/BundleManager.cpp index cae8382..da45d8f 100755 --- a/src/managers/BundleManager.cpp +++ b/src/managers/BundleManager.cpp @@ -100,8 +100,8 @@ int BundleManager::bundleXpcf() BOOST_LOG_TRIVIAL(error)<<" the xpcf configuration file must be an xml file with the correct .xml extension, file provided is "< & modulesPathMap = m_xpcfManager.parseXpcfModulesConfiguration(xpcfConfigFilePath); m_xpcfManager.updateXpcfModulesPath(m_options.getDestinationRoot()/xpcfConfigFilePath.filename()); for (auto & [name,modulePath] : modulesPathMap) { diff --git a/src/retrievers/CredentialsFileRetriever.cpp b/src/retrievers/CredentialsFileRetriever.cpp index 2863500..82391e9 100644 --- a/src/retrievers/CredentialsFileRetriever.cpp +++ b/src/retrievers/CredentialsFileRetriever.cpp @@ -64,7 +64,7 @@ http::status CredentialsFileRetriever::downloadArtefact (const std::string & sou httpWrapper->shutdown(); auto locationField = res.get().find("location"); - newLocation = locationField->value().to_string(); + newLocation = static_cast(locationField->value()); // not_connected happens sometimes // so don't bother reporting it. // diff --git a/src/utils/DepUtils.cpp b/src/utils/DepUtils.cpp index b764580..c2e71c2 100755 --- a/src/utils/DepUtils.cpp +++ b/src/utils/DepUtils.cpp @@ -283,7 +283,7 @@ fs::path DepUtils::downloadFile(const CmdOptions & options, const std::string & if (!fs::exists(outputDirectory)) { fs::create_directories(outputDirectory); } - bool result = fs::copy_file(compressedDependency,outputDirectory/name,fs::copy_option::overwrite_if_exists); + bool result = copy_file_overwrite(compressedDependency,outputDirectory/name); if (!result) { throw std::runtime_error("Error copying file " + source); } diff --git a/src/utils/OsUtils.cpp b/src/utils/OsUtils.cpp index 3519d7e..25fb703 100755 --- a/src/utils/OsUtils.cpp +++ b/src/utils/OsUtils.cpp @@ -168,7 +168,7 @@ void OsUtils::copyLibrary(const fs::path & sourceFile, const fs::path & destinat } else if (is_regular_file(sourceFile)) { if (!fs::exists(destinationFolderPath/sourceFile.filename()) || overwrite) { - fs::copy_file(sourceFile , destinationFolderPath/sourceFile.filename(), fs::copy_option::overwrite_if_exists); + copy_file_overwrite(sourceFile , destinationFolderPath/sourceFile.filename()); } } } From 9d838f35fb6d8165392ddee660cf685a4369bc45 Mon Sep 17 00:00:00 2001 From: Firefly35 Date: Fri, 6 Dec 2024 17:15:13 +0100 Subject: [PATCH 2/3] Improve meson build --- .gitignore | 1 + README.md | 20 ++++---------------- meson.build | 4 ++-- meson_build.sh | 12 ++++++++++++ 4 files changed, 19 insertions(+), 18 deletions(-) create mode 100755 meson_build.sh diff --git a/.gitignore b/.gitignore index 97ad2d0..53be2f3 100644 --- a/.gitignore +++ b/.gitignore @@ -32,6 +32,7 @@ *.app # Output directories +.build/* .build-rules/* scripts/*/build-* diff --git a/README.md b/README.md index 136b67f..f17448e 100644 --- a/README.md +++ b/README.md @@ -494,24 +494,12 @@ from the ```scripts/unixes``` folder, run ```./build_remaken.sh``` ### Meson build (on linux so far) from the repository root folder, run + ``` -pushd libs -git clone --recurse-submodules https://github.com/boostorg/boost -pushd boost -mkdir cmake-build -pushd cmake-build -cmake -DCMAKE_INSTALL_PREFIX=../../boost_install .. -make -make install -popd -popd -popd -meson setup meson-builddir -pushd meson-builddir -meson compile -popd +./meson_build.sh ``` -The remaken binary is in the meson-builddir folder + +The remaken binary is in the .build/remaken folder Note: this build depends on system openssl for now. ### Windows build diff --git a/meson.build b/meson.build index 1d99442..d54f560 100644 --- a/meson.build +++ b/meson.build @@ -4,7 +4,7 @@ add_project_arguments('-DMYVERSIONSTRING="1.10.1"', '-DBOOST_OS_LINUX_AVAILABLE' cc = meson.get_compiler('cpp') incdir = include_directories('libs/CLI11/include', 'libs/nlohmann-json/single_include', 'src') openssl_dep = dependency('openssl') -boost_lib_dir = meson.project_source_root() / 'libs/boost_install/lib' +boost_lib_dir = meson.project_source_root() / '.build/boost/install/lib' boost_dep = declare_dependency( dependencies : [cc.find_library('boost_atomic', dirs : [boost_lib_dir]), \ cc.find_library('boost_charconv', dirs : [boost_lib_dir]), \ @@ -43,7 +43,7 @@ boost_dep = declare_dependency( cc.find_library('boost_url', dirs : [boost_lib_dir]), \ cc.find_library('boost_wave', dirs : [boost_lib_dir]), \ cc.find_library('boost_wserialization', dirs : [boost_lib_dir])], \ - include_directories : include_directories('libs/boost_install/include/boost') + include_directories : include_directories('.build/boost/install/include/boost') ) #boost_dep = dependency('boost', modules : ['DLL', 'Filesystem', 'Fiber']) diff --git a/meson_build.sh b/meson_build.sh new file mode 100755 index 0000000..11204d5 --- /dev/null +++ b/meson_build.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +mkdir -p .build/boost/cmake +pushd .build/boost/cmake +cmake -DCMAKE_INSTALL_PREFIX=../install ../../../libs/boost +make +make install +popd +meson setup .build/remaken +pushd .build/remaken +meson compile +popd \ No newline at end of file From 13dc6250399e0e691396ed0ff91731bf92b14199 Mon Sep 17 00:00:00 2001 From: Firefly35 Date: Mon, 27 Jan 2025 21:46:52 +0100 Subject: [PATCH 3/3] Improve meson build --- .gitignore | 3 +++ meson.build | 8 ++++++-- meson_build.sh | 19 ++++++++++++++++++- subprojects/openssl.wrap | 15 +++++++++++++++ 4 files changed, 42 insertions(+), 3 deletions(-) create mode 100644 subprojects/openssl.wrap diff --git a/.gitignore b/.gitignore index 53be2f3..8b2e149 100644 --- a/.gitignore +++ b/.gitignore @@ -35,6 +35,9 @@ .build/* .build-rules/* scripts/*/build-* +libs/boost/* +subprojects/*/ + # Qmake temporary files *.pro.user diff --git a/meson.build b/meson.build index d54f560..0dd680d 100644 --- a/meson.build +++ b/meson.build @@ -1,9 +1,13 @@ -project('remaken', 'cpp') +project('remaken', 'cpp', default_options : ['cpp_std=c++17']) #NOTE: BOOST_OS_LINUX_AVAILABLE is defined hardcoded : must figure out why os detection doesn't work within boost/predef ? add_project_arguments('-DMYVERSIONSTRING="1.10.1"', '-DBOOST_OS_LINUX_AVAILABLE', language : 'cpp') + cc = meson.get_compiler('cpp') incdir = include_directories('libs/CLI11/include', 'libs/nlohmann-json/single_include', 'src') -openssl_dep = dependency('openssl') + +openssl_proj = subproject('openssl') +openssl_dep = openssl_proj.get_variable('openssl_dep') + boost_lib_dir = meson.project_source_root() / '.build/boost/install/lib' boost_dep = declare_dependency( dependencies : [cc.find_library('boost_atomic', dirs : [boost_lib_dir]), \ diff --git a/meson_build.sh b/meson_build.sh index 11204d5..750caa9 100755 --- a/meson_build.sh +++ b/meson_build.sh @@ -1,12 +1,29 @@ #!/bin/bash +if [ ! -d libs/boost ]; then + pushd libs + echo "Trying to clone boost from github" + git clone --recurse-submodules https://github.com/boostorg/boost + popd +fi + +if [ ! -d libs/boost ]; then + echo "Error cloning boost from github - exiting" + exit +fi + +echo "Building boost" mkdir -p .build/boost/cmake pushd .build/boost/cmake -cmake -DCMAKE_INSTALL_PREFIX=../install ../../../libs/boost +cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_POSITION_INDEPENDENT_CODE=ON ../../../libs/boost make make install popd + +echo "Meson setup for remaken" meson setup .build/remaken + +echo "Building remaken" pushd .build/remaken meson compile popd \ No newline at end of file diff --git a/subprojects/openssl.wrap b/subprojects/openssl.wrap new file mode 100644 index 0000000..873d551 --- /dev/null +++ b/subprojects/openssl.wrap @@ -0,0 +1,15 @@ +[wrap-file] +directory = openssl-3.0.8 +source_url = https://www.openssl.org/source/openssl-3.0.8.tar.gz +source_filename = openssl-3.0.8.tar.gz +source_hash = 6c13d2bf38fdf31eac3ce2a347073673f5d63263398f1f69d0df4a41253e4b3e +patch_filename = openssl_3.0.8-3_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/openssl_3.0.8-3/get_patch +patch_hash = 300da189e106942347d61a4a4295aa2edbcf06184f8d13b4cee0bed9fb936963 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/openssl_3.0.8-3/openssl-3.0.8.tar.gz +wrapdb_version = 3.0.8-3 + +[provide] +libcrypto = libcrypto_dep +libssl = libssl_dep +openssl = openssl_dep