Fixes Build Script & Formatting
- Build file is updated to prevent running `mkdir` command if the directory exists - Formatting error is fixed
This commit is contained in:
6
build.py
6
build.py
@@ -1,4 +1,5 @@
|
||||
from os import system
|
||||
from os.path import exists
|
||||
from sys import argv, stderr
|
||||
from platform import system as os_name
|
||||
|
||||
@@ -6,7 +7,11 @@ def build():
|
||||
system("mkdir -p build")
|
||||
system("git clone https://github.com/nix-enthusiast/unildd.git build/unildd")
|
||||
system("cargo build --release --manifest-path=build/unildd/Cargo.toml")
|
||||
|
||||
if not exists("lib"):
|
||||
system("mkdir lib")
|
||||
|
||||
if not exists("include"):
|
||||
system("mkdir include")
|
||||
|
||||
# I know this logic is dodgy
|
||||
@@ -20,7 +25,6 @@ def build():
|
||||
|
||||
system("cp build/unildd/header/unildd.h include")
|
||||
|
||||
|
||||
match argv[1]:
|
||||
case "--build" | "-b":
|
||||
build()
|
||||
|
||||
13
main.go
13
main.go
@@ -24,7 +24,8 @@ func toGoString(cStr *C.char) string {
|
||||
}
|
||||
|
||||
func printObjects(fileNames []string, isMultiple bool) {
|
||||
for _, fileName := range fileNames {
|
||||
fileNamesLen := len(fileNames)
|
||||
for index, fileName := range fileNames {
|
||||
CFileName := C.CString(fileName)
|
||||
|
||||
fileContent, err := os.ReadFile(fileName)
|
||||
@@ -79,11 +80,10 @@ func printObjects(fileNames []string, isMultiple bool) {
|
||||
|
||||
memberNamesLength := int(object.member_name.length)
|
||||
memberNames := unsafe.Slice(object.member_name.vec, memberNamesLength)
|
||||
for j := 0; j < memberNamesLength; j++ {
|
||||
member := memberNames[j]
|
||||
for i, member := range memberNames {
|
||||
memberName += C.GoString(member)
|
||||
|
||||
if j+1 != int(object.member_name.length) {
|
||||
if i+1 != memberNamesLength {
|
||||
memberName += " -> "
|
||||
}
|
||||
}
|
||||
@@ -137,6 +137,11 @@ func printObjects(fileNames []string, isMultiple bool) {
|
||||
|
||||
C.free_obj(readObjects, false)
|
||||
C.free(unsafe.Pointer(CFileName))
|
||||
|
||||
if index+1 != fileNamesLen {
|
||||
fmt.Println()
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user