bonsai makefile #5178

This commit is contained in:
Andrej730
2024-08-14 15:47:46 +05:00
committed by Andrej
parent b9c2e312e3
commit 3a9d79dcd3
2 changed files with 59 additions and 59 deletions
+43 -43
View File
@@ -95,7 +95,7 @@ endif
rm -rf build rm -rf build
mkdir -p build mkdir -p build
mkdir -p dist mkdir -p dist
cp -r blenderbim build/ cp -r bonsai build/
# To scope any build-time dependencies # To scope any build-time dependencies
cd build && $(PYTHON) -m venv env && . env/$(VENV_ACTIVATE) && $(PIP) install build cd build && $(PYTHON) -m venv env && . env/$(VENV_ACTIVATE) && $(PIP) install build
@@ -103,18 +103,18 @@ endif
mkdir -p build/wheels mkdir -p build/wheels
# Provides IfcOpenShell Python functionality # Provides IfcOpenShell Python functionality
cd ../ifcopenshell-python && make dist PLATFORM=$(PLATFORM)64 PYVERSION=$(PYVERSION) && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifcopenshell-python && make dist PLATFORM=$(PLATFORM)64 PYVERSION=$(PYVERSION) && mv dist/*.whl ../bonsai/build/wheels/
cd ../bcf && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../bcf && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../ifcclash && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifcclash && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../ifctester && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifctester && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../ifcfm && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifcfm && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../bsdd && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../bsdd && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../ifcdiff && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifcdiff && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../ifccsv && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifccsv && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../ifcpatch && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifcpatch && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../ifc4d && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifc4d && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../ifc5d && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifc5d && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd ../ifccityjson && make dist && mv dist/*.whl ../blenderbim/build/wheels/ cd ../ifccityjson && make dist && mv dist/*.whl ../bonsai/build/wheels/
cd build && . env/$(VENV_ACTIVATE) && $(PIP) download GitPython --dest=./wheels cd build && . env/$(VENV_ACTIVATE) && $(PIP) download GitPython --dest=./wheels
# Provides audio playback for costing # Provides audio playback for costing
# This is a REALLY IMPORTANT feature # This is a REALLY IMPORTANT feature
@@ -181,8 +181,8 @@ else
endif endif
# Provides jsgantt-improved supports for web-based construction sequencing gantt charts # Provides jsgantt-improved supports for web-based construction sequencing gantt charts
cd build/blenderbim/bim/data/gantt/ && wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.js cd build/bonsai/bim/data/gantt/ && wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.js
cd build/blenderbim/bim/data/gantt/ && wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.css cd build/bonsai/bim/data/gantt/ && wget https://raw.githubusercontent.com/jsGanttImproved/jsgantt-improved/master/dist/jsgantt.css
# Provides IFCJSON functionality # Provides IFCJSON functionality
# TODO: replace with main repo if https://github.com/IFCJSON-Team/IFC2JSON_python/pull/3 is merged. # TODO: replace with main repo if https://github.com/IFCJSON-Team/IFC2JSON_python/pull/3 is merged.
@@ -203,7 +203,7 @@ endif
# Brickschema requires pkg_resources which is provided by Blender. # Brickschema requires pkg_resources which is provided by Blender.
# Provides Brickschema functionality # Provides Brickschema functionality
# For now lets bundle the latest nightly schema # For now lets bundle the latest nightly schema
cd build/blenderbim/bim/schema && wget https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl cd build/bonsai/bim/schema && wget https://github.com/BrickSchema/Brick/releases/download/nightly/Brick.ttl
# Required for hipped roof generation # Required for hipped roof generation
cd build && wget https://github.com/prochitecture/bpypolyskel/archive/refs/heads/master.zip cd build && wget https://github.com/prochitecture/bpypolyskel/archive/refs/heads/master.zip
@@ -218,11 +218,11 @@ endif
cp -r build/bpypolyskel-master/dist/*.whl build/wheels/ cp -r build/bpypolyskel-master/dist/*.whl build/wheels/
# Required for Desktop icon and file association # Required for Desktop icon and file association
cp -r blenderbim/libs/desktop build/blenderbim/libs/ cp -r bonsai/libs/desktop build/bonsai/libs/
# Generate translations module for BBIM build # Generate translations module for Bonsai build
git clone https://github.com/IfcOpenShell/blenderbim-translations.git build/working git clone https://github.com/IfcOpenShell/bonsai-translations.git build/working
$(PYTHON) scripts/bbim_translations.py -i "build/working" -o "build/blenderbim" $(PYTHON) scripts/bonsai_translations.py -i "build/working" -o "build/bonsai"
rm -rf build/working rm -rf build/working
# Remove dependencies also bundled with Blender # Remove dependencies also bundled with Blender
@@ -230,17 +230,17 @@ endif
cp pyproject.toml build/ cp pyproject.toml build/
ifeq ($(IS_STABLE), TRUE) ifeq ($(IS_STABLE), TRUE)
$(SED) "s/0.0.0/$(VERSION)/" build/blenderbim/blender_manifest.toml $(SED) "s/0.0.0/$(VERSION)/" build/bonsai/blender_manifest.toml
$(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/pyproject.toml $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/pyproject.toml
else else
$(SED) "s/0.0.0/$(VERSION)-alpha$(VERSION_DATE)/" build/blenderbim/blender_manifest.toml $(SED) "s/0.0.0/$(VERSION)-alpha$(VERSION_DATE)/" build/bonsai/blender_manifest.toml
$(SED) "s/8888888/$(LAST_COMMIT_HASH)/" build/blenderbim/__init__.py $(SED) "s/8888888/$(LAST_COMMIT_HASH)/" build/bonsai/__init__.py
$(SED) 's/version = "0.0.0"/version = "$(VERSION)-alpha$(VERSION_DATE)"/' build/pyproject.toml $(SED) 's/version = "0.0.0"/version = "$(VERSION)-alpha$(VERSION_DATE)"/' build/pyproject.toml
endif endif
$(SED) "s/os-arch/$(BLENDER_PLATFORM)/" build/blenderbim/blender_manifest.toml $(SED) "s/os-arch/$(BLENDER_PLATFORM)/" build/bonsai/blender_manifest.toml
# Provides BlenderBIM Add-on functionality # Provides bonsai Add-on functionality
ifeq ($(IS_STABLE), TRUE) ifeq ($(IS_STABLE), TRUE)
$(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/pyproject.toml $(SED) 's/version = "0.0.0"/version = "$(VERSION)"/' build/pyproject.toml
else else
@@ -257,7 +257,7 @@ endif
echo "Error: non-wheel dependencies are not supported by Blender!"; \ echo "Error: non-wheel dependencies are not supported by Blender!"; \
exit 1; \ exit 1; \
fi fi
mv build/wheels/*.whl build/blenderbim/wheels/ mv build/wheels/*.whl build/bonsai/wheels/
# Ugly patch to accomodate MacOS universal builds not being recognized by Blender. # Ugly patch to accomodate MacOS universal builds not being recognized by Blender.
# Blender doesn't look into the wheel contents, it just checks the name. # Blender doesn't look into the wheel contents, it just checks the name.
@@ -266,41 +266,41 @@ endif
ifeq ($(PLATFORM), macosm1) ifeq ($(PLATFORM), macosm1)
# Has universal and x86_64 builds. # Has universal and x86_64 builds.
prev_whl_name=$$(find build/blenderbim/wheels/MarkupSafe-*.whl); \ prev_whl_name=$$(find build/bonsai/wheels/MarkupSafe-*.whl); \
whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_arm64/"); \ whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_arm64/"); \
mv "$$prev_whl_name" "$$whl_name"; mv "$$prev_whl_name" "$$whl_name";
# Has universal and x86_64 builds. # Has universal and x86_64 builds.
prev_whl_name=$$(find build/blenderbim/wheels/lxml-*.whl); \ prev_whl_name=$$(find build/bonsai/wheels/lxml-*.whl); \
whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_arm64/"); \ whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_arm64/"); \
mv "$$prev_whl_name" "$$whl_name"; mv "$$prev_whl_name" "$$whl_name";
prev_whl_name=$$(find build/blenderbim/wheels/tzfpy-*.whl); \ prev_whl_name=$$(find build/bonsai/wheels/tzfpy-*.whl); \
whl_name=$$(echo $$prev_whl_name | sed "s/macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2/macosx_10_12_arm64/"); \ whl_name=$$(echo $$prev_whl_name | sed "s/macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2/macosx_10_12_arm64/"); \
mv "$$prev_whl_name" "$$whl_name"; mv "$$prev_whl_name" "$$whl_name";
# Has only universal build. # Has only universal build.
prev_whl_name=$$(find build/blenderbim/wheels/greenlet-*.whl); \ prev_whl_name=$$(find build/bonsai/wheels/greenlet-*.whl); \
whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_arm64/"); \ whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_arm64/"); \
mv "$$prev_whl_name" "$$whl_name"; mv "$$prev_whl_name" "$$whl_name";
endif endif
ifeq ($(PLATFORM), macos) ifeq ($(PLATFORM), macos)
prev_whl_name=$$(find build/blenderbim/wheels/tzfpy-*.whl); \ prev_whl_name=$$(find build/bonsai/wheels/tzfpy-*.whl); \
whl_name=$$(echo $$prev_whl_name | sed "s/macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2/macosx_10_9_x86_64/"); \ whl_name=$$(echo $$prev_whl_name | sed "s/macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2/macosx_10_9_x86_64/"); \
mv "$$prev_whl_name" "$$whl_name"; mv "$$prev_whl_name" "$$whl_name";
prev_whl_name=$$(find build/blenderbim/wheels/greenlet-*.whl); \ prev_whl_name=$$(find build/bonsai/wheels/greenlet-*.whl); \
whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_x86_64/"); \ whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_x86_64/"); \
mv "$$prev_whl_name" "$$whl_name"; mv "$$prev_whl_name" "$$whl_name";
# has universal and amr64 builds. # has universal and amr64 builds.
prev_whl_name=$$(find build/blenderbim/wheels/fonttools-*.whl); \ prev_whl_name=$$(find build/bonsai/wheels/fonttools-*.whl); \
whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_x86_64/"); \ whl_name=$$(echo $$prev_whl_name | sed "s/_universal2/_x86_64/"); \
mv "$$prev_whl_name" "$$whl_name"; mv "$$prev_whl_name" "$$whl_name";
endif endif
# Safeguard for unhandled universal files. # Safeguard for unhandled universal files.
wheels=$$(find build/blenderbim/wheels/*universal2*.whl); \ wheels=$$(find build/bonsai/wheels/*universal2*.whl); \
if [ -n "$$wheels" ]; then \ if [ -n "$$wheels" ]; then \
echo "Found universal2 wheel files:"; \ echo "Found universal2 wheel files:"; \
echo "$$wheels"; \ echo "$$wheels"; \
@@ -311,7 +311,7 @@ endif
ifneq ($(PLATFORM), linux) ifneq ($(PLATFORM), linux)
# Safeguard: in case one of `pip download` will break, # Safeguard: in case one of `pip download` will break,
# it will produce a linux wheel for non-linux build (our github action machine is using linux). # it will produce a linux wheel for non-linux build (our github action machine is using linux).
wheels=$$(find build/blenderbim/wheels/*manylinux_*.whl); \ wheels=$$(find build/bonsai/wheels/*manylinux_*.whl); \
if [ -n "$$wheels" ]; then \ if [ -n "$$wheels" ]; then \
echo "Found linux wheel files in non-linux build:"; \ echo "Found linux wheel files in non-linux build:"; \
echo "$$wheels"; \ echo "$$wheels"; \
@@ -320,15 +320,15 @@ ifneq ($(PLATFORM), linux)
fi fi
endif endif
$(PYTHON) scripts/get_wheels.py build/blenderbim/wheels build/blenderbim/blender_manifest.toml $(PYTHON) scripts/get_wheels.py build/bonsai/wheels build/bonsai/blender_manifest.toml
rm -rf build/blenderbim/bim/ rm -rf build/bonsai/bim/
rm -rf build/blenderbim/core/ rm -rf build/bonsai/core/
rm -rf build/blenderbim/tool/ rm -rf build/bonsai/tool/
ifeq ($(IS_STABLE), TRUE) ifeq ($(IS_STABLE), TRUE)
cd build && zip -r bonsai_$(PYVERSION)-$(VERSION)-$(BLENDER_PLATFORM).zip ./blenderbim cd build && zip -r bonsai_$(PYVERSION)-$(VERSION)-$(BLENDER_PLATFORM).zip ./bonsai
else else
cd build && zip -r bonsai_$(PYVERSION)-$(VERSION)-alpha$(VERSION_DATE)-$(BLENDER_PLATFORM).zip ./blenderbim cd build && zip -r bonsai_$(PYVERSION)-$(VERSION)-alpha$(VERSION_DATE)-$(BLENDER_PLATFORM).zip ./bonsai
endif endif
mv build/bonsai*.zip dist/ mv build/bonsai*.zip dist/
@@ -374,13 +374,13 @@ qa:
.PHONY: coverage .PHONY: coverage
coverage: coverage:
coverage run --source blenderbim.core -m pytest -p no:pytest-blender test/core coverage run --source bonsai.core -m pytest -p no:pytest-blender test/core
coverage html coverage html
xdg-open htmlcov/index.html xdg-open htmlcov/index.html
.PHONY: license .PHONY: license
license: license:
copyright-header --license GPL3 --copyright-holder "Dion Moult <dion@thinkmoult.com>" --copyright-year "2022" --copyright-software "BlenderBIM Add-on" --copyright-software-description "OpenBIM Blender Add-on" -a ./ -o ./ copyright-header --license GPL3 --copyright-holder "Dion Moult <dion@thinkmoult.com>" --copyright-year "2022" --copyright-software "Bonsai" --copyright-software-description "OpenBIM Blender Add-on" -a ./ -o ./
.PHONY: clean .PHONY: clean
clean: clean:
@@ -21,7 +21,7 @@ from dataclasses import dataclass, field
from typing import Dict, List, Optional from typing import Dict, List, Optional
bl_info = { bl_info = {
"name": "BlenderBIM Translations", "name": "Bonsai Translations",
"description": "", "description": "",
"author": "IfcOpenShell Contributors", "author": "IfcOpenShell Contributors",
"blender": (2, 80, 0), "blender": (2, 80, 0),
@@ -34,7 +34,7 @@ bl_info = {
# NOTE: list of available languages in Blender can be retrieved # NOTE: list of available languages in Blender can be retrieved
# by the command below: # by the command below:
# bpy.context.preferences.view.language = "test" # bpy.context.preferences.view.language = "test"
ADDON_NAME = "blenderbim" ADDON_NAME = "bonsai"
TRANSLATION_UI_IS_LOADED = False TRANSLATION_UI_IS_LOADED = False
@@ -75,7 +75,7 @@ class Message:
translations: Optional[Dict[str, str]] = field(default_factory=dict) translations: Optional[Dict[str, str]] = field(default_factory=dict)
def blenderbim_strings_parse(addon_directory=None, po_directory=None): def bonsai_strings_parse(addon_directory=None, po_directory=None):
# NOTE: we decided to use our own parser due bug in Blender parser # NOTE: we decided to use our own parser due bug in Blender parser
# as it tends to pick up strings from other addons and other Blender parts # as it tends to pick up strings from other addons and other Blender parts
# and this bug probably would be to low of a priority for Blender to fix # and this bug probably would be to low of a priority for Blender to fix
@@ -136,7 +136,7 @@ def blenderbim_strings_parse(addon_directory=None, po_directory=None):
) )
message.sources.append(source_rel_path) message.sources.append(source_rel_path)
pot_filepath = po_directory / "blenderbim.pot" pot_filepath = po_directory / "bonsai.pot"
with open(pot_filepath, "w", encoding="utf-8") as fo: with open(pot_filepath, "w", encoding="utf-8") as fo:
for msg in matched_dict.values(): for msg in matched_dict.values():
# make sure sources are unique but keep the order # make sure sources are unique but keep the order
@@ -292,14 +292,14 @@ if BPY_IS_LOADED:
return {"FINISHED"} return {"FINISHED"}
class ParseBlenderBIMStrings(bpy.types.Operator): class ParseBonsaiStrings(bpy.types.Operator):
bl_idname = "bim.parse_blenderbim_strings" bl_idname = "bim.parse_bonsai_strings"
bl_label = "Parse BlenderBIM strings To .pot" bl_label = "Parse Bonsai strings To .pot"
bl_description = "Parse strings from BlenderBIM and save to .pot" bl_description = "Parse strings from Bonsai and save to .pot"
bl_options = set() bl_options = set()
def execute(self, context): def execute(self, context):
blenderbim_strings_parse() bonsai_strings_parse()
self.report({"INFO"}, "String were parsed and saved to .pot file.") self.report({"INFO"}, "String were parsed and saved to .pot file.")
return {"FINISHED"} return {"FINISHED"}
@@ -326,9 +326,9 @@ if BPY_IS_LOADED:
self.report({"INFO"}, f"Addon's translation updated from .po in {branches_dir}") self.report({"INFO"}, f"Addon's translation updated from .po in {branches_dir}")
return {"FINISHED"} return {"FINISHED"}
class BBIM_PT_translations(bpy.types.Panel): class Bonsai_PT_translations(bpy.types.Panel):
bl_label = "BlenderBIM Translations" bl_label = "Bonsai Translations"
bl_idname = "BBIM_PT_translations" bl_idname = "Bonsai_PT_translations"
bl_space_type = "PROPERTIES" bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW" bl_region_type = "WINDOW"
bl_context = "render" bl_context = "render"
@@ -343,17 +343,17 @@ if BPY_IS_LOADED:
return return
layout.label(text="Developer UI:") layout.label(text="Developer UI:")
layout.operator("bim.parse_blenderbim_strings", icon="FILE_REFRESH") layout.operator("bim.parse_bonsai_strings", icon="FILE_REFRESH")
layout.separator() layout.separator()
layout.label(text="Translator UI:") layout.label(text="Translator UI:")
layout.operator("bim.update_translations_from_po", icon="IMPORT") layout.operator("bim.update_translations_from_po", icon="IMPORT")
classes = ( classes = (
ParseBlenderBIMStrings, ParseBonsaiStrings,
UpdateTranslationsFromPo, UpdateTranslationsFromPo,
SetupTranslationUI, SetupTranslationUI,
BBIM_PT_translations, Bonsai_PT_translations,
) )
def register(): def register():
@@ -367,7 +367,7 @@ if BPY_IS_LOADED:
if __name__ == "__main__": if __name__ == "__main__":
# Example: # Example:
# py src/blenderbim/scripts/bbim_translations.py -i "C:/blenderbim-translations" -o "C:/Blender/4.0/scripts/addons/blenderbim/translations.py" # py src/bonsai/scripts/bbim_translations.py -i "C:/bonsai-translations" -o "C:/Blender/4.0/scripts/addons/bonsai/translations.py"
import argparse import argparse
parser = argparse.ArgumentParser(description="Converts .po files to translations.py") parser = argparse.ArgumentParser(description="Converts .po files to translations.py")