diff --git a/binding.gyp b/binding.gyp index e678f54..5009aad 100644 --- a/binding.gyp +++ b/binding.gyp @@ -13,18 +13,17 @@ "src/parser.c", "src/scanner.c", ], - "conditions": [ - ["OS!='win'", { - "cflags_c": [ - "-std=c11", - ], - }, { # OS == "win" - "cflags_c": [ + "cflags_c": [ + "-std=c11", + ], + "msvs_settings": { + "VCCLCompilerTool": { + "AdditionalOptions": [ "/std:c11", "/utf-8", ], - }], - ], + }, + }, } ] } diff --git a/setup.py b/setup.py index f038a5f..db5c534 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from os import path -from platform import system from sysconfig import get_config_var +from distutils.ccompiler import new_compiler from setuptools import Extension, find_packages, setup from setuptools.command.build import build @@ -21,10 +21,10 @@ if limited_api := not get_config_var("Py_GIL_DISABLED"): macros.append(("Py_LIMITED_API", "0x030A0000")) -if system() != "Windows": - cflags = ["-std=c11", "-fvisibility=hidden"] -else: +if new_compiler().compiler_type == "msvc": cflags = ["/std:c11", "/utf-8"] +else: + cflags = ["-std=c11", "-fvisibility=hidden"] class Build(build):