mirror of https://git.kore.io/kore.git
Better name consistency and only print CXXFLAGS if compiling C++
This commit is contained in:
parent
698b3f374f
commit
91d29a9914
24
src/cli.c
24
src/cli.c
|
@ -118,7 +118,7 @@ static void cli_file_write(int, const void *, size_t);
|
||||||
static int cli_vasprintf(char **, const char *, ...);
|
static int cli_vasprintf(char **, const char *, ...);
|
||||||
static void cli_spawn_proc(void (*cb)(void *), void *);
|
static void cli_spawn_proc(void (*cb)(void *), void *);
|
||||||
static void cli_write_asset(const char *, const char *);
|
static void cli_write_asset(const char *, const char *);
|
||||||
static void cli_register_cfile(char *, struct dirent *);
|
static void cli_register_source_file(char *, struct dirent *);
|
||||||
static void cli_file_create(const char *, const char *, size_t);
|
static void cli_file_create(const char *, const char *, size_t);
|
||||||
static int cli_file_requires_build(struct stat *, const char *);
|
static int cli_file_requires_build(struct stat *, const char *);
|
||||||
static void cli_find_files(const char *,
|
static void cli_find_files(const char *,
|
||||||
|
@ -251,7 +251,8 @@ static char *compiler_cpp = "g++";
|
||||||
static char *compiler_ld = "gcc";
|
static char *compiler_ld = "gcc";
|
||||||
static struct cfile_list source_files;
|
static struct cfile_list source_files;
|
||||||
static struct buildopt_list build_options;
|
static struct buildopt_list build_options;
|
||||||
static int cfiles_count;
|
static int source_files_count;
|
||||||
|
static int cxx_files_count;
|
||||||
static struct cmd *command = NULL;
|
static struct cmd *command = NULL;
|
||||||
static int cflags_count = 0;
|
static int cflags_count = 0;
|
||||||
static int cxxflags_count = 0;
|
static int cxxflags_count = 0;
|
||||||
|
@ -413,7 +414,8 @@ cli_build(int argc, char **argv)
|
||||||
if ((p = getenv("CXX")) != NULL)
|
if ((p = getenv("CXX")) != NULL)
|
||||||
compiler_cpp = p;
|
compiler_cpp = p;
|
||||||
|
|
||||||
cfiles_count = 0;
|
source_files_count = 0;
|
||||||
|
cxx_files_count = 0;
|
||||||
TAILQ_INIT(&source_files);
|
TAILQ_INIT(&source_files);
|
||||||
TAILQ_INIT(&build_options);
|
TAILQ_INIT(&build_options);
|
||||||
|
|
||||||
|
@ -438,6 +440,10 @@ cli_build(int argc, char **argv)
|
||||||
cli_buildopt_parse(build_path);
|
cli_buildopt_parse(build_path);
|
||||||
free(build_path);
|
free(build_path);
|
||||||
|
|
||||||
|
/* Build all source files. */
|
||||||
|
cli_find_files(src_path, cli_register_source_file);
|
||||||
|
free(src_path);
|
||||||
|
|
||||||
printf("building %s (%s)\n", appl, flavor);
|
printf("building %s (%s)\n", appl, flavor);
|
||||||
cli_build_cflags(bopt);
|
cli_build_cflags(bopt);
|
||||||
cli_build_cxxflags(bopt);
|
cli_build_cxxflags(bopt);
|
||||||
|
@ -464,10 +470,6 @@ cli_build(int argc, char **argv)
|
||||||
|
|
||||||
free(assets_path);
|
free(assets_path);
|
||||||
|
|
||||||
/* Build all source files. */
|
|
||||||
cli_find_files(src_path, cli_register_cfile);
|
|
||||||
free(src_path);
|
|
||||||
|
|
||||||
requires_relink = 0;
|
requires_relink = 0;
|
||||||
TAILQ_FOREACH(cf, &source_files, list) {
|
TAILQ_FOREACH(cf, &source_files, list) {
|
||||||
if (cf->build == BUILD_NOBUILD)
|
if (cf->build == BUILD_NOBUILD)
|
||||||
|
@ -822,7 +824,7 @@ cli_add_source_file(char *name, char *fpath, char *opath, struct stat *st,
|
||||||
{
|
{
|
||||||
struct cfile *cf;
|
struct cfile *cf;
|
||||||
|
|
||||||
cfiles_count++;
|
source_files_count++;
|
||||||
cf = kore_malloc(sizeof(*cf));
|
cf = kore_malloc(sizeof(*cf));
|
||||||
|
|
||||||
cf->st = *st;
|
cf->st = *st;
|
||||||
|
@ -835,7 +837,7 @@ cli_add_source_file(char *name, char *fpath, char *opath, struct stat *st,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cli_register_cfile(char *fpath, struct dirent *dp)
|
cli_register_source_file(char *fpath, struct dirent *dp)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
char *ext, *opath;
|
char *ext, *opath;
|
||||||
|
@ -853,6 +855,7 @@ cli_register_cfile(char *fpath, struct dirent *dp)
|
||||||
build = BUILD_NOBUILD;
|
build = BUILD_NOBUILD;
|
||||||
} else if (!strcmp(ext, ".cpp")) {
|
} else if (!strcmp(ext, ".cpp")) {
|
||||||
build = BUILD_CXX;
|
build = BUILD_CXX;
|
||||||
|
cxx_files_count++;
|
||||||
} else {
|
} else {
|
||||||
build = BUILD_C;
|
build = BUILD_C;
|
||||||
}
|
}
|
||||||
|
@ -1053,7 +1056,7 @@ cli_link_library(void *arg)
|
||||||
struct cfile *cf;
|
struct cfile *cf;
|
||||||
int idx, i;
|
int idx, i;
|
||||||
char *libname;
|
char *libname;
|
||||||
char *args[cfiles_count + 11 + LD_FLAGS_MAX];
|
char *args[source_files_count + 11 + LD_FLAGS_MAX];
|
||||||
|
|
||||||
(void)cli_vasprintf(&libname, "%s/%s.so", rootdir, appl);
|
(void)cli_vasprintf(&libname, "%s/%s.so", rootdir, appl);
|
||||||
|
|
||||||
|
@ -1303,6 +1306,7 @@ cli_build_cxxflags(struct buildopt *bopt)
|
||||||
}
|
}
|
||||||
|
|
||||||
string = kore_buf_stringify(bopt->cxxflags, NULL);
|
string = kore_buf_stringify(bopt->cxxflags, NULL);
|
||||||
|
if (cxx_files_count > 0)
|
||||||
printf("CXXFLAGS=%s\n", string);
|
printf("CXXFLAGS=%s\n", string);
|
||||||
cxxflags_count = kore_split_string(string, " ", cxxflags, CXXFLAGS_MAX);
|
cxxflags_count = kore_split_string(string, " ", cxxflags, CXXFLAGS_MAX);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue