Skip to content

Fixed broken symlink & added icudtl.dat download #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d6b50c8
Enhanced version management
Nov 24, 2018
fa4aa79
Merge remote-tracking branch 'draki/master'
Nov 24, 2018
53be955
Added downloader tracker
Nov 25, 2018
1947a5f
Func to unexported
Nov 25, 2018
c6ec92d
Added confirmation message to overwrite and unzip support (partially)
Nov 26, 2018
cc551fe
Updated Readme
Nov 26, 2018
583a3e2
Finished zip implementation depending on OS. And move files unzipped …
Nov 26, 2018
35f1f2b
Updated README
Nov 27, 2018
cab7108
omit type (inferred)
Nov 27, 2018
aa8ed97
Fixed var name & fixe path
Nov 27, 2018
9b15037
[Prompt for overwrite] [Y/n] prompt default.
Nov 27, 2018
8fb88c0
Adds where the downloaded engine is stored
Nov 27, 2018
29bccbd
Update README.md
Nov 27, 2018
5096eaa
Rename downloader
Nov 27, 2018
afacf0b
Merge pull request #1 from Drakirus/zephylac-master
zephylac Nov 27, 2018
9e4473a
Adding icudtl download
Nov 27, 2018
55d568b
Pull
Nov 27, 2018
82405c7
Download and unzip icudtl.dat
Nov 27, 2018
92108c9
Download icudtl.dat depending on installed flutter version
Nov 27, 2018
e252518
Use icudtl.dat downloaded from install script
Nov 27, 2018
f5bbcfe
Fixed broken symlink for Mac Version & finished artifacts download
Nov 27, 2018
fda0e7e
Use icudtl.dat from script
Nov 27, 2018
37a020e
pull origin
Nov 27, 2018
daf6e1a
Deleted unused code
Nov 27, 2018
e7ef703
Use icudtl.dat downloaded
Nov 28, 2018
c967348
Download icudtl.dat & fix broken symlink & display export
Nov 28, 2018
b4a7a9c
pull origin
Nov 28, 2018
c441333
Fixed bad english
Nov 28, 2018
4aeed24
Fixed symlink
Nov 28, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 61 additions & 8 deletions example/simpleDemo/engineDownloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ import (
"time"
)

func createSymLink(symlink string, file string) {

os.Remove(symlink)

err := os.Symlink(file, symlink)
if err != nil {
log.Fatal(err)
}
}

// Unzip will decompress a zip archive, moving all files and folders
// within the zip file (parameter 1) to an output directory (parameter 2).
func unzip(src string, dest string) ([]string, error) {
Expand Down Expand Up @@ -128,7 +138,7 @@ func printDownloadPercent(done chan int64, path string, total int64) {
size = 1
}

var percent float64 = float64(size) / float64(total) * 100
var percent = float64(size) / float64(total) * 100

// We use `\033[2K\r` to avoid carriage return, it will print above previous.
fmt.Printf("\033[2K\r %.0f %% / 100 %%", percent)
Expand All @@ -154,6 +164,7 @@ func downloadFile(filepath string, url string) error {
os.Exit(0)
}
}

start := time.Now()

// Create the file
Expand Down Expand Up @@ -242,45 +253,85 @@ func main() {
}

var platform = "undefined"
var downloadURL = ""
var downloadShareLibraryURL = ""
var endMessage = ""

// Retrieve the OS and set variable to retrieve correct flutter embedder
switch runtime.GOOS {
case "darwin":
platform = "darwin-x64"
downloadURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/FlutterEmbedder.framework.zip", hashResponse.Items[0].Sha, platform)
downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/FlutterEmbedder.framework.zip", hashResponse.Items[0].Sha, platform)
endMessage = "export CGO_LDFLAGS=\"-F${PWD} -Wl,-rpath,@executable_path\""

case "linux":
platform = "linux-x64"
downloadURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
endMessage = "export CGO_LDFLAGS=\"-L${PWD}\""

case "windows":
platform = "windows-x64"
downloadURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
downloadShareLibraryURL = fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/%s-embedder", hashResponse.Items[0].Sha, platform, platform)
endMessage = "set CGO_LDFLAGS=-L%cd%"

default:
log.Fatal("OS not supported")
}

err3 := downloadFile(dir+"/.build/temp.zip", downloadURL)
downloadIcudtlURL := fmt.Sprintf("https://storage.googleapis.com/flutter_infra/flutter/%s/%s/artifacts.zip", hashResponse.Items[0].Sha, platform)

err3 := downloadFile(dir+"/.build/temp.zip", downloadShareLibraryURL)
if err3 != nil {
log.Fatal(err3)
} else {
fmt.Printf("Downloaded embedder for %s platform, matching version : %s\n", platform, hashResponse.Items[0].Sha)
}

err4 := downloadFile(dir+"/.build/artifacts.zip", downloadIcudtlURL)
if err != nil {
log.Fatal(err4)
} else {
fmt.Printf("Downloaded artifact for %s platform.\n", platform)
}

_, err = unzip(".build/temp.zip", dir+"/.build/")
if err != nil {
log.Fatal(err)
}

_, err = unzip(".build/artifacts.zip", dir+"/.build/artifacts/")
if err != nil {
log.Fatal(err)
}

err = os.Rename(".build/artifacts/icudtl.dat", dir+"/icudtl.dat")
if err != nil {
log.Fatal(err)
}

switch platform {
case "darwin-x64":
_, err = unzip(".build/FlutterEmbedder.framework.zip", dir+"/FlutterEmbedder.framework")
_, err = unzip(dir+"/.build/FlutterEmbedder.framework.zip", dir+"/.build/FlutterEmbedder.framework/")
if err != nil {
log.Fatal(err)
}

os.RemoveAll(dir + "/FlutterEmbedder.framework")

err := os.Rename(dir+"/.build/FlutterEmbedder.framework/", dir+"/FlutterEmbedder.framework/")
if err != nil {
log.Fatal(err)
}

createSymLink(dir+"/FlutterEmbedder.framework/Versions/Current", dir+"/FlutterEmbedder.framework/Versions/A")

createSymLink(dir+"/FlutterEmbedder.framework/FlutterEmbedder", dir+"/FlutterEmbedder.framework/Versions/Current/FlutterEmbedder")

createSymLink(dir+"/FlutterEmbedder.framework/Headers", dir+"/FlutterEmbedder.framework/Versions/Current/Headers")

createSymLink(dir+"/FlutterEmbedder.framework/Modules", dir+"/FlutterEmbedder.framework/Versions/Current/Modules")

createSymLink(dir+"/FlutterEmbedder.framework/Resources", dir+"/FlutterEmbedder.framework/Versions/Current/Resources")

case "linux-x64":
err := os.Rename(".build/libflutter_engine.so", dir+"/libflutter_engine.so")
if err != nil {
Expand All @@ -296,6 +347,8 @@ func main() {
}
fmt.Printf("Unzipped files and moved them to correct repository.\n")

fmt.Printf("Done.\n")
fmt.Printf("\nTo let know the CGO compiler where to look for the share library, Please run:\n\t")
fmt.Printf("%s\n", endMessage)

fmt.Printf("Done.\n")
}
2 changes: 1 addition & 1 deletion example/simpleDemo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func main() {
* Linux : flutter/bin/cache/artifacts/engine/linux-x64/icudtl.dat
* Windows : flutter/bin/cache/artifacts/engine/windows-x64/icudtl.dat
*/
gutter.OptionICUDataPath("/opt/flutter/bin/cache/artifacts/engine/linux-x64/icudtl.dat"),
gutter.OptionICUDataPath(dir + "/icudtl.dat"),
gutter.OptionWindowInitializer(setIcon),
gutter.OptionWindowDimension(800, 600),
gutter.OptionWindowInitializer(setIcon),
Expand Down