From 6e09673f81a84e306bd9fd8f3470992024193ffb Mon Sep 17 00:00:00 2001 From: Aaron Veden Date: Fri, 24 Feb 2023 22:18:01 -0800 Subject: [PATCH] FACTO-235: adding shell script for racket make file --- .dir-locals.el | 24 +++++ make.rkt => make.sh | 254 ++++++++++++++++++++------------------------ 2 files changed, 141 insertions(+), 137 deletions(-) create mode 100644 .dir-locals.el rename make.rkt => make.sh (77%) mode change 100644 => 100755 diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..c0b5b9f --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,24 @@ +;; for configuration - projectile-project-configure-cmd +;; for compilation - projectile-project-compilation-cmd +;; for testing - projectile-project-test-cmd +;; for installation - projectile-project-install-cmd +;; for packaging - projectile-project-package-cmd +;; for running - projectile-project-run-cmd +;; for configuring the test prefix - projectile-project-test-prefix +;; for configuring the test suffix - projectile-project-test-suffix +;; for configuring the related-files-fn property - projectile-project-related-files-fn +;; for configuring the src-dir property - projectile-project-src-dir +;; for configuring the test-dir property - projectile-project-test-dir +;; projectile-configure-use-separate-buffer +;; projectile-compile-use-separate-buffer +;; projectile-test-use-separate-buffer +;; projectile-package-use-separate-buffer +;; projectile-run-use-separate-buffer +;; projectile-install-use-separate-buffer + + +((nil . ((projectile-project-install-cmd . "./make.sh copy") + (projectile-install-buffer-suffix . "install") + (projectile-project-package-cmd . "./make.sh zip") + (projectile-package-buffer-suffix . "package") + (projectile-project-run-cmd . "factorio")))) diff --git a/make.rkt b/make.sh old mode 100644 new mode 100755 similarity index 77% rename from make.rkt rename to make.sh index f7b3b5a..09b406c --- a/make.rkt +++ b/make.sh @@ -1,137 +1,117 @@ -;; Copyright (C) 2022 veden - -;; This program is free software: you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation, either version 3 of the License, or -;; (at your option) any later version. - -;; This program is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. - -;; You should have received a copy of the GNU General Public License -;; along with this program. If not, see . - - -(require file/zip) -(require json) - -(define modFolder "/mnt/gallery/gameFiles/factorio/mods/") -(define serverModFolder "/home/veden/Downloads/factorio/mods/") -(define configuration (call-with-input-file "info.json" - (lambda (port) - (string->jsexpr (port->string port))))) -(define packageName (string-append (string-replace (hash-ref configuration 'name) " " "_") - "_" - (hash-ref configuration 'version))) - -(define (makeZip folder) - (let ((packagePath (string->path (string-append folder - packageName - ".zip"))) - (unzippedPath (string->path (string-append folder - packageName)))) - - (delete-directory/files unzippedPath) - - (when (file-exists? packagePath) - (delete-file packagePath))) - - (zip (string-append folder - packageName - ".zip") - #:path-prefix packageName - (string->path "info.json") - (string->path "control.lua") - (string->path "data.lua") - (string->path "data-updates.lua") - (string->path "data-final-fixes.lua") - (string->path "COPYING") - (string->path "tests.lua") - (string->path "changelog.txt") - (string->path "Upgrade.lua") - (string->path "settings.lua") - (string->path "README.md") - (string->path "thumbnail.png") - (string->path "NOTICE") - (string->path "libs") - (string->path "sounds") - (string->path "migrations") - (string->path "locale") - (string->path "graphics") - (string->path "prototypes"))) - -(define (copyFile fileName modFolder) - (copy-file (string->path fileName) - (string->path (string-append modFolder - packageName - "/" - fileName)))) - -(define (copyDirectory directoryName modFolder) - (copy-directory/files (string->path directoryName) - (string->path (string-append modFolder - packageName - "/" - directoryName)))) - -(define (copyFiles modFolder) - (let ((packagePath (string->path (string-append modFolder - packageName)))) - (when (directory-exists? packagePath) - (delete-directory/files packagePath)) - (sleep 0.1) - (make-directory packagePath) - (copyFile "control.lua" modFolder) - (copyFile "info.json" modFolder) - (copyFile "data.lua" modFolder) - (copyFile "COPYING" modFolder) - (copyFile "NOTICE" modFolder) - (copyFile "README.md" modFolder) - (copyFile "data-updates.lua" modFolder) - (copyFile "data-final-fixes.lua" modFolder) - (copyFile "settings.lua" modFolder) - (copyFile "changelog.txt" modFolder) - (copyFile "Upgrade.lua" modFolder) - (copyFile "tests.lua" modFolder) - (copyFile "thumbnail.png" modFolder) - (copyDirectory "libs" modFolder) - (copyDirectory "locale" modFolder) - (copyDirectory "migrations" modFolder) - (copyDirectory "sounds" modFolder) - (copyDirectory "graphics" modFolder) - (copyDirectory "prototypes" modFolder))) - -(define (copy) - (set! configuration (call-with-input-file "info.json" - (lambda (port) - (string->jsexpr (port->string port))))) - (set! packageName (string-append (string-replace (hash-ref configuration 'name) " " "_") - "_" - (hash-ref configuration 'version))) - - (print (string-append "copying " (hash-ref configuration 'name) (hash-ref configuration 'version))) - (copyFiles modFolder) - ;; (copyFiles serverModFolder) - ) - -(define (zipIt) - (set! configuration (call-with-input-file "info.json" - (lambda (port) - (string->jsexpr (port->string port))))) - (set! packageName (string-append (string-replace (hash-ref configuration 'name) " " "_") - "_" - (hash-ref configuration 'version))) - (print (string-append "zipping " (hash-ref configuration 'name) (hash-ref configuration 'version))) - (makeZip modFolder)) - -(define (runStart) - (set! configuration (call-with-input-file "info.json" - (lambda (port) - (string->jsexpr (port->string port))))) - (set! packageName (string-append (string-replace (hash-ref configuration 'name) " " "_") - "_" - (hash-ref configuration 'version))) - (copyFiles modFolder) - (system*/exit-code "factorio")) +#! /usr/bin/env racket +#lang racket + +(require file/zip) +(require json) + +(define modFolder "/mnt/gallery/gameFiles/factorio/mods/") +(define serverModFolder "/home/veden/Downloads/factorio/mods/") +(define configuration (call-with-input-file "info.json" + (lambda (port) + (string->jsexpr (port->string port))))) +(define packageName (string-append (string-replace (hash-ref configuration 'name) " " "_") + "_" + (hash-ref configuration 'version))) + +(define (makeZip folder) + (let ((packagePath (string->path (string-append folder + packageName + ".zip"))) + (unzippedPath (string->path (string-append folder + packageName)))) + + (delete-directory/files unzippedPath) + + (when (file-exists? packagePath) + (delete-file packagePath))) + + (zip (string-append folder + packageName + ".zip") + #:path-prefix packageName + (string->path "info.json") + (string->path "control.lua") + (string->path "data.lua") + (string->path "data-updates.lua") + (string->path "data-final-fixes.lua") + (string->path "COPYING") + (string->path "tests.lua") + (string->path "changelog.txt") + (string->path "Upgrade.lua") + (string->path "settings.lua") + (string->path "README.md") + (string->path "thumbnail.png") + (string->path "NOTICE") + (string->path "libs") + (string->path "sounds") + (string->path "migrations") + (string->path "locale") + (string->path "graphics") + (string->path "prototypes"))) + +(define (copyFile fileName modFolder) + (copy-file (string->path fileName) + (string->path (string-append modFolder + packageName + "/" + fileName)))) + +(define (copyDirectory directoryName modFolder) + (copy-directory/files (string->path directoryName) + (string->path (string-append modFolder + packageName + "/" + directoryName)))) + +(define (copyFiles modFolder) + (let ((packagePath (string->path (string-append modFolder + packageName)))) + (when (directory-exists? packagePath) + (delete-directory/files packagePath)) + (sleep 0.1) + (make-directory packagePath) + (copyFile "control.lua" modFolder) + (copyFile "info.json" modFolder) + (copyFile "data.lua" modFolder) + (copyFile "COPYING" modFolder) + (copyFile "NOTICE" modFolder) + (copyFile "README.md" modFolder) + (copyFile "data-updates.lua" modFolder) + (copyFile "data-final-fixes.lua" modFolder) + (copyFile "settings.lua" modFolder) + (copyFile "changelog.txt" modFolder) + (copyFile "Upgrade.lua" modFolder) + (copyFile "tests.lua" modFolder) + (copyFile "thumbnail.png" modFolder) + (copyDirectory "libs" modFolder) + (copyDirectory "locale" modFolder) + (copyDirectory "migrations" modFolder) + (copyDirectory "sounds" modFolder) + (copyDirectory "graphics" modFolder) + (copyDirectory "prototypes" modFolder))) + +(define (copy) + (set! configuration (call-with-input-file "info.json" + (lambda (port) + (string->jsexpr (port->string port))))) + (set! packageName (string-append (string-replace (hash-ref configuration 'name) " " "_") + "_" + (hash-ref configuration 'version))) + + (print (string-append "copying " (hash-ref configuration 'name) (hash-ref configuration 'version))) + (copyFiles modFolder)) + +(define (zipIt) + (set! configuration (call-with-input-file "info.json" + (lambda (port) + (string->jsexpr (port->string port))))) + (set! packageName (string-append (string-replace (hash-ref configuration 'name) " " "_") + "_" + (hash-ref configuration 'version))) + (print (string-append "zipping " (hash-ref configuration 'name) (hash-ref configuration 'version))) + (makeZip modFolder)) + +(let ((arg (vector-ref (current-command-line-arguments) 0))) + (cond ((equal? arg "copy") (copy)) + ((equal? arg "zip") (zipIt)) + (else "Invalid command arg [copy,zip]")))