mirror of
https://github.com/holub/mame
synced 2025-07-01 00:09:18 +03:00
simplified mamemak (nw)
This commit is contained in:
parent
1953d6cf08
commit
766a73b041
@ -118,7 +118,7 @@ static tagmap_t<char *> include_map;
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
// core output functions
|
// core output functions
|
||||||
static int recurse_dir(int srcrootlen, astring &srcdir);
|
static int recurse_dir(astring &srcdir);
|
||||||
static file_entry &compute_dependencies(astring &srcfile);
|
static file_entry &compute_dependencies(astring &srcfile);
|
||||||
|
|
||||||
// path helpers
|
// path helpers
|
||||||
@ -405,7 +405,7 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// recurse over subdirectories
|
// recurse over subdirectories
|
||||||
return recurse_dir(srcdir.len(), srcdir);
|
return recurse_dir(srcdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -414,14 +414,6 @@ int main(int argc, char *argv[])
|
|||||||
CORE OUTPUT FUNCTIONS
|
CORE OUTPUT FUNCTIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
static int compare_list_entries(const void *p1, const void *p2)
|
|
||||||
{
|
|
||||||
const list_entry *entry1 = *(const list_entry **)p1;
|
|
||||||
const list_entry *entry2 = *(const list_entry **)p2;
|
|
||||||
return entry1->name.cmp(entry2->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
/*-------------------------------------------------
|
||||||
recurse_dependencies - recurse through the
|
recurse_dependencies - recurse through the
|
||||||
dependencies found, adding the mto the tagmap
|
dependencies found, adding the mto the tagmap
|
||||||
@ -451,86 +443,24 @@ static void recurse_dependencies(file_entry &file, dependency_map &map)
|
|||||||
recurse_dir - recurse through a directory
|
recurse_dir - recurse through a directory
|
||||||
-------------------------------------------------*/
|
-------------------------------------------------*/
|
||||||
|
|
||||||
static int recurse_dir(int srcrootlen, astring &srcdir)
|
static int recurse_dir(astring &srcdir)
|
||||||
{
|
{
|
||||||
static const osd_dir_entry_type typelist[] = { ENTTYPE_DIR, ENTTYPE_FILE };
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
// iterate first over directories, then over files
|
|
||||||
for (int entindex = 0; entindex < ARRAY_LENGTH(typelist) && result == 0; entindex++)
|
|
||||||
{
|
|
||||||
osd_dir_entry_type entry_type = typelist[entindex];
|
|
||||||
|
|
||||||
// open the directory and iterate through it
|
|
||||||
osd_directory *dir = osd_opendir(srcdir);
|
|
||||||
if (dir == NULL)
|
|
||||||
{
|
|
||||||
result = 1;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
// build up the list of files
|
|
||||||
const osd_directory_entry *entry;
|
|
||||||
list_entry *list = NULL;
|
|
||||||
int found = 0;
|
|
||||||
while ((entry = osd_readdir(dir)) != NULL)
|
|
||||||
if (entry->type == entry_type && entry->name[0] != '.')
|
|
||||||
{
|
|
||||||
list_entry *lentry = new list_entry;
|
|
||||||
lentry->name.cpy(entry->name);
|
|
||||||
lentry->next = list;
|
|
||||||
list = lentry;
|
|
||||||
found++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// close the directory
|
|
||||||
osd_closedir(dir);
|
|
||||||
|
|
||||||
// skip if nothing found
|
|
||||||
if (found == 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// allocate memory for sorting
|
|
||||||
list_entry **listarray = new list_entry *[found];
|
|
||||||
found = 0;
|
|
||||||
for (list_entry *curlist = list; curlist != NULL; curlist = curlist->next)
|
|
||||||
listarray[found++] = curlist;
|
|
||||||
|
|
||||||
// sort the list
|
|
||||||
qsort(listarray, found, sizeof(listarray[0]), compare_list_entries);
|
|
||||||
|
|
||||||
// rebuild the list
|
|
||||||
list = NULL;
|
|
||||||
while (--found >= 0)
|
|
||||||
{
|
|
||||||
listarray[found]->next = list;
|
|
||||||
list = listarray[found];
|
|
||||||
}
|
|
||||||
delete[] listarray;
|
|
||||||
|
|
||||||
// iterate through each file
|
// iterate through each file
|
||||||
for (list_entry *curlist = list; curlist != NULL && result == 0; curlist = curlist->next)
|
for(int i=0;i<sourcecount;i++)
|
||||||
{
|
{
|
||||||
astring srcfile;
|
astring srcfile;
|
||||||
|
|
||||||
// build the source filename
|
// build the source filename
|
||||||
srcfile.printf("%s%c%s", srcdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr());
|
srcfile.printf("%s%c%s.c", srcdir.cstr(), PATH_SEPARATOR[0], sourcelst[i]);
|
||||||
|
|
||||||
// if we have a file, output it
|
|
||||||
if (entry_type == ENTTYPE_FILE)
|
|
||||||
{
|
|
||||||
// make sure we care, first
|
|
||||||
if (core_filename_ends_with(curlist->name, ".c"))
|
|
||||||
{
|
|
||||||
dependency_map depend_map;
|
dependency_map depend_map;
|
||||||
|
|
||||||
// find dependencies
|
// find dependencies
|
||||||
file_entry &file = compute_dependencies(srcfile);
|
file_entry &file = compute_dependencies(srcfile);
|
||||||
recurse_dependencies(file, depend_map);
|
recurse_dependencies(file, depend_map);
|
||||||
astring fn = astring(curlist->name);
|
|
||||||
fn.replace(".c","");
|
|
||||||
if (isonlist(fn))
|
|
||||||
{
|
|
||||||
for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
|
for (dependency_map::entry_t *entry = depend_map.first(); entry != NULL; entry = depend_map.next(entry))
|
||||||
{
|
{
|
||||||
astring t(entry->tag());
|
astring t(entry->tag());
|
||||||
@ -544,35 +474,24 @@ static int recurse_dir(int srcrootlen, astring &srcdir)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// iterate through each file
|
// iterate through each file
|
||||||
for (list_entry *curlist = list; curlist != NULL && result == 0; curlist = curlist->next)
|
for(int i=0;i<sourcecount;i++)
|
||||||
{
|
{
|
||||||
astring srcfile;
|
astring srcfile;
|
||||||
|
|
||||||
// build the source filename
|
// build the source filename
|
||||||
srcfile.printf("%s%c%s", srcdir.cstr(), PATH_SEPARATOR[0], curlist->name.cstr());
|
srcfile.printf("%s%c%s.c", srcdir.cstr(), PATH_SEPARATOR[0], sourcelst[i]);
|
||||||
|
|
||||||
// if we have a file, output it
|
|
||||||
if (entry_type == ENTTYPE_FILE)
|
|
||||||
{
|
|
||||||
// make sure we care, first
|
|
||||||
if (core_filename_ends_with(curlist->name, ".c"))
|
|
||||||
{
|
|
||||||
dependency_map depend_map;
|
dependency_map depend_map;
|
||||||
|
|
||||||
// find dependencies
|
// find dependencies
|
||||||
file_entry &file = compute_dependencies(srcfile);
|
file_entry &file = compute_dependencies(srcfile);
|
||||||
recurse_dependencies(file, depend_map);
|
recurse_dependencies(file, depend_map);
|
||||||
astring fn = astring(curlist->name);
|
|
||||||
fn.replace(".c","");
|
|
||||||
if (isonlist(fn))
|
|
||||||
{
|
|
||||||
// convert the target from source to object (makes assumptions about rules)
|
// convert the target from source to object (makes assumptions about rules)
|
||||||
astring target(file.name);
|
astring target(file.name);
|
||||||
target.replace(0, "src/", "$(OBJ)/");
|
target.replace(0, "src/", "$(OBJ)/");
|
||||||
@ -617,21 +536,8 @@ static int recurse_dir(int srcrootlen, astring &srcdir)
|
|||||||
printf("%s: %s\n", target2.cstr(), t.cstr());
|
printf("%s: %s\n", target2.cstr(), t.cstr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// free all the allocated entries
|
|
||||||
while (list != NULL)
|
|
||||||
{
|
|
||||||
list_entry *next = list->next;
|
|
||||||
delete list;
|
|
||||||
list = next;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
error:
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user