5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-17 01:19:29 +08:00

Move generated assets to build dir. Precompile platform runtime.

This commit is contained in:
Lea Anthony 2021-01-05 13:01:03 +11:00
parent 98789bd85a
commit d2020fedda
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
7 changed files with 22 additions and 16 deletions

2
.gitignore vendored
View File

@ -22,8 +22,6 @@ v2/test/**/frontend/dist
v2/test/**/build/
v2/test/frameless/icon.png
v2/test/hidden/icon.png
v2/internal/ffenestri/runtime.c
v2/internal/runtime/assets/desktop.js
v2/test/kitchensink/frontend/public/bundle.*
v2/pkg/parser/testproject/frontend/wails
v2/test/kitchensink/frontend/public

View File

@ -98,15 +98,15 @@
#define NSAlertThirdButtonReturn 1002
// References to assets
extern const unsigned char *assets[];
#include "assets.h"
extern const unsigned char runtime;
// Tray icons
extern const unsigned char *trayIcons[];
#include "trayicons.h"
// Dialog icons
extern const unsigned char *defaultDialogIcons[];
extern const unsigned char *userDialogIcons[];
#include "userdialogicons.h"
// MAIN DEBUG FLAG
int debug;

View File

@ -156,7 +156,7 @@ func (a *AssetBundle) WriteToCFile(targetDir string) (string, error) {
var cdata strings.Builder
// Write header
header := `// assets.c
header := `// assets.h
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL.
// This file was auto-generated. DO NOT MODIFY.
@ -185,7 +185,7 @@ func (a *AssetBundle) WriteToCFile(targetDir string) (string, error) {
}
// Save file
assetsFile := filepath.Join(targetDir, "assets.c")
assetsFile := filepath.Join(targetDir, "assets.h")
err = ioutil.WriteFile(assetsFile, []byte(cdata.String()), 0600)
if err != nil {
return "", err

View File

@ -206,6 +206,15 @@ func (b *BaseBuilder) CompileProject(options *Options) error {
// Set GO111MODULE environment variable
cmd.Env = append(os.Environ(), "GO111MODULE=on")
// Add CGO flags
// We use the project/build dir as a temporary place for our generated c headers
buildBaseDir, err := fs.RelativeToCwd("build")
if err != nil {
return err
}
cmd.Env = append(os.Environ(), fmt.Sprintf("CGO_CFLAGS=-I%s", buildBaseDir))
// Setup buffers
var stdo, stde bytes.Buffer
cmd.Stdout = &stdo

View File

@ -113,10 +113,6 @@ func Build(options *Options) (string, error) {
// Build the base assets
outputLogger.Println(" - Compiling Assets")
err = builder.BuildRuntime(options)
if err != nil {
return "", err
}
err = builder.BuildAssets(options)
if err != nil {
return "", err

View File

@ -64,7 +64,10 @@ func (d *DesktopBuilder) BuildBaseAssets(assets *html.AssetBundle, options *Opti
outputLogger.Print(" - Embedding Assets...")
// Get target asset directory
assetDir := fs.RelativePath("../../../internal/ffenestri")
assetDir, err := fs.RelativeToCwd("build")
if err != nil {
return err
}
// Dump assets as C
assetsFile, err := assets.WriteToCFile(assetDir)

View File

@ -46,7 +46,7 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
// Setup target
targetFilename := "trayicons"
targetFile := filepath.Join(assetDir, targetFilename+".c")
targetFile := filepath.Join(assetDir, targetFilename+".h")
d.addFileToDelete(targetFile)
var dataBytes []byte
@ -55,7 +55,7 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err
var cdata strings.Builder
// Write header
header := `// trayicons.c
header := `// trayicons.h
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL.
// This file was auto-generated. DO NOT MODIFY.
@ -135,7 +135,7 @@ func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) e
// Setup target
targetFilename := "userdialogicons"
targetFile := filepath.Join(assetDir, targetFilename+".c")
targetFile := filepath.Join(assetDir, targetFilename+".h")
d.addFileToDelete(targetFile)
var dataBytes []byte
@ -144,7 +144,7 @@ func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) e
var cdata strings.Builder
// Write header
header := `// userdialogicons.c
header := `// userdialogicons.h
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL.
// This file was auto-generated. DO NOT MODIFY.