From eb2eab872f0d859741589ef383cbbd7437133de3 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Sun, 2 Jan 2022 10:49:27 +0000 Subject: [PATCH] add automation files --- util/automation/build.sh | 104 ++++++++++++++++++++++ util/automation/build_minimal.sh | 20 +++++ util/automation/genapisamples.py | 39 +++++++++ util/automation/genovf.py | 14 +++ util/automation/run_tests.sh | 15 ++++ util/automation/template.ovf | 142 +++++++++++++++++++++++++++++++ 6 files changed, 334 insertions(+) create mode 100755 util/automation/build.sh create mode 100755 util/automation/build_minimal.sh create mode 100644 util/automation/genapisamples.py create mode 100644 util/automation/genovf.py create mode 100755 util/automation/run_tests.sh create mode 100644 util/automation/template.ovf diff --git a/util/automation/build.sh b/util/automation/build.sh new file mode 100755 index 0000000..16e9411 --- /dev/null +++ b/util/automation/build.sh @@ -0,0 +1,104 @@ +#!/bin/bash +set -eux + +# TODO: +# Copy the source onto the drive for self hosting. +# Producing installer images (including for real hardware). + +cd essence +COMMIT=`git log | head -n 1 | cut -b 8-14` + +# Setup config files. +mkdir -p bin root +echo "accepted_license=1" >> bin/build_config.ini +echo "automated_build=1" >> bin/build_config.ini +echo "Flag.DEBUG_BUILD=0" >> bin/config.ini +echo "Flag.ENABLE_POSIX_SUBSYSTEM=1" >> bin/config.ini +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-source prefix https://github.com/nakst/build-gcc/releases/download/gcc-11.1.0/gcc-x86_64-essence.tar.xz +./start.sh setup-pre-built-toolchain +./start.sh build-optimised +./start.sh build-optional-ports > /dev/null + +# Copy a few sample files. +mkdir -p root/Demo\ Content +cp -r res/Sample\ Images/* root/Demo\ Content/ +cp -r help root/Demo\ Content/ +cp bin/noodle.rom root/Demo\ Content/Noodle.uxn +cp res/A\ Study\ in\ Scarlet.txt root/Demo\ Content/ +cp res/Theme\ Source.dat root/Demo\ Content/Theme.designer +cp res/Flip.* root/Demo\ Content/ +cp res/Teapot.obj root/Demo\ Content/ +cp res/Fonts/Atkinson\ Hyperlegible\ Regular.ttf root/Demo\ Content/ + +# Copy API samples. +mkdir -p root/API\ Samples +python util/automation/genapisamples.py + +# Enable extra applications. +echo "util/designer2.ini" >> bin/extra_applications.ini +echo "util/build_core.ini" >> bin/extra_applications.ini +echo "ports/uxn/emulator.ini" >> bin/extra_applications.ini +echo "ports/bochs/bochs.ini" >> bin/extra_applications.ini +echo "ports/mesa/obj_viewer.ini" >> bin/extra_applications.ini + +# Build the extra applications. +./start.sh build-optimised +cd .. + +# Create a virtual machine file. +mkdir -p ova +qemu-img convert -f raw essence/bin/drive -O vmdk -o adapter_type=lsilogic,subformat=streamOptimized,compat6 ova/Essence-disk001.vmdk +python essence/util/automation/genovf.py > ova/Essence.ovf +cd ova +tar -cf Essence.ova Essence.ovf Essence-disk001.vmdk +cd .. + +# Copy licenses. +mkdir -p Essence Essence/Licenses +cp essence/LICENSE.md Essence/Licenses/Essence\ License.txt +cp essence/util/nanosvg.h Essence/Licenses/ +cp essence/util/hsluv.h Essence/Licenses/ +cp essence/util/stb_*.h Essence/Licenses/ +cp essence/shared/stb_*.h Essence/Licenses/ +cp essence/res/Fonts/Hack\ License.md Essence/Licenses/ +cp essence/res/Fonts/Inter\ License.txt Essence/Licenses/ +cp essence/res/Fonts/Atkinson\ Hyperlegible\ License.txt Essence/Licenses/ +cp essence/res/Fonts/OpenDyslexic\ License.txt Essence/Licenses/ +cp essence/res/elementary\ Icons\ License.txt Essence/Licenses/ +cp essence/res/Sample\ Images/Licenses.txt Essence/Licenses/Sample\ Images.txt +cp essence/res/Keyboard\ Layouts/License.txt Essence/Licenses/Keyboard\ Layouts.txt +cp essence/ports/acpica/licensing.txt Essence/Licenses/ACPICA.txt +cp essence/ports/bochs/COPYING Essence/Licenses/Bochs.txt +cp essence/ports/efitoolkit/LICENSE Essence/Licenses/EFI.txt +cp essence/ports/freetype/FTL.TXT Essence/Licenses/FreeType.txt +cp essence/ports/harfbuzz/LICENSE Essence/Licenses/HarfBuzz.txt +cp essence/ports/md4c/LICENSE.md Essence/Licenses/Md4c.txt +cp essence/ports/musl/COPYRIGHT Essence/Licenses/Musl.txt +cp essence/ports/uxn/LICENSE Essence/Licenses/Uxn.txt +cp essence/bin/BusyBox\ License.txt Essence/Licenses/BusyBox.txt +cp -r essence/bin/FFmpeg\ License Essence/Licenses/ +cp essence/bin/Mesa\ License.html Essence/Licenses/Mesa.html +cp essence/bin/Nasm\ License.txt Essence/Licenses/Nasm.txt +cp essence/bin/GCC\ License.txt Essence/Licenses/GCC.txt +cp essence/bin/Binutils\ License.txt Essence/Licenses/Binutils.txt +cp essence/bin/GMP\ License.txt Essence/Licenses/GMP.txt +cp essence/bin/MPFR\ License.txt Essence/Licenses/GMPF.txt +cp essence/bin/MPC\ License.txt Essence/Licenses/MPC.txt + +# Compress the result. +mv ova/Essence.ova Essence/ +mv essence/bin/drive Essence/ +tar -cJf Essence.tar.xz Essence/ +echo $COMMIT > essence/bin/commit.txt +rm -rf essence/cross essence/.git essence/bin/cache essence/bin/freetype essence/bin/harfbuzz essence/bin/musl essence/root/Applications/POSIX/lib +tar -cJf debug_info.tar.xz essence + +# Set outputs for workflow. +echo "::set-output name=OUTPUT_BINARY::Essence.tar.xz" +echo "::set-output name=DEBUG_OUTPUT_BINARY::debug_info.tar.xz" +echo "::set-output name=RELEASE_NAME::essence-`date +%Y_%m_%d`-${COMMIT}" +echo "::set-output name=COMMIT::${COMMIT}" diff --git a/util/automation/build_minimal.sh b/util/automation/build_minimal.sh new file mode 100755 index 0000000..e095242 --- /dev/null +++ b/util/automation/build_minimal.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -eux + +cd essence +mkdir -p bin root +echo "accepted_license=1" >> bin/build_config.ini +echo "automated_build=1" >> bin/build_config.ini +echo "Flag.DEBUG_BUILD=0" >> bin/config.ini +echo "BuildCore.NoImportPOSIX=1" >> bin/config.ini +echo "BuildCore.RequiredFontsOnly=1" >> bin/config.ini +echo "Emulator.PrimaryDriveMB=32" >> bin/config.ini +echo "Emulator.PrimaryDriveMB=32" >> bin/config.ini +echo "Dependency.ACPICA=0" >> bin/config.ini +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-source prefix https://github.com/nakst/build-gcc/releases/download/gcc-11.1.0/gcc-x86_64-essence.tar.xz +./start.sh setup-pre-built-toolchain +./start.sh build-optimised diff --git a/util/automation/genapisamples.py b/util/automation/genapisamples.py new file mode 100644 index 0000000..286e74d --- /dev/null +++ b/util/automation/genapisamples.py @@ -0,0 +1,39 @@ +import os +for config_file in os.listdir('apps/samples'): + if config_file.endswith('.ini'): + source_file = config_file.split('.')[0] + '.c' + if not os.path.exists('apps/samples/' + source_file): + source_file = config_file.split('.')[0] + '.cpp' + if not os.path.exists('apps/samples/' + source_file): + continue + application_name = None + with open('apps/samples/' + config_file, 'r') as config_fd: + config = config_fd.read().split('\n') + config_section = '' + for config_line in config: + if len(config_line) > 0 and config_line[0] == '[': + config_section = config_line + elif config_section == '[general]' and config_line.startswith('name='): + application_name = config_line[5:] + if not application_name: + continue + print(application_name, source_file, config_file) + folder = 'root/API Samples/' + application_name + try: + os.mkdir(folder) + except: + pass + with open('apps/samples/' + source_file, 'r') as source_fd: + with open(folder + '/' + source_file, 'w') as source_dest_fd: + source_dest_fd.write(source_fd.read()) + with open('apps/samples/' + config_file, 'r') as config_fd: + with open(folder + '/make.build_core', 'w') as config_dest_fd: + config = config_fd.read().split('\n') + config_section = '' + for config_line in config: + if len(config_line) > 0 and config_line[0] == '[': + config_section = config_line + if config_section == '[build]' and config_line.startswith('source='): + config_dest_fd.write('source=' + source_file + '\n') + else: + config_dest_fd.write(config_line + '\n') diff --git a/util/automation/genovf.py b/util/automation/genovf.py new file mode 100644 index 0000000..966fe1e --- /dev/null +++ b/util/automation/genovf.py @@ -0,0 +1,14 @@ +import os +import uuid +template = open('essence/util/automation/template.ovf','r').read().split('$') +uuid1 = uuid.uuid4() +uuid2 = uuid.uuid4() +print(template[0], end='') +print(os.path.getsize('essence/bin/drive'), end='') +print(template[1], end='') +print(uuid1, end='') +print(template[2], end='') +print(uuid2, end='') +print(template[3], end='') +print(uuid1, end='') +print(template[4], end='') diff --git a/util/automation/run_tests.sh b/util/automation/run_tests.sh new file mode 100755 index 0000000..8d99717 --- /dev/null +++ b/util/automation/run_tests.sh @@ -0,0 +1,15 @@ +#!/bin/bash +set -eux + +# TODO: +# Run stress tests. + +cd essence +mkdir -p bin +echo "accepted_license=1" >> bin/build_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-source prefix https://github.com/nakst/build-gcc/releases/download/gcc-11.1.0/gcc-x86_64-essence.tar.xz +./start.sh setup-pre-built-toolchain +./start.sh run-tests +rm -rf cross .git bin/cache bin/freetype bin/harfbuzz bin/musl root/Applications/POSIX/lib bin/drive diff --git a/util/automation/template.ovf b/util/automation/template.ovf new file mode 100644 index 0000000..9dadb01 --- /dev/null +++ b/util/automation/template.ovf @@ -0,0 +1,142 @@ + + + + + + + List of the virtual disks used in the package + + + + Logical networks used in the package + + Logical network used by this appliance. + + + + A virtual machine + + The kind of installed guest operating system + Windows7 + Windows7_64 + + + Virtual hardware requirements for a virtual machine + + Virtual Hardware Family + 0 + Essence2 + virtualbox-2.2 + + + 2 virtual CPU + Number of virtual CPUs + 2 virtual CPU + 1 + 3 + 2 + + + MegaBytes + 2048 MB of memory + Memory Size + 2048 MB of memory + 2 + 4 + 2048 + + + 0 + sataController0 + SATA Controller + sataController0 + 3 + AHCI + 20 + + + 0 + usb + USB Controller + usb + 4 + 23 + + + 3 + false + sound + Sound Card + sound + 5 + ensoniq1371 + 35 + + + 0 + disk1 + Disk Image + disk1 + /disk/vmdisk1 + 6 + 3 + 17 + + + true + Ethernet adapter on 'NAT' + NAT + Ethernet adapter on 'NAT' + 7 + E1000 + 10 + + + + Complete VirtualBox machine configuration in VirtualBox format + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +