-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBuildfile.cpp
50 lines (38 loc) · 1010 Bytes
/
Buildfile.cpp
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
//
// Buildfile.cpp
// KTPuild-Jarek
//
// Created by Nathan Brown on 4/6/19.
// Copyright © 2019 Nathan Brown. All rights reserved.
//
#include <stdio.h>
#include "Buildfile.h"
#include <fstream>
#include "nlohmann/json.hpp"
#include <iostream>
#include <stdexcept>
using namespace std;
using namespace nlohmann;
Buildfile :: Buildfile(){
json data;
ifstream fs("Buildfile.json");
if (!fs.is_open()) {
std::cerr << "Missing build file, -10 KTPoints\n";
throw(std::runtime_error("no buildfile"));
}
//parses JSON file. Will throw if invalid JSON
fs >> data;
//set executable name
executable = data["Name"];
//set the compilation flags
for(auto &i: data["Flags"]){
compilation_flags.push_back(i);
}
//set the linker flags. For now they are the same as the compilation flags, but
//we may want to provide the ability to override this
linker_flags = compilation_flags;
//set the sources
for(auto &i: data["Sources"]){
cpp_files.push_back(i);
}
}