kicad2ems.emsdev.build¶
Build a solver's optional compiled core: one C++ file and pybind11 with
OpenMP, the module written next to the package's own modules (mom25d._core,
gfdtd._core). A package's core/build.py is
from kicad2ems.emsdev.build import build_core
build_core(__file__, 'mom25d_core.cpp', arch_env='MOM25D_ARCH')
Linux and macOS: g++ (-fopenmp). Windows, either of:
MSVC (Visual Studio 2022 or its Build Tools, "Desktop development with C++"),
found by setuptools as for any extension module, with /openmp:llvm: the
cores use OpenMP 3 (collapse, simd), which MSVC's default /openmp (2.0)
rejects. Its OpenMP runtime, libomp140.x86_64.dll, is copied next to the
module.
GCC MinGW-w64's g++ on the PATH (MSYS2's UCRT64 toolchain, or a standalone
one), linked against this Python's DLL; its runtime DLLs (libgomp,
libstdc++, libgcc, winpthread) are copied next to the module.
MSVC when Visual Studio is installed, else g++; EMSDEV_COMPILER=msvc or gcc
chooses. Python finds a module's
DLLs in the module's own folder, so the copies need no PATH.
`arch_env` names the environment variable that replaces the default instruction
set: -march=native for g++ (a portable build: -march=x86-64-v3), /arch:AVX2 for
MSVC. A -march=x86-64-vN given to MSVC is translated.
- kicad2ems.emsdev.build.build_core(build_py, source, arch_env=None, module='_core', includes_here=False, includes=())[source]¶
Build core/<source> (next to build_py, a package's core/build.py) into <package>/<module><EXT_SUFFIX>. includes_here: the core's own directory is on the include path (its headers); includes: more (NATIVE). Returns the module's path.
- kicad2ems.emsdev.build.build_msvc(here, source, out, arch='-march=native', includes=())[source]¶
Build `source` (in `here`) with MSVC into the extension module `out` (setuptools finds the compiler and sets its environment), then put the OpenMP runtime beside it.
- kicad2ems.emsdev.build.command(here, source, out, arch='-march=native', includes=(), mingw=False, gxx='g++')[source]¶
The g++ command line that builds `source` (in `here`) into the extension module `out`. mingw: MinGW-w64's on Windows: no -fPIC, CPython's Windows defines, the C++ runtime static, and this Python's DLL linked directly (MinGW's ld reads a DLL's exports; no import library needed).
- kicad2ems.emsdev.build.compiler()[source]¶
'msvc' or 'gcc': EMSDEV_COMPILER where set; on Windows MSVC when Visual Studio's C++ tools are installed (or cl is on the PATH), else g++ (MinGW-w64) when it is on the PATH, else 'msvc' (whose error says what is missing); elsewhere g++.
- kicad2ems.emsdev.build.find_omp_dll(installs=None)[source]¶
The path of MSVC's LLVM OpenMP runtime (libomp140.x86_64.dll): anywhere under a Visual Studio install's VC folder (its redistributable or tools folder; their layout differs between versions), the x64 release build, newest toolset first; else Windows' own (System32, where the VC++ redistributable puts it) or the PATH; None where there is none.
- kicad2ems.emsdev.build.mingw_dlls(gxx='g++')[source]¶
The runtime DLLs a MinGW-w64 build needs at import, from g++'s own bin folder: [paths] of those there.
- kicad2ems.emsdev.build.msvc_arch(arch)[source]¶
An instruction-set setting as MSVC's /arch flag: an /arch: flag as it is, a -march=X translated ('' for MSVC's default, SSE2), '' for anything else.
- kicad2ems.emsdev.build.msvc_env(root)[source]¶
The environment Visual Studio's x64 developer prompt has (its vcvars64.bat run, then 'set'), as a dict; {} where it fails. With it, cl, link and the SDK are on the PATH and their INCLUDE / LIB set.
- kicad2ems.emsdev.build.msvc_flags(arch='-march=native')[source]¶
cl's compile flags for a core: optimised, C++17, exceptions (pybind11), OpenMP 3 through LLVM's runtime.