diff --git a/v2/internal/ffenestri/ffenestri.go b/v2/internal/ffenestri/ffenestri.go index 67b12210..ed045725 100644 --- a/v2/internal/ffenestri/ffenestri.go +++ b/v2/internal/ffenestri/ffenestri.go @@ -20,7 +20,7 @@ import ( #cgo darwin LDFLAGS: -framework WebKit -lobjc #cgo windows CXXFLAGS: -std=c++11 -#cgo windows,amd64 LDFLAGS: -L./windows/x64 -lwebview -lWebView2Loader -lgdi32 -lole32 -lShlwapi -luser32 -loleaut32 +#cgo windows,amd64 LDFLAGS: -L./windows/x64 -lWebView2Loader -lgdi32 -lole32 -lShlwapi -luser32 -loleaut32 #include #include "ffenestri.h" diff --git a/v2/internal/ffenestri/ffenestri_windows.go b/v2/internal/ffenestri/ffenestri_windows.go index f13c5fa8..249b89e0 100644 --- a/v2/internal/ffenestri/ffenestri_windows.go +++ b/v2/internal/ffenestri/ffenestri_windows.go @@ -5,7 +5,7 @@ import "C" /* #cgo windows CXXFLAGS: -std=c++11 -#cgo windows,amd64 LDFLAGS: -L./windows/x64 -lwebview -lWebView2Loader -lgdi32 -lole32 -lShlwapi -luser32 -loleaut32 +#cgo windows,amd64 LDFLAGS: -lgdi32 -lole32 -lShlwapi -luser32 -loleaut32 #include "ffenestri.h" diff --git a/v2/internal/ffenestri/windows/test/CMakeLists.txt b/v2/internal/ffenestri/windows/test/CMakeLists.txt deleted file mode 100644 index 304e016f..00000000 --- a/v2/internal/ffenestri/windows/test/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -cmake_minimum_required(VERSION 3.19) -project(test) - -set(CMAKE_CXX_STANDARD 14) - -add_executable(test main.cpp) \ No newline at end of file diff --git a/v2/internal/ffenestri/windows/x64/webview.dll b/v2/internal/ffenestri/windows/x64/webview.dll deleted file mode 100644 index 1a7e95f1..00000000 Binary files a/v2/internal/ffenestri/windows/x64/webview.dll and /dev/null differ diff --git a/v2/internal/ffenestri/windows/x64/x64.go b/v2/internal/ffenestri/windows/x64/x64.go index 6b4c5f26..8e4e2f31 100644 --- a/v2/internal/ffenestri/windows/x64/x64.go +++ b/v2/internal/ffenestri/windows/x64/x64.go @@ -4,8 +4,5 @@ package x64 import _ "embed" -//go:embed webview.dll -var WebView2 []byte - //go:embed WebView2Loader.dll var WebView2Loader []byte diff --git a/v2/internal/ffenestri/windows/x64/x64_stub.go b/v2/internal/ffenestri/windows/x64/x64_stub.go deleted file mode 100644 index ec441390..00000000 --- a/v2/internal/ffenestri/windows/x64/x64_stub.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build !windows - -// This is a stub to define the following even though they don't exist -// on non-Windows systems. Note: This is not the right way to handle this. -package x64 - -var WebView2 []byte - -var WebView2Loader []byte diff --git a/v2/pkg/commands/build/base.go b/v2/pkg/commands/build/base.go index a2178c24..bb3e48c8 100644 --- a/v2/pkg/commands/build/base.go +++ b/v2/pkg/commands/build/base.go @@ -3,7 +3,6 @@ package build import ( "bytes" "fmt" - "github.com/wailsapp/wails/v2/internal/ffenestri/windows/x64" "io/ioutil" "os" "os/exec" @@ -326,17 +325,6 @@ func (b *BaseBuilder) CompileProject(options *Options) error { } println("Done.") - // If we are targeting windows, dump the DLLs - if options.Platform == "windows" { - err := os.WriteFile(filepath.Join(appDir, "webview.dll"), x64.WebView2, 0755) - if err != nil { - return err - } - err = os.WriteFile(filepath.Join(appDir, "WebView2Loader.dll"), x64.WebView2Loader, 0755) - if err != nil { - return err - } - } if !options.Compress { return nil diff --git a/v2/pkg/commands/build/build.go b/v2/pkg/commands/build/build.go index f3f61580..3eee7ee1 100644 --- a/v2/pkg/commands/build/build.go +++ b/v2/pkg/commands/build/build.go @@ -25,8 +25,6 @@ const ( Production ) -var modeMap = []string{"Debug", "Production"} - // Options contains all the build options as well as the project data type Options struct { LDFlags string // Optional flags to pass to linker @@ -51,11 +49,6 @@ type Options struct { AppleIdentity string } -// GetModeAsString returns the current mode as a string -func GetModeAsString(mode Mode) string { - return modeMap[mode] -} - // Build the project! func Build(options *Options) (string, error) { @@ -212,6 +205,12 @@ func Build(options *Options) (string, error) { outputLogger.Println("Done.") } + // Post compilation tasks + err = builder.PostCompilation(options) + if err != nil { + return "", err + } + return projectData.OutputFilename, nil } diff --git a/v2/pkg/commands/build/builder.go b/v2/pkg/commands/build/builder.go index 8dda4d57..81dd5d30 100644 --- a/v2/pkg/commands/build/builder.go +++ b/v2/pkg/commands/build/builder.go @@ -13,5 +13,6 @@ type Builder interface { BuildRuntime(*Options) error CompileProject(*Options) error OutputFilename(*Options) string + PostCompilation(*Options) error CleanUp() } diff --git a/v2/pkg/commands/build/desktop_darwin.go b/v2/pkg/commands/build/desktop_darwin.go index 9cf0d888..1d0870b6 100644 --- a/v2/pkg/commands/build/desktop_darwin.go +++ b/v2/pkg/commands/build/desktop_darwin.go @@ -110,6 +110,11 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err return nil } +// PostCompilation is called after the compilation step, if successful +func (d *DesktopBuilder) PostCompilation(options *Options) error { + return nil +} + // We will compile all dialog icons found at /icons/dialog/*.png into the application func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) error { diff --git a/v2/pkg/commands/build/desktop_default.go b/v2/pkg/commands/build/desktop_default.go deleted file mode 100644 index 0418001f..00000000 --- a/v2/pkg/commands/build/desktop_default.go +++ /dev/null @@ -1,8 +0,0 @@ -// +build !linux - -package build - -// This is used when there is no compilation to be done for the asset -func (d *DesktopBuilder) compileIcon(assetDir string, iconFile string) error { - return nil -} diff --git a/v2/pkg/commands/build/desktop_linux.go b/v2/pkg/commands/build/desktop_linux.go index f72100ff..1d94e5ac 100644 --- a/v2/pkg/commands/build/desktop_linux.go +++ b/v2/pkg/commands/build/desktop_linux.go @@ -233,3 +233,8 @@ func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) e // } return nil } + +// PostCompilation is called after the compilation step, if successful +func (d *DesktopBuilder) PostCompilation(options *Options) error { + return nil +} diff --git a/v2/pkg/commands/build/desktop_windows.go b/v2/pkg/commands/build/desktop_windows.go index 39698818..ee724285 100644 --- a/v2/pkg/commands/build/desktop_windows.go +++ b/v2/pkg/commands/build/desktop_windows.go @@ -2,6 +2,22 @@ package build +import ( + "github.com/wailsapp/wails/v2/internal/ffenestri/windows/x64" + "os" + "path/filepath" +) + +// PostCompilation is called after the compilation step, if successful +func (d *DesktopBuilder) PostCompilation(options *Options) error { + // Dump the DLLs + err := os.WriteFile(filepath.Join(options.BuildDirectory, "WebView2Loader.dll"), x64.WebView2Loader, 0755) + if err != nil { + return err + } + return nil +} + // We will compile all tray icons found at /assets/trayicons/*.png into the application func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) error { // @@ -91,6 +107,11 @@ func (d *DesktopBuilder) processTrayIcons(assetDir string, options *Options) err return nil } +// compileIcon will compile the icon found at /icon.png into the application +func (d *DesktopBuilder) compileIcon(assetDir string, iconFile string) error { + return nil +} + // We will compile all dialog icons found at /icons/dialog/*.png into the application func (d *DesktopBuilder) processDialogIcons(assetDir string, options *Options) error { diff --git a/v2/pkg/commands/build/hybrid.go b/v2/pkg/commands/build/hybrid.go index 8047e20e..d21c78e6 100644 --- a/v2/pkg/commands/build/hybrid.go +++ b/v2/pkg/commands/build/hybrid.go @@ -88,3 +88,8 @@ func (b *HybridBuilder) CleanUp() { b.desktop.CleanUp() b.server.CleanUp() } + +// PostCompilation is called after the compilation step, if successful +func (s *HybridBuilder) PostCompilation(_ *Options) error { + return nil +} diff --git a/v2/pkg/commands/build/server.go b/v2/pkg/commands/build/server.go index e6e34bfb..fd37aebf 100644 --- a/v2/pkg/commands/build/server.go +++ b/v2/pkg/commands/build/server.go @@ -40,6 +40,11 @@ func (s *ServerBuilder) BuildAssets(_ *Options) error { return nil } +// PostCompilation is called after the compilation step, if successful +func (s *ServerBuilder) PostCompilation(_ *Options) error { + return nil +} + // BuildBaseAssets builds the base assets func (s *ServerBuilder) BuildBaseAssets(assets *html.AssetBundle) error { db, err := assets.ConvertToAssetDB()