Repository: lucy Updated Branches: refs/heads/master dffc23a47 -> 212c0664d
Add "host" CLI arg Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/212c0664 Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/212c0664 Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/212c0664 Branch: refs/heads/master Commit: 212c0664de332775e14acec9912e4bf6ba98be91 Parents: dffc23a Author: Nick Wellnhofer <[email protected]> Authored: Sat Dec 27 15:52:11 2014 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Sat Dec 27 15:52:11 2014 +0100 ---------------------------------------------------------------------- c/configure | 2 +- c/configure.bat | 2 +- common/charmonizer.c | 35 ++++++++++++++++++++++++++++++++--- common/charmonizer.main | 2 ++ 4 files changed, 36 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/212c0664/c/configure ---------------------------------------------------------------------- diff --git a/c/configure b/c/configure index 875a7bd..8e61308 100755 --- a/c/configure +++ b/c/configure @@ -45,5 +45,5 @@ echo $command $command || exit echo Running charmonizer -./charmonizer --cc=$CC --enable-c --enable-makefile "$@" +./charmonizer --cc=$CC --host=c --enable-c --enable-makefile "$@" http://git-wip-us.apache.org/repos/asf/lucy/blob/212c0664/c/configure.bat ---------------------------------------------------------------------- diff --git a/c/configure.bat b/c/configure.bat index 0a6d855..d89a678 100644 --- a/c/configure.bat +++ b/c/configure.bat @@ -44,5 +44,5 @@ echo gcc ..\common\charmonizer.c -o charmonizer.exe gcc ..\common\charmonizer.c -o charmonizer.exe if errorlevel 1 exit /b 1 echo Running charmonizer -charmonizer.exe --cc=gcc --enable-c --enable-makefile %* +charmonizer.exe --cc=gcc --host=c --enable-c --enable-makefile %* exit /b http://git-wip-us.apache.org/repos/asf/lucy/blob/212c0664/common/charmonizer.c ---------------------------------------------------------------------- diff --git a/common/charmonizer.c b/common/charmonizer.c index 465938b..573e213 100644 --- a/common/charmonizer.c +++ b/common/charmonizer.c @@ -301,6 +301,12 @@ chaz_CC_compile_obj(const char *source_path, const char *obj_path, int chaz_CC_test_compile(const char *source); +/* Attempt to compile and link the supplied source code and return true if + * the effort succeeds. + */ +int +chaz_CC_test_link(const char *source); + /* Attempt to compile the supplied source code. If successful, capture the * output of the program and return a pointer to a newly allocated buffer. * If the compilation fails, return NULL. The length of the captured @@ -2262,7 +2268,7 @@ S_chaz_CLI_rebuild_help(chaz_CLI *self) { } strcat(self->help, "\n"); if (self->num_opts) { - strcat(self->help, "\nOptional arguments:\n"); + strcat(self->help, "\nArguments:\n"); for (i = 0; i < self->num_opts; i++) { chaz_CLIOption *opt = &self->opts[i]; size_t line_start = strlen(self->help); @@ -2281,7 +2287,7 @@ S_chaz_CLI_rebuild_help(chaz_CLI *self) { self->help[current_len++] = toupper(opt->name[j]); } if (opt->flags & CHAZ_CLI_ARG_OPTIONAL) { - strcat(self->help, "]"); + self->help[current_len++] = ']'; } self->help[current_len] = '\0'; } @@ -2520,6 +2526,15 @@ chaz_CLI_parse(chaz_CLI *self, int argc, const char *argv[]) { } free(name); + + for (i = 0; i < self->num_opts; i++) { + chaz_CLIOption *opt = &self->opts[i]; + if (!opt->defined && (opt->flags & CHAZ_CLI_ARG_REQUIRED)) { + S_chaz_CLI_error(self, "Option '%s' is required", opt->name); + return 0; + } + } + return 1; } @@ -2793,6 +2808,18 @@ chaz_CC_test_compile(const char *source) { return compile_succeeded; } +int +chaz_CC_test_link(const char *source) { + int link_succeeded; + if (!chaz_Util_remove_and_verify(chaz_CC.try_exe_name)) { + chaz_Util_die("Failed to delete file '%s'", chaz_CC.try_exe_name); + } + link_succeeded = chaz_CC_compile_exe(CHAZ_CC_TRY_SOURCE_PATH, + CHAZ_CC_TRY_BASENAME, source); + chaz_Util_remove_and_verify(chaz_CC.try_exe_name); + return link_succeeded; +} + char* chaz_CC_capture_output(const char *source, size_t *output_len) { char *captured_output = NULL; @@ -5557,7 +5584,7 @@ chaz_Probe_parse_cli_args(int argc, const char *argv[], chaz_CLI *cli) { chaz_CLI_register(cli, "enable-makefile", NULL, CHAZ_CLI_NO_ARG); chaz_CLI_register(cli, "enable-coverage", NULL, CHAZ_CLI_NO_ARG); chaz_CLI_register(cli, "cc", "compiler command", CHAZ_CLI_ARG_REQUIRED); - chaz_CLI_register(cli, "cflags", NULL, CHAZ_CLI_ARG_REQUIRED); + chaz_CLI_register(cli, "cflags", NULL, CHAZ_CLI_ARG_OPTIONAL); chaz_CLI_register(cli, "make", "make command", 0); /* Parse options, exiting on failure. */ @@ -7789,6 +7816,8 @@ int main(int argc, const char **argv) { /* Initialize. */ chaz_CLI *cli = chaz_CLI_new(argv[0], "charmonizer: Probe C build environment"); + chaz_CLI_register(cli, "host", "specify host binding language", + CHAZ_CLI_ARG_REQUIRED); chaz_CLI_register(cli, "clownfish-prefix", "prefix of Clownfish installation", CHAZ_CLI_ARG_OPTIONAL); http://git-wip-us.apache.org/repos/asf/lucy/blob/212c0664/common/charmonizer.main ---------------------------------------------------------------------- diff --git a/common/charmonizer.main b/common/charmonizer.main index 7a6e66a..d93bbb2 100644 --- a/common/charmonizer.main +++ b/common/charmonizer.main @@ -109,6 +109,8 @@ int main(int argc, const char **argv) { /* Initialize. */ chaz_CLI *cli = chaz_CLI_new(argv[0], "charmonizer: Probe C build environment"); + chaz_CLI_register(cli, "host", "specify host binding language", + CHAZ_CLI_ARG_REQUIRED); chaz_CLI_register(cli, "clownfish-prefix", "prefix of Clownfish installation", CHAZ_CLI_ARG_OPTIONAL);
