From 674bfd77764dd12c6b34ea46831e6d787a79d21b Mon Sep 17 00:00:00 2001 From: Aleksander Einarsen <aleksace@stud.ntnu.no> Date: Wed, 9 Oct 2024 23:07:08 +0200 Subject: [PATCH] Renamed OS to platform, and package data to platform --- modules/compiler/compiler.go | 6 +++--- modules/compiler/go-compiler/go_compiler.go | 2 +- modules/compiler/rust-compiler/rust_compiler.go | 2 +- .../{data/OS.go => platform/platform.go} | 2 +- modules/compiler_v2/utils/make_command.go | 14 +++++++------- 5 files changed, 13 insertions(+), 13 deletions(-) rename modules/compiler_v2/{data/OS.go => platform/platform.go} (85%) diff --git a/modules/compiler/compiler.go b/modules/compiler/compiler.go index 7f272a5..73a7dc8 100644 --- a/modules/compiler/compiler.go +++ b/modules/compiler/compiler.go @@ -28,7 +28,7 @@ const ( ) // TODO: I want to make an interface for a compilable language, so that we can add more languages in the future -// TODO: The cmd might also be an interface or a struct, so that it can build itself based on the OS and language +// TODO: The cmd might also be an interface or a struct, so that it can build itself based on the platform and language // TODO: A cleanup and panic might be needed in setup because if it panics the temp folders should be removed // TODO: I am not sure that the setup should panic, maybe it should return an error instead so its easier to clean up @@ -126,14 +126,14 @@ func InitCompiler(OS OS, language Language, sourceCode string, filename string, } func getOsPrefix(OS OS) string { - // Set the cmd prefix based on the OS + // Set the cmd prefix based on the platform switch OS { case Windows: return "cmd /c " case Linux, MacOS: return "" default: - panic("Unsupported OS") + panic("Unsupported platform") } } diff --git a/modules/compiler/go-compiler/go_compiler.go b/modules/compiler/go-compiler/go_compiler.go index 8a03ee5..e5b4d4f 100644 --- a/modules/compiler/go-compiler/go_compiler.go +++ b/modules/compiler/go-compiler/go_compiler.go @@ -9,7 +9,7 @@ import ( // The function does not produce any executables, since they are deleted after the function ends. func CompileStringToGo(code string, filename string, dependencies ...string) (string, error) { - // Get the OS + // Get the platform OS := runtime.GOOS // SetupEnvironment diff --git a/modules/compiler/rust-compiler/rust_compiler.go b/modules/compiler/rust-compiler/rust_compiler.go index 0d5f46f..7564fc0 100644 --- a/modules/compiler/rust-compiler/rust_compiler.go +++ b/modules/compiler/rust-compiler/rust_compiler.go @@ -8,7 +8,7 @@ import ( // CompileStringToRust compiles a string of go code to a rust executable func CompileStringToRust(code string, filename string, dependencies ...string) (string, error) { - // Get the OS + // Get the platform OS := runtime.GOOS // SetupEnvironment diff --git a/modules/compiler_v2/data/OS.go b/modules/compiler_v2/platform/platform.go similarity index 85% rename from modules/compiler_v2/data/OS.go rename to modules/compiler_v2/platform/platform.go index ee712af..9d23851 100644 --- a/modules/compiler_v2/data/OS.go +++ b/modules/compiler_v2/platform/platform.go @@ -1,4 +1,4 @@ -package data +package platform type OS = string diff --git a/modules/compiler_v2/utils/make_command.go b/modules/compiler_v2/utils/make_command.go index 83f0ded..52b8c6f 100644 --- a/modules/compiler_v2/utils/make_command.go +++ b/modules/compiler_v2/utils/make_command.go @@ -1,20 +1,20 @@ package utils import ( - "compiler_V2/data" + p "compiler_V2/platform" "os/exec" "runtime" ) -// MakeCommand creates a command based on the runtime OS +// MakeCommand creates a command based on the runtime platform func MakeCommand(cmd string) *exec.Cmd { - OS := runtime.GOOS - switch OS { - case data.Windows: + platform := runtime.GOOS + switch platform { + case p.Windows: return exec.Command("cmd", "/c", cmd) - case data.Linux, data.MacOS: + case p.Linux, p.MacOS: return exec.Command("bash", "-c", cmd) default: - panic("Unsupported OS") + panic("Unsupported platform") } } -- GitLab