File: detect_compiler.c

package info (click to toggle)
meson-python 0.19.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,328 kB
  • sloc: python: 3,114; ansic: 304; cpp: 16; makefile: 8
file content (38 lines) | stat: -rw-r--r-- 732 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// SPDX-FileCopyrightText: 2023 The meson-python developers
//
// SPDX-License-Identifier: MIT

#include <Python.h>

#if defined _MSC_VER
#  define _COMPILER "msvc"
#elif defined __clang__
#  define _COMPILER "clang"
#elif defined __GNUC__
#  define _COMPILER "gcc"
#else
#  define _COMPILER "unknown"
#endif

static PyObject* compiler(PyObject* self)
{
    return PyUnicode_FromString(_COMPILER);
}

static PyMethodDef methods[] = {
    {"compiler", (PyCFunction)compiler, METH_NOARGS, NULL},
    {NULL, NULL, 0, NULL},
};

static struct PyModuleDef module = {
    PyModuleDef_HEAD_INIT,
    "detect_compiler",
    NULL,
    -1,
    methods,
};

PyMODINIT_FUNC PyInit_detect_compiler(void)
{
    return PyModule_Create(&module);
}