aboutsummaryrefslogtreecommitdiff
path: root/backend/ninja/Ninja.hpp
blob: 3ccee1e0bf7933ec56a987b8b017c72796c02de8 (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
#ifndef BACKEND_NINJA_HPP
#define BACKEND_NINJA_HPP

#include "../../include/Dependency.hpp"
#include "../../include/Result.hpp"
#include "../../include/Linker.hpp"
#include <vector>
#include <string>
#include <functional>


namespace backend
{
    class Ninja
    {
    public:
        enum class LibraryType
        {
            EXECUTABLE,
            DYNAMIC,
            STATIC
        };

        Ninja(LibraryType libraryType = LibraryType::EXECUTABLE);

        void addSourceFile(const char *filepath);
        const std::vector<std::string>& getSourceFiles() const;
        sibs::Result<bool> createBuildFile(const std::string &packageName, const std::vector<sibs::Dependency> &dependencies, const char *savePath, sibs::LinkerFlagCallbackFunc linkerFlagCallbackFunc = nullptr);
        sibs::Result<bool> build(const char *buildFilePath);
    private:
        bool containsSourceFile(const char *filepath) const;
        sibs::Result<std::string> getLinkerFlags(const std::vector<sibs::Dependency> &dependencies, sibs::LinkerFlagCallbackFunc linkerFlagCallbackFunc) const;
    private:
        std::vector<std::string> sourceFiles;
        LibraryType libraryType;
    };
}

#endif //BACKEND_NINJA_HPP