1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-06-12 17:14:46 +02:00

Compile ALL 3rd party modules through modulemanager, including unmanaged.

This gets rid of src/buildmod and unifies the process a little, which
i need later.

We still compile the 3rd party modules unconditionally and twice (during
both make and make install). Which is a quirk that is in there since U6
and maybe U5 already :D. That's because we don't check if header files
have changed. There was previously a "is the .c file newer than the .so"
in there, though, that is gone now. Anyway, that's something for later.

Another quirk is that we do not halt compile if a 3rd party module fails
to compile. Which was sortof intentional at one point but.. is not ideal,
so will probably changed as well.

Anyway, that's not why i am doing all this stuff right now...
This commit is contained in:
Bram Matthys
2026-01-19 09:00:56 +01:00
parent 0cf0c0faa2
commit 96f4954e2b
3 changed files with 77 additions and 34 deletions
-21
View File
@@ -1,21 +0,0 @@
#!/bin/sh
MAKE="$1"
echo ""
echo "Checking for updates for third party modules..."
# We can't use the "unrealircd" script, since possibly the ircd
# has not been installed to it's final location.. yet.
# So this is basically "unrealircd module upgrade --no-install":
../../ircd -m upgrade --no-install
echo ""
echo "Building all third party modules..."
for x in *.c
do
if [ "$x" != "*.c" ]; then
x="`echo $x|sed 's/\.c//'`"
if [ ! -f $x.so -o $x.c -nt $x.so -o ../../ircd -nt $x.so ]; then
rm -f $x.so
echo "Building 3rd party module $x..."
$MAKE custommodule MODULEFILE=$x || (echo "*****"; echo "Building 3rd party module $x failed."; echo "Contact the module author of the $x module (not the UnrealIRCd team), or simply delete the $PWD/$x.c file"; echo "*****")
fi
fi
done
+75 -12
View File
@@ -28,6 +28,7 @@ struct ManagedModule
char *max_unrealircd_version;
char *description;
MultiLine *post_install_text;
int unmanaged;
};
static ManagedModule *managed_modules = NULL;
@@ -883,7 +884,7 @@ void mm_list(char *searchname)
print_documentation();
}
int mm_compile(ManagedModule *m, const char *tmpfile, int test)
int mm_compile(ManagedModule *m, const char *tmpfile, int test, int upgrade)
{
char newpath[512];
char cmd[512];
@@ -894,16 +895,15 @@ int mm_compile(ManagedModule *m, const char *tmpfile, int test)
int n;
if (test)
printf("Test compiling %s...\n", m->name);
printf("\nTest compiling %s...\n", m->name);
else
printf("Compiling %s...\n", m->name);
printf("\nCompiling %s...\n", m->name);
basename = unreal_getfilename(test ? tmpfile : m->name);
snprintf(newpath, sizeof(newpath), "%s/src/modules/third/%s%s", BUILDDIR, basename, test ? "" : ".c");
if (!test)
if (!test && upgrade)
{
/* If the file already exists then we are upgrading.
* It's a good idea to backup the file rather than
/* It's a good idea to backup the file rather than
* just delete it. Perhaps the user had local changes
* he/she wished to preserve and accidently went
* through the upgrade procedure.
@@ -913,7 +913,8 @@ int mm_compile(ManagedModule *m, const char *tmpfile, int test)
unlink(backupfile);
(void)rename(newpath, backupfile);
}
if (!unreal_copyfileex(tmpfile, newpath, 0))
if (tmpfile && !unreal_copyfileex(tmpfile, newpath, 0))
return 0;
snprintf(cmd, sizeof(cmd),
@@ -947,12 +948,69 @@ int mm_compile(ManagedModule *m, const char *tmpfile, int test)
if (WIFEXITED(n) && (WEXITSTATUS(n) == 0))
return 1;
fprintf(stderr, "ERROR: Compile errors encountered while compiling module '%s'\n"
"You are suggested to contact the author (%s) of this module:\n%s\n",
m->name, m->author, m->troubleshooting);
fprintf(stderr, "ERROR: Compile errors encountered while compiling module '%s'\n", m->name);
if (!m->unmanaged)
{
fprintf(stderr, "You are suggested to contact the author (%s) of this module %s:\n%s\n",
m->author, m->name, m->troubleshooting);
} else {
/* Uh yeah, not much we can say? */
}
return 0;
}
/** Compile all modules (including unknown), this is used by generic 'make' */
int mm_compile_all(int argc, char *args[])
{
DIR *fd;
struct dirent *dir;
char dirname[512];
ManagedModule *m;
int n;
snprintf(dirname, sizeof(dirname), "%s/src/modules/third", BUILDDIR);
fd = opendir(dirname);
if (fd)
{
while ((dir = readdir(fd)))
{
char *fname = dir->d_name;
if (filename_has_suffix(fname, ".c"))
{
char modname[512];
//char sofile[512];
char *p;
char simplename[512];
strlcpy(simplename, filename_strip_suffix(fname, ".c"), sizeof(simplename));
snprintf(modname, sizeof(modname), "third/%s", simplename);
if (!(m = mm_find_module(modname)))
{
/* Untracked module: create a simple struct */
m = safe_alloc(sizeof(ManagedModule));
m->unmanaged = 1;
safe_strdup(m->name, modname);
n = mm_compile(m, NULL, 0, 0);
safe_free_managed_module(m);
} else {
n = mm_compile(m, NULL, 0, 0);
}
if (n == 0)
{
/* Something if it fails? Error was already printed.
* We silently continue for now.
*/
}
}
}
closedir(fd);
}
return 1; // always 1 atm
}
/** Actually download and install the module.
* This assumes compatibility checks have already been done.
*/
@@ -988,13 +1046,13 @@ int mm_install_module(ManagedModule *m)
m->repo_url);
return 0;
}
if (!mm_compile(m, tmpfile, 1))
if (!mm_compile(m, tmpfile, 1, 1))
{
fprintf(stderr, "Fatal error encountered, see above.\n");
return 0;
}
if (!mm_compile(m, tmpfile, 0))
if (!mm_compile(m, tmpfile, 0, 1))
{
fprintf(stderr, "The test compile went OK earlier, but the final compile did not. BAD!!\n");
return 0;
@@ -1500,6 +1558,11 @@ void modulemanager(int argc, char *args[])
mm_parse_c_file(argc, args);
exit(0);
}
else if (!strcasecmp(args[0], "compile-all"))
{
mm_compile_all(argc, args);
exit(0);
}
/* Fetch the repository list */
if (!mm_refresh_repository())
+2 -1
View File
@@ -40,7 +40,8 @@ RM=@RM@
all: build
build:
../../buildmod $(MAKE)
../../../src/ircd -m upgrade --no-install
../../../src/ircd -m compile-all
custommodule: $(MODULEFILE).c
$(CC) $(CFLAGS) $(MODULEFLAGS) -DDYNAMIC_LINKING \