perf(@desktop): "make run" boost and build correct qrc

This commit is contained in:
Andrei Smirnov 2021-07-19 09:05:15 +03:00 committed by Iuri Matias
parent 011b7804ef
commit 4031db9bf1
3 changed files with 72 additions and 17 deletions

View File

@ -155,6 +155,7 @@ ifeq ($(RELEASE),false)
# Enable debugging symbols in DOtherSide, in case we need GDB backtraces
CFLAGS += -g
CXXFLAGS += -g
RCC_PARAMS = --no-compress
else
# Additional optimization flags for release builds are not included at present;
# adding them will involve refactoring config.nims in the root of this repo
@ -209,8 +210,8 @@ rcc:
echo -e $(BUILD_MSG) "resources.rcc"
rm -f ./resources.rcc
rm -f ./ui/resources.qrc
./ui/generate-rcc.sh
rcc -binary ui/resources.qrc -o ./resources.rcc
go run ui/generate-rcc.go -source=ui -output=ui/resources.qrc
rcc -binary $(RCC_PARAMS) ui/resources.qrc -o ./resources.rcc
# default token is a free-tier token with limited capabilities and usage
# limits; our docs should include directions for community contributor to setup

69
ui/generate-rcc.go Normal file
View File

@ -0,0 +1,69 @@
package main
import (
"flag"
"fmt"
"log"
"os"
"path/filepath"
"strings"
)
var qrcExtensions = map[string]bool{
".qml": true,
".js": true,
".svg": true,
".png": true,
".ico": true,
".icns": true,
".mp3": true,
".wav": true,
".otf": true,
".ttf": true,
".webm": true,
".qm": true,
}
func main() {
sourceDirName := flag.String("source", "", "source dir containing ui files")
qrcFileName := flag.String("output", "resources.qrc", "output filename")
flag.Parse()
if flag.NFlag() == 0 {
flag.Usage()
return
}
qrcFile, err := os.Create(*qrcFileName)
if err != nil {
log.Fatalf("Failed creating qrc file: %s", err)
}
defer qrcFile.Close()
qrcFile.WriteString("<!DOCTYPE RCC>\n")
qrcFile.WriteString("<RCC version=\"1.0\">\n")
qrcFile.WriteString(" <qresource>\n")
counter := 0
err = filepath.Walk(*sourceDirName,
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if !info.IsDir() {
ext := filepath.Ext(path)
base := filepath.Base(path)
if qrcExtensions[ext] || base == "qmldir" {
counter++
fixedPath := strings.ReplaceAll(path, "\\", "/")
fixedPath = "./" + strings.TrimPrefix(fixedPath, *sourceDirName)
qrcFile.WriteString(" <file>" + fixedPath + "</file>\n")
}
}
return nil
})
qrcFile.WriteString(" </qresource>\n")
qrcFile.WriteString("</RCC>")
fmt.Printf("%d resources added\n", counter)
}

View File

@ -1,15 +0,0 @@
#!/bin/sh
cd ./ui/
QRC=./resources.qrc
echo '<!DOCTYPE RCC>' > $QRC
echo '<RCC version="1.0">' >> $QRC
echo ' <qresource>' >> $QRC
for a in $(find -L . -not -name "*.pro" -not -name "*.rcc" -not -name "*.sh" -not -name "*.qrc" -not -name ".git" -not -name ".gitignore" )
do
if [ ! -d "$a" ]; then
echo ' <file>'$a'</file>' >> $QRC
fi
done
echo ' </qresource>' >> $QRC
echo '</RCC>' >> $QRC
cd ..