aboutsummaryrefslogtreecommitdiff
path: root/include/Package.hpp
blob: 72652be8460d5862b2bb4e6776729be81ccde7a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef SIBS_PACKAGE_HPP
#define SIBS_PACKAGE_HPP

#include "../external/rapidjson/document.h"
#include "Platform.hpp"
#include "Result.hpp"
#include "Version.hpp"
#include <string>
#include <vector>

namespace sibs
{
    enum class PackageType : int
    {
        // Compile as executable when compiling project with this directly.
        // If used in dependency, then fail because you can't (currently) have dependency to executable.
        EXECUTABLE,

        // Compile as static library when compiling project with this directly.
        // If used in dependency, then this is the preferred library type, but the dependant project can override this.
        STATIC,

        // Compile as dynamic library when compiling project with this directly.
        // If used in dependency, then this is the preferred library type, but the dependant project can override this.
        DYNAMIC,

        // Identical to DYNAMIC
        LIBRARY
    };
    
    struct PackageMetadata
    {
        std::string description;
        PackageVersion version;
        std::vector<std::string> platforms;
        std::vector<std::string> urls;
    };
    
    class Package
    {
    public:
        /*
         * Get package list from url which contains json file.
         * Returns json document structure (rapidjson)
         */
        static Result<rapidjson::Document*> getPackageList(const char *url);
        
        /*
         * Return the package data for the package we can use
         * TODO: If we fail to fetch package from first url, try other other ones in the list (or if the first url is too slow / takes too long to respond).
         */
        static Result<PackageMetadata> getPackage(const char *packageName, const PackageVersionRange &versionRange, Platform platform);
    };
}

#endif //SIBS_PACKAGE_HPP