Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions example/flint.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "example-package"
version = "0.1.0"
authors = ["author1", "author2"]
description = "A example library for Flint programming language."
license = "MIT"
repository = "https://github.com/example/example-repo"

[build]
type = "native"
language = "c"
entry = "example.c"
output = "example"
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module flint
go 1.25.4

require (
github.com/BurntSushi/toml v1.5.0 // indirect
github.com/llir/llvm v0.3.6 // indirect
github.com/mewmew/float v0.0.0-20201204173432-505706aa38fa // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
github.com/BurntSushi/toml v1.5.0 h1:W5quZX/G/csjUnuI8SUYlsHs9M38FC7znL0lIO+DvMg=
github.com/BurntSushi/toml v1.5.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
Expand Down
17 changes: 17 additions & 0 deletions internal/toml/buildconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package toml

type buildConfig struct {
Type string `toml:"type"`
Language string `toml:"language"`
Entry string `toml:"entry"`
Output string `toml:"output"`
}

func newExampleBuildConfig() buildConfig {
return buildConfig{
Type: "native",
Language: "c",
Entry: "example.c",
Output: "example",
}
}
65 changes: 65 additions & 0 deletions internal/toml/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package toml

import (
"fmt"
"os"

"github.com/BurntSushi/toml"
)

type (
ProjectConfig struct {
PackageConfig packageConfig `toml:"package"`
BuildConfig buildConfig `toml:"build"`
}
)

var configFile = "flint.toml"

func newExampleProjectConfig() ProjectConfig {
return ProjectConfig{
PackageConfig: newExamplePackageConfig(),
BuildConfig: newExampleBuildConfig(),
}
}

func newExampleProjectConfigAt(path string) {
saveProjectConfigAt(newExampleProjectConfig(), path)
}

func loadProjectConfig() (ProjectConfig, error) {
return loadProjectConfigAt("")
}

func loadProjectConfigAt(path string) (ProjectConfig, error){
var config ProjectConfig
_, err := toml.DecodeFile(path + "/" + configFile, &config)
return config, err
}

func saveProjectConfig(config ProjectConfig) {
saveProjectConfigAt(config, "")
}

func saveProjectConfigAt(config ProjectConfig, path string) error {
os.MkdirAll(path, os.ModePerm)

file, fileErr := os.Create(path + "/" + configFile)

if fileErr != nil {
return fileErr
}

err := toml.NewEncoder(file).Encode(config)

if err != nil {
return err
}
return nil
}

func printProjectConfig(config ProjectConfig) {
fmt.Printf("%+v", config)
}


21 changes: 21 additions & 0 deletions internal/toml/packageconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package toml

type packageConfig struct {
Name string `toml:"name"`
Version string `toml:"version"`
Authors []string `toml:"authors"`
Description string `toml:"description"`
License string `toml:"license"`
Repository string `toml:"repository"`
}

func newExamplePackageConfig() packageConfig {
return packageConfig{
Name: "example-package",
Version: "0.1.0",
Authors: []string{"author1", "author2"},
Description: "A example library for Flint programming language.",
License: "MIT",
Repository: "https://github.com/example/example-repo",
}
}
Empty file modified scripts/build.sh
100644 → 100755
Empty file.