firasuke / cross / slibtool

Forked from cross/slibtool 3 months ago
Clone

Blame include/slibtool/slibtool.h

9ca8c4
#ifndef SOFORT_H
9ca8c4
#define SOFORT_H
9ca8c4
9ca8c4
#include <stdint.h>
528799
#include <stddef.h>
9ca8c4
#include <stdio.h>
528799
#include <unistd.h>
9ca8c4
9ca8c4
#include "slibtool_api.h"
9ca8c4
9ca8c4
#ifdef __cplusplus
9ca8c4
extern "C" {
9ca8c4
#endif
9ca8c4
9ca8c4
/* pre-alpha */
9ca8c4
#ifndef SLBT_APP
9ca8c4
#ifndef SLBT_PRE_ALPHA
9ca8c4
#error  libslibtool: pre-alpha: ABI is not final!
9ca8c4
#error  to use the library, please pass -DSLBT_PRE_ALPHA to the compiler.
9ca8c4
#endif
9ca8c4
#endif
9ca8c4
9ca8c4
/* status codes */
9ca8c4
#define SLBT_OK				0x00
9ca8c4
#define SLBT_USAGE			0x01
9ca8c4
#define SLBT_BAD_OPT			0x02
9ca8c4
#define SLBT_BAD_OPT_VAL		0x03
9ca8c4
#define SLBT_IO_ERROR			0xA0
9ca8c4
#define SLBT_MAP_ERROR			0xA1
9ca8c4
9ca8c4
/* driver flags */
9ca8c4
#define SLBT_DRIVER_VERBOSITY_NONE	0x0000
9ca8c4
#define SLBT_DRIVER_VERBOSITY_ERRORS	0x0001
9ca8c4
#define SLBT_DRIVER_VERBOSITY_STATUS	0x0002
9ca8c4
#define SLBT_DRIVER_VERBOSITY_USAGE	0x0004
9ca8c4
#define SLBT_DRIVER_CLONE_VECTOR	0x0008
9ca8c4
9ca8c4
#define SLBT_DRIVER_VERSION		0x0010
9ca8c4
#define SLBT_DRIVER_DRY_RUN		0x0020
173b54
#define SLBT_DRIVER_CONFIG		0x0040
fea1b8
#define SLBT_DRIVER_DEBUG		0x0080
d03fbc
#define SLBT_DRIVER_FEATURES		0x0100
40fabb
#define SLBT_DRIVER_DEPS		0x0200
398419
#define SLBT_DRIVER_SILENT		0x0400
25956b
#define SLBT_DRIVER_VERBOSE		0x0800
4f1b20
#define SLBT_DRIVER_PRO_PIC		0x1000
4f1b20
#define SLBT_DRIVER_ANTI_PIC		0x2000
9c25c7
#define SLBT_DRIVER_SHARED		0x4000
9c25c7
#define SLBT_DRIVER_STATIC		0x8000
9ca8c4
e4a8ce
#define SLBT_DRIVER_HEURISTICS		0x010000
e4a8ce
#define SLBT_DRIVER_STRICT		0x020000
93b62c
#define SLBT_DRIVER_NO_UNDEFINED	0x040000
e4a8ce
ed069f
/* execution modes */
ed069f
enum slbt_mode {
ed069f
	SLBT_MODE_UNKNOWN,
ed069f
	SLBT_MODE_CLEAN,
ed069f
	SLBT_MODE_COMPILE,
ed069f
	SLBT_MODE_EXECUTE,
ed069f
	SLBT_MODE_FINISH,
ed069f
	SLBT_MODE_INSTALL,
ed069f
	SLBT_MODE_LINK,
ed069f
	SLBT_MODE_UNINSTALL,
ed069f
};
ed069f
53f4ec
enum slbt_tag {
53f4ec
	SLBT_TAG_UNKNOWN,
53f4ec
	SLBT_TAG_CC,
53f4ec
	SLBT_TAG_CXX,
53f4ec
};
53f4ec
6376f0
enum slbt_warning_level {
6376f0
	SLBT_WARNING_LEVEL_UNKNOWN,
6376f0
	SLBT_WARNING_LEVEL_ALL,
6376f0
	SLBT_WARNING_LEVEL_ERROR,
6376f0
	SLBT_WARNING_LEVEL_NONE,
6376f0
};
6376f0
9ca8c4
struct slbt_input {
9ca8c4
	void *	addr;
9ca8c4
	size_t	size;
9ca8c4
};
9ca8c4
528799
struct slbt_exec_ctx {
528799
	char *	program;
27a8e1
	char *	compiler;
27a8e1
	char **	cargv;
528799
	char **	argv;
528799
	char **	envp;
6d0e8a
	char ** altv;
5aae4b
	char ** dpic;
5aae4b
	char ** fpic;
5aae4b
	char ** cass;
93b62c
	char ** noundef;
0f8591
	char ** soname;
0f8591
	char ** lsoname;
5aae4b
	char ** lout[2];
b1f977
	char ** sentinel;
5ee0d1
	FILE *	fwrapper;
df088e
	char *	csrc;
df088e
	char *	ldirname;
df088e
	char *	lbasename;
df088e
	char *	lobjname;
e02305
	char *	aobjname;
e88a39
	char *	ltobjname;
680670
	char *	arfilename;
680670
	char *	lafilename;
680670
	char *	dsofilename;
680670
	char *	exefilename;
528799
	pid_t	pid;
528799
	int	exitcode;
528799
};
528799
5a9161
struct slbt_version_info {
5a9161
	int				major;
5a9161
	int				minor;
5a9161
	int				revision;
5a9161
	const char *			verinfo;
5a9161
};
5a9161
a2fcc0
struct slbt_host_params {
a2fcc0
	const char *			host;
a2fcc0
	const char *			flavor;
a2fcc0
	const char *			ar;
a2fcc0
	const char *			ranlib;
a2fcc0
	const char *			dlltool;
a2fcc0
};
a2fcc0
a66d34
struct slbt_flavor_settings {
a66d34
	const char *			arprefix;
a66d34
	const char *			arsuffix;
a66d34
	const char *			dsoprefix;
a66d34
	const char *			dsosuffix;
a66d34
	const char *			exeprefix;
a66d34
	const char *			exesuffix;
a66d34
	const char *			impprefix;
a66d34
	const char *			impsuffix;
41790b
	const char *			ldpathenv;
a66d34
};
a66d34
9ca8c4
struct slbt_common_ctx {
9ca8c4
	uint64_t			drvflags;
9ca8c4
	uint64_t			actflags;
9ca8c4
	uint64_t			fmtflags;
a2fcc0
	struct slbt_host_params		host;
a2fcc0
	struct slbt_host_params		cfgmeta;
a66d34
	struct slbt_flavor_settings	settings;
5a9161
	struct slbt_version_info	verinfo;
667ce2
	enum slbt_mode			mode;
53f4ec
	enum slbt_tag			tag;
6376f0
	enum slbt_warning_level		warnings;
4df790
	const char *			target;
b83b64
	const char *			output;
f8e27e
	char *				libname;
9c664d
	const char *			rpath;
a288c4
	char **				targv;
a288c4
	char **				cargv;
9ca8c4
};
9ca8c4
9ca8c4
struct slbt_driver_ctx {
9ca8c4
	const char **			units;
9ca8c4
	const char *			program;
9ca8c4
	const char *			module;
9ca8c4
	const struct slbt_common_ctx *	cctx;
9ca8c4
	void *				any;
9ca8c4
	int				status;
9ca8c4
	int				nerrors;
9ca8c4
};
9ca8c4
9ca8c4
struct slbt_unit_ctx {
9ca8c4
	const char * const *		path;
9ca8c4
	const struct slbt_input *	map;
9ca8c4
	const struct slbt_common_ctx *	cctx;
9ca8c4
	void *				any;
9ca8c4
	int				status;
9ca8c4
	int				nerrors;
9ca8c4
};
9ca8c4
9ca8c4
/* driver api */
9ca8c4
slbt_api int  slbt_get_driver_ctx	(char ** argv, char ** envp, uint32_t flags, struct slbt_driver_ctx **);
9ca8c4
slbt_api int  slbt_create_driver_ctx	(const struct slbt_common_ctx *, struct slbt_driver_ctx **);
9ca8c4
slbt_api void slbt_free_driver_ctx	(struct slbt_driver_ctx *);
9ca8c4
9ca8c4
slbt_api int  slbt_get_unit_ctx		(const struct slbt_driver_ctx *, const char * path, struct slbt_unit_ctx **);
9ca8c4
slbt_api void slbt_free_unit_ctx	(struct slbt_unit_ctx *);
9ca8c4
528799
slbt_api int  slbt_get_exec_ctx		(const struct slbt_driver_ctx *, struct slbt_exec_ctx **);
528799
slbt_api void slbt_free_exec_ctx	(struct slbt_exec_ctx *);
e7ddb2
slbt_api void slbt_reset_arguments	(struct slbt_exec_ctx *);
5aae4b
slbt_api void slbt_reset_placeholders	(struct slbt_exec_ctx *);
528799
36de3e
slbt_api int  slbt_exec_compile		(const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
2bd749
slbt_api int  slbt_exec_link		(const struct slbt_driver_ctx *, struct slbt_exec_ctx *);
36de3e
9ca8c4
slbt_api int  slbt_map_input		(int fd, const char * path, int prot, struct slbt_input *);
9ca8c4
slbt_api int  slbt_unmap_input		(struct slbt_input *);
9ca8c4
9ca8c4
/* utility api */
617bbc
slbt_api int  slbt_output_config	(const struct slbt_driver_ctx *);
fab986
slbt_api int  slbt_output_exec		(const struct slbt_driver_ctx *, const struct slbt_exec_ctx *, const char *);
6f991b
slbt_api int  slbt_output_compile	(const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
ba3523
slbt_api int  slbt_output_link		(const struct slbt_driver_ctx *, const struct slbt_exec_ctx *);
9ca8c4
9ca8c4
#ifdef __cplusplus
9ca8c4
}
9ca8c4
#endif
9ca8c4
9ca8c4
#endif