From fdce1c19ce363e758099e12c7d1b85e2762b94f2 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Thu, 23 Sep 2021 12:03:28 +0100 Subject: [PATCH] bugfixes --- desktop/api.cpp | 2 ++ ports/uxn/port.sh | 5 ++++- util/build_common.h | 15 +++++++++------ util/build_core.c | 20 +++++++++----------- util/config_editor.c | 6 +----- util/uefi.sh | 2 +- util/uefi_to_device.sh | 9 ++++++++- 7 files changed, 34 insertions(+), 25 deletions(-) diff --git a/desktop/api.cpp b/desktop/api.cpp index 6680ed3..5bdb06b 100644 --- a/desktop/api.cpp +++ b/desktop/api.cpp @@ -2030,6 +2030,8 @@ void EsPOSIXInitialise(int *, char ***) { EsInstance *instance = EsInstanceCreate(message, INTERFACE_STRING(POSIXTitle)); EsPanel *panel = EsPanelCreate((EsElement *) instance->window, ES_PANEL_VERTICAL | ES_CELL_FILL, ES_STYLE_PANEL_WINDOW_BACKGROUND); EsTextDisplayCreate(panel, ES_CELL_H_CENTER | ES_CELL_V_FILL | ES_TEXT_DISPLAY_RICH_TEXT, nullptr, INTERFACE_STRING(POSIXUnavailable)); + } else if (message->type == ES_MSG_INSTANCE_OPEN) { + EsInstanceOpenComplete(message, true); } } } diff --git a/ports/uxn/port.sh b/ports/uxn/port.sh index e62c312..15e4dc9 100755 --- a/ports/uxn/port.sh +++ b/ports/uxn/port.sh @@ -1,6 +1,9 @@ set -e rm -rf bin/uxn bin/noodle -git clone --depth=1 https://git.sr.ht/~rabbits/uxn bin/uxn +git clone https://git.sr.ht/~rabbits/uxn bin/uxn +cd bin/uxn +git checkout e79004a07563060d66bc771b6285b7fe7e6b02bf +cd ../.. git clone --depth=1 https://git.sr.ht/~rabbits/noodle bin/noodle cc -DNDEBUG -Os -g0 -s bin/uxn/src/uxnasm.c -o bin/uxnasm bin/uxnasm bin/noodle/src/main.tal bin/noodle.rom diff --git a/util/build_common.h b/util/build_common.h index 0efe43d..bceb34f 100644 --- a/util/build_common.h +++ b/util/build_common.h @@ -310,7 +310,7 @@ Option options[] = { { "Emulator.VBoxEFI", OPTION_TYPE_BOOL, { .b = false } }, { "Emulator.QemuEFI", OPTION_TYPE_BOOL, { .b = false } }, { "BuildCore.Verbose", OPTION_TYPE_BOOL, { .b = false } }, - { "BuildCore.DeletePOSIXBeforeImport", OPTION_TYPE_BOOL, { .b = false } }, + { "BuildCore.NoImportPOSIX", OPTION_TYPE_BOOL, { .b = false } }, { "General.first_application", OPTION_TYPE_STRING, { .s = NULL } }, { "General.wallpaper", OPTION_TYPE_STRING, { .s = NULL } }, { "General.installation_state", OPTION_TYPE_STRING, { .s = "0" } }, @@ -318,11 +318,7 @@ Option options[] = { char *previousOptionsBuffer; -void LoadOptions() { - free(previousOptionsBuffer); - EsINIState s = { .buffer = (char *) LoadFile("bin/config.ini", &s.bytes) }; - previousOptionsBuffer = s.buffer; - +void LoadDefaultOptions() { for (uintptr_t i = 0; i < sizeof(options) / sizeof(options[0]); i++) { options[i].state = options[i].defaultState; options[i].useDefaultState = true; @@ -331,6 +327,13 @@ void LoadOptions() { options[i].state.s = strdup(options[i].state.s); } } +} + +void LoadOptions() { + free(previousOptionsBuffer); + EsINIState s = { .buffer = (char *) LoadFile("bin/config.ini", &s.bytes) }; + previousOptionsBuffer = s.buffer; + LoadDefaultOptions(); while (s.buffer && EsINIParse(&s)) { EsINIZeroTerminate(&s); diff --git a/util/build_core.c b/util/build_core.c index 325fa37..ae431b7 100644 --- a/util/build_core.c +++ b/util/build_core.c @@ -156,7 +156,7 @@ char kernelAssemblyFlags[4096] = " -felf64 -Fdwarf "; bool verbose; bool useColoredOutput; -bool forEmulator, bootUseVBE, deletePOSIXBeforeImport; +bool forEmulator, bootUseVBE, noImportPOSIX; bool systemBuild; bool convertFonts = true; EsINIState *fontLines; @@ -380,7 +380,9 @@ void CreateImportNode(const char *path, ImportNode *node) { ImportNode child = {}; - if (children[i].type == ES_NODE_DIRECTORY) { + if (noImportPOSIX && 0 == strcmp(pathBuffer, "root/Applications/POSIX")) { + continue; + } else if (children[i].type == ES_NODE_DIRECTORY) { CreateImportNode(pathBuffer, &child); } else { child.isFile = true; @@ -411,7 +413,9 @@ void CreateImportNode(const char *path, ImportNode *node) { ImportNode child = {}; - if (S_ISDIR(s.st_mode)) { + if (noImportPOSIX && 0 == strcmp(pathBuffer, "root/Applications/POSIX")) { + continue; + } else if (S_ISDIR(s.st_mode)) { CreateImportNode(pathBuffer, &child); } else if ((s.st_mode & S_IFMT) == S_IFLNK) { continue; @@ -1169,12 +1173,6 @@ void Install(const char *driveFile, uint64_t partitionSize, const char *partitio _partitionOffset = 1048576; Format(partitionSize - _partitionOffset, partitionLabel, installationIdentifier, kernel, kernelBytes); -#ifndef OS_ESSENCE - if (deletePOSIXBeforeImport) { - system("rm -r root/Applications/POSIX"); - } -#endif - Log("Copying files to the drive... "); ImportNode root = {}; @@ -1308,8 +1306,8 @@ int main(int argc, char **argv) { bootUseVBE = !!atoi(s.value); } else if (0 == strcmp(s.key, "Flag.COM_OUTPUT") && atoi(s.value)) { strcat(kernelAssemblyFlags, " -DCOM_OUTPUT "); - } else if (0 == strcmp(s.key, "BuildCore.DeletePOSIXBeforeImport")) { - deletePOSIXBeforeImport = !!atoi(s.value); + } else if (0 == strcmp(s.key, "BuildCore.NoImportPOSIX")) { + noImportPOSIX = !!atoi(s.value); } else if (0 == memcmp(s.key, "General.", 8)) { EsINIState s2 = s; s2.key += 8, s2.keyBytes -= 8; diff --git a/util/config_editor.c b/util/config_editor.c index 57eb6c0..6648772 100644 --- a/util/config_editor.c +++ b/util/config_editor.c @@ -83,11 +83,7 @@ int OptionTableMessage(UIElement *element, UIMessage message, int di, void *dp) } void ActionDefaults(void *_unused) { - for (uintptr_t i = 0; i < sizeof(options) / sizeof(options[0]); i++) { - options[i].state = options[i].defaultState; - options[i].useDefaultState = true; - } - + LoadDefaultOptions(); UIElementRefresh(&optionTable->e); UILabelSetContent(unsavedChangedLabel, "You have unsaved changes!", -1); UIElementRefresh(&unsavedChangedLabel->e); diff --git a/util/uefi.sh b/util/uefi.sh index d2d81f5..533eedd 100755 --- a/util/uefi.sh +++ b/util/uefi.sh @@ -10,9 +10,9 @@ set -e +# Duplicated in uefi_to_device.sh. CC="clang -target x86_64-unknown-windows -ffreestanding -fshort-wchar -mno-red-zone -I ports/efitoolkit/inc -c -Wall -Wextra" LINK="clang -target x86_64-unknown-windows -nostdlib -Wl,-entry:efi_main -Wl,-subsystem:efi_application -fuse-ld=lld-link" - $CC -o bin/uefi.o boot/x86/uefi.c $LINK -o bin/uefi bin/uefi.o diff --git a/util/uefi_to_device.sh b/util/uefi_to_device.sh index 9768558..c9d71d2 100755 --- a/util/uefi_to_device.sh +++ b/util/uefi_to_device.sh @@ -3,6 +3,13 @@ # Pass device file of EsFS partition as second argument. set -e + +# Duplicated from uefi.sh. +CC="clang -target x86_64-unknown-windows -ffreestanding -fshort-wchar -mno-red-zone -I ports/efitoolkit/inc -c -Wall -Wextra" +LINK="clang -target x86_64-unknown-windows -nostdlib -Wl,-entry:efi_main -Wl,-subsystem:efi_application -fuse-ld=lld-link" +$CC -o bin/uefi.o boot/x86/uefi.c +$LINK -o bin/uefi bin/uefi.o + mkdir -p mount mount $1 mount mkdir -p mount/EFI/BOOT @@ -18,7 +25,7 @@ SOURCE_COUNT=`fdisk -l bin/drive | grep 'Linux' | awk '{print $5}'` DESTINATION_COUNT=`blockdev --getsz $2` if [ "$SOURCE_COUNT" -gt "$DESTINATION_COUNT" ]; then - echo Please set Emulator.PrimaryDriveMB lower than $DESTINATION_COUNT. + echo Please set Emulator.PrimaryDriveMB to fit on the drive. exit 1 fi