Skip to content

Commit

Permalink
Merge branch 'feature/conan2' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Leduc committed Dec 18, 2023
2 parents 65439b5 + 1941ea4 commit 5c215df
Show file tree
Hide file tree
Showing 47 changed files with 2,160 additions and 901 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ To get a sample how to declare an additional remote/bucket/ppa ... see the repos


### Installing/Configure dependencies
```remaken install [--conan_profile conan_profile_name] [-r path_to_remaken_root] -i [-o linux] -t github [-l nexus -u http://url_to_root_nexus_repo] [--cpp-std 17] [-c debug|release] [--project_mode,-p] [path_to_remaken_dependencies_description_file.txt] [--condition name=value]* [--conan-build dependency]* ```
```remaken install [--conan_profile conan_profile_name] [-r path_to_remaken_root] -i [-o linux] -t github [-l nexus -u http://url_to_root_nexus_repo] [--cpp-std 17] [-c debug|release] [-m static|shared] [--project_mode,-p] [path_to_remaken_dependencies_description_file.txt] [--condition name=value]* [--conan-build dependency]* ```

```remaken configure [--conan_profile conan_profile_name] [-r path_to_remaken_root] -i [-o linux] -t github [-l nexus -u http://url_to_root_nexus_repo] [--cpp-std 17] [-c debug|release] [--project_mode,-p] [path_to_remaken_dependencies_description_file.txt] [--condition name=value]* ```
```remaken configure [--conan_profile conan_profile_name] [-r path_to_remaken_root] -i [-o linux] -t github [-l nexus -u http://url_to_root_nexus_repo] [--cpp-std 17] [-c debug|release] [-m static|shared] [--project_mode,-p] [path_to_remaken_dependencies_description_file.txt] [--condition name=value]* ```

**Notes:**

Expand Down Expand Up @@ -253,7 +253,8 @@ Note: ```remaken_dependencies_description_file``` defaults to current folder ```

### Listing dependencies tree from a packagedependencies.txt file
```remaken info [path_to_remaken_dependencies_description_file.txt]```: displays the recursive dependency tree from the file.
```remaken info --pkg_systemfile -d path_to_write_pkgfile [path_to_remaken_dependencies_description_file.txt]```: generates pkg system files from packagedependencies files into specified folder - currently Only conan is managed.
```remaken info pkg_systemfile -d path_to_write_pkgfile [path_to_remaken_dependencies_description_file.txt]```: generates pkg system files from packagedependencies files into specified folder - currently Only conan is managed.
```remaken info [path_to_remaken_dependencies_description_file.txt] [-p [-m static|shared]]```: displays include, lib, and bin paths of all dependencies. can take an optionnal ```mode``` option (static or release) for defined default use mode.

### Listing remaken installed packages
The **list** command allows to :
Expand Down
4 changes: 2 additions & 2 deletions packagedependencies.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
boost|1.74.0|boost|conan|conan-center|default|zlib=False#bzip2=False
openssl|1.1.1f|openssl|conan|conan-center
boost|1.78.0|boost|conan|conan-center|default|
openssl|1.1.1t|openssl|conan|conan-center
12 changes: 2 additions & 10 deletions remaken.pro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
TARGET = remaken
VERSION=1.9.4
VERSION=1.10.0

CONFIG += c++1z
CONFIG += console
Expand Down Expand Up @@ -147,7 +147,6 @@ unix {
linux {
LIBS += -ldl -lpthread
QMAKE_CXXFLAGS += -std=c++17 -D_GLIBCXX_USE_CXX11_ABI=1
LIBS += -L/usr/local/lib -lZipper-static -lz
INCLUDEPATH += /usr/local/include
}

Expand All @@ -156,21 +155,14 @@ macx {
QMAKE_MAC_SDK= macosx
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15
QMAKE_CXXFLAGS += -fasm-blocks -x objective-c++ -std=c++17
#LIBS += -L/usr/lib -lz -lssl -lcrypto -L/usr/local/lib -lZipper-static
#Zipper dependency : https://github.com/sebastiandev/zipper
LIBS += -L/usr/local/lib -lboost_system -lstdc++
QMAKE_LFLAGS += -mmacosx-version-min=10.15 -v -lstdc++
INCLUDEPATH += /usr/local/include
}

win32 {
# windows libs
contains(QMAKE_TARGET.arch, x86_64) {
LIBS += -L$$(VCINSTALLDIR)lib/amd64 -L$$(VCINSTALLDIR)atlmfc/lib/amd64 -L$$(WINDOWSSDKDIR)lib/winv6.3/um/x64
}
else {
LIBS += -L$$(VCINSTALLDIR)lib -L$$(VCINSTALLDIR)atlmfc/lib -L$$(WINDOWSSDKDIR)lib/winv6.3/um/x86
}
LIBS += -L$$(WINDOWSSDKDIR)lib/winv6.3/um/x64
LIBS += -lshell32 -lgdi32 -lComdlg32
# openssl libs dependencies
LIBS += -luser32 -ladvapi32 -lCrypt32
Expand Down
8 changes: 7 additions & 1 deletion scripts/unixes/build_remaken.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
QTVERSION=5.15.2
PROJECTROOT=../..

# default linux values
QMAKEPATH=$HOME/Qt/${QTVERSION}/gcc_64/bin
if [[ "$OSTYPE" == "darwin"* ]]; then
# overload for mac values
Expand All @@ -27,8 +26,15 @@ if [ $# -ge 1 ]; then
fi
if [ $# -ge 2 ]; then
QTVERSION=$2

QMAKEPATH=$HOME/Qt/${QTVERSION}/gcc_64/bin
if [[ "$OSTYPE" == "darwin"* ]]; then
# overload for mac values
QMAKE_PATH=/Application/Qt/${QTVERSION}/clang_64/bin
fi
fi
if [ $# -eq 3 ]; then
# default linux values
QMAKEPATH=$3
fi

Expand Down
1 change: 1 addition & 0 deletions scripts/win/build_remaken.bat
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ for %%A in ("--help" "-h") do if "%1"==%%A (call:display_usage %1 & exit /b 0)
REM default win walues
if NOT [%1]==[] set PROJECTROOT=%1
if NOT [%2]==[] set QTVERSION=%2
set QMAKEPATH=C:\Qt\%QTVERSION%\msvc2019_64\bin
if NOT [%3]==[] set QMAKEPATH=%3

if not exist %PROJECTROOT% (echo "Remaken project root path '%PROJECTROOT%' doesn't exist" & exit /b 2)
Expand Down
34 changes: 27 additions & 7 deletions src/CmdOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ CmdOptions::CmdOptions()
m_cliApp.add_flag("--recurse", m_recurse, "recursive mode : parse dependencies recursively");
m_cliApp.add_option("--conan_profile", m_conanProfile, "force conan profile name to use (overrides detected profile)"); // ,true);
m_cliApp.add_option("--generator,-g", m_generator, "generator to use in [" + getOptionString("--generator") + "] (default: qmake) "); // ,true);
m_cliApp.add_option("--apiKey,-k", m_apiKey, "Artifactory api key");
m_dependenciesFile = "packagedependencies.txt";

// BUNDLE COMMAND
Expand All @@ -191,18 +192,23 @@ CmdOptions::CmdOptions()
bundleXpcfCommand->add_option("xpcf_file", m_xpcfConfigurationFile, "XPCF xml module declaration file")->required();
bundleXpcfCommand->add_flag("--ignore-errors", m_ignoreErrors, "force command execution : ignore error when a remaken dependency doesn't contains shared library");

CLI::App * cleanCommand = m_cliApp.add_subcommand("clean", "WARNING : remove every remaken installed packages");
/*CLI::App * cleanCommand =*/ m_cliApp.add_subcommand("clean", "WARNING : remove every remaken installed packages");

// CONFIGURE COMMAND
CLI::App * configureCommand = m_cliApp.add_subcommand("configure", "configure project dependencies");
configureCommand->add_option("file", m_dependenciesFile, "Remaken dependencies files - must be located in project root"); // ,true);
configureCommand->add_option("--condition", m_configureConditions, "set condition to value");
m_mode = "shared";
configureCommand->add_option("--mode,-m", m_mode, "Mode: " + getOptionString("--mode")); // ,true);

// INFO COMMAND
CLI::App * infoCommand = m_cliApp.add_subcommand("info", "Read package dependencies informations");
infoCommand->add_option("file", m_dependenciesFile, "Remaken dependencies files"); // ,true);
CLI::App * pkgSystemFileCommand = infoCommand->add_subcommand("pkg_systemfile", "write the dependency file of packaging system provided corresponding to the packagedependencies.txt - restrict with [" + getOptionString("--pkgrestrict") + "]");
pkgSystemFileCommand->add_option("--destination,-d", m_destinationRoot, "Destination directory for save conanfile.txt")->required();
infoCommand->add_flag("--paths,-p", m_infoDisplayPathsOption, "display all lib and bin paths of dependencies");
m_mode = "shared";
infoCommand->add_option("--mode,-m", m_mode, "Mode: " + getOptionString("--mode")); // ,true);

// PROFILE COMMAND
CLI::App * profileCommand = m_cliApp.add_subcommand("profile", "manage remaken profiles configuration");
Expand All @@ -223,21 +229,20 @@ CmdOptions::CmdOptions()
initVcpkgCommand->add_option("--tag", m_vcpkgTag, "the vcpkg tag version to install");
CLI::App * initArtifactPackagerCommand = initCommand->add_subcommand("artifactpkg", "setup artifact packager script");
initArtifactPackagerCommand->add_option("--tag", m_artifactPackagerTag, "the artifact packager tag version to install");
CLI::App * initWizardsCommand = initCommand->add_subcommand("wizards", "installs qtcreator wizards for remaken/Xpcf projects");
/*CLI::App * initWizardsCommand =*/ initCommand->add_subcommand("wizards", "installs qtcreator wizards for remaken/Xpcf projects");

#if defined(BOOST_OS_MACOS_AVAILABLE) || defined(BOOST_OS_LINUX_AVAILABLE)
CLI::App * initBrewCommand = initCommand->add_subcommand("brew", "setup brew repository");
/*CLI::App * initBrewCommand =*/ initCommand->add_subcommand("brew", "setup brew repository");
#endif

// VERSION COMMAND
CLI::App * versionCommand = m_cliApp.add_subcommand("version", "display remaken version");
/*CLI::App * versionCommand =*/ m_cliApp.add_subcommand("version", "display remaken version");

// INSTALL COMMAND
CLI::App * installCommand = m_cliApp.add_subcommand("install", "install dependencies for a package from its packagedependencies file(s)");
installCommand->add_option("--alternate-remote-type,-l", m_altRepoType, "alternate remote type: " + getOptionString("--alternate-remote-type"));
installCommand->add_option("--alternate-remote-url,-u", m_altRepoUrl, "alternate remote url to use when the declared remote fails to provide a dependency");
installCommand->add_flag("--invert-remote-order", m_invertRepositoryOrder, "invert alternate and base remote search order : alternate remote is searched before packagedependencies declared remote");
installCommand->add_option("--apiKey,-k", m_apiKey, "Artifactory api key");
installCommand->add_option("file", m_dependenciesFile, "Remaken dependencies files : can be a local file or an url to the file"); // ,true);
installCommand->add_flag("--project_mode,-p", m_projectMode, "enable project mode to generate project build files from packaging tools (conanbuildinfo ...).");//\nProject mode is enabled automatically when the folder containing the packagedependencies file also contains a QT project file");

Expand Down Expand Up @@ -271,7 +276,7 @@ CmdOptions::CmdOptions()

// REMOTE COMMAND
CLI::App * remoteCommand = m_cliApp.add_subcommand("remote", "Remote/sources/repositories/tap management");
CLI::App * remoteListCommand = remoteCommand->add_subcommand("list", "list all remotes/sources/tap from installed packaging systems");
/*CLI::App * remoteListCommand =*/ remoteCommand->add_subcommand("list", "list all remotes/sources/tap from installed packaging systems");
CLI::App * remoteListFileCommand = remoteCommand->add_subcommand("listfile", "list remotes/sources/tap declared from packagedependencies file");
remoteListFileCommand->add_option("file", m_dependenciesFile, "Remaken dependencies files"); // ,true);
CLI::App * remoteAddCommand = remoteCommand->add_subcommand("add", "add remotes/sources/tap declared from packagedependencies file");
Expand Down Expand Up @@ -413,7 +418,7 @@ CmdOptions::OptionResult CmdOptions::parseArguments(int argc, char** argv)
try {
fs::detail::utf8_codecvt_facet utf8;
m_cliApp.parse(argc, argv);
validateOptions();
validateOptions();
auto sub = m_cliApp.get_subcommands().at(0);
if (sub->get_name() == "profile") {
if (sub->get_subcommands().size() > 0) {
Expand Down Expand Up @@ -490,6 +495,18 @@ CmdOptions::OptionResult CmdOptions::parseArguments(int argc, char** argv)
return OptionResult::RESULT_ERROR;
}
}
if (sub->get_name() == "info") {
if (sub->get_subcommands().size() > 0) {
m_subcommand = sub->get_subcommands().at(0)->get_name();
if (!m_subcommand.empty()) {
if (m_subcommand != "pkg_systemfile") {
cout << "Error : info subcommand must be [pkg_systemfile]. "<<m_subcommand<<" is an invalid subcommand !"<<endl;
return OptionResult::RESULT_ERROR;
}
}
}
}

if (m_cliApp.get_subcommands().size() == 1) {
m_action = m_cliApp.get_subcommands().at(0)->get_name();
}
Expand Down Expand Up @@ -521,6 +538,9 @@ void CmdOptions::writeConfigurationFile() const
fs::detail::utf8_codecvt_facet utf8;
fs::path remakenRootPath = PathBuilder::getHomePath() / Constants::REMAKEN_FOLDER;
fs::path remakenProfilesPath = remakenRootPath / Constants::REMAKEN_PROFILES_FOLDER;
if (!fs::exists(remakenProfilesPath)) {
fs::create_directories(remakenProfilesPath);
}
fs::path remakenProfilePath = remakenProfilesPath/m_profileName;
ofstream fos;
fos.open(remakenProfilePath.generic_string(utf8),ios::out|ios::trunc);
Expand Down
5 changes: 5 additions & 0 deletions src/CmdOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ class CmdOptions
return m_installWizards;
}

bool infoDisplayPathsOption() const {
return m_infoDisplayPathsOption;
}

const std::string & getBuildConfig() const {
return m_buildConfig;
}
Expand Down Expand Up @@ -334,6 +338,7 @@ class CmdOptions
bool m_installWizards = false;
bool m_debugEnabled = false;
bool m_remoteOnly = false;
bool m_infoDisplayPathsOption = false;
std::vector<std::string> m_conanForceBuildRefs;
std::vector<std::string> m_configureConditions;
CLI::App m_cliApp{"remaken"};
Expand Down
4 changes: 3 additions & 1 deletion src/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Constants {
static constexpr const char * REMAKEN_PROFILES_FOLDER = "profiles";
static constexpr const char * REMAKEN_CACHE_FILE = ".remaken-cache";
static constexpr const char * ARTIFACTORY_API_KEY = "artifactoryApiKey";
static constexpr const char * QMAKE_RULES_DEFAULT_TAG = "4.9.5";
static constexpr const char * QMAKE_RULES_DEFAULT_TAG = "4.10.0-pre-release";
static constexpr const char * PKGINFO_FOLDER = ".pkginfo";
static constexpr const char * VCPKG_REPOURL = "https://github.com/microsoft/vcpkg";
static constexpr const char * EXTRA_DEPS = "extra-packages.txt";
Expand Down Expand Up @@ -70,6 +70,8 @@ namespace fs = boost::filesystem;
#include <sys/types.h>
#endif

#include <map>


template < typename Key, typename T> bool mapContains(const std::map<Key,T> & mapContainer, Key k)
{
Expand Down
3 changes: 2 additions & 1 deletion src/Dependency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ Dependency::Dependency(const std::string & rawFormat, const std::string & mainMo
m_mode = stripEndlineChar(results[5]);
boost::trim(m_mode);
if ((m_mode!= "static" && m_mode!= "shared" && m_mode!= "na") || (m_mode == "default")){
m_mode = mainMode;
std::cout << "[WARNING]: Current mode '" << m_mode << "' is unsupported for '"<< m_name << "' dependency, then apply '" << mainMode << "'default mode" << std::endl;
m_mode = mainMode;
}
}
else {
Expand Down
11 changes: 10 additions & 1 deletion src/Dependency.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ class Dependency
return m_libs;
}

const std::vector<std::string> & defines() const {
return m_defines;
}

std::vector<std::string> & cflags() {
return m_cflags;
}
Expand All @@ -141,11 +145,15 @@ class Dependency
return m_libdirs;
}


std::vector<std::string> & libs() {
return m_libs;
}

std::vector<std::string> & defines() {
return m_defines;
}


bool isSystemDependency() const;
bool isSpecificSystemToolDependency() const;
bool isGenericSystemDependency() const;
Expand Down Expand Up @@ -174,6 +182,7 @@ class Dependency
std::vector<std::string> m_libs;
std::string m_prefix;
std::vector<std::string> m_libdirs;
std::vector<std::string> m_defines;
Type m_type;
bool m_bHasOptions = false;
bool m_bHasConditions = false;
Expand Down
5 changes: 3 additions & 2 deletions src/FileHandlerFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ std::shared_ptr<IFileRetriever> FileHandlerFactory::getAlternateHandler(Dependen
retriever = getHandler(depType, options, repoType);
}
if (!retriever) {
// This should never happen, as command line options are validated in CmdOptions after parsing
throw std::runtime_error("Unknown repository type " + repoType);
if (options.getVerbose()) {
BOOST_LOG_TRIVIAL(warning)<<"No alternate repository found";
}
}
return retriever;
}
Expand Down
2 changes: 1 addition & 1 deletion src/backends/BazelGeneratorBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ void BazelGeneratorBackend::parseConditionsFile(const fs::path & rootFolderPath
std::vector<std::string> results;
std::string curStr;
getline(configureFile,curStr);
std::string formatRegexStr = "^[\t ]*REMAKENDEFINES[\t ]*=[\t ]*[\[]+([a-zA-Z0-9_, ]*)[\]]+";
std::string formatRegexStr = "^[\t ]*REMAKENDEFINES[\t ]*=[\t ]*[\\[]+([a-zA-Z0-9_, ]*)[\\]]+";
std::regex formatRegexr(formatRegexStr, std::regex_constants::extended);
std::smatch sm;
if (std::regex_search(curStr, sm, formatRegexr, std::regex_constants::match_any)) {
Expand Down
8 changes: 4 additions & 4 deletions src/backends/CMakeGeneratorBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,23 @@

#include <boost/log/trivial.hpp>

std::pair<std::string, fs::path> CMakeGeneratorBackend::generate(const std::vector<Dependency> & deps, Dependency::Type depType)
std::pair<std::string, fs::path> CMakeGeneratorBackend::generate([[maybe_unused]] const std::vector<Dependency> & deps, [[maybe_unused]] Dependency::Type depType)
{
BOOST_LOG_TRIVIAL(warning)<<"CMakeGeneratorBackend::generate NOT IMPLEMENTED";
return {"",fs::path()};
}

void CMakeGeneratorBackend::generateIndex(std::map<std::string,fs::path> setupInfos)
void CMakeGeneratorBackend::generateIndex([[maybe_unused]] std::map<std::string,fs::path> setupInfos)
{
BOOST_LOG_TRIVIAL(warning)<<"CMakeGeneratorBackend::generateIndex NOT IMPLEMENTED";
}

void CMakeGeneratorBackend::generateConfigureConditionsFile(const fs::path & rootFolderPath, const std::vector<Dependency> & deps)
void CMakeGeneratorBackend::generateConfigureConditionsFile([[maybe_unused]] const fs::path & rootFolderPath, [[maybe_unused]] const std::vector<Dependency> & deps)
{
BOOST_LOG_TRIVIAL(warning)<<"CMakeGeneratorBackend::generateConfigureConditionsFile NOT IMPLEMENTED";
}

void CMakeGeneratorBackend::parseConditionsFile(const fs::path & rootFolderPath, std::map<std::string,bool> & conditionsMap)
void CMakeGeneratorBackend::parseConditionsFile([[maybe_unused]] const fs::path & rootFolderPath, [[maybe_unused]] std::map<std::string,bool> & conditionsMap)
{
BOOST_LOG_TRIVIAL(warning)<<"CMakeGeneratorBackend::parseConditionsFile NOT IMPLEMENTED";
}
25 changes: 24 additions & 1 deletion src/backends/IGeneratorBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class IGeneratorBackend
virtual void generateIndex(std::map<std::string,fs::path> setupInfos) = 0;
virtual void generateConfigureConditionsFile(const fs::path & rootFolderPath, const std::vector<Dependency> & deps) = 0;
virtual void parseConditionsFile(const fs::path & rootFolderPath, std::map<std::string,bool> & conditionsMap) = 0;

virtual void forceConditions(std::map<std::string,bool> & conditionsMap) = 0;
};


Expand All @@ -49,12 +49,35 @@ class AbstractGeneratorBackend : virtual public IGeneratorBackend {
AbstractGeneratorBackend(const CmdOptions & options, const std::string & extension): m_options(options), m_extension(extension) {}
virtual ~AbstractGeneratorBackend() override = default;

void forceConditions(std::map<std::string,bool> & conditionsMap) override
{
// Manage force configure conditions by command line
for (auto & arg : m_options.getConfigureConditions()) {
std::vector<std::string> condition;
boost::split(condition, arg, [](char c){return c == '=';});
std::string conditionName = condition[0];
std::string conditionValue;
if (condition.size() >= 2) {
conditionValue = condition[1];
}
if (!conditionName.empty() && !conditionValue.empty()) {
if (boost::iequals(conditionValue, "true")) {
conditionsMap.insert_or_assign(conditionName, true);
}
else if (boost::iequals(conditionValue, "false")) {
conditionsMap.insert_or_assign(conditionName, false);
}
}
}
}

protected:
std::string getGeneratorFileName(const std::string & file) const
{
std::string fileName = file + m_extension;
return fileName;
}

const CmdOptions & m_options;
std::string m_extension;
};
Expand Down
Loading

0 comments on commit 5c215df

Please sign in to comment.