mirror of
https://github.com/encounter/decomp.dev.git
synced 2026-07-10 03:18:48 -07:00
Protobuf type updates
This commit is contained in:
@@ -22,51 +22,6 @@ func main() {
|
||||
logger := baseapp.NewLogger(cfg.Logging)
|
||||
zerolog.DefaultContextLogger = &logger
|
||||
|
||||
// Configure a temporary directory
|
||||
//if cfg.App.TmpDir == "" {
|
||||
// cfg.App.TmpDir, err = os.MkdirTemp(os.TempDir(), "decompal")
|
||||
// if err != nil {
|
||||
// logger.Fatal().
|
||||
// Err(err).
|
||||
// Str("path", cfg.App.TmpDir).
|
||||
// Msg("failed to create temporary directory")
|
||||
// }
|
||||
//}
|
||||
//if _, err := os.Stat(cfg.App.TmpDir); err != nil {
|
||||
// if os.IsNotExist(err) {
|
||||
// err := os.MkdirAll(cfg.App.TmpDir, 0755)
|
||||
// if err != nil {
|
||||
// logger.Fatal().
|
||||
// Err(err).
|
||||
// Str("path", cfg.App.TmpDir).
|
||||
// Msg("failed to create temporary directory")
|
||||
// }
|
||||
// } else {
|
||||
// logger.Fatal().
|
||||
// Err(err).
|
||||
// Str("path", cfg.App.TmpDir).
|
||||
// Msg("failed to stat temporary directory")
|
||||
// }
|
||||
//}
|
||||
//logger.Debug().
|
||||
// Str("path", cfg.App.TmpDir).
|
||||
// Msg("Using temporary directory")
|
||||
//// Delete the temporary directory on exit
|
||||
//defer func() {
|
||||
// if err := os.RemoveAll(cfg.App.TmpDir); err != nil {
|
||||
// logger.Error().
|
||||
// Err(err).
|
||||
// Str("path", cfg.App.TmpDir).
|
||||
// Msg("failed to remove temporary directory")
|
||||
// }
|
||||
//}()
|
||||
|
||||
// Create a task queue
|
||||
//queueFactory := memqueue.NewFactory()
|
||||
//taskQueue := queueFactory.RegisterQueue(&taskq.QueueOptions{
|
||||
// Name: "background-tasks",
|
||||
//})
|
||||
|
||||
// Create the server
|
||||
serverParams := baseapp.DefaultParams(logger, "decompal.")
|
||||
server, err := baseapp.NewServer(cfg.Server, serverParams...)
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh -e
|
||||
SRC_DIR=../objdiff/objdiff-cli/protos
|
||||
SRC_DIR=../objdiff/objdiff-core/protos
|
||||
protoc -I=$SRC_DIR \
|
||||
--go_out=paths=source_relative:objdiff \
|
||||
--go_opt=Mreport.proto=github.com/encounter/decompal/objdiff \
|
||||
$SRC_DIR/*.proto
|
||||
$SRC_DIR/report.proto
|
||||
|
||||
+5
-5
@@ -183,7 +183,7 @@ func upsertComment(
|
||||
|
||||
func createChanges(changes *objdiff.Changes) string {
|
||||
out := "### Overall\n\n"
|
||||
overallTable := changeInfoTable(changes.From, changes.To)
|
||||
overallTable := measuresTable(changes.From, changes.To)
|
||||
if overallTable == "" {
|
||||
if len(changes.Units) == 0 {
|
||||
return ""
|
||||
@@ -194,7 +194,7 @@ func createChanges(changes *objdiff.Changes) string {
|
||||
}
|
||||
for _, unit := range changes.Units {
|
||||
out += fmt.Sprintf("---\n### `%s`\n\n", unit.Name)
|
||||
unitTable := changeInfoTable(unit.From, unit.To)
|
||||
unitTable := measuresTable(unit.From, unit.To)
|
||||
if unitTable != "" {
|
||||
out += unitTable + "\n\n"
|
||||
}
|
||||
@@ -268,15 +268,15 @@ func changeItemInfoRow(item *objdiff.ChangeItem) string {
|
||||
)
|
||||
}
|
||||
|
||||
func changeInfoTable(prev, curr *objdiff.ChangeInfo) string {
|
||||
func measuresTable(prev, curr *objdiff.Measures) string {
|
||||
if prev == nil && curr == nil {
|
||||
return ""
|
||||
} else if prev == nil {
|
||||
// TODO: added
|
||||
prev = &objdiff.ChangeInfo{}
|
||||
prev = &objdiff.Measures{}
|
||||
} else if curr == nil {
|
||||
// TODO: removed
|
||||
curr = &objdiff.ChangeInfo{}
|
||||
curr = &objdiff.Measures{}
|
||||
}
|
||||
header := "|Metric|Previous|Current|Change|\n|-|-|-|-|"
|
||||
rows := make([]string, 0)
|
||||
|
||||
+35
-23
@@ -46,17 +46,19 @@ type legacyReportItem struct {
|
||||
|
||||
func (r *legacyReport) convert() *Report {
|
||||
report := &Report{
|
||||
FuzzyMatchPercent: r.FuzzyMatchPercent,
|
||||
TotalCode: r.TotalCode,
|
||||
MatchedCode: r.MatchedCode,
|
||||
MatchedCodePercent: r.MatchedCodePercent,
|
||||
TotalData: r.TotalData,
|
||||
MatchedData: r.MatchedData,
|
||||
MatchedDataPercent: r.MatchedDataPercent,
|
||||
TotalFunctions: r.TotalFunctions,
|
||||
MatchedFunctions: r.MatchedFunctions,
|
||||
MatchedFunctionsPercent: r.MatchedFunctionsPercent,
|
||||
Units: make([]*ReportUnit, 0, len(r.Units)),
|
||||
Measures: &Measures{
|
||||
FuzzyMatchPercent: r.FuzzyMatchPercent,
|
||||
TotalCode: r.TotalCode,
|
||||
MatchedCode: r.MatchedCode,
|
||||
MatchedCodePercent: r.MatchedCodePercent,
|
||||
TotalData: r.TotalData,
|
||||
MatchedData: r.MatchedData,
|
||||
MatchedDataPercent: r.MatchedDataPercent,
|
||||
TotalFunctions: r.TotalFunctions,
|
||||
MatchedFunctions: r.MatchedFunctions,
|
||||
MatchedFunctionsPercent: r.MatchedFunctionsPercent,
|
||||
},
|
||||
Units: make([]*ReportUnit, 0, len(r.Units)),
|
||||
}
|
||||
for _, unit := range r.Units {
|
||||
report.Units = append(report.Units, unit.convert())
|
||||
@@ -65,8 +67,7 @@ func (r *legacyReport) convert() *Report {
|
||||
}
|
||||
|
||||
func (u *legacyReportUnit) convert() *ReportUnit {
|
||||
unit := &ReportUnit{
|
||||
Name: u.Name,
|
||||
measures := &Measures{
|
||||
FuzzyMatchPercent: u.FuzzyMatchPercent,
|
||||
TotalCode: u.TotalCode,
|
||||
MatchedCode: u.MatchedCode,
|
||||
@@ -74,11 +75,18 @@ func (u *legacyReportUnit) convert() *ReportUnit {
|
||||
MatchedData: u.MatchedData,
|
||||
TotalFunctions: u.TotalFunctions,
|
||||
MatchedFunctions: u.MatchedFunctions,
|
||||
Complete: u.Complete,
|
||||
ModuleName: u.ModuleName,
|
||||
ModuleId: u.ModuleID,
|
||||
Sections: make([]*ReportItem, 0, len(u.Sections)),
|
||||
Functions: make([]*ReportItem, 0, len(u.Functions)),
|
||||
}
|
||||
measures.CalcMatchedPercent()
|
||||
unit := &ReportUnit{
|
||||
Name: u.Name,
|
||||
Measures: measures,
|
||||
Sections: make([]*ReportItem, 0, len(u.Sections)),
|
||||
Functions: make([]*ReportItem, 0, len(u.Functions)),
|
||||
Metadata: &ReportUnitMetadata{
|
||||
Complete: u.Complete,
|
||||
ModuleName: u.ModuleName,
|
||||
ModuleId: u.ModuleID,
|
||||
},
|
||||
}
|
||||
for _, section := range u.Sections {
|
||||
unit.Sections = append(unit.Sections, section.convert())
|
||||
@@ -90,20 +98,24 @@ func (u *legacyReportUnit) convert() *ReportUnit {
|
||||
}
|
||||
|
||||
func (i *legacyReportItem) convert() *ReportItem {
|
||||
var address uint64
|
||||
var address *uint64
|
||||
if i.Address != nil {
|
||||
addressStr := *i.Address
|
||||
if strings.HasPrefix(addressStr, "0x") {
|
||||
address, _ = strconv.ParseUint(addressStr[2:], 16, 64)
|
||||
v, _ := strconv.ParseUint(addressStr[2:], 16, 64)
|
||||
address = &v
|
||||
} else {
|
||||
address, _ = strconv.ParseUint(addressStr, 10, 64)
|
||||
v, _ := strconv.ParseUint(addressStr, 10, 64)
|
||||
address = &v
|
||||
}
|
||||
}
|
||||
return &ReportItem{
|
||||
Name: i.Name,
|
||||
DemangledName: i.DemangledName,
|
||||
Address: &address,
|
||||
Size: i.Size,
|
||||
FuzzyMatchPercent: i.FuzzyMatchPercent,
|
||||
Metadata: &ReportItemMetadata{
|
||||
DemangledName: i.DemangledName,
|
||||
VirtualAddress: address,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
+16
-1
@@ -22,7 +22,7 @@ type ReportFile struct {
|
||||
Report *Report
|
||||
}
|
||||
|
||||
var artifactNameRegex = regexp.MustCompile(`^(?P<version>[A-z0-9_\-]+)_report$`)
|
||||
var artifactNameRegex = regexp.MustCompile(`^(?P<version>[A-z0-9_\-]+)[_-]report(?:[_-].*)?$`)
|
||||
|
||||
func FetchReportFiles(
|
||||
ctx context.Context,
|
||||
@@ -151,3 +151,18 @@ func parseJson(data []byte, v *Report) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Measures) CalcMatchedPercent() {
|
||||
m.MatchedCodePercent = 100
|
||||
if m.TotalCode != 0 {
|
||||
m.MatchedCodePercent = float32(m.MatchedCode) / float32(m.TotalCode) * 100
|
||||
}
|
||||
m.MatchedDataPercent = 100
|
||||
if m.TotalData != 0 {
|
||||
m.MatchedDataPercent = float32(m.MatchedData) / float32(m.TotalData) * 100
|
||||
}
|
||||
m.MatchedFunctionsPercent = 100
|
||||
if m.TotalFunctions != 0 {
|
||||
m.MatchedFunctionsPercent = float32(m.MatchedFunctions) / float32(m.TotalFunctions) * 100
|
||||
}
|
||||
}
|
||||
|
||||
+588
-511
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user