From cd1759ed4a7ce4be700c1f1d67665a882adba6c1 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Sat, 22 Jan 2022 09:36:22 +0000 Subject: [PATCH] fix cross compiler build recursion; possibly fix macos --- ports/harfbuzz/build.sh | 3 ++- start.sh | 4 ++-- util/automation/build.sh | 1 + util/automation/build_minimal.sh | 1 + util/automation/run_tests.sh | 1 + util/build.c | 34 +++++++++++++++++--------------- 6 files changed, 25 insertions(+), 19 deletions(-) diff --git a/ports/harfbuzz/build.sh b/ports/harfbuzz/build.sh index 813769a..e43cb57 100755 --- a/ports/harfbuzz/build.sh +++ b/ports/harfbuzz/build.sh @@ -72,7 +72,8 @@ if [ ! -d "bin/harfbuzz" ]; then SED=sed - if [ "$OSTYPE" = "darwin"* ]; then + uname -a | grep Darwin > /dev/null + if [ $? -ne 1 ]; then SED=gsed fi diff --git a/start.sh b/start.sh index d54833c..c40e8df 100755 --- a/start.sh +++ b/start.sh @@ -18,8 +18,8 @@ uname -a | grep Darwin > /dev/null if [ $? -ne 1 ]; then export CC=gcc-11 export CXX=g++-11 - export CPPFLAGS=-I/opt/homebrew/include - export LDFLAGS=-L/opt/homebrew/lib + export CPPFLAGS=-I$(brew --prefix)/include + export LDFLAGS=-L$(brew --prefix)/lib alias md5sum="md5" alias gcc="gcc-11" alias g++="g++-11" diff --git a/util/automation/build.sh b/util/automation/build.sh index 3d13c63..23b6862 100755 --- a/util/automation/build.sh +++ b/util/automation/build.sh @@ -18,6 +18,7 @@ echo "General.wallpaper=0:/Demo Content/Abstract.jpg" >> bin/config.ini echo "General.window_color=5" >> bin/config.ini # Setup toolchain, build the system and ports. +./start.sh get-toolchain ./start.sh build-optimised ./start.sh build-optional-ports > /dev/null diff --git a/util/automation/build_minimal.sh b/util/automation/build_minimal.sh index 2629197..d333454 100755 --- a/util/automation/build_minimal.sh +++ b/util/automation/build_minimal.sh @@ -15,4 +15,5 @@ echo "Dependency.stb_image=0" >> bin/config.ini echo "Dependency.stb_image_write=0" >> bin/config.ini echo "Dependency.stb_sprintf=0" >> bin/config.ini echo "Dependency.FreeTypeAndHarfBuzz=0" >> bin/config.ini +./start.sh get-toolchain ./start.sh build-optimised diff --git a/util/automation/run_tests.sh b/util/automation/run_tests.sh index 06250c2..2aa01ca 100755 --- a/util/automation/run_tests.sh +++ b/util/automation/run_tests.sh @@ -10,6 +10,7 @@ echo "accepted_license=1" >> bin/build_config.ini echo "Flag.ENABLE_POSIX_SUBSYSTEM=1" >> bin/config.ini echo "desktop/api_tests.ini" >> bin/extra_applications.ini echo `git log | head -n 1 | cut -b 8-14` > bin/commit.txt +./start.sh get-toolchain ./start.sh build ./start.sh build-port busybox util/x11/build.sh apps/samples/hello.c diff --git a/util/build.c b/util/build.c index 9e78dbb..825f2f8 100644 --- a/util/build.c +++ b/util/build.c @@ -758,7 +758,7 @@ void BuildCrossCompiler() { if (processorCount > 16) processorCount = 16; printf("Type 'yes' if you have updated your system.\n"); - if (!GetYes()) { printf("The build has been canceled.\n"); exit(0); } + if (interactiveMode && !GetYes()) { printf("The build has been canceled.\n"); exit(0); } { getcwd(installationFolder, 4096); @@ -768,7 +768,7 @@ void BuildCrossCompiler() { strcpy(compilerPath, installationFolder); strcat(compilerPath, "/bin"); printf("\nType 'yes' to install the compiler into '%s'.\n", installationFolder); - if (!GetYes()) { printf("The build has been canceled.\n"); exit(0); } + if (interactiveMode && !GetYes()) { printf("The build has been canceled.\n"); exit(0); } } if (!AddCompilerToPath()) { @@ -1864,6 +1864,16 @@ void DoCommand(const char *l) { getcwd(compilerPath, sizeof(compilerPath) - 64); strcat(compilerPath, "/cross/bin2"); SaveConfig(); + } else if (0 == strcmp(l, "get-toolchain")) { +#if defined(__linux__) && defined(__x86_64__) + fprintf(stderr, "Downloading the compiler toolchain...\n"); + DoCommand("get-source-checked 700205f81c7a5ca3279ae7b1fdb24e025d33b36a9716b81a71125bf0fec0de50 " + "prefix https://github.com/nakst/build-gcc/releases/download/gcc-11.1.0/gcc-x86_64-essence.tar.xz"); + DoCommand("setup-pre-built-toolchain"); + AddCompilerToPath(); +#else + BuildCrossCompiler(); +#endif } else if (0 == strcmp(l, "help") || 0 == strcmp(l, "h") || 0 == strcmp(l, "?")) { printf(ColorHighlight "\n=== Common Commands ===\n" ColorNormal); printf("build (b) - Build.\n"); @@ -1961,20 +1971,6 @@ int main(int _argc, char **_argv) { const char *runFirstCommand = NULL; - if (CallSystem("" TOOLCHAIN_PREFIX "-gcc --version > /dev/null 2>&1 ")) { -#if defined(__linux__) && defined(__x86_64__) - fprintf(stderr, "Downloading the compiler toolchain...\n"); - DoCommand("get-source-checked 700205f81c7a5ca3279ae7b1fdb24e025d33b36a9716b81a71125bf0fec0de50 " - "prefix https://github.com/nakst/build-gcc/releases/download/gcc-11.1.0/gcc-x86_64-essence.tar.xz"); - DoCommand("setup-pre-built-toolchain"); - AddCompilerToPath(); -#else - BuildCrossCompiler(); -#endif - runFirstCommand = "b"; - foundValidCrossCompiler = true; - } - if (argc >= 2) { char buffer[4096]; buffer[0] = 0; @@ -1991,6 +1987,12 @@ int main(int _argc, char **_argv) { interactiveMode = true; } + if (CallSystem("" TOOLCHAIN_PREFIX "-gcc --version > /dev/null 2>&1 ")) { + DoCommand("get-toolchain"); + runFirstCommand = "b"; + foundValidCrossCompiler = true; + } + SaveConfig(); if (runFirstCommand) {