-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
148 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import argparse | ||
import os | ||
import platform | ||
import subprocess | ||
|
||
|
||
def run_command(command, shell=False): | ||
subprocess.run(command, shell=shell, check=True) | ||
|
||
def build_windows(pythonver): | ||
os.system('rm build/CMakeCache.txt') | ||
|
||
# Download libsndfile | ||
libsndfile_dir = "thirdparty/libsndfile-1.2.0-win64/" | ||
if not os.path.exists(libsndfile_dir): | ||
print("Downloading libsndfile...") | ||
os.chdir('thirdparty') | ||
run_command(["curl", "-OL", "https://github.com/libsndfile/libsndfile/releases/download/1.2.0/libsndfile-1.2.0-win64.zip"]) | ||
run_command(["7z", "x", "libsndfile-1.2.0-win64.zip", "-y"]) | ||
os.remove("libsndfile-1.2.0-win64.zip") | ||
print("Downloaded libsndfile.") | ||
os.chdir("..") | ||
|
||
# Build with CMake | ||
cmake_command = [ | ||
"cmake", "-Bbuild", "-DCMAKE_BUILD_TYPE=Release", | ||
"-DLIBFAUST_DIR=thirdparty/libfaust/win64/Release", | ||
"-DSndFile_DIR=thirdparty/libsndfile/build", | ||
f"-DPYTHONVER={pythonver}" | ||
] | ||
run_command(cmake_command) | ||
run_command(["cmake", "--build", "build", "--config", "Release"]) | ||
os.system(f'cp "thirdparty/libsndfile-1.2.0-win64/bin/sndfile.dll" "Plugins/sndfile.dll"') | ||
|
||
def build_macos(pythonver, touchdesigner_app): | ||
os.system('rm -r Plugins/TD-Faust.plugin') | ||
|
||
cmake_osx_deployment_target = "11.0" | ||
if platform.machine() == 'arm64': | ||
libfaust_dir = f"{os.getcwd()}/thirdparty/libfaust/darwin-arm64/Release" | ||
elif platform.machine() == 'x86_64': | ||
libfaust_dir = f"{os.getcwd()}/thirdparty/libfaust/darwin-x64/Release" | ||
else: | ||
raise RuntimeError(f"Unknown CPU architecture: {platform.machine()}.") | ||
|
||
# Build libsndfile | ||
print("Building libsndfile.") | ||
os.chdir("thirdparty/libsndfile") | ||
run_command(["cmake", "-Bbuild", "-DCMAKE_VERBOSE_MAKEFILE=ON", "-DCMAKE_INSTALL_PREFIX=./install"]) | ||
run_command(["cmake", "--build", "build", "--config", "Release"]) | ||
run_command(["cmake", "--build", "build", "--target", "install"]) | ||
os.chdir("../..") | ||
|
||
# Build with CMake | ||
cmake_command = [ | ||
"cmake", "-Bbuild", "-G", "Xcode", | ||
f"-DCMAKE_OSX_DEPLOYMENT_TARGET={cmake_osx_deployment_target}", | ||
f"-DLIBFAUST_DIR={libfaust_dir}", | ||
f"-DPYTHONVER={pythonver}", | ||
f"-DPython_ROOT_DIR={touchdesigner_app}/Contents/Frameworks/Python.framework/Versions/{pythonver}" | ||
] | ||
run_command(cmake_command) | ||
run_command(["xcodebuild", "-configuration", "Release", "-project", "build/TD-Faust.xcodeproj"], shell=True) | ||
os.system('mv build/Release/TD-Faust.plugin Plugins') | ||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Build TD-Faust plugin for Windows or macOS.") | ||
parser.add_argument("--pythonver", default="3.11", help="Specify the Python version.") | ||
parser.add_argument("--touchdesigner_app", default="/Applications/TouchDesigner.app", help="Path to TouchDesigner app (macOS only).") | ||
args = parser.parse_args() | ||
|
||
if platform.system() == "Windows": | ||
build_windows(args.pythonver) | ||
elif platform.system() == "Darwin": | ||
build_macos(args.pythonver, args.touchdesigner_app) | ||
else: | ||
raise RuntimeError(f"Unsupported operating system: {platform.system()}.") |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import argparse | ||
import os | ||
import platform | ||
import subprocess | ||
from pathlib import Path | ||
|
||
|
||
def download_file(url: str, output: str) -> None: | ||
if os.path.exists(output) and not args.force: | ||
print(f"File already exists: {output}") | ||
else: | ||
subprocess.run(["curl", "-L", url, "-o", output], check=True) | ||
|
||
def install_windows(version: str) -> None: | ||
exe_file = f"Faust-{version}-win64.exe" | ||
download_file(f"https://github.com/grame-cncm/faust/releases/download/{version}/{exe_file}", exe_file) | ||
cwd = str(Path(__file__).parent) | ||
subprocess.run([exe_file, "/S", f"/D={cwd}\\win64\\Release"], check=True) | ||
|
||
def install_macos(version: str) -> None: | ||
for arch in ["arm64", "x64"]: | ||
dmg_file = f"Faust-{version}-{arch}.dmg" | ||
download_file(f"https://github.com/grame-cncm/faust/releases/download/{version}/{dmg_file}", dmg_file) | ||
subprocess.run(["hdiutil", "attach", dmg_file], check=True) | ||
dir_path = f"darwin-{arch}/Release" | ||
os.makedirs(dir_path, exist_ok=True) | ||
subprocess.run(["cp", "-R", f"/Volumes/Faust-{version}/Faust-{version}/*", dir_path], check=True) | ||
subprocess.run(["hdiutil", "detach", f"/Volumes/Faust-{version}/"], check=True) | ||
|
||
def install_linux(version: str) -> None: | ||
zip_file = f"libfaust-ubuntu-x86_64.zip" | ||
download_file(f"https://github.com/grame-cncm/faust/releases/download/{version}/{zip_file}", zip_file) | ||
dir_path = "ubuntu-x86_64/Release" | ||
os.makedirs(dir_path, exist_ok=True) | ||
subprocess.run(["unzip", zip_file, "-d", dir_path], check=True) | ||
|
||
def main(version: str) -> None: | ||
system = platform.system() | ||
if system == "Windows": | ||
install_windows(version) | ||
elif system == "Darwin": | ||
install_macos(version) | ||
elif system == "Linux": | ||
install_linux(version) | ||
else: | ||
raise RuntimeError(f"Unknown operating system: {system}.") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description="Download and install Libfaust.") | ||
parser.add_argument("-v", "--version", default="2.69.3", help="Specify the version of Faust to download.") | ||
parser.add_argument("--force", action="store_true", help="Force download even if files already exist.") | ||
args = parser.parse_args() | ||
|
||
main(args.version) |
This file was deleted.
Oops, something went wrong.