Start working on build system.
This commit is contained in:
parent
4b308f6c32
commit
521486be62
88 changed files with 1065 additions and 349 deletions
73
src/base/compiler/BuildSession.cpp
Normal file
73
src/base/compiler/BuildSession.cpp
Normal file
|
@ -0,0 +1,73 @@
|
|||
#include "BuildSession.h"
|
||||
|
||||
#include "Logger.h"
|
||||
#include "Process.h"
|
||||
#include "Directory.h"
|
||||
|
||||
BuildSession::BuildSession(const String& source_dir,
|
||||
const String& build_dir)
|
||||
: m_source_dir(source_dir)
|
||||
{
|
||||
if (build_dir.empty())
|
||||
{
|
||||
m_build_dir = FileSystemPath::current_dir().value();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_build_dir = build_dir;
|
||||
}
|
||||
}
|
||||
|
||||
Status BuildSession::scan()
|
||||
{
|
||||
LOG_INFO("Scanning sources at:" << m_source_dir);
|
||||
Vector<FileSystemPath> toml_files;
|
||||
STATUS_CHECK(Directory::getFilesWithExtension(
|
||||
m_source_dir,
|
||||
".toml",
|
||||
toml_files,
|
||||
true), "Error looking for build files");
|
||||
|
||||
for(const auto& toml_file : toml_files)
|
||||
{
|
||||
if (toml_file.file_name() == "build")
|
||||
{
|
||||
STATUS_CHECK(add_library(toml_file),
|
||||
"Error adding library");
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
||||
}
|
||||
|
||||
Status BuildSession::add_library(const FileSystemPath& config_path)
|
||||
{
|
||||
LOG_INFO("Adding library at: " << config_path);
|
||||
BuildLibrary lib(config_path);
|
||||
STATUS_CHECK(lib.scan(), "Error scanning library");
|
||||
m_libraries.push_back(lib);
|
||||
return {};
|
||||
}
|
||||
|
||||
Status BuildSession::build()
|
||||
{
|
||||
for(const auto& library : m_libraries)
|
||||
{
|
||||
for(const auto& source : library.get_sources())
|
||||
{
|
||||
String compiler_command = m_compiler_command + " -c ";
|
||||
compiler_command += source.str() + " ";
|
||||
LOG_INFO("Running command: " << compiler_command);
|
||||
|
||||
const auto self_name = Process::get_self_name();
|
||||
if (!self_name.ok())
|
||||
{
|
||||
return Status(self_name.error());
|
||||
}
|
||||
LOG_INFO("Self name is: " << self_name.value());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return {};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue