init
This commit is contained in:
35
launcher/__build.c
Normal file
35
launcher/__build.c
Normal file
@@ -0,0 +1,35 @@
|
||||
#include "god/c.h"
|
||||
#include "god/ld.h"
|
||||
#include "god/utils.h"
|
||||
|
||||
void launcher_build(struct build_data b)
|
||||
{
|
||||
char* files[] = {
|
||||
"launcher/launcher.cpp",
|
||||
NULL,
|
||||
};
|
||||
|
||||
|
||||
struct project p = {
|
||||
.b = &b,
|
||||
.files = files,
|
||||
.name = "launcher",
|
||||
};
|
||||
|
||||
struct project o = C_compile(p, (struct C_settings){
|
||||
.generation_flags = C_GENERATION_FLAGS_PIC,
|
||||
.compile_flags = C_COMPILE_FLAGS_WALL,
|
||||
.include_dirs = include_dirs,
|
||||
});
|
||||
|
||||
char* libs[] = {
|
||||
"c",
|
||||
NULL,
|
||||
};
|
||||
|
||||
char* launcher_dll = ld_link_project(o, (struct link_settings){
|
||||
.type = LINK_TYPE_EXECUTABLE,
|
||||
.libs = libs,
|
||||
});
|
||||
mv("build/"GAME_NAME"/game/bin/"GAME_NAME,launcher_dll);
|
||||
}
|
||||
46
launcher/launcher.cpp
Normal file
46
launcher/launcher.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "string.h"
|
||||
#include "stdio.h"
|
||||
#include "unistd.h"
|
||||
#include "dlfcn.h"
|
||||
#include "libgen.h"
|
||||
|
||||
#define MAX_PATH 4096
|
||||
|
||||
static char szLauncherPath[MAX_PATH];
|
||||
static char szEnginePath[MAX_PATH];
|
||||
static char szTier0Path[MAX_PATH];
|
||||
|
||||
void *pEngineLib;
|
||||
void *pTier0Lib;
|
||||
typedef void (*EngineMainFn)(int argc, char** argv);
|
||||
EngineMainFn pEngineMain;
|
||||
|
||||
int main( int argc, char **argv ) {
|
||||
readlink("/proc/self/exe",szLauncherPath, MAX_PATH);
|
||||
dirname(szLauncherPath);
|
||||
|
||||
snprintf(szEnginePath, MAX_PATH, "%s/libengine.so", szLauncherPath);
|
||||
snprintf(szTier0Path, MAX_PATH, "%s/libtier0.so", szLauncherPath);
|
||||
|
||||
pTier0Lib = dlopen(szTier0Path, RTLD_NOW | RTLD_GLOBAL);
|
||||
if ( !pTier0Lib ) {
|
||||
printf("Failed to open libtier0.so\n");
|
||||
printf("\t%s\n",dlerror());
|
||||
}
|
||||
pEngineLib = dlopen(szEnginePath, RTLD_NOW | RTLD_GLOBAL);
|
||||
if ( !pEngineLib ) {
|
||||
printf("Failed to open libengine.so\n");
|
||||
printf("\t%s\n",dlerror());
|
||||
}
|
||||
pEngineMain = (EngineMainFn)dlsym(pEngineLib, "FunnyMain");
|
||||
if ( !pEngineMain ) {
|
||||
printf("Symbol not found: FunnyMain\n");
|
||||
}
|
||||
|
||||
// chdir to right directory
|
||||
dirname(szLauncherPath);
|
||||
chdir(szLauncherPath);
|
||||
|
||||
pEngineMain(argc, argv);
|
||||
dlclose(pEngineLib);
|
||||
};
|
||||
Reference in New Issue
Block a user