mirror of
https://git.kore.io/kore.git
synced 2024-11-11 04:39:00 +01:00
Formatting and slight C++ build improvements.
Do not link against libstdc++ when not having any C++ files. Let the compiler decide what subprocess to use for compiling certain files, thus killing the CXX need. Can be overwritten in the same old default in CC.
This commit is contained in:
parent
160eb791f7
commit
3a608a99bb
45
src/cli.c
45
src/cli.c
@ -190,7 +190,6 @@ static int s_fd = -1;
|
|||||||
static char *appl = NULL;
|
static char *appl = NULL;
|
||||||
static char *rootdir = NULL;
|
static char *rootdir = NULL;
|
||||||
static char *compiler = "gcc";
|
static char *compiler = "gcc";
|
||||||
static char *cppcompiler = "g++";
|
|
||||||
static struct cfile_list source_files;
|
static struct cfile_list source_files;
|
||||||
static int cfiles_count;
|
static int cfiles_count;
|
||||||
static struct cmd *command = NULL;
|
static struct cmd *command = NULL;
|
||||||
@ -303,9 +302,6 @@ cli_build(int argc, char **argv)
|
|||||||
if ((p = getenv("CC")) != NULL)
|
if ((p = getenv("CC")) != NULL)
|
||||||
compiler = p;
|
compiler = p;
|
||||||
|
|
||||||
if ((p = getenv("CXX")) != NULL)
|
|
||||||
cppcompiler = p;
|
|
||||||
|
|
||||||
cfiles_count = 0;
|
cfiles_count = 0;
|
||||||
TAILQ_INIT(&source_files);
|
TAILQ_INIT(&source_files);
|
||||||
|
|
||||||
@ -674,7 +670,8 @@ cli_build_asset(char *fpath, struct dirent *dp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cli_add_cfile(char *name, char *fpath, char *opath, struct stat *st, int build, int cpp)
|
cli_add_cfile(char *name, char *fpath, char *opath, struct stat *st,
|
||||||
|
int build, int cpp)
|
||||||
{
|
{
|
||||||
struct cfile *cf;
|
struct cfile *cf;
|
||||||
|
|
||||||
@ -698,7 +695,8 @@ cli_register_cfile(char *fpath, struct dirent *dp)
|
|||||||
char *ext, *opath;
|
char *ext, *opath;
|
||||||
int cpp;
|
int cpp;
|
||||||
|
|
||||||
if ((ext = strrchr(fpath, '.')) == NULL || !(!strcmp(ext, ".c") || !strcmp(ext, ".cpp")))
|
if ((ext = strrchr(fpath, '.')) == NULL ||
|
||||||
|
(strcmp(ext, ".c") && strcmp(ext, ".cpp")))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!strcmp(ext, ".cpp"))
|
if (!strcmp(ext, ".cpp"))
|
||||||
@ -860,7 +858,7 @@ cli_compile_cfile(void *arg)
|
|||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
struct cfile *cf = arg;
|
struct cfile *cf = arg;
|
||||||
char *args[24], *ipath[2], *cppdialect;
|
char *args[24], *ipath[2], *p, *cppstandard;
|
||||||
#if defined(KORE_USE_PGSQL)
|
#if defined(KORE_USE_PGSQL)
|
||||||
char *ppath;
|
char *ppath;
|
||||||
#endif
|
#endif
|
||||||
@ -888,8 +886,6 @@ cli_compile_cfile(void *arg)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
args[idx++] = "-Wall";
|
args[idx++] = "-Wall";
|
||||||
args[idx++] = "-Wstrict-prototypes";
|
|
||||||
args[idx++] = "-Wmissing-prototypes";
|
|
||||||
args[idx++] = "-Wmissing-declarations";
|
args[idx++] = "-Wmissing-declarations";
|
||||||
args[idx++] = "-Wshadow";
|
args[idx++] = "-Wshadow";
|
||||||
args[idx++] = "-Wpointer-arith";
|
args[idx++] = "-Wpointer-arith";
|
||||||
@ -899,16 +895,17 @@ cli_compile_cfile(void *arg)
|
|||||||
args[idx++] = "-g";
|
args[idx++] = "-g";
|
||||||
|
|
||||||
if (cf->cpp) {
|
if (cf->cpp) {
|
||||||
|
|
||||||
args[idx++] = "-Woverloaded-virtual";
|
args[idx++] = "-Woverloaded-virtual";
|
||||||
args[idx++] = "-Wold-style-cast";
|
args[idx++] = "-Wold-style-cast";
|
||||||
args[idx++] = "-Wnon-virtual-dtor";
|
args[idx++] = "-Wnon-virtual-dtor";
|
||||||
|
|
||||||
if ((cppdialect = getenv("CXXSTD")) != NULL) {
|
if ((p = getenv("CXXSTD")) != NULL) {
|
||||||
char *cppstandard = NULL;
|
(void)cli_vasprintf(&cppstandard, "-std=%s", p);
|
||||||
(void)cli_vasprintf(&cppstandard, "-std=%s", cppdialect);
|
|
||||||
args[idx++] = cppstandard;
|
args[idx++] = cppstandard;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
args[idx++] = "-Wstrict-prototypes";
|
||||||
|
args[idx++] = "-Wmissing-prototypes";
|
||||||
}
|
}
|
||||||
|
|
||||||
args[idx++] = "-c";
|
args[idx++] = "-c";
|
||||||
@ -917,9 +914,6 @@ cli_compile_cfile(void *arg)
|
|||||||
args[idx++] = cf->opath;
|
args[idx++] = cf->opath;
|
||||||
args[idx] = NULL;
|
args[idx] = NULL;
|
||||||
|
|
||||||
if (cf->cpp)
|
|
||||||
execvp(cppcompiler, args);
|
|
||||||
else
|
|
||||||
execvp(compiler, args);
|
execvp(compiler, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -927,10 +921,9 @@ static void
|
|||||||
cli_link_library(void *arg)
|
cli_link_library(void *arg)
|
||||||
{
|
{
|
||||||
struct cfile *cf;
|
struct cfile *cf;
|
||||||
int idx, f, i;
|
int idx, f, i, has_cpp;
|
||||||
char *p, *libname, *flags[LD_FLAGS_MAX];
|
|
||||||
char *args[cfiles_count + 11 + LD_FLAGS_MAX];
|
char *args[cfiles_count + 11 + LD_FLAGS_MAX];
|
||||||
char *cpplib;
|
char *p, *libname, *flags[LD_FLAGS_MAX], *cpplib;
|
||||||
|
|
||||||
if ((p = getenv("LDFLAGS")) != NULL)
|
if ((p = getenv("LDFLAGS")) != NULL)
|
||||||
f = kore_split_string(p, " ", flags, LD_FLAGS_MAX);
|
f = kore_split_string(p, " ", flags, LD_FLAGS_MAX);
|
||||||
@ -951,16 +944,20 @@ cli_link_library(void *arg)
|
|||||||
args[idx++] = "-shared";
|
args[idx++] = "-shared";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TAILQ_FOREACH(cf, &source_files, list)
|
TAILQ_FOREACH(cf, &source_files, list) {
|
||||||
|
if (cf->cpp)
|
||||||
|
has_cpp = 1;
|
||||||
args[idx++] = cf->opath;
|
args[idx++] = cf->opath;
|
||||||
|
}
|
||||||
|
|
||||||
if ((cpplib = getenv("CXXLIB")) != NULL) {
|
if (has_cpp) {
|
||||||
char *cpplibrary = NULL;
|
if ((p = getenv("CXXLIB")) != NULL) {
|
||||||
(void)cli_vasprintf(&cpplibrary, "-l%s", cpplib);
|
(void)cli_vasprintf(&cpplib, "-l%s", p);
|
||||||
args[idx++] = cpplibrary;
|
args[idx++] = cpplib;
|
||||||
} else {
|
} else {
|
||||||
args[idx++] = "-lstdc++";
|
args[idx++] = "-lstdc++";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < f; i++)
|
for (i = 0; i < f; i++)
|
||||||
args[idx++] = flags[i];
|
args[idx++] = flags[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user