Core lib building
This commit is contained in:
parent
3ed195d7dd
commit
94fcc42aed
73 changed files with 625 additions and 661 deletions
|
@ -16,6 +16,8 @@ BuildSession::BuildSession(const String& source_dir,
|
|||
{
|
||||
m_build_dir = build_dir;
|
||||
}
|
||||
const auto build_str = m_build_dir.str() + "/build";
|
||||
m_build_dir = FileSystemPath(build_str);
|
||||
m_compiler_flags.push_back("-g");
|
||||
m_compiler_flags.push_back("-fno-exceptions");
|
||||
m_compiler_flags.push_back("-fno-rtti");
|
||||
|
@ -24,23 +26,22 @@ BuildSession::BuildSession(const String& source_dir,
|
|||
Status BuildSession::scan()
|
||||
{
|
||||
LOG_INFO("Scanning sources at:" << m_source_dir);
|
||||
Vector<FileSystemPath> toml_files;
|
||||
Vector<FileSystemPath> ini_files;
|
||||
STATUS_CHECK(Directory::getFilesWithExtension(
|
||||
m_source_dir,
|
||||
".toml",
|
||||
toml_files,
|
||||
".ini",
|
||||
ini_files,
|
||||
true), "Error looking for build files");
|
||||
|
||||
for(const auto& toml_file : toml_files)
|
||||
for(const auto& ini_file : ini_files)
|
||||
{
|
||||
if (toml_file.file_name() == "build")
|
||||
if (ini_file.file_name() == "build")
|
||||
{
|
||||
STATUS_CHECK(add_library(toml_file),
|
||||
STATUS_CHECK(add_library(ini_file),
|
||||
"Error adding library");
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
||||
}
|
||||
|
||||
Status BuildSession::add_library(const FileSystemPath& config_path)
|
||||
|
@ -54,26 +55,52 @@ Status BuildSession::add_library(const FileSystemPath& config_path)
|
|||
|
||||
Status BuildSession::build()
|
||||
{
|
||||
for(const auto& library : m_libraries)
|
||||
Directory::create(m_build_dir, true);
|
||||
for(auto& library : m_libraries)
|
||||
{
|
||||
for(const auto& source : library.get_sources())
|
||||
const auto run_status = compile_library(library);
|
||||
if (!run_status.ok())
|
||||
{
|
||||
Vector<String> args = m_compiler_flags;
|
||||
args.push_back("-c");
|
||||
for(const auto& include_dir : library.get_include_dirs())
|
||||
{
|
||||
args.push_back(_s("-I") + include_dir.str());
|
||||
}
|
||||
args.push_back(source.str());
|
||||
LOG_INFO("Compiling " << source.file_name());
|
||||
const auto run_status = Process::launch(m_compiler_command, args);
|
||||
if (!run_status.ok())
|
||||
{
|
||||
return run_status;
|
||||
}
|
||||
//break;
|
||||
}
|
||||
return run_status;
|
||||
}
|
||||
//break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Status BuildSession::compile_library(BuildLibrary& lib)
|
||||
{
|
||||
for(const auto& source : lib.get_sources())
|
||||
{
|
||||
const auto run_status = compile_source_file(source, lib);
|
||||
if (!run_status.ok())
|
||||
{
|
||||
return run_status;
|
||||
}
|
||||
//break;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Status BuildSession::compile_source_file(const FileSystemPath& source,
|
||||
const BuildLibrary& lib)
|
||||
{
|
||||
Vector<String> args = m_compiler_flags;
|
||||
args.push_back("-c");
|
||||
add_include_dirs(args, lib);
|
||||
args.push_back(source.str());
|
||||
|
||||
const auto output_path = m_build_dir / source.file_name();
|
||||
args.push_back("-o");
|
||||
args.push_back(output_path.str() + ".o");
|
||||
LOG_INFO("Compiling " << source.file_name());
|
||||
return Process::launch(m_compiler_command, args);
|
||||
}
|
||||
|
||||
void BuildSession::add_include_dirs(Vector<String>& args, const BuildLibrary& lib)
|
||||
{
|
||||
for(const auto& include_dir : lib.get_include_dirs())
|
||||
{
|
||||
args.push_back(_s("-I") + include_dir.str());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue