update freetype and nasm to use scripts

This commit is contained in:
nakst 2022-01-30 09:10:30 +00:00
parent c06a2cf70d
commit 9f8571dff9
6 changed files with 70 additions and 61 deletions

View File

@ -0,0 +1,47 @@
#import "util/get_source.script" get_source;
str targetName #option;
str toolchainPrefix #option;
int processorCount #option;
void Start() {
if processorCount == 0 processorCount = SystemGetProcessorCount();
if !PathExists("bin/freetype") {
get_source.Get("https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz", "freetype-2.9",
"bf380e4d7c4f3b5b1c1a7b2bf3abb967bda5e9ab480d0df656e0e08c5019c5e6");
assert PathMove("bin/source", "bin/freetype");
assert FileCopy("ports/freetype/patch-ftoption.h", "bin/freetype/include/freetype/config/ftoption.h");
assert FileCopy("ports/freetype/patch-ftstdlib.h", "bin/freetype/include/freetype/config/ftstdlib.h");
assert FileCopy("ports/freetype/patch-modules.cfg", "bin/freetype/modules.cfg");
}
if !PathExists("root/Applications/POSIX/include/ft2build.h") {
assert SystemShellExecute("cp -p bin/freetype/include/ft2build.h root/Applications/POSIX/include");
assert SystemShellExecute("cp -p -r bin/freetype/include/freetype root/Applications/POSIX/include");
}
if !PathExists("bin/freetype/libfreetype_%targetName%.a") {
PathDelete("bin/freetype/objs/.libs/libfreetype.a");
if targetName == "x86_64" {
assert SystemShellExecuteWithWorkingDirectory("bin/freetype",
"./configure --without-zlib --without-bzip2 --without-png --without-harfbuzz "
+ "CC=%toolchainPrefix%-gcc CFLAGS=\"-g -ffreestanding -Wno-unused-function -O3\" --host=%toolchainPrefix%");
} else if targetName == "x86_32" {
assert SystemShellExecuteWithWorkingDirectory("bin/freetype",
"./configure --without-zlib --without-bzip2 --without-png --without-harfbuzz "
+ "CFLAGS=\"-g -ffreestanding -Wno-unused-function -O3 -I../../root/Applications/POSIX/include\" "
+ "LDFLAGS=\"-nostdlib -lgcc\" CC=%toolchainPrefix%-gcc --host=%toolchainPrefix%");
assert SystemShellExecuteWithWorkingDirectory("bin/freetype",
"sed -i '/define FT_USE_AUTOCONF_SIZEOF_TYPES/d' builds/unix/ftconfig.h");
} else {
assert false;
}
assert SystemShellExecuteWithWorkingDirectory("bin/freetype", "make -j %processorCount%");
assert FileCopy("bin/freetype/objs/.libs/libfreetype.a", "bin/freetype/libfreetype_%targetName%.a");
}
assert FileCopy("bin/freetype/libfreetype_%targetName%.a", "root/Applications/POSIX/lib/libfreetype.a");
}

View File

@ -1,49 +0,0 @@
set -e
if [ ! -d "bin/freetype" ]; then
echo "Downloading FreeType..."
bin/script util/get_source.script checksum=bf380e4d7c4f3b5b1c1a7b2bf3abb967bda5e9ab480d0df656e0e08c5019c5e6 directoryName=freetype-2.9 url=https://download.savannah.gnu.org/releases/freetype/freetype-2.9.tar.gz
mv bin/source bin/freetype
cp ports/freetype/patch-ftoption.h bin/freetype/include/freetype/config/ftoption.h
cp ports/freetype/patch-ftstdlib.h bin/freetype/include/freetype/config/ftstdlib.h
cp ports/freetype/patch-modules.cfg bin/freetype/modules.cfg
fi
if [ "$1" = "x86_64" ]; then
if [ ! -f "bin/freetype/libfreetype_x86_64.a" ]; then
echo "Building FreeType for x86_64..."
cd bin/freetype
rm -f objs/.libs/libfreetype.a
./configure --without-zlib --without-bzip2 --without-png --without-harfbuzz \
CC=x86_64-essence-gcc CFLAGS="-g -ffreestanding -Wno-unused-function -O3" \
--host=x86_64-essence > ../Logs/freetype_configure.txt 2>&1
make -j`nproc` > /dev/null
cp objs/.libs/libfreetype.a libfreetype_x86_64.a
cd ../..
fi
cp -p bin/freetype/libfreetype_x86_64.a root/Applications/POSIX/lib/libfreetype.a
fi
if [ "$1" = "x86_32" ]; then
if [ ! -f "bin/freetype/libfreetype_x86_32.a" ]; then
echo "Building FreeType for x86_32..."
INC=`realpath root/Applications/POSIX/include`
cd bin/freetype
rm -f objs/.libs/libfreetype.a
./configure --without-zlib --without-bzip2 --without-png --without-harfbuzz \
CC=i686-elf-gcc CFLAGS="-g -ffreestanding -Wno-unused-function -O3 -I$INC" \
LDFLAGS="-nostdlib -lgcc" --host=i686-elf > ../Logs/freetype_configure.txt 2>&1
sed -i '/define FT_USE_AUTOCONF_SIZEOF_TYPES/d' builds/unix/ftconfig.h
make -j`nproc` > /dev/null
cp objs/.libs/libfreetype.a libfreetype_x86_32.a
cd ../..
fi
cp -p bin/freetype/libfreetype_x86_32.a root/Applications/POSIX/lib/libfreetype.a
fi
cp -p bin/freetype/include/ft2build.h root/Applications/POSIX/include
cp -p -r bin/freetype/include/freetype root/Applications/POSIX/include

View File

@ -24,7 +24,9 @@ void Start() {
assert SystemShellExecuteWithWorkingDirectory("bin/harfbuzz/src",
"find . -type f -exec %sed% -i 's/#include <%headers[i]%.h>/#include <essence.h>/g' {} \\;");
}
}
if !PathExists("root/Applications/POSIX/include/harfbuzz") {
assert PathCreateLeadingDirectories("root/Applications/POSIX/include/harfbuzz");
assert SystemShellExecute("cp -p bin/harfbuzz/src/*.h root/Applications/POSIX/include/harfbuzz");
}

20
ports/nasm/port.script Normal file
View File

@ -0,0 +1,20 @@
#import "util/get_source.script" get_source;
str targetName #option;
str toolchainPrefix #option;
int processorCount #option;
void Start() {
str rootDirectory = PathGetDefaultPrefix() + "/root";
str version = "2.15.05";
if processorCount == 0 processorCount = SystemGetProcessorCount();
get_source.Get("https://www.nasm.us/pub/nasm/releasebuilds/%version%/nasm-%version%.tar.xz", "nasm-%version%",
"3caf6729c1073bf96629b57cee31eeb54f4f8129b01902c73428836550b30a3f");
assert SystemShellExecuteWithWorkingDirectory("bin/source", "./configure --host=%toolchainPrefix% CC=%toolchainPrefix%-gcc CXX=%toolchainPrefix%-g++ --prefix=/Applications/POSIX");
assert SystemShellExecuteWithWorkingDirectory("bin/source", "make -j %processorCount%");
assert SystemShellExecuteWithWorkingDirectory("bin/source", "make install DESTDIR=%rootDirectory%");
assert FileCopy("bin/source/LICENSE", "bin/Nasm License.txt");
PathDeleteRecursively("bin/source");
}

View File

@ -1,11 +0,0 @@
set -e
SYSROOT=`realpath root`
VERSION=2.15.05
bin/script util/get_source.script checksum=3caf6729c1073bf96629b57cee31eeb54f4f8129b01902c73428836550b30a3f directoryName=nasm-$VERSION url=https://www.nasm.us/pub/nasm/releasebuilds/$VERSION/nasm-$VERSION.tar.xz
cd bin/source
./configure --host=x86_64-essence CC=x86_64-essence-gcc CXX=x86_64-essence-g++ --prefix=/Applications/POSIX
make -j `nproc`
DESTDIR=$SYSROOT make install
mv LICENSE ../Nasm\ License.txt
cd ../..
rm -r bin/source

View File

@ -174,7 +174,7 @@ bool BuildAPIDependencies() {
if (CallSystem(TOOLCHAIN_PREFIX "-gcc -c desktop/crtglue.c -o cross/lib/gcc/" TOOLCHAIN_PREFIX "/" GCC_VERSION "/crtglue.o")) return false;
if (IsOptionEnabled("Dependency.FreeTypeAndHarfBuzz")) {
if (CallSystem("ports/freetype/build.sh " TARGET_NAME)) return false;
if (CallSystem("bin/script ports/freetype/build.script targetName=" TARGET_NAME " toolchainPrefix=" TOOLCHAIN_PREFIX)) return false;
if (CallSystem("bin/script ports/harfbuzz/build.script targetName=" TARGET_NAME " toolchainPrefix=" TOOLCHAIN_PREFIX)) return false;
}