From 8e67fc98d964d131b5616dd1e83f54491afaad57 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sat, 16 Dec 2023 13:53:17 +0100 Subject: [PATCH 1/5] rust: Copy template files on compile --- src/langs/rust/Compiler.js | 9 ++++++++- src/sessions.js | 21 +-------------------- src/util.js | 27 ++++++++++++++++++++++++--- 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/src/langs/rust/Compiler.js b/src/langs/rust/Compiler.js index 4f479b414..d218b2774 100644 --- a/src/langs/rust/Compiler.js +++ b/src/langs/rust/Compiler.js @@ -1,7 +1,11 @@ import Gio from "gi://Gio"; import GLib from "gi://GLib"; import dbus_previewer from "../../Previewer/DBusPreviewer.js"; -import { decode, encode } from "../../util.js"; +import { copyDirectory, decode, encode } from "../../util.js"; + +const rust_template_dir = Gio.File.new_for_path( + pkg.pkgdatadir, +).resolve_relative_path("langs/rust/template"); export default function Compiler({ session }) { const { file } = session; @@ -15,6 +19,9 @@ export default function Compiler({ session }) { let savedRustcVersion; async function compile() { + console.log("copy!"); + copyDirectory(rust_template_dir, file); + rustcVersion ||= await getRustcVersion(); savedRustcVersion ||= await getSavedRustcVersion({ rustcVersionFile }); diff --git a/src/sessions.js b/src/sessions.js index be3ebc874..9d71ff758 100644 --- a/src/sessions.js +++ b/src/sessions.js @@ -7,11 +7,11 @@ import { ensureDir, getNowForFilename, demos_dir, - rust_template_dir, settings as global_settings, encode, languages, settings, + copyDirectory, } from "./util.js"; export const sessions_dir = data_dir.get_child("sessions"); @@ -64,7 +64,6 @@ export function createSessionFromDemo(demo) { const { file, settings } = session; copyDirectory(demo_dir, file); - copyDirectory(rust_template_dir, file); settings.set_string("name", name); settings.set_boolean("show-code", panels.includes("code")); @@ -79,24 +78,6 @@ export function createSessionFromDemo(demo) { return session; } -// There is no copy directory function -function copyDirectory(source, destination) { - for (const file_info of source.enumerate_children( - "", - Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, - null, - )) { - if (file_info.get_file_type() === Gio.FileType.DIRECTORY) continue; - const child = source.get_child(file_info.get_name()); - child.copy( - destination.get_child(child.get_basename()), - Gio.FileCopyFlags.NONE, - null, - null, - ); - } -} - export async function deleteSession(session) { // There is no method to recursively delete a folder so we trash instead // https://github.com/flatpak/xdg-desktop-portal/issues/630 :/ diff --git a/src/util.js b/src/util.js index ce71f3166..f48e6c2e2 100644 --- a/src/util.js +++ b/src/util.js @@ -177,9 +177,30 @@ export const demos_dir = Gio.File.new_for_path( pkg.pkgdatadir, ).resolve_relative_path("Library/demos"); -export const rust_template_dir = Gio.File.new_for_path( - pkg.pkgdatadir, -).resolve_relative_path("langs/rust/template"); +// There is no copy directory function +export function copyDirectory(source, destination) { + for (const file_info of source.enumerate_children( + "", + Gio.FileQueryInfoFlags.NOFOLLOW_SYMLINKS, + null, + )) { + if (file_info.get_file_type() === Gio.FileType.DIRECTORY) continue; + const child = source.get_child(file_info.get_name()); + + try { + child.copy( + destination.get_child(child.get_basename()), + Gio.FileCopyFlags.NONE, + null, + null, + ); + } catch (err) { + if (!err.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.EXISTS)) { + throw err; + } + } + } +} export function getNowForFilename() { return new GLib.DateTime().format("%Y-%m-%d %H-%M-%S"); From 4e2e971b329859767bed528caffefcd98812478e Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sat, 16 Dec 2023 14:00:14 +0100 Subject: [PATCH 2/5] f --- .gitignore | 7 ------- src/langs/rust/Compiler.js | 1 - 2 files changed, 8 deletions(-) diff --git a/.gitignore b/.gitignore index 0971b223a..8860b4d23 100644 --- a/.gitignore +++ b/.gitignore @@ -17,10 +17,3 @@ __pycache__ # IDEs / editors .idea - -# Project files - sync with Makefile -src/Library/**/settings -src/Library/**/workbench.vala -src/Library/**/main.ui -src/Library/**/libworkbenchcode.so -src/Library/**/__pycache__ diff --git a/src/langs/rust/Compiler.js b/src/langs/rust/Compiler.js index d218b2774..b31796a0b 100644 --- a/src/langs/rust/Compiler.js +++ b/src/langs/rust/Compiler.js @@ -19,7 +19,6 @@ export default function Compiler({ session }) { let savedRustcVersion; async function compile() { - console.log("copy!"); copyDirectory(rust_template_dir, file); rustcVersion ||= await getRustcVersion(); From e9c37556292d94a61bdfd1ebc2bd8b69c983dd94 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sat, 16 Dec 2023 14:05:09 +0100 Subject: [PATCH 3/5] f --- .github/CODEOWNERS | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 2929169cf..71f9a3c8b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,8 +1,20 @@ * @sonnyp + +# Vala *.vala @lw64 +/src/langs/vala/ + +# Rust *.rs @Hofer-Julian Cargo.toml @Hofer-Julian Cargo.lock @Hofer-Julian +src/langs/rust/* @Hofer-Julian +/src/langs/rust/ + +# C *.c @andyholmes *.h @andyholmes + +# Python *.py @theCapypara +/src/langs/python/ From af43d245c06deef54d2cbbacd925551444719988 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Sat, 16 Dec 2023 14:07:11 +0100 Subject: [PATCH 4/5] f --- .github/CODEOWNERS | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 71f9a3c8b..5c24e480c 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2,14 +2,13 @@ # Vala *.vala @lw64 -/src/langs/vala/ +/src/langs/vala/ @lw64 # Rust *.rs @Hofer-Julian Cargo.toml @Hofer-Julian Cargo.lock @Hofer-Julian -src/langs/rust/* @Hofer-Julian -/src/langs/rust/ +/src/langs/rust/ @Hofer-Julian # C *.c @andyholmes @@ -17,4 +16,4 @@ src/langs/rust/* @Hofer-Julian # Python *.py @theCapypara -/src/langs/python/ +/src/langs/python/ @theCapypara From 862fcc6761c5570a48c5a9d437534090a1f8f4a8 Mon Sep 17 00:00:00 2001 From: Sonny Piers Date: Mon, 8 Jan 2024 00:15:42 +0100 Subject: [PATCH 5/5] f --- data/app.metainfo.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/app.metainfo.xml b/data/app.metainfo.xml index 0e8f37211..2f2153909 100644 --- a/data/app.metainfo.xml +++ b/data/app.metainfo.xml @@ -5,7 +5,7 @@ Workbench Sonny Piers - + Sonny Piers sonnyp@gnome.org