54 target_dir = os.path.abspath(self.build_lib)
55 cmake_build_dir = os.getenv(
"CMAKE_BUILD_DIR")
56 if not cmake_build_dir:
57 cmake_build_dir = os.path.abspath(
58 os.path.join(target_dir,
"..",
"cmake_build"))
63 configs_to_build = [
"Release"]
64 if platform.system() ==
"Windows":
65 configs_to_build.append(
"Debug")
67 for cfg
in configs_to_build:
69 current_build_dir = cmake_build_dir
70 if len(configs_to_build) > 1:
71 current_build_dir = os.path.join(cmake_build_dir, cfg)
73 os.makedirs(current_build_dir, exist_ok=
True)
74 cmake_cache_file = os.path.join(current_build_dir,
"CMakeCache.txt")
75 if os.path.exists(cmake_cache_file):
76 os.remove(cmake_cache_file)
81 "-DCMAKE_BUILD_TYPE={}".format(cfg),
82 "-DPython3_EXECUTABLE={}".format(sys.executable.replace(
"\\",
"/")),
83 "-DPython_EXECUTABLE={}".format(sys.executable.replace(
"\\",
"/")),
93 nanobind_dir = nanobind.cmake_dir()
94 cmake_args.append(
"-Dnanobind_DIR={}".format(
95 nanobind_dir.replace(
"\\",
"/")))
97 print(
"Skipping nanobind directory detection, nanobind not found.")
99 cxx = os.getenv(
"CXX")
101 cmake_args.append(
"-DCMAKE_CXX_COMPILER={}".format(cxx))
102 cxxflags = os.getenv(
"CXXFLAGS")
103 if cxxflags
is not None:
104 cmake_args.append(
"-DCMAKE_CXX_FLAGS={}".format(cxxflags))
108 cmake_args.append(
"-DCMAKE_C_COMPILER={}".format(cc))
109 cflags = os.getenv(
"CFLAGS")
110 if cflags
is not None:
111 cmake_args.append(
"-DCMAKE_C_FLAGS={}".format(cflags))
113 if "VCPKG_INSTALLATION_ROOT" in os.environ:
115 f
"-DCMAKE_TOOLCHAIN_FILE={os.environ['VCPKG_INSTALLATION_ROOT']}/scripts/buildsystems/vcpkg.cmake"
118 if "CIRCT_EXTRA_CMAKE_ARGS" in os.environ:
119 cmake_args += os.environ[
"CIRCT_EXTRA_CMAKE_ARGS"].split(
" ")
125 if platform.system() ==
"Linux":
126 python_libdir = sysconfig.get_config_var(
'LIBDIR')
127 python_library = sysconfig.get_config_var(
'LIBRARY')
128 if python_libdir
and not os.path.isabs(python_library):
129 python_library = os.path.join(python_libdir, python_library)
130 if python_library
and not os.path.exists(python_library):
131 print(
"Detected static linked python. Faking a library for cmake.")
132 fake_libdir = os.path.join(current_build_dir,
"fake_python",
"lib")
133 os.makedirs(fake_libdir, exist_ok=
True)
134 fake_library = os.path.join(fake_libdir,
135 sysconfig.get_config_var(
'LIBRARY'))
136 subprocess.check_call([
"ar",
"q", fake_library])
137 cmake_args.append(
"-DPython3_LIBRARY:PATH={}".format(fake_library))
140 print(f
"Configuring {cfg} build...")
141 subprocess.check_call([
"cmake", src_dir] + cmake_args,
142 cwd=current_build_dir)
143 print(
" ".join([
"cmake", src_dir] + cmake_args))
152 print(f
"Building {cfg} configuration...")
153 subprocess.check_call(
162 cwd=current_build_dir,
168 if cfg ==
"Release" and os.path.exists(target_dir):
169 shutil.rmtree(target_dir)
171 print(f
"Installing {cfg} configuration...")
179 install_dir = os.path.join(target_dir,
"esiaccel")
180 os.makedirs(install_dir, exist_ok=
True)
182 "ESICppRuntime*.dll",
183 "ESICppRuntime*.lib",
190 for pattern
in debug_patterns:
191 for f
in glob.glob(os.path.join(current_build_dir, pattern)):
192 print(f
" Installing {os.path.basename(f)}")
193 shutil.copy2(f, install_dir)
195 subprocess.check_call(
201 os.path.join(target_dir,
"esiaccel"),
205 cwd=current_build_dir,