Browse Source

Remove BUILD_MAC_ARM64_ONLY feature. Use new Rack user dir. Ensure that version string is increasing for source plugins. Ensure that modules are not removed from plugins.

v2
Andrew Belt 4 months ago
parent
commit
7683867d8a
1 changed files with 75 additions and 64 deletions
  1. +75
    -64
      scripts/update.py

+ 75
- 64
scripts/update.py View File

@@ -6,6 +6,7 @@ import time
import re import re
import tempfile import tempfile
import random import random
import functools


import common import common
import update_modulargrid import update_modulargrid
@@ -16,12 +17,43 @@ TOOLCHAIN_DIR = "../toolchain-v2"
PACKAGES_DIR = "../packages" PACKAGES_DIR = "../packages"
MANIFESTS_DIR = "manifests" MANIFESTS_DIR = "manifests"
RACK_SYSTEM_DIR = "../Rack2" RACK_SYSTEM_DIR = "../Rack2"
RACK_USER_DIR = "$HOME/.Rack2"
RACK_USER_DIR = "$HOME/.local/share/Rack2"
SCREENSHOTS_DIR = os.path.join(RACK_USER_DIR, "screenshots") SCREENSHOTS_DIR = os.path.join(RACK_USER_DIR, "screenshots")
PLUGIN_DIR = os.path.join(RACK_USER_DIR, "plugins-lin-x64") PLUGIN_DIR = os.path.join(RACK_USER_DIR, "plugins-lin-x64")
FILES_DIR = "../files/packages" FILES_DIR = "../files/packages"


BUILD_MAC_ARM64_ONLY = False

def version_part_less(a, b):
try:
ai = int(a)
except ValueError:
ai = None

try:
bi = int(b)
except ValueError:
bi = None

if ai is not None and bi is not None:
return ai < bi
elif ai is not None:
return False
elif bi is not None:
return True
else:
return a < b


def version_less(a, b):
a_parts = a.split(".")
b_parts = b.split(".")

for a_part, b_part in zip(a_parts, b_parts):
if a_part == b_part:
continue
return version_part_less(a_part, b_part)

return len(a_parts) < len(b_parts)




def package_exists(slug, version, os_, cpu): def package_exists(slug, version, os_, cpu):
@@ -53,24 +85,21 @@ def print_missing_mac_arm64():


print(f"{slug} {version}\t\t{email}\t\t{license}") print(f"{slug} {version}\t\t{email}\t\t{license}")


# print_missing_mac_arm64()
# exit(0)



# Update git before continuing # Update git before continuing
if not BUILD_MAC_ARM64_ONLY:
common.system("git pull")
common.system("git submodule sync --recursive --quiet")
common.system("git submodule update --init --recursive")
common.system("git pull")
common.system("git submodule sync --recursive --quiet")
common.system("git submodule update --init --recursive")


plugin_paths = sys.argv[1:] plugin_paths = sys.argv[1:]


# Default to all repos, so all out-of-date repos are built # Default to all repos, so all out-of-date repos are built
if not plugin_paths: if not plugin_paths:
plugin_paths = glob.glob("repos/*") plugin_paths = glob.glob("repos/*")
plugin_paths.sort()


# Randomize repo order # Randomize repo order
plugin_paths = random.sample(plugin_paths, len(plugin_paths))
# plugin_paths = random.sample(plugin_paths, len(plugin_paths))


manifest_versions = {} manifest_versions = {}


@@ -131,30 +160,25 @@ for plugin_path in plugin_paths:
library_manifest = json.load(f) library_manifest = json.load(f)
except IOError: except IOError:
# Warn if manifest is new # Warn if manifest is new
print(f"Manifest {slug} is new, press enter to approve.")
if input() != '':
continue
# print(f"Manifest {slug} is new, press enter to approve.")
# if input() != '':
# continue
pass pass


# Ensure that no modules are removed from library
if library_manifest:
library_modules = set(module['slug'] for module in library_manifest['modules'])
modules = set(module['slug'] for module in manifest['modules'])
removed_modules = library_modules - modules
if removed_modules:
raise Exception(f"Plugin {slug} removes modules {", ".join(removed_modules)}")

# Source dir # Source dir
if os.path.isdir(plugin_path): if os.path.isdir(plugin_path):
# Check library manifest version
if library_manifest and version == library_manifest['version']:
# Build only if library manifest is out of date
if not BUILD_MAC_ARM64_ONLY:
continue
else:
# Build Mac ARM64 only if library manifest is up to date
if BUILD_MAC_ARM64_ONLY:
continue

# Build repo
if BUILD_MAC_ARM64_ONLY:
if package_exists(slug, version, 'mac', 'arm64'):
print(f"{slug} {version} Mac ARM64 package already exists")
continue
if not package_exists(slug, version, 'mac', 'x64'):
print(f"{slug} {version} Mac x64 doesn't exist, not building")
# Ensure that version is higher than library version
if library_manifest:
# if not version_less(library_manifest['version'], version):
if library_manifest['version'] == version:
continue continue


print() print()
@@ -164,17 +188,16 @@ for plugin_path in plugin_paths:
common.system(f'cd "{TOOLCHAIN_DIR}" && make plugin-build-clean') common.system(f'cd "{TOOLCHAIN_DIR}" && make plugin-build-clean')
# Build repo for each arch # Build repo for each arch
common.system(f'cd "{TOOLCHAIN_DIR}" && make -j2 plugin-build-mac-arm64 PLUGIN_DIR="{plugin_path}"') common.system(f'cd "{TOOLCHAIN_DIR}" && make -j2 plugin-build-mac-arm64 PLUGIN_DIR="{plugin_path}"')
if not BUILD_MAC_ARM64_ONLY:
common.system(f'cd "{TOOLCHAIN_DIR}" && make -j2 plugin-build-mac-x64 PLUGIN_DIR="{plugin_path}"')
common.system(f'cd "{TOOLCHAIN_DIR}" && make -j2 plugin-build-win-x64 PLUGIN_DIR="{plugin_path}"')
common.system(f'cd "{TOOLCHAIN_DIR}" && make -j2 plugin-build-lin-x64 PLUGIN_DIR="{plugin_path}"')
common.system(f'cd "{TOOLCHAIN_DIR}" && make -j2 plugin-build-mac-x64 PLUGIN_DIR="{plugin_path}"')
common.system(f'cd "{TOOLCHAIN_DIR}" && make -j2 plugin-build-win-x64 PLUGIN_DIR="{plugin_path}"')
common.system(f'cd "{TOOLCHAIN_DIR}" && make -j2 plugin-build-lin-x64 PLUGIN_DIR="{plugin_path}"')
# Copy package to packages dir # Copy package to packages dir
common.system(f'cp -v "{TOOLCHAIN_DIR}"/plugin-build/* "{PACKAGES_DIR}"/') common.system(f'cp -v "{TOOLCHAIN_DIR}"/plugin-build/* "{PACKAGES_DIR}"/')
# Copy Mac ARM64 package to files dir for testing
common.system(f'cp -v "{TOOLCHAIN_DIR}"/plugin-build/*-mac-arm64.vcvplugin "{FILES_DIR}"/')
# Copy Mac packages to files dir for testing
# common.system(f'cp -v "{TOOLCHAIN_DIR}"/plugin-build/*-mac-x64.vcvplugin "{FILES_DIR}"/')
# common.system(f'cp -v "{TOOLCHAIN_DIR}"/plugin-build/*-mac-arm64.vcvplugin "{FILES_DIR}"/')
# Install Linux package for testing # Install Linux package for testing
if not BUILD_MAC_ARM64_ONLY:
common.system(f'cp -v "{TOOLCHAIN_DIR}"/plugin-build/*-lin-x64.vcvplugin "{PLUGIN_DIR}"/')
common.system(f'cp -v "{TOOLCHAIN_DIR}"/plugin-build/*-lin-x64.vcvplugin "{PLUGIN_DIR}"/')
except Exception as e: except Exception as e:
print(e) print(e)
print(f"{slug} build failed") print(f"{slug} build failed")
@@ -184,8 +207,7 @@ for plugin_path in plugin_paths:
common.system(f'cd "{TOOLCHAIN_DIR}" && make plugin-build-clean') common.system(f'cd "{TOOLCHAIN_DIR}" && make plugin-build-clean')


# Open plugin issue thread # Open plugin issue thread
if not BUILD_MAC_ARM64_ONLY:
os.system(f"xdg-open 'https://github.com/VCVRack/library/issues?q=is%3Aissue+in%3Atitle+{slug}' &")
os.system(f"xdg-open 'https://github.com/VCVRack/library/issues?q=is%3Aissue+sort%3Aupdated-desc+in%3Atitle+{slug}' &")


# Plugin package # Plugin package
elif plugin_ext == ".vcvplugin": elif plugin_ext == ".vcvplugin":
@@ -200,34 +222,25 @@ for plugin_path in plugin_paths:
package_filename = os.path.basename(plugin_path) package_filename = os.path.basename(plugin_path)
common.system(f'touch "{PACKAGES_DIR}/{package_filename}"') common.system(f'touch "{PACKAGES_DIR}/{package_filename}"')
# Copy Mac ARM64 package to files dir for testing # Copy Mac ARM64 package to files dir for testing
if os_ == 'mac' and cpu == 'arm64':
common.system(f'cp -v "{plugin_path}" "{FILES_DIR}"/')
# if os_ == 'mac' and cpu == 'arm64':
# common.system(f'cp -v "{plugin_path}" "{FILES_DIR}"/')
# Install Linux package for testing # Install Linux package for testing
if os_ == 'lin': if os_ == 'lin':
common.system(f'cp "{plugin_path}" "{PLUGIN_DIR}/"') common.system(f'cp "{plugin_path}" "{PLUGIN_DIR}/"')


# Copy manifest # Copy manifest
if not BUILD_MAC_ARM64_ONLY:
with open(library_manifest_filename, "w") as f:
json.dump(manifest, f, indent=" ")
with open(library_manifest_filename, "w") as f:
json.dump(manifest, f, indent=" ")


if not BUILD_MAC_ARM64_ONLY:
# Delete screenshot cache
screenshots_dir = os.path.join(SCREENSHOTS_DIR, slug)
common.system(f'rm -rf "{screenshots_dir}"')
# Delete screenshot cache
screenshots_dir = os.path.join(SCREENSHOTS_DIR, slug)
common.system(f'rm -rf "{screenshots_dir}"')


manifest_versions[slug] = version manifest_versions[slug] = version


manifest_versions_str = ", ".join(map(lambda pair: pair[0] + " to " + pair[1], manifest_versions.items())) manifest_versions_str = ", ".join(map(lambda pair: pair[0] + " to " + pair[1], manifest_versions.items()))




if BUILD_MAC_ARM64_ONLY:
print()
print(f"Test plugins on Mac ARM64 and press enter if approved: {manifest_versions_str}")
input()
common.system("cd ../packages && make upload")
exit(0)

if not manifest_versions: if not manifest_versions:
print("Nothing to build") print("Nothing to build")
exit(0) exit(0)
@@ -235,14 +248,14 @@ if not manifest_versions:
update_cache.update() update_cache.update()
update_modulargrid.update() update_modulargrid.update()


# Upload data


# Test plugins
print() print()
print(f"Press enter to launch Rack and test the following packages: {manifest_versions_str}") print(f"Press enter to launch Rack and test the following packages: {manifest_versions_str}")
input() input()
try: try:
common.system(f"cd {RACK_SYSTEM_DIR} && ./Rack") common.system(f"cd {RACK_SYSTEM_DIR} && ./Rack")
common.system(f"cd {RACK_USER_DIR} && grep 'warn' log.txt || true")
common.system(f"cd {RACK_USER_DIR} && grep '\\bwarn|debug\\b' log.txt || true")
except: except:
print(f"Rack failed! Enter to continue if desired") print(f"Rack failed! Enter to continue if desired")


@@ -256,18 +269,16 @@ except:
print(f"Rack failed! Enter to continue if desired") print(f"Rack failed! Enter to continue if desired")
common.system("cd ../screenshots && make -j$(nproc)") common.system("cd ../screenshots && make -j$(nproc)")


# Commit git repo
common.system("git add manifests")
common.system("git add manifests-cache.json ModularGrid-VCVLibrary.json")
common.system(f"git commit -m 'Update manifest {manifest_versions_str}'")

# Upload packages # Upload packages
common.system("cd ../packages && make upload") common.system("cd ../packages && make upload")


# Upload screenshots # Upload screenshots
common.system("cd ../screenshots && make upload") common.system("cd ../screenshots && make upload")


# Push git repo
# Commit git repo
common.system("git add manifests")
common.system("git add manifests-cache.json ModularGrid-VCVLibrary.json")
common.system(f"git commit -m 'Update manifest {manifest_versions_str}'")
common.system("git push") common.system("git push")


print() print()


Loading…
Cancel
Save