Repository: lucy-clownfish Updated Branches: refs/heads/chaz_generic_cli [created] 63038203c
Adapt for Charmonizer CLI changes. Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/125d05ab Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/125d05ab Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/125d05ab Branch: refs/heads/chaz_generic_cli Commit: 125d05ab859b7644404335df676e1a0acb49ea7e Parents: 5f4ab0a Author: Marvin Humphrey <[email protected]> Authored: Thu Oct 9 18:06:51 2014 -0700 Committer: Marvin Humphrey <[email protected]> Committed: Tue Oct 14 19:27:23 2014 -0700 ---------------------------------------------------------------------- compiler/common/charmonizer.main | 29 ++++++++++++++++------------- runtime/common/charmonizer.main | 30 +++++++++++++++++------------- 2 files changed, 33 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/125d05ab/compiler/common/charmonizer.main ---------------------------------------------------------------------- diff --git a/compiler/common/charmonizer.main b/compiler/common/charmonizer.main index 26ac692..8d8ea73 100644 --- a/compiler/common/charmonizer.main +++ b/compiler/common/charmonizer.main @@ -29,7 +29,7 @@ typedef struct SourceFileContext { } SourceFileContext; static void -S_add_compiler_flags(struct chaz_CLIArgs *args) { +S_add_compiler_flags(struct chaz_CLI *cli) { chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags(); if (chaz_Probe_gcc_version_num()) { @@ -41,7 +41,7 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) { "-DLUCY_DEBUG -pedantic -Wall -Wextra -Wno-variadic-macros" ); } - if (args->charmony_pm) { + if (chaz_CLI_defined(cli, "enable-perl")) { chaz_CFlags_append(extra_cflags, "-DPERL_GCC_PEDANTIC"); } @@ -92,7 +92,7 @@ S_source_file_callback(const char *dir, char *file, void *context) { } static void -S_write_makefile(struct chaz_CLIArgs *args) { +S_write_makefile(struct chaz_CLI *cli) { SourceFileContext sfc; const char *base_dir = ".."; @@ -140,7 +140,7 @@ S_write_makefile(struct chaz_CLIArgs *args) { chaz_CFlags_add_include_dir(makefile_cflags, "."); chaz_CFlags_add_include_dir(makefile_cflags, include_dir); chaz_CFlags_add_include_dir(makefile_cflags, src_dir); - if (args->code_coverage) { + if (chaz_CLI_defined(cli, "enable-coverage")) { chaz_CFlags_enable_code_coverage(makefile_cflags); } @@ -189,7 +189,7 @@ S_write_makefile(struct chaz_CLIArgs *args) { if (chaz_CC_msvc_version_num()) { chaz_CFlags_append(link_flags, "/nologo"); } - if (args->code_coverage) { + if (chaz_CLI_defined(cli, "enable-coverage")) { chaz_CFlags_enable_code_coverage(link_flags); } chaz_MakeFile_add_exe(makefile, cfc_exe, "$(COMMON_OBJS) $(CFC_OBJS)", @@ -201,7 +201,7 @@ S_write_makefile(struct chaz_CLIArgs *args) { rule = chaz_MakeFile_add_rule(makefile, "test", test_cfc_exe); chaz_MakeRule_add_command(rule, test_cfc_exe); - if (args->code_coverage) { + if (chaz_CLI_defined(cli, "enable-coverage")) { rule = chaz_MakeFile_add_rule(makefile, "coverage", test_cfc_exe); chaz_MakeRule_add_command(rule, "lcov" @@ -228,7 +228,7 @@ S_write_makefile(struct chaz_CLIArgs *args) { chaz_MakeRule_add_rm_command(clean_rule, "$(CFC_OBJS)"); chaz_MakeRule_add_rm_command(clean_rule, "$(TEST_CFC_OBJS)"); - if (args->code_coverage) { + if (chaz_CLI_defined(cli, "enable-coverage")) { chaz_MakeRule_add_rm_command(clean_rule, "cfc.info"); chaz_MakeRule_add_recursive_rm_command(clean_rule, "coverage"); } @@ -250,14 +250,16 @@ S_write_makefile(struct chaz_CLIArgs *args) { int main(int argc, const char **argv) { /* Initialize. */ - struct chaz_CLIArgs args; + chaz_CLI *cli + = chaz_CLI_new(argv[0], "charmonizer: Probe C build environment"); + chaz_CLI_set_usage(cli, "Usage: charmonizer [OPTIONS] [-- [CFLAGS]]"); { - int result = chaz_Probe_parse_cli_args(argc, argv, &args); + int result = chaz_Probe_parse_cli_args(argc, argv, cli); if (!result) { chaz_Probe_die_usage(); } - chaz_Probe_init(&args); - S_add_compiler_flags(&args); + chaz_Probe_init(cli); + S_add_compiler_flags(cli); } /* Define stdint types in charmony.h. */ @@ -278,11 +280,12 @@ int main(int argc, const char **argv) { chaz_UnusedVars_run(); chaz_VariadicMacros_run(); - if (args.write_makefile) { - S_write_makefile(&args); + if (chaz_CLI_defined(cli, "enable-makefile")) { + S_write_makefile(cli); } /* Clean up. */ + chaz_CLI_destroy(cli); chaz_Probe_clean_up(); return 0; http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/125d05ab/runtime/common/charmonizer.main ---------------------------------------------------------------------- diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main index 36a5d5b..4664782 100644 --- a/runtime/common/charmonizer.main +++ b/runtime/common/charmonizer.main @@ -33,6 +33,7 @@ #include "Charmonizer/Probe/SymbolVisibility.h" #include "Charmonizer/Probe/VariadicMacros.h" #include "Charmonizer/Core/HeaderChecker.h" +#include "Charmonizer/Core/CLI.h" #include "Charmonizer/Core/ConfWriter.h" #include "Charmonizer/Core/ConfWriterC.h" #include "Charmonizer/Core/ConfWriterPerl.h" @@ -46,7 +47,7 @@ static const char cfish_version[] = "0.4.0"; static const char cfish_major_version[] = "0.4"; static void -S_add_compiler_flags(struct chaz_CLIArgs *args) { +S_add_compiler_flags(struct chaz_CLI *cli) { chaz_CFlags *extra_cflags = chaz_CC_get_extra_cflags(); if (chaz_Probe_gcc_version_num()) { @@ -57,7 +58,7 @@ S_add_compiler_flags(struct chaz_CLIArgs *args) { else if (getenv("LUCY_DEBUG")) { chaz_CFlags_append(extra_cflags, "-DLUCY_DEBUG -pedantic -Wall -Wextra -Wno-variadic-macros"); - if (args->charmony_pm) { + if (chaz_CLI_defined(cli, "enable-perl")) { chaz_CFlags_append(extra_cflags, "-DPERL_GCC_PEDANTIC"); } } @@ -131,7 +132,7 @@ S_cfh_file_callback(const char *dir, char *file, void *context) { } static void -S_write_makefile(struct chaz_CLIArgs *args) { +S_write_makefile(struct chaz_CLI *cli) { SourceFileContext sfc; const char *base_dir = ".."; @@ -188,7 +189,7 @@ S_write_makefile(struct chaz_CLIArgs *args) { chaz_CFlags_enable_debugging(makefile_cflags); chaz_CFlags_disable_strict_aliasing(makefile_cflags); chaz_CFlags_compile_shared_library(makefile_cflags); - if (args->code_coverage) { + if (chaz_CLI_defined(cli, "enable-coverage")) { chaz_CFlags_enable_code_coverage(makefile_cflags); } @@ -265,7 +266,7 @@ S_write_makefile(struct chaz_CLIArgs *args) { if (math_library) { chaz_CFlags_add_external_library(link_flags, math_library); } - if (args->code_coverage) { + if (chaz_CLI_defined(cli, "enable-coverage")) { chaz_CFlags_enable_code_coverage(link_flags); } chaz_MakeFile_add_shared_lib(makefile, shared_lib, "$(CLOWNFISH_OBJS)", @@ -294,7 +295,7 @@ S_write_makefile(struct chaz_CLIArgs *args) { } chaz_MakeRule_add_command(rule, test_command); - if (args->code_coverage) { + if (chaz_CLI_defined(cli, "enable-coverage")) { rule = chaz_MakeFile_add_rule(makefile, "coverage", test_cfish_exe); chaz_MakeRule_add_command(rule, "lcov" @@ -319,7 +320,7 @@ S_write_makefile(struct chaz_CLIArgs *args) { chaz_MakeRule_add_rm_command(clean_rule, "$(CLOWNFISH_OBJS)"); chaz_MakeRule_add_recursive_rm_command(clean_rule, "autogen"); - if (args->code_coverage) { + if (chaz_CLI_defined(cli, "enable-coverage")) { chaz_MakeRule_add_rm_command(clean_rule, "clownfish.info"); chaz_MakeRule_add_recursive_rm_command(clean_rule, "coverage"); } @@ -351,14 +352,16 @@ S_write_makefile(struct chaz_CLIArgs *args) { int main(int argc, const char **argv) { /* Initialize. */ - struct chaz_CLIArgs args; + chaz_CLI *cli + = chaz_CLI_new(argv[0], "charmonizer: Probe C build environment"); + chaz_CLI_set_usage(cli, "Usage: charmonizer [OPTIONS] [-- [CFLAGS]]"); { - int result = chaz_Probe_parse_cli_args(argc, argv, &args); + int result = chaz_Probe_parse_cli_args(argc, argv, cli); if (!result) { chaz_Probe_die_usage(); } - chaz_Probe_init(&args); - S_add_compiler_flags(&args); + chaz_Probe_init(cli); + S_add_compiler_flags(cli); } { int i; @@ -420,11 +423,12 @@ int main(int argc, const char **argv) { "#endif\n\n" ); - if (args.write_makefile) { - S_write_makefile(&args); + if (chaz_CLI_defined(cli, "enable-makefile")) { + S_write_makefile(cli); } /* Clean up. */ + chaz_CLI_destroy(cli); chaz_Probe_clean_up(); return 0;
