Adapt for Charmonizer CLI changes.
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 @@
} 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 @@
"-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 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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;
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_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 @@
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 @@
}
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 @@
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 @@
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 @@
}
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 @@
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 @@
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 @@
"#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;