|
|
5db3db |
/*******************************************************************/
|
|
|
5db3db |
/* slibtool: a skinny libtool implementation, written in C */
|
|
|
49181b |
/* Copyright (C) 2016--2024 SysDeer Technologies, LLC */
|
|
|
5db3db |
/* Released under the Standard MIT License; see COPYING.SLIBTOOL. */
|
|
|
5db3db |
/*******************************************************************/
|
|
|
5db3db |
|
|
|
5db3db |
#include <stdlib.h>
|
|
|
5db3db |
#include <stdio.h>
|
|
|
5db3db |
#include <string.h>
|
|
|
5db3db |
#include <fcntl.h>
|
|
|
5db3db |
#include <errno.h>
|
|
|
5db3db |
#include <sys/stat.h>
|
|
|
5db3db |
|
|
|
5db3db |
#include <slibtool/slibtool.h>
|
|
|
5db3db |
#include "slibtool_driver_impl.h"
|
|
|
5db3db |
#include "slibtool_errinfo_impl.h"
|
|
|
5db3db |
#include "slibtool_linkcmd_impl.h"
|
|
|
5db3db |
#include "slibtool_mapfile_impl.h"
|
|
|
5db3db |
#include "slibtool_metafile_impl.h"
|
|
|
5db3db |
#include "slibtool_snprintf_impl.h"
|
|
|
5db3db |
#include "slibtool_symlink_impl.h"
|
|
|
5db3db |
#include "slibtool_spawn_impl.h"
|
|
|
5db3db |
|
|
|
5db3db |
int slbt_exec_link_create_import_library(
|
|
|
5db3db |
const struct slbt_driver_ctx * dctx,
|
|
|
5db3db |
struct slbt_exec_ctx * ectx,
|
|
|
5db3db |
char * impfilename,
|
|
|
5db3db |
char * deffilename,
|
|
|
5db3db |
char * soname)
|
|
|
5db3db |
{
|
|
|
5db3db |
int fmdso;
|
|
|
5db3db |
char * eargv[8];
|
|
|
5db3db |
char program[PATH_MAX];
|
|
|
5db3db |
|
|
|
5db3db |
/* dlltool or mdso? */
|
|
|
5db3db |
if (dctx->cctx->drvflags & SLBT_DRIVER_IMPLIB_DSOMETA)
|
|
|
5db3db |
fmdso = 1;
|
|
|
5db3db |
|
|
|
6d7ad6 |
else if (dctx->cctx->drvflags & SLBT_DRIVER_IMPLIB_IDATA)
|
|
|
5db3db |
fmdso = 0;
|
|
|
5db3db |
|
|
|
5db3db |
else if (!(strcmp(dctx->cctx->host.flavor,"midipix")))
|
|
|
5db3db |
fmdso = 1;
|
|
|
5db3db |
|
|
|
5db3db |
else
|
|
|
5db3db |
fmdso = 0;
|
|
|
5db3db |
|
|
|
5db3db |
/* eargv */
|
|
|
5db3db |
if (fmdso) {
|
|
|
5db3db |
if (slbt_snprintf(program,sizeof(program),
|
|
|
5db3db |
"%s",dctx->cctx->host.mdso) < 0)
|
|
|
5db3db |
return SLBT_BUFFER_ERROR(dctx);
|
|
|
5db3db |
|
|
|
5db3db |
eargv[0] = program;
|
|
|
5db3db |
eargv[1] = "-i";
|
|
|
5db3db |
eargv[2] = impfilename;
|
|
|
5db3db |
eargv[3] = "-n";
|
|
|
5db3db |
eargv[4] = soname;
|
|
|
5db3db |
eargv[5] = deffilename;
|
|
|
5db3db |
eargv[6] = 0;
|
|
|
5db3db |
} else {
|
|
|
5db3db |
if (slbt_snprintf(program,sizeof(program),
|
|
|
5db3db |
"%s",dctx->cctx->host.dlltool) < 0)
|
|
|
5db3db |
return SLBT_BUFFER_ERROR(dctx);
|
|
|
5db3db |
|
|
|
5db3db |
eargv[0] = program;
|
|
|
5db3db |
eargv[1] = "-l";
|
|
|
5db3db |
eargv[2] = impfilename;
|
|
|
5db3db |
eargv[3] = "-d";
|
|
|
5db3db |
eargv[4] = deffilename;
|
|
|
5db3db |
eargv[5] = "-D";
|
|
|
5db3db |
eargv[6] = soname;
|
|
|
5db3db |
eargv[7] = 0;
|
|
|
5db3db |
}
|
|
|
5db3db |
|
|
|
5db3db |
/* alternate argument vector */
|
|
|
5db3db |
ectx->argv = eargv;
|
|
|
5db3db |
ectx->program = program;
|
|
|
5db3db |
|
|
|
5db3db |
/* step output */
|
|
|
5db3db |
if (!(dctx->cctx->drvflags & SLBT_DRIVER_SILENT))
|
|
|
5db3db |
if (slbt_output_link(dctx,ectx))
|
|
|
5db3db |
return SLBT_NESTED_ERROR(dctx);
|
|
|
5db3db |
|
|
|
5db3db |
/* dlltool/mdso spawn */
|
|
|
5db3db |
if ((slbt_spawn(ectx,true) < 0) && (ectx->pid < 0)) {
|
|
|
5db3db |
return SLBT_SPAWN_ERROR(dctx);
|
|
|
5db3db |
|
|
|
5db3db |
} else if (ectx->exitcode) {
|
|
|
5db3db |
return SLBT_CUSTOM_ERROR(
|
|
|
5db3db |
dctx,
|
|
|
5db3db |
fmdso ? SLBT_ERR_MDSO_ERROR : SLBT_ERR_DLLTOOL_ERROR);
|
|
|
5db3db |
}
|
|
|
5db3db |
|
|
|
5db3db |
return 0;
|
|
|
5db3db |
}
|