From d448fa95e3c3ab9c39948e13bc4143165fb86b8c Mon Sep 17 00:00:00 2001 From: Thomas Krijnen Date: Sun, 19 Apr 2026 10:21:23 +0200 Subject: [PATCH] build-all.py use single build dir --- nix/build-all.py | 90 +++++++++---------- .../ifcopenshell/simple_spf | 2 +- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/nix/build-all.py b/nix/build-all.py index 64e4929da4..b2336443ac 100644 --- a/nix/build-all.py +++ b/nix/build-all.py @@ -1308,8 +1308,8 @@ if os.environ.get("NO_CLEAN", "").lower() not in {"1", "on", "true"}: if os.path.exists(IFCOS_DIR): shutil.rmtree(IFCOS_DIR) os.makedirs(IFCOS_DIR, exist_ok=True) -executables_dir = os.path.join(IFCOS_DIR, "executables") -os.makedirs(executables_dir, exist_ok=True) +ifcos_build_dir = os.path.join(IFCOS_DIR, "build") +os.makedirs(ifcos_build_dir, exist_ok=True) cmake_args = [ @@ -1412,40 +1412,33 @@ if "rocksdb" in targets: if "swig" in targets: 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)): logger.info("\rConfiguring executables...") exec_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]}", + *ifcos_build_args, 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... ") - run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "VERBOSE=1"], cwd=executables_dir) - run([make, "install/strip" if BUILD_CFG == "Release" else "install"], 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=ifcos_build_dir) if "IfcOpenShell-Python" in targets: - # On OSX the actual Python library is not linked against. - ADDITIONAL_ARGS = "" + wrapper_ldflags = "" if platform.system() == "Darwin": - ADDITIONAL_ARGS = "-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) + # On OSX the actual Python library is not linked against. + wrapper_ldflags = "-Wl,-undefined,dynamic_lookup" def compile_python_wrapper( python_version: str, @@ -1460,10 +1453,6 @@ if "IfcOpenShell-Python" in targets: 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: # We couldn't just prefix PATH and have to provide all variables explicitly, # see ifcwrap/cmake for the details. @@ -1477,27 +1466,38 @@ if "IfcOpenShell-Python" in targets: ) assert python_include - run_cmake( - "", - cmake_args - + get_cmake_args_prefix_path() - + [ - *([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=python_dir, - ) + old_ldflags = os.environ["LDFLAGS"] + if wrapper_ldflags: + os.environ["LDFLAGS"] = f"{old_ldflags} {wrapper_ldflags}" + + try: + run_cmake( + "", + ifcos_build_args + + [ + "-DBUILD_IFCPYTHON=ON", + ] + + cmake_args + + get_cmake_args_prefix_path() + + [ + *([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... ") - run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "ifcopenshell_wrapper", "VERBOSE=1"], cwd=python_dir) - run([make, "install/local"], cwd=os.path.join(python_dir, "ifcwrap")) + run([make, f"-j{IFCOS_NUM_BUILD_PROCS}", "ifcopenshell_wrapper", "VERBOSE=1"], cwd=ifcos_build_dir) + run([make, "install/local"], cwd=os.path.join(ifcos_build_dir, "ifcwrap")) if python_executable: run([python_executable, "-m", "ensurepip"]) diff --git a/src/ifcopenshell-python/ifcopenshell/simple_spf b/src/ifcopenshell-python/ifcopenshell/simple_spf index ed50b756c4..2849a31788 160000 --- a/src/ifcopenshell-python/ifcopenshell/simple_spf +++ b/src/ifcopenshell-python/ifcopenshell/simple_spf @@ -1 +1 @@ -Subproject commit ed50b756c4035290d50eb2d928f89423f3aa0947 +Subproject commit 2849a31788c4f82edca7d1b1046d0606fdf8b9be