From 445a758ccd35d5e9b983137968211168eabcba17 Mon Sep 17 00:00:00 2001 From: falkTX Date: Sat, 30 Jan 2021 23:36:42 +0000 Subject: [PATCH] Start work for new windows toolchain build Signed-off-by: falkTX --- Makefile | 37 ++-------- Makefile.dist.mk | 132 +++++++++++++++++++++++++++++----- data/windows/app-control.py | 11 +-- data/windows/app-gui.py | 11 +-- data/windows/app-plugin-ui.py | 8 +-- source/frontend/carla_app.py | 4 +- source/plugin/Makefile | 10 +-- 7 files changed, 144 insertions(+), 69 deletions(-) diff --git a/Makefile b/Makefile index f5fdae99a..7587cb204 100644 --- a/Makefile +++ b/Makefile @@ -222,39 +222,6 @@ msys2fix: cp -r source/modules/lilv/sratom-0.6.0/sratom source/includes/sratom cp -r source/modules/lilv/lilv-0.24.0/lilv source/includes/lilv -# --------------------------------------------------------------------------------------------------------------------- -# nuitka - -nuitka: bin/carla bin/carla-rack bin/carla-plugin - -bin/carla: - python3 -m nuitka \ - -j 4 \ - --python-flag -O --warn-unusual-code --warn-implicit-exceptions \ - --follow-imports \ - -o ./$@ \ - ./source/frontend/carla - -bin/carla-rack: - python3 -m nuitka \ - -j 8 \ - --recurse-all \ - --python-flag -O --warn-unusual-code --warn-implicit-exceptions \ - --recurse-not-to=PyQt5 \ - --file-reference-choice=runtime \ - -o ./$@ \ - ./source/frontend/carla - -bin/carla-plugin: - python3 -m nuitka \ - -j 8 \ - --recurse-all \ - --python-flag -O --warn-unusual-code --warn-implicit-exceptions \ - --recurse-not-to=PyQt5 \ - --file-reference-choice=runtime \ - -o ./$@ \ - ./source/native-plugins/resources/carla-plugin - # --------------------------------------------------------------------------------------------------------------------- # Binaries (arm32) @@ -828,6 +795,10 @@ HAVE_DIST = true endif endif +ifeq ($(WIN32),true) +HAVE_DIST = true +endif + ifeq ($(HAVE_DIST),true) include Makefile.dist.mk else diff --git a/Makefile.dist.mk b/Makefile.dist.mk index 7b799e24e..f1aea22f3 100644 --- a/Makefile.dist.mk +++ b/Makefile.dist.mk @@ -8,6 +8,17 @@ # ---------------------------------------------------------------------------------------------------------------------------- +PYTHON = $(EXE_WRAPPER) $(shell which python3$(APP_EXT)) + +ifeq ($(WIN32),true) +QT5_DLL_EXT = .dll +QT5_DLL_V = 5 +endif + +ifeq ($(MACOS),true) +QT5_LIB_PREFIX = lib +endif + QT5_PREFIX = $(shell pkg-config --variable=prefix Qt5OpenGLExtensions) # ---------------------------------------------------------------------------------------------------------------------------- @@ -20,30 +31,48 @@ _PLUGIN_UIS = \ xycontroller-ui _QT5_DLLS = \ - QtCore \ - QtGui \ - QtOpenGL \ - QtPrintSupport \ - QtSvg \ - QtWidgets + Qt$(QT5_DLL_V)Core$(QT5_DLL_EXT) \ + Qt$(QT5_DLL_V)Gui$(QT5_DLL_EXT) \ + Qt$(QT5_DLL_V)OpenGL$(QT5_DLL_EXT) \ + Qt$(QT5_DLL_V)PrintSupport$(QT5_DLL_EXT) \ + Qt$(QT5_DLL_V)Svg$(QT5_DLL_EXT) \ + Qt$(QT5_DLL_V)Widgets$(QT5_DLL_EXT) _QT5_PLUGINS = \ - iconengines/libqsvgicon$(LIB_EXT) \ - imageformats/libqjpeg$(LIB_EXT) \ - imageformats/libqsvg$(LIB_EXT) \ - platforms/libqcocoa$(LIB_EXT) + iconengines/$(QT5_LIB_PREFIX)qsvgicon$(LIB_EXT) \ + imageformats/$(QT5_LIB_PREFIX)qjpeg$(LIB_EXT) \ + imageformats/$(QT5_LIB_PREFIX)qsvg$(LIB_EXT) + +ifeq ($(MACOS),true) +_QT5_PLUGINS += \ + platforms/$(QT5_LIB_PREFIX)qcocoa$(LIB_EXT) +else ifeq ($(WIN32),true) +_QT5_PLUGINS += \ + platforms/$(QT5_LIB_PREFIX)qwindows$(LIB_EXT) +endif + +# NOTE this has to be hardcoded for now. oh well +ifeq ($(WIN32),true) +_PYTHON_FILES = \ + libpython3.8.dll +endif _THEME_FILES = \ styles/carlastyle.json \ styles/carlastyle$(LIB_EXT) _CARLA_HOST_FILES = \ - carla-bridge-lv2-cocoa$(APP_EXT) \ carla-bridge-lv2$(LIB_EXT) \ carla-bridge-native$(APP_EXT) \ carla-discovery-native$(APP_EXT) \ - libcarla_utils$(LIB_EXT) \ - $(_PLUGIN_UIS:%=resources/%$(APP_EXT)) + libcarla_utils$(LIB_EXT) + +# TODO plugin UIs on windows +ifeq ($(MACOS),true) +_CARLA_HOST_FILES += \ + $(_PLUGIN_UIS:%=resources/%$(APP_EXT)) \ + carla-bridge-lv2-cocoa$(APP_EXT) +endif _CARLA_APP_FILES = \ Carla$(APP_EXT) \ @@ -51,6 +80,7 @@ _CARLA_APP_FILES = \ $(_CARLA_HOST_FILES) \ $(_QT5_DLLS) \ $(_QT5_PLUGINS) \ + $(_PYTHON_FILES) \ $(_THEME_FILES) _CARLA_CONTROL_APP_FILES = \ @@ -58,6 +88,7 @@ _CARLA_CONTROL_APP_FILES = \ libcarla_utils$(LIB_EXT) \ $(_QT5_DLLS) \ $(_QT5_PLUGINS) \ + $(_PYTHON_FILES) \ $(_THEME_FILES) _CARLA_LV2_PLUGIN_FILES = \ @@ -88,15 +119,26 @@ _CARLA_VST2SYN_PLUGIN_FILES = \ $(_QT5_PLUGINS:%=carla.vst/Contents/MacOS/resources/%) \ $(_THEME_FILES:%=carla.vst/Contents/MacOS/resources/%) +ifeq ($(WIN32),true) +CARLA_APP_FILES = $(_CARLA_APP_FILES:%=build/Carla/%) +CARLA_APP_ZIPS = $(_PLUGIN_UIS:%=build/%/lib/library.zip) +CARLA_CONTROL_APP_FILES = $(_CARLA_CONTROL_APP_FILES:%=build/Carla-Control/%) +else CARLA_APP_FILES = $(_CARLA_APP_FILES:%=build/Carla.app/Contents/MacOS/%) CARLA_APP_ZIPS = $(_PLUGIN_UIS:%=build/%.app/Contents/MacOS/lib/library.zip) - CARLA_CONTROL_APP_FILES = $(_CARLA_CONTROL_APP_FILES:%=build/Carla-Control.app/Contents/MacOS/%) +endif # ---------------------------------------------------------------------------------------------------------------------------- # entry point +ifeq ($(WIN64),true) +TARGETS = Carla-$(VERSION)-win64.zip +else ifeq ($(WIN32),true) +TARGETS = Carla-$(VERSION)-win32.zip +else TARGETS = Carla-$(VERSION)-macOS.dmg +endif dist: $(TARGETS) @@ -110,8 +152,12 @@ Carla-$(VERSION)-macOS.dmg: build/Carla.app/Contents/Info.plist build/Carla-Cont hdiutil create $@ -srcfolder build/macos-pkg -volname "Carla-$(VERSION)" -fs HFS+ -ov rm -rf build/macos-pkg +Carla-$(VERSION)-win64.zip: $(CARLA_APP_FILES) + $(call CLEANUP_AND_PATCH_CXFREEZE_FILES,Carla) +# env PYTHONPATH=$(CURDIR)/source/frontend $(PYTHON) ./data/windows/app-gui.py build_exe + # ---------------------------------------------------------------------------------------------------------------------------- -# final cleanup, after everything is in place +# macOS final cleanup, after everything is in place define PATCH_QT_DEPENDENCIES install_name_tool -change "@rpath/QtCore.framework/Versions/5/QtCore" @executable_path/QtCore ${1} && \ @@ -123,6 +169,7 @@ define PATCH_QT_DEPENDENCIES install_name_tool -change "@rpath/QtMacExtras.framework/Versions/5/QtMacExtras" @executable_path/QtMacExtras ${1} endef +ifeq ($(MACOS),true) define CLEANUP_AND_PATCH_CXFREEZE_FILES # cleanup find build/${1}.app/Contents/MacOS/ -type f -name "*.py" -delete @@ -142,6 +189,22 @@ define CLEANUP_AND_PATCH_CXFREEZE_FILES $(call PATCH_QT_DEPENDENCIES,$$f); \ done) endef +else ifeq ($(WIN32),true) +define CLEANUP_AND_PATCH_CXFREEZE_FILES + # cleanup + find build/${1}/ -type f -name "*.py" -delete + find build/${1}/ -type f -name "*.pyi" -delete + find build/${1}/ -type f -name "pylupdate.so" -delete + find build/${1}/ -type f -name "pyrcc.so" -delete + find build/${1}/ -type f -name "QtMacExtras*" -delete + find build/${1}/ -type f -name "QtNetwork*" -delete + find build/${1}/ -type f -name "QtSql*" -delete + find build/${1}/ -type f -name "QtTest*" -delete + find build/${1}/ -type f -name "QtXml*" -delete + #find build/${1}/ -type f -name "*.pyc" -delete + rm -rf build/${1}/lib/PyQt5/uic +endef +endif build/Carla.app/Contents/Info.plist: $(CARLA_APP_FILES) $(call CLEANUP_AND_PATCH_CXFREEZE_FILES,Carla) @@ -159,11 +222,18 @@ build/Carla-Control.app/Contents/Info.plist: $(CARLA_CONTROL_APP_FILES) touch $@ # ---------------------------------------------------------------------------------------------------------------------------- -# macOS application bundle, depends on cxfreeze library.zip +# application bundle, depends on cxfreeze library.zip +ifeq ($(WIN32),true) +define GENERATE_LIBRARY_ZIP + # FIXME + env PYTHONPATH=$(CURDIR)/source/frontend SCRIPT_NAME=${1} $(PYTHON) ./data/windows/app-gui.py build_exe +endef +else define GENERATE_LIBRARY_ZIP - env PYTHONPATH=$(CURDIR)/source/frontend SCRIPT_NAME=${1} python3 ./data/macos/bundle.py bdist_mac --bundle-name=${1} + env PYTHONPATH=$(CURDIR)/source/frontend SCRIPT_NAME=${1} $(PYTHON) ./data/macos/bundle.py bdist_mac --bundle-name=${1} endef +endif # ---------------------------------------------------------------------------------------------------------------------------- @@ -184,6 +254,15 @@ build/Carla.app/Contents/MacOS/lib/library.zip: $(CARLA_APP_ZIPS) data/macos/bun # ---------------------------------------------------------------------------------------------------------------------------- +build/Carla/Carla.exe: build/Carla/lib/library.zip + +build/Carla/lib/library.zip: data/windows/app-gui.py # source/frontend/* + $(call GENERATE_LIBRARY_ZIP,Carla) + +# $(CARLA_APP_ZIPS) + +# ---------------------------------------------------------------------------------------------------------------------------- + build/Carla-Control.app/Contents/MacOS/Carla-Control: build/Carla-Control.app/Contents/MacOS/lib/library.zip build/Carla-Control.app/Contents/MacOS/lib/library.zip: data/macos/bundle.py data/macos/Carla-Control.plist source/frontend/* @@ -231,6 +310,25 @@ build/Carla.app/Contents/MacOS/% build/Carla-Control.app/Contents/MacOS/%: bin/% -@mkdir -p $(shell dirname $@) @cp -v $< $@ +# ---------------------------------------------------------------------------------------------------------------------------- +# win32 generic bundle files (either Qt or Carla binaries) + +build/Carla/libpython3% build/Carla-Control/libpython3%: $(QT5_PREFIX)/bin/libpython3% + -@mkdir -p $(shell dirname $@) + @cp -v $< $@ + +build/Carla/Qt5% build/Carla-Control/Qt5%: $(QT5_PREFIX)/bin/Qt5% + -@mkdir -p $(shell dirname $@) + @cp -v $< $@ + +build/Carla/iconengines/% build/Carla-Control/iconengines/%: $(QT5_PREFIX)/lib/qt5/plugins/iconengines/% + -@mkdir -p $(shell dirname $@) + @cp -v $< $@ + +build/Carla/% build/Carla-Control/%: bin/% + -@mkdir -p $(shell dirname $@) + @cp -v $< $@ + # ---------------------------------------------------------------------------------------------------------------------------- # Plugin rules diff --git a/data/windows/app-control.py b/data/windows/app-control.py index 51d2dbb2b..4dfdf1c69 100644 --- a/data/windows/app-control.py +++ b/data/windows/app-control.py @@ -10,21 +10,24 @@ from cx_Freeze import setup, Executable # Imports (Custom Stuff) from carla_host import VERSION +from os import getenv # ------------------------------------------------------------------------------------------------------------ +name = getenv("TARGET_NAME") + options = { "zip_include_packages": ["*"], "zip_exclude_packages": ["PyQt5"], "replace_paths": [["*",".\\lib\\"]], - "build_exe": ".\\CarlaControl\\", + "build_exe": ".\\build\\CarlaControl\\", "optimize": True, } exe_options = { - "script": "..\\..\\source\\frontend\\carla-control", - "icon": "..\\..\\resources\\ico\\carla-control.ico", - "copyright": "Copyright (C) 2011-2019 Filipe Coelho", + "script": ".\\source\\frontend\\carla-control", + "icon": ".\\resources\\ico\\carla-control.ico", + "copyright": "Copyright (C) 2011-2021 Filipe Coelho", "base": "Win32GUI", "targetName": "CarlaControl.exe", } diff --git a/data/windows/app-gui.py b/data/windows/app-gui.py index a75ed08c7..48d1d23eb 100644 --- a/data/windows/app-gui.py +++ b/data/windows/app-gui.py @@ -10,21 +10,24 @@ from cx_Freeze import setup, Executable # Imports (Custom Stuff) from carla_host import VERSION +from os import getenv # ------------------------------------------------------------------------------------------------------------ +name = getenv("TARGET_NAME") + options = { "zip_include_packages": ["*"], "zip_exclude_packages": ["PyQt5"], "replace_paths": [["*",".\\lib\\"]], - "build_exe": ".\\Carla\\", + "build_exe": ".\\build\\Carla\\", "optimize": True, } exe_options = { - "script": "..\\..\\source\\frontend\\carla", - "icon": "..\\..\\resources\\ico\\carla.ico", - "copyright": "Copyright (C) 2011-2020 Filipe Coelho", + "script": ".\\source\\frontend\\carla", + "icon": ".\\resources\\ico\\carla.ico", + "copyright": "Copyright (C) 2011-2021 Filipe Coelho", "base": "Win32GUI", "targetName": "Carla.exe", } diff --git a/data/windows/app-plugin-ui.py b/data/windows/app-plugin-ui.py index 59eaf7683..7f5d19ab1 100644 --- a/data/windows/app-plugin-ui.py +++ b/data/windows/app-plugin-ui.py @@ -20,14 +20,14 @@ options = { "zip_include_packages": ["*"], "zip_exclude_packages": ["PyQt5"], "replace_paths": [["*",".\\lib\\"]], - "build_exe": ".\\Carla\\resources\\", + "build_exe": ".\\build\\Carla\\resources\\", "optimize": True, } exe_options = { - "script": "..\\..\\bin\\resources\\{}".format(name), - "icon": "..\\..\\resources\\ico\\carla.ico", - "copyright": "Copyright (C) 2011-2019 Filipe Coelho", + "script": ".\\source\\frontend\\{}".format(name), + "icon": ".\\resources\\ico\\carla.ico", + "copyright": "Copyright (C) 2011-2021 Filipe Coelho", "base": "Win32GUI", "targetName": "{}.exe".format(name), } diff --git a/source/frontend/carla_app.py b/source/frontend/carla_app.py index 2e6e12cce..aa6b87512 100644 --- a/source/frontend/carla_app.py +++ b/source/frontend/carla_app.py @@ -63,9 +63,9 @@ class CarlaApplication(): # Needed for local wine build if WINDOWS and CWD.endswith(("frontend", "resources")) and os.getenv("CXFREEZE") is None: if kIs64bit: - path = "H:\\builds\\msys2-x86_64\\mingw64\\share\\qt5\\plugins" + path = "H:\\PawPawBuilds\\targets\\win64\\lib\\qt5\\plugins" else: - path = "H:\\builds\\msys2-i686\\mingw32\\share\\qt5\\plugins" + path = "H:\\PawPawBuilds\\targets\\win32\\lib\\qt5\\plugins" QApplication.addLibraryPath(path) # Use binary dir as library path diff --git a/source/plugin/Makefile b/source/plugin/Makefile index 2e5c1063c..2ec4eb305 100644 --- a/source/plugin/Makefile +++ b/source/plugin/Makefile @@ -27,6 +27,10 @@ OBJDIR := $(CWD)/../build/plugin/Release MODULEDIR := $(CWD)/../build/modules/Release endif +ifeq ($(NEEDS_WINE),true) +EXE_WRAPPER ?= wine +endif + # --------------------------------------------------------------------------------------------------------------------- BUILD_CXX_FLAGS += -I$(CWD)/backend -I$(CWD)/includes -I$(CWD)/modules -I$(CWD)/utils @@ -475,11 +479,7 @@ $(BINDIR)/carla.lv2/manifest.ttl: $(OBJDIR)/carla-lv2-export.cpp.o $(BINDIR)/car @$(CXX) $< $(LIBS_START) $(LIBS) $(LIBS_END) $(NATIVE_LINK_FLAGS) -o $(BINDIR)/carla-lv2-export$(APP_EXT) @echo "Generating LV2 ttl data" -ifeq ($(NEEDS_WINE),true) - @cd $(BINDIR) && wine ./carla-lv2-export$(APP_EXT) -else - @cd $(BINDIR) && ./carla-lv2-export$(APP_EXT) -endif + @cd $(BINDIR) && $(EXE_WRAPPER) ./carla-lv2-export$(APP_EXT) @cd $(BINDIR)/carla.lv2 && ln -sf ../*bridge-* ../carla-discovery-* . $(BINDIR)/carla-lv2-export$(APP_EXT): $(OBJDIR)/carla-lv2-export.cpp.o