Skip to content

Commit a181307

Browse files
committed
Add flags to make local builds more convenient
1 parent cce32ee commit a181307

File tree

1 file changed

+72
-50
lines changed

1 file changed

+72
-50
lines changed

build.py

Lines changed: 72 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@
1212
type=str,
1313
help="Optional compiler launcher (e.g., ccache, sccache)"
1414
)
15+
parser.add_argument(
16+
"--generator",
17+
choices=["ninja", "xcode", "visualstudio"],
18+
default="ninja",
19+
help="CMake generator to use: ninja (default), xcode, or visualstudio"
20+
)
21+
parser.add_argument(
22+
"--configure-only",
23+
action="store_true",
24+
help="Only run CMake configuration, skip the build step"
25+
)
26+
1527
args = parser.parse_args()
1628

1729
system = platform.system()
@@ -20,6 +32,14 @@
2032
else:
2133
cmake_compiler = []
2234

35+
if args.generator == "xcode":
36+
cmake_generator = ["-GXcode"]
37+
elif args.generator == "visualstudio":
38+
cmake_generator = ["-GVisual Studio 17 2022", "-A x64"]
39+
cmake_compiler = []
40+
else:
41+
cmake_generator = ["-GNinja"]
42+
2343
# Load config.json
2444
with open("config.json") as f:
2545
plugins_config = json.load(f)
@@ -41,7 +61,7 @@
4161
formats = plugin.get("formats", [])
4262
is_fx = plugin.get("type", "").lower() == "fx"
4363

44-
build_dir = builds_parent_dir / f"Build-{name}"
64+
build_dir = builds_parent_dir / f"{args.generator}-{name}"
4565
print(f"\nProcessing: {name}")
4666

4767
author = plugin.get("author", False)
@@ -53,6 +73,7 @@
5373
cmake_configure = [
5474
"cmake",
5575
"-GNinja",
76+
*cmake_generator,
5677
*cmake_compiler,
5778
f"-B{build_dir}",
5879
f"-DCUSTOM_PLUGIN_NAME={name}",
@@ -76,53 +97,54 @@
7697
continue
7798

7899
# Build all combinations of type + format
79-
for fmt in formats:
80-
if system != "Darwin" and fmt == "AU":
81-
continue
82-
target = f"plugdata_{'fx_' if is_fx else ''}{fmt}"
83-
if fmt == "Standalone":
84-
target = "plugdata_standalone"
85-
86-
cmake_build = [
87-
"cmake",
88-
"--build", str(build_dir),
89-
"--target", target,
90-
"--config Release"
91-
]
92-
print(f"Building target: {target}")
93-
result_build = subprocess.run(cmake_build, cwd=plugdata_dir)
94-
if result_build.returncode != 0:
95-
print(f"Failed to build target: {target}")
96-
else:
97-
print(f"Successfully built: {target}")
98-
format_path = os.path.join(plugins_dir, fmt)
99-
target_dir = os.path.join(build_output_dir, fmt)
100-
101-
if fmt == "Standalone":
102-
if os.path.isdir(format_path):
103-
if os.path.exists(target_dir):
104-
shutil.rmtree(target_dir)
105-
shutil.copytree(format_path, target_dir)
106-
else:
107-
extension = ""
108-
if fmt == "VST3":
109-
extension = ".vst3"
110-
elif fmt == "AU":
111-
extension = ".component"
112-
elif fmt == "LV2":
113-
extension = ".lv2"
114-
elif fmt == "CLAP":
115-
extension = ".clap"
116-
117-
plugin_filename = name + extension;
118-
os.makedirs(target_dir, exist_ok=True)
119-
src = os.path.join(format_path, plugin_filename);
120-
dst = os.path.join(target_dir, plugin_filename);
121-
if os.path.isdir(src):
122-
if os.path.exists(dst):
123-
shutil.rmtree(dst)
124-
shutil.copytree(src, dst)
100+
if not args.configure_only:
101+
for fmt in formats:
102+
if system != "Darwin" and fmt == "AU":
103+
continue
104+
target = f"plugdata_{'fx_' if is_fx else ''}{fmt}"
105+
if fmt == "Standalone":
106+
target = "plugdata_standalone"
107+
108+
cmake_build = [
109+
"cmake",
110+
"--build", str(build_dir),
111+
"--target", target,
112+
"--config Release"
113+
]
114+
print(f"Building target: {target}")
115+
result_build = subprocess.run(cmake_build, cwd=plugdata_dir)
116+
if result_build.returncode != 0:
117+
print(f"Failed to build target: {target}")
118+
else:
119+
print(f"Successfully built: {target}")
120+
format_path = os.path.join(plugins_dir, fmt)
121+
target_dir = os.path.join(build_output_dir, fmt)
122+
123+
if fmt == "Standalone":
124+
if os.path.isdir(format_path):
125+
if os.path.exists(target_dir):
126+
shutil.rmtree(target_dir)
127+
shutil.copytree(format_path, target_dir)
125128
else:
126-
if os.path.exists(dst):
127-
os.remove(dst)
128-
shutil.copy2(src, dst)
129+
extension = ""
130+
if fmt == "VST3":
131+
extension = ".vst3"
132+
elif fmt == "AU":
133+
extension = ".component"
134+
elif fmt == "LV2":
135+
extension = ".lv2"
136+
elif fmt == "CLAP":
137+
extension = ".clap"
138+
139+
plugin_filename = name + extension;
140+
os.makedirs(target_dir, exist_ok=True)
141+
src = os.path.join(format_path, plugin_filename);
142+
dst = os.path.join(target_dir, plugin_filename);
143+
if os.path.isdir(src):
144+
if os.path.exists(dst):
145+
shutil.rmtree(dst)
146+
shutil.copytree(src, dst)
147+
else:
148+
if os.path.exists(dst):
149+
os.remove(dst)
150+
shutil.copy2(src, dst)

0 commit comments

Comments
 (0)