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))
105 cmake_args.append(
"-DCMAKE_C_COMPILER={}".format(cc))
107 if "VCPKG_INSTALLATION_ROOT" in os.environ:
109 f
"-DCMAKE_TOOLCHAIN_FILE={os.environ['VCPKG_INSTALLATION_ROOT']}/scripts/buildsystems/vcpkg.cmake"
112 if "CIRCT_EXTRA_CMAKE_ARGS" in os.environ:
113 cmake_args += os.environ[
"CIRCT_EXTRA_CMAKE_ARGS"].split(
" ")
119 if platform.system() ==
"Linux":
120 python_libdir = sysconfig.get_config_var(
'LIBDIR')
121 python_library = sysconfig.get_config_var(
'LIBRARY')
122 if python_libdir
and not os.path.isabs(python_library):
123 python_library = os.path.join(python_libdir, python_library)
124 if python_library
and not os.path.exists(python_library):
125 print(
"Detected static linked python. Faking a library for cmake.")
126 fake_libdir = os.path.join(current_build_dir,
"fake_python",
"lib")
127 os.makedirs(fake_libdir, exist_ok=
True)
128 fake_library = os.path.join(fake_libdir,
129 sysconfig.get_config_var(
'LIBRARY'))
130 subprocess.check_call([
"ar",
"q", fake_library])
131 cmake_args.append(
"-DPython3_LIBRARY:PATH={}".format(fake_library))
134 print(f
"Configuring {cfg} build...")
135 subprocess.check_call([
"cmake", src_dir] + cmake_args,
136 cwd=current_build_dir)
137 print(
" ".join([
"cmake", src_dir] + cmake_args))
146 print(f
"Building {cfg} configuration...")
147 subprocess.check_call(
156 cwd=current_build_dir,
162 if cfg ==
"Release" and os.path.exists(target_dir):
163 shutil.rmtree(target_dir)
165 print(f
"Installing {cfg} configuration...")
173 install_dir = os.path.join(target_dir,
"esiaccel")
174 os.makedirs(install_dir, exist_ok=
True)
176 "ESICppRuntime*.dll",
177 "ESICppRuntime*.lib",
184 for pattern
in debug_patterns:
185 for f
in glob.glob(os.path.join(current_build_dir, pattern)):
186 print(f
" Installing {os.path.basename(f)}")
187 shutil.copy2(f, install_dir)
189 subprocess.check_call(
195 os.path.join(target_dir,
"esiaccel"),
199 cwd=current_build_dir,