mirror of
https://github.com/Ed94/Odin.git
synced 2026-06-18 20:02:22 -07:00
Added support for monolithic packages
Not sure if the base name for them, lets the user by specifying a .ODIN_MONOLITHIC_PACKAGE; make compiler assume that all files in child directories are part of the same package (making a uniform prackage across subdirectoreis).
This commit is contained in:
+39
-1
@@ -5433,6 +5433,43 @@ gb_internal void parser_add_foreign_file_to_process(Parser *p, AstPackage *pkg,
|
||||
thread_pool_add_task(foreign_file_worker_proc, wd);
|
||||
}
|
||||
|
||||
gb_internal ReadDirectoryError read_directory_recursive(String path, Array<FileInfo> *fi, String const &FILE_EXT) {
|
||||
Array<FileInfo> sub_list = {};
|
||||
ReadDirectoryError rd_err = read_directory(path, &sub_list);
|
||||
defer(array_free(&sub_list));
|
||||
|
||||
if (rd_err != ReadDirectory_None) {
|
||||
return rd_err;
|
||||
}
|
||||
|
||||
String const FILE_EXT_MONLITHIC = str_lit(".ODIN_MONOLITHIC_PACKAGE");
|
||||
|
||||
String ext = path_extension(sub_list[0].name);
|
||||
bool monolithic_specified = false;
|
||||
if (ext == FILE_EXT_MONLITHIC) {
|
||||
monolithic_specified = true;
|
||||
}
|
||||
for (FileInfo sub_fi : sub_list)
|
||||
{
|
||||
String ext = path_extension(sub_fi.name);
|
||||
if (monolithic_specified && sub_fi.is_dir) {
|
||||
rd_err = read_directory_recursive(sub_fi.fullpath, fi, FILE_EXT);
|
||||
if (rd_err != ReadDirectory_None) {
|
||||
return rd_err;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ext != FILE_EXT_MONLITHIC && (ext == FILE_EXT || ext == ".S" || ext == ".s")) {
|
||||
if (fi->data == nullptr) {
|
||||
array_init(fi, heap_allocator(), 0, 100);
|
||||
}
|
||||
array_add(fi, sub_fi);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rd_err;
|
||||
}
|
||||
|
||||
// NOTE(bill): Returns true if it's added
|
||||
gb_internal AstPackage *try_add_import_path(Parser *p, String path, String const &rel_path, TokenPos pos, PackageKind kind = Package_Normal) {
|
||||
@@ -5469,7 +5506,8 @@ gb_internal AstPackage *try_add_import_path(Parser *p, String path, String const
|
||||
|
||||
|
||||
Array<FileInfo> list = {};
|
||||
ReadDirectoryError rd_err = read_directory(path, &list);
|
||||
ReadDirectoryError rd_err;
|
||||
rd_err = read_directory_recursive( path, &list, FILE_EXT );
|
||||
defer (array_free(&list));
|
||||
|
||||
if (list.count == 1) {
|
||||
|
||||
Reference in New Issue
Block a user