mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 01:38:00 +00:00
build-all.py use single build dir
This commit is contained in:
+45
-45
@@ -1308,8 +1308,8 @@ if os.environ.get("NO_CLEAN", "").lower() not in {"1", "on", "true"}:
|
|||||||
if os.path.exists(IFCOS_DIR):
|
if os.path.exists(IFCOS_DIR):
|
||||||
shutil.rmtree(IFCOS_DIR)
|
shutil.rmtree(IFCOS_DIR)
|
||||||
os.makedirs(IFCOS_DIR, exist_ok=True)
|
os.makedirs(IFCOS_DIR, exist_ok=True)
|
||||||
executables_dir = os.path.join(IFCOS_DIR, "executables")
|
ifcos_build_dir = os.path.join(IFCOS_DIR, "build")
|
||||||
os.makedirs(executables_dir, exist_ok=True)
|
os.makedirs(ifcos_build_dir, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
cmake_args = [
|
cmake_args = [
|
||||||
@@ -1412,40 +1412,33 @@ if "rocksdb" in targets:
|
|||||||
if "swig" in targets:
|
if "swig" in targets:
|
||||||
cmake_args_prefix_path.append(f"{DEPS_DIR}/install/swig-{SWIG_VERSION}")
|
cmake_args_prefix_path.append(f"{DEPS_DIR}/install/swig-{SWIG_VERSION}")
|
||||||
|
|
||||||
|
ifcos_build_args = [
|
||||||
|
f"-DBUILD_IFCGEOM={OFF_ON['IfcGeom' in targets]}",
|
||||||
|
f"-DBUILD_GEOMSERVER={OFF_ON['IfcGeomServer' in targets]}",
|
||||||
|
f"-DBUILD_CONVERT={OFF_ON['IfcConvert' in targets]}",
|
||||||
|
f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/ifcopenshell",
|
||||||
|
]
|
||||||
|
|
||||||
if not WASM and (not explicit_targets or {"IfcGeom", "IfcConvert", "IfcGeomServer"} & set(explicit_targets)):
|
if not WASM and (not explicit_targets or {"IfcGeom", "IfcConvert", "IfcGeomServer"} & set(explicit_targets)):
|
||||||
logger.info("\rConfiguring executables...")
|
logger.info("\rConfiguring executables...")
|
||||||
|
|
||||||
exec_args = [
|
exec_args = [
|
||||||
f"-DBUILD_IFCGEOM={OFF_ON['IfcGeom' in targets]}",
|
*ifcos_build_args,
|
||||||
f"-DBUILD_GEOMSERVER={OFF_ON['IfcGeomServer' in targets]}",
|
|
||||||
f"-DBUILD_CONVERT={OFF_ON['IfcConvert' in targets]}",
|
|
||||||
f"-DBUILD_IFCPYTHON=OFF",
|
f"-DBUILD_IFCPYTHON=OFF",
|
||||||
f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/ifcopenshell",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
run_cmake("", exec_args + cmake_args + get_cmake_args_prefix_path(), cmake_dir=CMAKE_DIR, cwd=executables_dir)
|
run_cmake("", exec_args + cmake_args + get_cmake_args_prefix_path(), cmake_dir=CMAKE_DIR, cwd=ifcos_build_dir)
|
||||||
|
|
||||||
logger.info("\rBuilding executables... ")
|
logger.info("\rBuilding executables... ")
|
||||||
|
|
||||||
run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "VERBOSE=1"], cwd=executables_dir)
|
run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "VERBOSE=1"], cwd=ifcos_build_dir)
|
||||||
run([make, "install/strip" if BUILD_CFG == "Release" else "install"], cwd=executables_dir)
|
run([make, "install/strip" if BUILD_CFG == "Release" else "install"], cwd=ifcos_build_dir)
|
||||||
|
|
||||||
if "IfcOpenShell-Python" in targets:
|
if "IfcOpenShell-Python" in targets:
|
||||||
# On OSX the actual Python library is not linked against.
|
wrapper_ldflags = ""
|
||||||
ADDITIONAL_ARGS = ""
|
|
||||||
if platform.system() == "Darwin":
|
if platform.system() == "Darwin":
|
||||||
ADDITIONAL_ARGS = "-Wl,-undefined,dynamic_lookup"
|
# On OSX the actual Python library is not linked against.
|
||||||
|
wrapper_ldflags = "-Wl,-undefined,dynamic_lookup"
|
||||||
# NOTE: We don't use `CXXFLAGS` for wrappers, so wrapper is compiled with different flags
|
|
||||||
# (e.g. ` -fdata-sections` is missing, which is set by default for executables)
|
|
||||||
# So cache doesn't match and running build-all.py builds most of ifcopenshell libraries twice.
|
|
||||||
os.environ["CPPFLAGS"] = f"{CXXFLAGS_MINIMAL} {ADDITIONAL_ARGS}"
|
|
||||||
os.environ["CXXFLAGS"] = f"{CXXFLAGS_MINIMAL} {ADDITIONAL_ARGS}"
|
|
||||||
os.environ["CFLAGS"] = f"{CFLAGS_MINIMAL} {ADDITIONAL_ARGS}"
|
|
||||||
os.environ["LDFLAGS"] = f"{LDFLAGS} {ADDITIONAL_ARGS}"
|
|
||||||
|
|
||||||
python_dir = os.path.join(IFCOS_DIR, "pythonwrapper")
|
|
||||||
os.makedirs(python_dir, exist_ok=True)
|
|
||||||
|
|
||||||
def compile_python_wrapper(
|
def compile_python_wrapper(
|
||||||
python_version: str,
|
python_version: str,
|
||||||
@@ -1460,10 +1453,6 @@ if "IfcOpenShell-Python" in targets:
|
|||||||
|
|
||||||
logger.info(f"\rConfiguring python {python_version} wrapper...")
|
logger.info(f"\rConfiguring python {python_version} wrapper...")
|
||||||
|
|
||||||
cache_path = os.path.join(python_dir, "CMakeCache.txt")
|
|
||||||
if os.path.exists(cache_path):
|
|
||||||
os.remove(cache_path)
|
|
||||||
|
|
||||||
if python_path:
|
if python_path:
|
||||||
# We couldn't just prefix PATH and have to provide all variables explicitly,
|
# We couldn't just prefix PATH and have to provide all variables explicitly,
|
||||||
# see ifcwrap/cmake for the details.
|
# see ifcwrap/cmake for the details.
|
||||||
@@ -1477,27 +1466,38 @@ if "IfcOpenShell-Python" in targets:
|
|||||||
)
|
)
|
||||||
|
|
||||||
assert python_include
|
assert python_include
|
||||||
run_cmake(
|
old_ldflags = os.environ["LDFLAGS"]
|
||||||
"",
|
if wrapper_ldflags:
|
||||||
cmake_args
|
os.environ["LDFLAGS"] = f"{old_ldflags} {wrapper_ldflags}"
|
||||||
+ get_cmake_args_prefix_path()
|
|
||||||
+ [
|
try:
|
||||||
*([f"-DPYTHON_EXECUTABLE={python_executable}"] if python_executable else []),
|
run_cmake(
|
||||||
# Needed because pyodide is expecting setup.py to be in the root.
|
"",
|
||||||
*([f"-DPYTHON_MODULE_INSTALL_DIR={REPO_PATH}"] * WASM),
|
ifcos_build_args
|
||||||
f"-DPYTHON_INCLUDE_DIR={python_include}",
|
+ [
|
||||||
f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/ifcopenshell/tmp",
|
"-DBUILD_IFCPYTHON=ON",
|
||||||
"-DUSERSPACE_PYTHON_PREFIX="
|
]
|
||||||
+ ["Off", "On"][os.environ.get("PYTHON_USER_SITE", "").lower() in {"1", "on", "true"}],
|
+ cmake_args
|
||||||
],
|
+ get_cmake_args_prefix_path()
|
||||||
cmake_dir=CMAKE_DIR,
|
+ [
|
||||||
cwd=python_dir,
|
*([f"-DPYTHON_EXECUTABLE={python_executable}"] if python_executable else []),
|
||||||
)
|
# Needed because pyodide is expecting setup.py to be in the root.
|
||||||
|
*([f"-DPYTHON_MODULE_INSTALL_DIR={REPO_PATH}"] * WASM),
|
||||||
|
f"-DPYTHON_INCLUDE_DIR={python_include}",
|
||||||
|
f"-DCMAKE_INSTALL_PREFIX={DEPS_DIR}/install/ifcopenshell/tmp",
|
||||||
|
"-DUSERSPACE_PYTHON_PREFIX="
|
||||||
|
+ ["Off", "On"][os.environ.get("PYTHON_USER_SITE", "").lower() in {"1", "on", "true"}],
|
||||||
|
],
|
||||||
|
cmake_dir=CMAKE_DIR,
|
||||||
|
cwd=ifcos_build_dir,
|
||||||
|
)
|
||||||
|
finally:
|
||||||
|
os.environ["LDFLAGS"] = old_ldflags
|
||||||
|
|
||||||
logger.info(f"\rBuilding python {python_version} wrapper... ")
|
logger.info(f"\rBuilding python {python_version} wrapper... ")
|
||||||
|
|
||||||
run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "ifcopenshell_wrapper", "VERBOSE=1"], cwd=python_dir)
|
run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "ifcopenshell_wrapper", "VERBOSE=1"], cwd=ifcos_build_dir)
|
||||||
run([make, "install/local"], cwd=os.path.join(python_dir, "ifcwrap"))
|
run([make, "install/local"], cwd=os.path.join(ifcos_build_dir, "ifcwrap"))
|
||||||
|
|
||||||
if python_executable:
|
if python_executable:
|
||||||
run([python_executable, "-m", "ensurepip"])
|
run([python_executable, "-m", "ensurepip"])
|
||||||
|
|||||||
Reference in New Issue
Block a user