utils

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	O_EXT             = ".o"
	C_EXT             = ".c"
	CPP_EXT           = ".cpp"
	TIME_FORMAT       = "2006-01-02 15:04:05"
	DEFAULT_FILE_PERM = 0755
)

Variables

View Source
var (
	DefaultMainCPPFile = `
#include <iostream>

int main(int argc, char** argv) {
	std::cout << "Hello, World!" << std::endl;
	return 0;
}
`
	DefaultMainCFile = `
#include<stdio.h>

int main(int argc, char** argv) {
	printf("Hello, World!");
	return 0;
}
`
	DefaultCommandGitignoreFile = `
build/*
include/*
lib/*
`
)

file contents

View Source
var Dirs = map[string]string{
	"Src_Dir_Path":               "",
	"Include_Dir_Path":           "",
	"Lib_Dir_Path":               "",
	"Lib_PkgConf_Dir_Path":       "",
	"Debug_Dir_Path":             "",
	"Debug_Lib_Dir_Path":         "",
	"Debug_Lib_PkgConf_Dir_Path": "",
	"Debug_Bin_Dir_Path":         "",
	"Debug_Bin_O_Dir_Path":       "",
	"Debug_Bin_Out_Dir_Path":     "",
	"Build_Dir_Path":             "",
	"Build_Cache_Dir_Path":       "",
	"Build_Release_Dir_Path":     "",
}
View Source
var Files = map[string]string{
	"Debug_Bin_Log_File_Path": "",
	"Config_File_Path":        "",
}
View Source
var Work_Dir_Path = "" // ${Work_Dir_Path}

Functions

func Compile

func Compile(packages *[]Package, src_file, output_dir string) bool

func CopyDirectory added in v1.2.5

func CopyDirectory(srcDir, dstDir string) ([]string, error)

Copies and pastes all the contents inside of the directory from source to destination Args:

srcDir string source directory path
dstDir string destination directory path

Returns:

array list of all items thats been copied
error if error has occured while copying

func CopyFile

func CopyFile(src, dst string) error

Copies a file from source to destination Args:

src string source file path
dst string destination file path

func CreateConfigFile added in v1.12.0

func CreateConfigFile(project_name, project_type string, targets []string) error

func CreateDir added in v1.12.0

func CreateDir(dir_path string) bool

Creates a directory in the specified path Args:

dir_path string the path where directory is supposed to be created

Returns:

true if directory created successfully
false if error occured

func DeleteFile added in v1.14.0

func DeleteFile(filePath string) bool

Deletes a file Args:

filepath string path of the file thats supposed to be deleted

Returns:

true if file is succesfullly deleted
false if not

func DetectCompiler added in v1.14.0

func DetectCompiler(compiler string) bool

func DetectInstalledCompilers added in v1.12.0

func DetectInstalledCompilers(compilers []string) []string

Detects installed compilers Args:

compilers array list of compilers to detect
Returns:
	array list of detected compilers

func DirExists added in v1.5.8

func DirExists(dir_path string) bool

Checks it directory exists or not Returns:

true of directory exists
false if not

func FindPackage added in v1.12.0

func FindPackage(package_name string) string

func GetCompilerPath

func GetCompilerPath(compiler string) (string, error)

Gets the compiler path Args:

compiler string compiler name
Returns:
	string path of the compiler
	error if error occures

func GetCompilerVersion

func GetCompilerVersion(compiler string) (string, error)

Get compiler version Args:

compiler string name of the compiler

Returns:

string version of the compiler
error if error has occured

func GetInstalledPackages added in v1.12.0

func GetInstalledPackages() *[]os.DirEntry

func GetLogFile added in v1.12.0

func GetLogFile() *os.File

Opens log file Returns:

log_file *os.File

func GetModLogs added in v1.12.0

func GetModLogs(log_file *os.File) *map[string]string

Reads filemod.log file and maps the file names and their last modification time Args:

log_file *os.File

Returns:

map[file_name]last_modification_time

func GetObjectFiles added in v1.12.0

func GetObjectFiles(object_files_dir string) *[]string

Get a list of object file names Returns:

o_list *[]string

func GetPackages added in v1.12.0

func GetPackages(pkgconfig_dir_path string) (*[]Package, error)

func GetVCPKG_ROOT added in v1.12.0

func GetVCPKG_ROOT() (string, error)

func GetWorkDir added in v1.1.0

func GetWorkDir() (string, error)

Gets the directory of the path where the application is running Returns:

string path
error if error occurs

func InstallPackage added in v1.12.0

func InstallPackage(package_name string)

func IsCompiled

func IsCompiled(o_files []os.DirEntry, src_file_name string) bool

Checks if file is present inside the list of object files Args:

o_files array list of object files
src_file_name string name of the source file

Returns:

true if file is compiled
false if not
func Link(
	project_type,
	target string,
	packages *[]Package,
	lib_dir_path string,
	obj_files []string,
	output_file_path string,
) bool

func PromptBool added in v1.14.0

func PromptBool(question string) bool

Prompts a question expects response to be in y or n

func PromptList added in v1.14.0

func PromptList(question string, options []string) string

Prompts a list returns the selected item

func PromptText added in v1.14.0

func PromptText(question string) string

Prompts a question expects the response to be a string

func SetGlobalPaths added in v1.12.0

func SetGlobalPaths(pwd string)

Sets all the paths of directories and files Args:

pwd string current directory path

func SrcFileExist

func SrcFileExist(src_files []os.DirEntry, o_file_name string) bool

Checks if file is present inside the list of source files Args:

src_files array list of source files
o_file_name string name of the object file

Returns:

true if file is present
false if not

func UpdateConfigFile added in v1.14.0

func UpdateConfigFile(project_config ProjectConfig) error

Types

type Package added in v1.12.0

type Package struct {
	Name        string `toml:"name"`
	Description string `toml:"description"`
	URL         string `toml:"url"`
	Version     string `toml:"version"`
	Libs        string `toml:"libs"`
	Cflags      string `toml:"cflags"`
}

func ReadPCFile added in v1.12.0

func ReadPCFile(pc_file_path string) *Package

type ProjectConfig

type ProjectConfig struct {
	Project struct {
		Name        string `toml:"name"`
		Description string `toml:"description"`
		Version     string `toml:"version"`
		Type        string `toml:"type"`
	} `toml:"project"`
	Build struct {
		OS      string   `toml:"os"`
		Arch    string   `toml:"arch"`
		Targets []string `toml:"targets"`
	} `toml:"build"`
	Packages []Package `toml:"packages"`
}

func GetProjectConfig added in v1.3.1

func GetProjectConfig() (*ProjectConfig, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL