From e7c459d86d0124602ad9c5ae56ccb41696ea56f8 Mon Sep 17 00:00:00 2001 From: Rob1103 Date: Thu, 24 Nov 2022 19:18:47 +0100 Subject: [PATCH] extractertool tar gz files bug fix --- srcs/dependtool/parserClang.py | 3 ++- srcs/extractertool/parserClang.py | 3 ++- srcs/extractertool/run_extractertool.go | 24 +++++++++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/srcs/dependtool/parserClang.py b/srcs/dependtool/parserClang.py index 502ed2c..1ae84dd 100755 --- a/srcs/dependtool/parserClang.py +++ b/srcs/dependtool/parserClang.py @@ -64,7 +64,8 @@ def check_type_file(filepath, includePaths): cOptions = cOptions + ' ' + includePaths if silent_flag is False: print("Gathering symbols of " + filepath) - if filepath.endswith(".cpp") or filepath.endswith(".hpp"): + if filepath.endswith(".cpp") or filepath.endswith(".hpp") or filepath.endswith(".cc") or \ + filepath.endswith(".hcc"): parse_file(filepath, cplusplusOptions) elif filepath.endswith(".c") or filepath.endswith(".h"): parse_file(filepath, cOptions) diff --git a/srcs/extractertool/parserClang.py b/srcs/extractertool/parserClang.py index 56c1f9d..3d3816b 100755 --- a/srcs/extractertool/parserClang.py +++ b/srcs/extractertool/parserClang.py @@ -64,7 +64,8 @@ def check_type_file(filepath, includePaths): cOptions = cOptions + ' ' + includePaths if silent_flag is False: print("Gathering symbols of " + filepath) - if filepath.endswith(".cpp") or filepath.endswith(".hpp"): + if filepath.endswith(".cpp") or filepath.endswith(".hpp") or filepath.endswith(".cc") or \ + filepath.endswith(".hcc"): parse_file(filepath, cplusplusOptions) elif filepath.endswith(".c") or filepath.endswith(".h"): parse_file(filepath, cOptions) diff --git a/srcs/extractertool/run_extractertool.go b/srcs/extractertool/run_extractertool.go index 56bc79e..2acaf4c 100644 --- a/srcs/extractertool/run_extractertool.go +++ b/srcs/extractertool/run_extractertool.go @@ -103,7 +103,7 @@ func detectURL(mapVariables map[string]*Variables) *string { return nil } -//TODO REPLACE +// TODO REPLACE func CreateFolder(path string) (bool, error) { if _, err := os.Stat(path); os.IsNotExist(err) { if err = os.Mkdir(path, 0755); err != nil { @@ -157,7 +157,7 @@ func findSourcesFiles(workspace string) ([]string, error) { return filenames, nil } -//TODO REPLACE +// TODO REPLACE // ExecuteCommand a single command without displaying the output. // // It returns a string which represents stdout and an error if any, otherwise @@ -261,7 +261,14 @@ func RunExtracterTool(homeDir string) { return } - fileExtension := filepath.Ext(*url) + var fileExtension string + urlSplit := strings.Split(*url, "/") + if urlSplit[len(urlSplit)-1] == "download" { + fileExtension = filepath.Ext(urlSplit[len(urlSplit)-2]) + } else { + fileExtension = filepath.Ext(*url) + } + folderName := lib + "_sources_folder" created, err := CreateFolder(folderName) if err != nil { @@ -269,7 +276,15 @@ func RunExtracterTool(homeDir string) { } var files []string - archiveName := lib + "_sources" + fileExtension + var archiveName string + + if fileExtension == ".gz" { + archiveName = lib + "_sources.tar" + fileExtension + + } else { + archiveName = lib + "_sources" + fileExtension + } + if created { u.PrintInfo(*url + " is found. Download the lib sources...") err := DownloadFile(archiveName, *url) @@ -327,7 +342,6 @@ func RunExtracterTool(homeDir string) { } u.PrintOk(strconv.Itoa(len(mapSymbols)) + " symbols from " + lib + " have been extracted.") - filename := filepath.Join(os.Getenv("GOPATH"), "src", "tools", "libs", "external", lib) if err := u.RecordDataJson(filename, mf); err != nil { u.PrintErr(err)