Verified Commit 3a725fa5 authored by Camil Staps's avatar Camil Staps
Browse files

Add support for .implib on Windows

Imported libraries are collected as object files, because they need to
be found in Clean System Files in the same way. In the link step
(`add_imported_object_files`) we check if the dependency is a normal
object file or a library, and prepend `-l` if it is a library.

Library names starting with `-l` are still ignored so that you can use
`import code from library "-lmysql"` and `import code from library
"mysql_library"` in the same implementation module and compile for POSIX
and Windows.
parent 978cfd39
Pipeline #46003 passed with stage
in 14 seconds
......@@ -250,6 +250,9 @@ P_NODE first_project_node,last_project_node,main_project_node;
struct object_file_list {
struct object_file_list * object_file_next;
#ifdef _WINDOWS_
int object_file_is_library;
#endif
#if !defined (GNU_C)
char object_file_name[];
#else
......@@ -1013,10 +1016,8 @@ static int get_version_and_options_of_abc_file (P_NODE project_node,int *version
enum dependency_type {
NO_DEPENDENCY,
ABC_DEPENDENCY,
OBJECT_FILE_DEPENDENCY
#ifndef _WINDOWS_
,LIBRARY_DEPENDENCY
#endif
OBJECT_FILE_DEPENDENCY,
LIBRARY_DEPENDENCY
};
static int get_dependency_or_imported_object_or_library_file_of_abc_file (char *file_name,int max_length)
......@@ -1041,13 +1042,10 @@ static int get_dependency_or_imported_object_or_library_file_of_abc_file (char *
{
dependency_type=OBJECT_FILE_DEPENDENCY;
break;
}
#ifndef _WINDOWS_
else if (last_char_was ('l') && last_char_was ('i') && last_char_was ('b')){
} else if (last_char_was ('l') && last_char_was ('i') && last_char_was ('b')){
dependency_type=LIBRARY_DEPENDENCY;
break;
}
#endif
} else if (last_char_was ('e') && last_char_was ('n') && last_char_was ('d')
&& last_char_was ('i') && last_char_was ('n') && last_char_was ('f')
&& last_char_was ('o'))
......@@ -1089,7 +1087,11 @@ static void close_abc_file (void)
fclose (abc_file);
}
static void add_imported_object_file_to_project_node (char *object_file_name,P_NODE project_node)
static void add_imported_object_file_to_project_node (char *object_file_name,P_NODE project_node
#ifdef _WINDOWS_
,int is_library
#endif
)
{
int object_file_name_size;
struct object_file_list *new_imported_object_file,**object_file_h;
......@@ -1120,6 +1122,10 @@ static void add_imported_object_file_to_project_node (char *object_file_name,P_N
#endif
new_imported_object_file->object_file_name[object_file_name_size]='\0';
}
#ifdef _WINDOWS_
new_imported_object_file->object_file_is_library=is_library;
#endif
new_imported_object_file->object_file_next=NULL;
......@@ -1313,15 +1319,22 @@ static int project_node_is_abc_up_to_date (P_NODE project_node)
*/
}
} else if (dependency_type==OBJECT_FILE_DEPENDENCY)
add_imported_object_file_to_project_node (dependent_module,project_node);
#ifndef _WINDOWS_
add_imported_object_file_to_project_node (dependent_module,project_node
#ifdef _WINDOWS_
,0
#endif
);
else if (dependency_type==LIBRARY_DEPENDENCY){
if (dependent_module[0]=='-' && dependent_module[1]=='l')
add_library (dependent_module);
#ifdef _WINDOWS_
else
add_imported_object_file_to_project_node (dependent_module,project_node,1);
#else
else if (strchr (dependent_module,'.')!=NULL)
add_imported_object_file_to_project_node (dependent_module,project_node);
}
#endif
}
}
}
......@@ -2309,15 +2322,22 @@ static void get_dependencies (P_NODE project_node)
if (dependency_type==ABC_DEPENDENCY)
add_dependency (&dependency_list,dependent_module);
else if (dependency_type==OBJECT_FILE_DEPENDENCY)
add_imported_object_file_to_project_node (dependent_module,project_node);
#ifndef _WINDOWS_
add_imported_object_file_to_project_node (dependent_module,project_node
#ifdef _WINDOWS_
,0
#endif
);
else if (dependency_type==LIBRARY_DEPENDENCY){
if (dependent_module[0]=='-' && dependent_module[1]=='l')
add_library (dependent_module);
#ifdef _WINDOWS_
else
add_imported_object_file_to_project_node (dependent_module,project_node,1);
#else
else if (strchr (dependent_module,'.')!=NULL)
add_imported_object_file_to_project_node (dependent_module,project_node);
}
#endif
}
} while (dependency_type!=NO_DEPENDENCY);
close_abc_file();
......@@ -3262,15 +3282,33 @@ static char **add_imported_object_files (P_NODE first_project_node,char *o_file_
}
#ifdef QUOTE_SPAWN_ARGUMENTS
file_name=memory_allocate (strlen (o_file_name)+3);
file_name=memory_allocate (strlen (o_file_name)+3+(imported_object_file->object_file_is_library ? 2 : 0));
file_name[0]='\"';
strcpy (file_name+1,o_file_name);
strcat (file_name+1,"\"");
if (imported_object_file->object_file_is_library){
file_name[1]='-';
file_name[2]='l';
strcpy (file_name+3,o_file_name);
strcat (file_name+3,"\"");
} else {
strcpy (file_name+1,o_file_name);
strcat (file_name+1,"\"");
}
#else
# ifdef _WINDOWS_
file_name=memory_allocate (strlen (o_file_name)+1+(imported_object_file->object_file_is_library ? 2 : 0));
if (imported_object_file->object_file_is_library){
file_name[0]='-';
file_name[1]='l';
strcpy (file_name+2,o_file_name);
} else
strcpy (file_name,o_file_name);
# else
file_name=memory_allocate (strlen (o_file_name)+1);
strcpy (file_name,o_file_name);
# endif
#endif
*arg++=file_name;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment