Repository: lucy-clownfish Updated Branches: refs/heads/master b2da42dcc -> 3369bc139
Add "host" CLI arg Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/3369bc13 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/3369bc13 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/3369bc13 Branch: refs/heads/master Commit: 3369bc139affd86b8b53394253e875a1ad861204 Parents: b2da42d Author: Nick Wellnhofer <[email protected]> Authored: Thu Dec 4 20:55:27 2014 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Sat Dec 27 15:43:51 2014 +0100 ---------------------------------------------------------------------- compiler/c/configure | 2 +- compiler/c/configure.bat | 2 +- compiler/common/charmonizer.c | 37 +++++++++++++++-- compiler/common/charmonizer.main | 4 +- .../lib/Clownfish/CFC/Perl/Build/Charmonic.pm | 1 + runtime/c/configure | 2 +- runtime/c/configure.bat | 2 +- runtime/common/charmonizer.c | 43 ++++++++++++++++---- runtime/common/charmonizer.main | 10 +++-- 9 files changed, 83 insertions(+), 20 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3369bc13/compiler/c/configure ---------------------------------------------------------------------- diff --git a/compiler/c/configure b/compiler/c/configure index 4e8e47e..0a955c0 100755 --- a/compiler/c/configure +++ b/compiler/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-clownfish/blob/3369bc13/compiler/c/configure.bat ---------------------------------------------------------------------- diff --git a/compiler/c/configure.bat b/compiler/c/configure.bat index f877d71..e60f61f 100644 --- a/compiler/c/configure.bat +++ b/compiler/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-clownfish/blob/3369bc13/compiler/common/charmonizer.c ---------------------------------------------------------------------- diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c index 8e37274..d69a9b5 100644 --- a/compiler/common/charmonizer.c +++ b/compiler/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. */ @@ -7721,6 +7748,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_set_usage(cli, "Usage: charmonizer [OPTIONS] [-- [CFLAGS]]"); { int result = chaz_Probe_parse_cli_args(argc, argv, cli); @@ -7773,7 +7802,7 @@ S_add_compiler_flags(struct chaz_CLI *cli) { "-DLUCY_DEBUG -pedantic -Wall -Wextra -Wno-variadic-macros" ); } - if (chaz_CLI_defined(cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(cli, "host"), "perl") == 0) { chaz_CFlags_append(extra_cflags, "-DPERL_GCC_PEDANTIC"); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3369bc13/compiler/common/charmonizer.main ---------------------------------------------------------------------- diff --git a/compiler/common/charmonizer.main b/compiler/common/charmonizer.main index 47694d3..b3fc2d6 100644 --- a/compiler/common/charmonizer.main +++ b/compiler/common/charmonizer.main @@ -41,6 +41,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_set_usage(cli, "Usage: charmonizer [OPTIONS] [-- [CFLAGS]]"); { int result = chaz_Probe_parse_cli_args(argc, argv, cli); @@ -93,7 +95,7 @@ S_add_compiler_flags(struct chaz_CLI *cli) { "-DLUCY_DEBUG -pedantic -Wall -Wextra -Wno-variadic-macros" ); } - if (chaz_CLI_defined(cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(cli, "host"), "perl") == 0) { chaz_CFlags_append(extra_cflags, "-DPERL_GCC_PEDANTIC"); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3369bc13/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm ---------------------------------------------------------------------- diff --git a/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm b/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm index a37b6b4..7d55bb4 100644 --- a/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm +++ b/compiler/perl/lib/Clownfish/CFC/Perl/Build/Charmonic.pm @@ -79,6 +79,7 @@ sub ACTION_charmony { my @command = ( $CHARMONIZER_EXE_PATH, "--cc=$cc", + '--host=perl', '--enable-c', '--enable-perl', ); http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3369bc13/runtime/c/configure ---------------------------------------------------------------------- diff --git a/runtime/c/configure b/runtime/c/configure index 29b0c14..9557e66 100755 --- a/runtime/c/configure +++ b/runtime/c/configure @@ -48,5 +48,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-clownfish/blob/3369bc13/runtime/c/configure.bat ---------------------------------------------------------------------- diff --git a/runtime/c/configure.bat b/runtime/c/configure.bat index 40b5cb0..9a34abd 100644 --- a/runtime/c/configure.bat +++ b/runtime/c/configure.bat @@ -40,7 +40,7 @@ echo cl /nologo ..\common\charmonizer.c cl /nologo ..\common\charmonizer.c if errorlevel 1 exit /b 1 echo Running charmonizer -charmonizer.exe --cc=cl --enable-c --enable-makefile %* +charmonizer.exe --cc=cl --host=c --enable-c --enable-makefile %* exit /b :found_gcc http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3369bc13/runtime/common/charmonizer.c ---------------------------------------------------------------------- diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c index 133494b..eaef833 100644 --- a/runtime/common/charmonizer.c +++ b/runtime/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. */ @@ -7777,6 +7804,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, "disable-threads", "whether to disable threads", CHAZ_CLI_NO_ARG); chaz_CLI_set_usage(cli, "Usage: charmonizer [OPTIONS] [-- [CFLAGS]]"); @@ -7865,7 +7894,7 @@ S_add_compiler_flags(struct chaz_CLI *cli) { else if (getenv("LUCY_DEBUG")) { chaz_CFlags_append(extra_cflags, "-DLUCY_DEBUG -pedantic -Wall -Wextra -Wno-variadic-macros"); - if (chaz_CLI_defined(cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(cli, "host"), "perl") == 0) { chaz_CFlags_append(extra_cflags, "-DPERL_GCC_PEDANTIC"); } } @@ -7915,7 +7944,7 @@ cfish_MakeFile_new(chaz_CLI *cli) { self->autogen_target = chaz_Util_join(dir_sep, "autogen", "hierarchy.json", NULL); - if (chaz_CLI_defined(cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(self->cli, "host"), "perl") == 0) { static const char *perl_autogen_src_files[] = { "boot", "callbacks", @@ -8035,7 +8064,7 @@ cfish_MakeFile_write(cfish_MakeFile *self) { chaz_MakeFile_add_rule(self->makefile, "all", scratch); free(scratch); - if (!chaz_CLI_defined(self->cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(self->cli, "host"), "c") == 0) { cfish_MakeFile_write_c_cfc_rules(self); } @@ -8064,7 +8093,7 @@ cfish_MakeFile_write(cfish_MakeFile *self) { chaz_MakeFile_add_static_lib(self->makefile, self->static_lib, "$(CLOWNFISH_OBJS)"); - if (!chaz_CLI_defined(self->cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(self->cli, "host"), "c") == 0) { cfish_MakeFile_write_c_test_rules(self); } http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/3369bc13/runtime/common/charmonizer.main ---------------------------------------------------------------------- diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main index 4c2bcd5..30bdff2 100644 --- a/runtime/common/charmonizer.main +++ b/runtime/common/charmonizer.main @@ -97,6 +97,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, "disable-threads", "whether to disable threads", CHAZ_CLI_NO_ARG); chaz_CLI_set_usage(cli, "Usage: charmonizer [OPTIONS] [-- [CFLAGS]]"); @@ -185,7 +187,7 @@ S_add_compiler_flags(struct chaz_CLI *cli) { else if (getenv("LUCY_DEBUG")) { chaz_CFlags_append(extra_cflags, "-DLUCY_DEBUG -pedantic -Wall -Wextra -Wno-variadic-macros"); - if (chaz_CLI_defined(cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(cli, "host"), "perl") == 0) { chaz_CFlags_append(extra_cflags, "-DPERL_GCC_PEDANTIC"); } } @@ -235,7 +237,7 @@ cfish_MakeFile_new(chaz_CLI *cli) { self->autogen_target = chaz_Util_join(dir_sep, "autogen", "hierarchy.json", NULL); - if (chaz_CLI_defined(cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(self->cli, "host"), "perl") == 0) { static const char *perl_autogen_src_files[] = { "boot", "callbacks", @@ -355,7 +357,7 @@ cfish_MakeFile_write(cfish_MakeFile *self) { chaz_MakeFile_add_rule(self->makefile, "all", scratch); free(scratch); - if (!chaz_CLI_defined(self->cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(self->cli, "host"), "c") == 0) { cfish_MakeFile_write_c_cfc_rules(self); } @@ -384,7 +386,7 @@ cfish_MakeFile_write(cfish_MakeFile *self) { chaz_MakeFile_add_static_lib(self->makefile, self->static_lib, "$(CLOWNFISH_OBJS)"); - if (!chaz_CLI_defined(self->cli, "enable-perl")) { + if (strcmp(chaz_CLI_strval(self->cli, "host"), "c") == 0) { cfish_MakeFile_write_c_test_rules(self); }
