Skip to content

Commit

Permalink
app.App: new type, reorganize work tree
Browse files Browse the repository at this point in the history
  • Loading branch information
kurth4cker committed Feb 19, 2025
1 parent 910b792 commit e0b67a4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 51 deletions.
36 changes: 36 additions & 0 deletions internal/app/application.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2024-2025 kurth4cker <[email protected]>

package app

import (
"fmt"
"log"
"os/exec"
"path/filepath"
"slices"
)

type App struct {
Name string
Sources []string
}

func (a *App) Build() {
args := []string{"-o", a.Name}
args = slices.Concat(args, a.Sources)

cmd := exec.Command("cc", args...)
cmd.Run()
fmt.Println(cmd)
}

func (a *App) Scan(basedir string) {
abs, err := filepath.Abs(basedir)
if err != nil {
log.Fatalln(err)
}
a.Name = filepath.Base(abs)

a.Sources, _ = filepath.Glob(filepath.Join(basedir, "*.c"))
}
4 changes: 4 additions & 0 deletions internal/app/application_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2024-2025 kurth4cker <[email protected]>

package app
7 changes: 1 addition & 6 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2024 kurth4cker <[email protected]>
// SPDX-FileCopyrightText: 2024-2025 kurth4cker <[email protected]>

package main

func main() {
var project Project
project.Initialize()
project.Scan()

project.Build()
}
45 changes: 0 additions & 45 deletions project.go

This file was deleted.

0 comments on commit e0b67a4

Please sign in to comment.