Clownfish-CFC

 view release on metacpan or  search on metacpan

charmonizer.c  view on Meta::CPAN

#include <stdlib.h>


/* Code for verifying ISO-style variadic macros. */
static const char chaz_VariadicMacros_iso_code[] =
    CHAZ_QUOTE(  #include <stdio.h>                                    )
                "#define ISO_TEST(fmt, ...) printf(fmt, __VA_ARGS__)\n"
    CHAZ_QUOTE(  void f() { ISO_TEST("%d %d", 1, 1); }                 );

/* Code for verifying GNU-style variadic macros. */
static const char chaz_VariadicMacros_gnuc_code[] =
    CHAZ_QUOTE(  #include <stdio.h>                                    )
    CHAZ_QUOTE(  #define GNU_TEST(fmt, args...) printf(fmt, ##args)    )
    CHAZ_QUOTE(  void f() { GNU_TEST("%d %d", 1, 1); }                 );

void
chaz_VariadicMacros_run(void) {
    int has_varmacros = false;

    chaz_ConfWriter_start_module("VariadicMacros");

    /* Test for ISO-style variadic macros. */
    if (chaz_CC_test_compile(chaz_VariadicMacros_iso_code)) {
        has_varmacros = true;
        chaz_ConfWriter_add_def("HAS_VARIADIC_MACROS", NULL);
        chaz_ConfWriter_add_def("HAS_ISO_VARIADIC_MACROS", NULL);
    }

    /* Test for GNU-style variadic macros. */
    if (chaz_CC_test_compile(chaz_VariadicMacros_gnuc_code)) {
        if (has_varmacros == false) {
            has_varmacros = true;
            chaz_ConfWriter_add_def("HAS_VARIADIC_MACROS", NULL);
        }
        chaz_ConfWriter_add_def("HAS_GNUC_VARIADIC_MACROS", NULL);
    }

    chaz_ConfWriter_end_module();
}




#line 1 "compiler/common/charmonizer.main"
/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* Source fragment for the Clownfish compiler's charmonizer.c.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* #include "Charmonizer/Probe.h" */
/* #include "Charmonizer/Probe/Integers.h" */

typedef struct SourceFileContext {
    chaz_MakeBinary *core_binary;
    chaz_MakeBinary *test_binary;
} SourceFileContext;

static const char cfc_version[]       = "0.8.0";
static const char cfc_major_version[] = "0.8";

static void
S_add_compiler_flags(struct chaz_CLI *cli);

static void
S_write_makefile(struct chaz_CLI *cli);

static void
S_source_file_callback(const char *dir, char *file, void *context);

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_register(cli, "with-system-cmark", "use system cmark library",
                      CHAZ_CLI_NO_ARG);
    chaz_CLI_set_usage(cli, "Usage: charmonizer [OPTIONS] [-- [CFLAGS]]");
    {
        int result = chaz_Probe_parse_cli_args(argc, argv, cli);
        if (!result) {
            chaz_Probe_die_usage();
        }
        chaz_Probe_init(cli);
        S_add_compiler_flags(cli);
    }

    /* Define stdint types in charmony.h. */
    chaz_ConfWriter_append_conf("#define CHY_EMPLOY_INTEGERTYPES\n\n");
    chaz_ConfWriter_append_conf("#define CHY_EMPLOY_INTEGERLITERALS\n\n");
    chaz_ConfWriter_append_conf("#define CHY_EMPLOY_INTEGERFORMATSTRINGS\n\n");

    /* Run probe modules. */
    chaz_BuildEnv_run();
    chaz_DirManip_run();
    chaz_Headers_run();
    chaz_FuncMacro_run();
    chaz_Booleans_run();
    chaz_Integers_run();
    chaz_Strings_run();
    chaz_Memory_run();
    chaz_SymbolVisibility_run();



( run in 1.234 second using v1.01-cache-2.11-cpan-364913b4093 )