From: Brendan Hansen Date: Wed, 22 Feb 2023 01:44:40 +0000 (-0600) Subject: onyx-pkg: added generating a single file to load X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=bf223348c4edfac22d98298d7015bd77604dc0f4;p=onyx.git onyx-pkg: added generating a single file to load --- diff --git a/scripts/onyx-pkg.onyx b/scripts/onyx-pkg.onyx index 7b1253bf..a3f2a38a 100644 --- a/scripts/onyx-pkg.onyx +++ b/scripts/onyx-pkg.onyx @@ -325,6 +325,8 @@ run_sync_command :: (args: [] cstr) { dependencies_installed[to_install.repo] = to_install.version; } + build_package_file_to_load(); + if options.clean { for os.list_directory(config.config.lib_source_directory) { if it.type != .Directory do continue; @@ -616,6 +618,42 @@ run_command_and_forward_output :: (cmd: str) => { return os.process_wait(^run_proc); } +build_package_file_to_load :: () { + filepath := tprintf("{}/{}", config.config.lib_source_directory, "packages.onyx"); + + if os.file_exists(filepath) { + os.remove_file(filepath); + } + + for os.with_file(filepath, .Write) { + w := io.writer_make(it); + defer io.writer_free(^w); + + io.write(^w, """ +// +// THIS FILE WAS AUTOMATICALLY GENERATED BY onyx-pkg. +// DO NOT MODIFY UNLESS YOU KNOW WHAT YOU ARE DOING. +// + +// PACKAGE LOADING +"""); + + for config.dependencies.dependencies->as_iter() { + dependency_repo := it.key; + dependency_folder := config.dependency_folders.folders[dependency_repo]; + + io.write_format(^w, + "#load \"./{}/module.onyx\"\n", + dependency_folder); + } + + io.write(^w, "\n\n// NATIVE LIBRARY PATH\n"); + + io.write_format(^w, "#library_path \"{}\"\n", config.config.lib_bin_directory); + } +} + + #tag conv.Custom_Parse.{parse} #tag conv.Custom_Format.{format}