added config files argument
This commit is contained in:
parent
816d1958ad
commit
53aeeba760
4 changed files with 44 additions and 8 deletions
|
@ -7,9 +7,10 @@
|
||||||
package buildtool
|
package buildtool
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/akamensky/argparse"
|
|
||||||
"os"
|
"os"
|
||||||
u "tools/srcs/common"
|
u "tools/srcs/common"
|
||||||
|
|
||||||
|
"github.com/akamensky/argparse"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -18,6 +19,7 @@ const (
|
||||||
sourcesArg = "sources"
|
sourcesArg = "sources"
|
||||||
objsArg = "objects"
|
objsArg = "objects"
|
||||||
makefileArg = "makefile"
|
makefileArg = "makefile"
|
||||||
|
configArg = "config"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ParseArguments parses arguments of the application.
|
// ParseArguments parses arguments of the application.
|
||||||
|
@ -34,11 +36,13 @@ func parseLocalArguments(p *argparse.Parser, args *u.Arguments) error {
|
||||||
&argparse.Options{Required: true, Help: "App Sources " +
|
&argparse.Options{Required: true, Help: "App Sources " +
|
||||||
"Folder"})
|
"Folder"})
|
||||||
args.InitArgParse(p, args, u.BOOL, "o", objsArg,
|
args.InitArgParse(p, args, u.BOOL, "o", objsArg,
|
||||||
&argparse.Options{Required: false, Default: false, Help: "Add objects from external build system " +
|
&argparse.Options{Required: false, Default: false, Help: "Add objects from external" +
|
||||||
"Folder"})
|
"build system Folder"})
|
||||||
args.InitArgParse(p, args, u.STRING, "m", makefileArg,
|
args.InitArgParse(p, args, u.STRING, "m", makefileArg,
|
||||||
&argparse.Options{Required: false, Help: "Add additional properties " +
|
&argparse.Options{Required: false, Help: "Add additional properties " +
|
||||||
"for Makefile"})
|
"for Makefile"})
|
||||||
|
args.InitArgParse(p, args, u.STRINGLIST, "c", configArg,
|
||||||
|
&argparse.Options{Required: false, Help: "Add configuration files"})
|
||||||
|
|
||||||
return u.ParserWrapper(p, os.Args)
|
return u.ParserWrapper(p, os.Args)
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,6 +123,8 @@ func RunBuildTool(homeDir string, data *u.Data) {
|
||||||
u.PrintErr(err)
|
u.PrintErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fmt.Println(args)
|
||||||
|
fmt.Println(*args.StringListArg[configArg])
|
||||||
// Get program Name
|
// Get program Name
|
||||||
programName := *args.StringArg[programArg]
|
programName := *args.StringArg[programArg]
|
||||||
|
|
||||||
|
@ -213,11 +215,33 @@ func RunBuildTool(homeDir string, data *u.Data) {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Move config files to Unikraft folder
|
||||||
|
configArg := *args.StringListArg[configArg]
|
||||||
|
for _, configFilePath := range configArg {
|
||||||
|
pathSplit := strings.Split(configFilePath, "/")
|
||||||
|
file := pathSplit[len(pathSplit)-1]
|
||||||
|
fileSplit := strings.Split(file, ".")
|
||||||
|
ext := fileSplit[len(fileSplit)-1]
|
||||||
|
|
||||||
|
if ext == "h" || ext == "hpp" || ext == "hcc" {
|
||||||
|
if err = u.CopyFileContents(configFilePath, *includeFolder+file); err != nil {
|
||||||
|
u.PrintErr(err)
|
||||||
|
}
|
||||||
|
} else if ext == "c" || ext == "cpp" || ext == "cc" {
|
||||||
|
if err = u.CopyFileContents(configFilePath, appFolder+file); err != nil {
|
||||||
|
u.PrintErr(err)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
u.PrintWarning("Unsupported extension for file: " + file)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Match micro-libs
|
// Match micro-libs
|
||||||
matchedLibs, externalLibs, err := matchLibs(unikraftPath+"lib"+u.SEP, data)
|
matchedLibs, externalLibs, err := matchLibs(unikraftPath+"lib"+u.SEP, data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
u.PrintErr(err)
|
u.PrintErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("\nPREFINAL\n")
|
fmt.Println("\nPREFINAL\n")
|
||||||
fmt.Println(matchedLibs)
|
fmt.Println(matchedLibs)
|
||||||
// Clone the external git repositories
|
// Clone the external git repositories
|
||||||
|
@ -232,6 +256,7 @@ func RunBuildTool(homeDir string, data *u.Data) {
|
||||||
for _, lib := range matchedLibs {
|
for _, lib := range matchedLibs {
|
||||||
u.PrintOk("Match lib: " + lib)
|
u.PrintOk("Match lib: " + lib)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("\nFINAL\n")
|
fmt.Println("\nFINAL\n")
|
||||||
fmt.Println(matchedLibs)
|
fmt.Println(matchedLibs)
|
||||||
// Clone the external git repositories (if changed)
|
// Clone the external git repositories (if changed)
|
||||||
|
|
|
@ -195,7 +195,7 @@ func processSourceFiles(sourcesPath, appFolder, includeFolder string,
|
||||||
if err = u.CopyFileContents(path, appFolder+info.Name()); err != nil {
|
if err = u.CopyFileContents(path, appFolder+info.Name()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
} else if extension == ".h" {
|
} else if extension == ".h" || extension == ".hpp" || extension == ".hcc" {
|
||||||
// Add source files to includesFiles list
|
// Add source files to includesFiles list
|
||||||
includesFiles = append(includesFiles, info.Name())
|
includesFiles = append(includesFiles, info.Name())
|
||||||
|
|
||||||
|
|
|
@ -8,9 +8,10 @@ package common
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/akamensky/argparse"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/akamensky/argparse"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Exported constants to determine arguments type.
|
// Exported constants to determine arguments type.
|
||||||
|
@ -18,6 +19,7 @@ const (
|
||||||
INT = iota
|
INT = iota
|
||||||
BOOL
|
BOOL
|
||||||
STRING
|
STRING
|
||||||
|
STRINGLIST
|
||||||
)
|
)
|
||||||
|
|
||||||
// Exported constants to determine which tool is used.
|
// Exported constants to determine which tool is used.
|
||||||
|
@ -38,9 +40,10 @@ const (
|
||||||
|
|
||||||
// Exported constants to represent different types of arguments.
|
// Exported constants to represent different types of arguments.
|
||||||
type Arguments struct {
|
type Arguments struct {
|
||||||
IntArg map[string]*int
|
IntArg map[string]*int
|
||||||
BoolArg map[string]*bool
|
BoolArg map[string]*bool
|
||||||
StringArg map[string]*string
|
StringArg map[string]*string
|
||||||
|
StringListArg map[string]*[]string
|
||||||
}
|
}
|
||||||
|
|
||||||
// InitArguments allows to initialize the parser in order to parse given
|
// InitArguments allows to initialize the parser in order to parse given
|
||||||
|
@ -52,6 +55,7 @@ func (args *Arguments) InitArguments(name, description string) (*argparse.Parser
|
||||||
args.IntArg = make(map[string]*int)
|
args.IntArg = make(map[string]*int)
|
||||||
args.BoolArg = make(map[string]*bool)
|
args.BoolArg = make(map[string]*bool)
|
||||||
args.StringArg = make(map[string]*string)
|
args.StringArg = make(map[string]*string)
|
||||||
|
args.StringListArg = make(map[string]*[]string)
|
||||||
|
|
||||||
p := argparse.NewParser(name, description)
|
p := argparse.NewParser(name, description)
|
||||||
|
|
||||||
|
@ -130,5 +134,8 @@ func (*Arguments) InitArgParse(p *argparse.Parser, args *Arguments, typeVar int,
|
||||||
case STRING:
|
case STRING:
|
||||||
args.StringArg[long] = new(string)
|
args.StringArg[long] = new(string)
|
||||||
args.StringArg[long] = p.String(short, long, options)
|
args.StringArg[long] = p.String(short, long, options)
|
||||||
|
case STRINGLIST:
|
||||||
|
args.StringListArg[long] = new([]string)
|
||||||
|
args.StringListArg[long] = p.StringList(short, long, options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue