From e56fd945312f4948226b40463fdeff8b8fb8c286 Mon Sep 17 00:00:00 2001
From: nakst <>
Date: Thu, 20 Jan 2022 10:50:48 +0000
Subject: [PATCH] don't call freetype/harfbuzz build scripts if not used

---
 util/build.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/util/build.c b/util/build.c
index 93d00d0..e8184b5 100644
--- a/util/build.c
+++ b/util/build.c
@@ -158,17 +158,25 @@ int CallSystemF(const char *format, ...) {
 }
 
 bool BuildAPIDependencies() {
+	LoadOptions();
+
 	if (CheckDependencies("API Header")) {
 		CallSystem("bin/build_core headers");
 		ParseDependencies("bin/dependency_files/api_header.d", "API Header", false);
 	}
 
 	if (CallSystem("ports/musl/build.sh " TARGET_NAME)) return false;
+
 	if (CallSystem(TOOLCHAIN_PREFIX "-gcc -c desktop/crt1.c -o cross/lib/gcc/" TOOLCHAIN_PREFIX "/" GCC_VERSION "/crt1.o")) return false;
 	if (CallSystem(TOOLCHAIN_PREFIX "-gcc -c desktop/crtglue.c -o cross/lib/gcc/" TOOLCHAIN_PREFIX "/" GCC_VERSION "/crtglue.o")) return false;
-	if (CallSystem("ports/freetype/build.sh " TARGET_NAME)) return false;
-	if (CallSystem("ports/harfbuzz/build.sh " TARGET_NAME)) return false;
+
+	if (IsOptionEnabled("Dependency.FreeTypeAndHarfBuzz")) {
+		if (CallSystem("ports/freetype/build.sh " TARGET_NAME)) return false;
+		if (CallSystem("ports/harfbuzz/build.sh " TARGET_NAME)) return false;
+	}
+
 	if (CallSystem("cp -p kernel/module.h root/Applications/POSIX/include")) return false;
+
 	return true;
 }