From f3cedf2f4419c81ea8f580a1f0f6cfe824f8b059 Mon Sep 17 00:00:00 2001 From: Lex Berezhny Date: Thu, 11 Jul 2019 17:20:36 -0400 Subject: [PATCH] added windows build for ver --- dart/packages/ver/windows/.gitignore | 332 ++++++++++++++++++ dart/packages/ver/windows/Runner.sln | 25 ++ dart/packages/ver/windows/Runner.vcxproj | 161 +++++++++ .../ver/windows/Runner.vcxproj.filters | 34 ++ .../ver/windows/flutter_embedder_example.cpp | 73 ++++ .../scripts/bundle_assets_and_deps.bat | 43 +++ .../windows/scripts/prepare_dependencies.bat | 17 + 7 files changed, 685 insertions(+) create mode 100644 dart/packages/ver/windows/.gitignore create mode 100644 dart/packages/ver/windows/Runner.sln create mode 100644 dart/packages/ver/windows/Runner.vcxproj create mode 100644 dart/packages/ver/windows/Runner.vcxproj.filters create mode 100644 dart/packages/ver/windows/flutter_embedder_example.cpp create mode 100644 dart/packages/ver/windows/scripts/bundle_assets_and_deps.bat create mode 100644 dart/packages/ver/windows/scripts/prepare_dependencies.bat diff --git a/dart/packages/ver/windows/.gitignore b/dart/packages/ver/windows/.gitignore new file mode 100644 index 000000000..0f3fe5afa --- /dev/null +++ b/dart/packages/ver/windows/.gitignore @@ -0,0 +1,332 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# Local additions, not from the link above +flutter/ + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ diff --git a/dart/packages/ver/windows/Runner.sln b/dart/packages/ver/windows/Runner.sln new file mode 100644 index 000000000..4492e99a7 --- /dev/null +++ b/dart/packages/ver/windows/Runner.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28307.645 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Runner", "Runner.vcxproj", "{5A827760-CF8B-408A-99A3-B6C0AD2271E7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug|x64.ActiveCfg = Debug|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Debug|x64.Build.0 = Debug|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release|x64.ActiveCfg = Release|x64 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {B8A69CB0-A974-4774-9EBD-1E5EECACD186} + EndGlobalSection +EndGlobal diff --git a/dart/packages/ver/windows/Runner.vcxproj b/dart/packages/ver/windows/Runner.vcxproj new file mode 100644 index 000000000..3f28a6e48 --- /dev/null +++ b/dart/packages/ver/windows/Runner.vcxproj @@ -0,0 +1,161 @@ + + + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {5A827760-CF8B-408A-99A3-B6C0AD2271E7} + GLFWExample + 10.0.17763.0 + + + + Application + true + v141 + v142 + MultiByte + + + Application + false + v141 + v142 + true + MultiByte + + + + + + + + + + + + + + + + + $(ProjectDir)..\build\windows\$(Platform)\$(Configuration)\$(ProjectName)\ + $(ProjectDir)..\build\windows\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ + $(ProjectDir)flutter\;$(ProjectDir)flutter\cpp_client_wrapper\include\;$(IncludePath) + $(ProjectDir)flutter;$(LibraryPath) + Flutter Desktop Example + + + $(ProjectDir)..\build\windows\$(Platform)\$(Configuration)\$(ProjectName)\ + $(ProjectDir)..\build\windows\intermediates\$(Platform)\$(Configuration)\$(ProjectName)\ + $(ProjectDir)flutter\;$(ProjectDir)flutter\cpp_client_wrapper\include\;$(IncludePath) + $(ProjectDir)flutter;$(LibraryPath) + Flutter Desktop Example + + + + Level3 + Disabled + true + true + + + _MBCS;%(PreprocessorDefinitions) + + + flutter_windows.dll.lib;opengl32.lib;%(AdditionalDependencies) + + + "$(ProjectDir)scripts\prepare_dependencies" debug + Sync and build dependencies + + + + + + + + + + + + + + + + + "$(ProjectDir)scripts\bundle_assets_and_deps" "$(ProjectDir)flutter\" "$(OutputPath)" "$(TargetFileName)" + + + Bundling dependencies + Dummy_Run_Always + + + + + + + Level3 + MaxSpeed + true + true + true + true + + + _MBCS;%(PreprocessorDefinitions) + + + true + true + flutter_windows.dll.lib;opengl32.lib;%(AdditionalDependencies) + + + "$(ProjectDir)scripts\prepare_dependencies" release + Sync and build dependencies + + + + + + + + + + + + + + + + + "$(ProjectDir)scripts\bundle_assets_and_deps" "$(ProjectDir)flutter\" "$(OutputPath)" "$(TargetFileName)" + + + Bundling dependencies + Dummy_Run_Always + + + + + + + + + + + + + + + $(SolutionDir) + + diff --git a/dart/packages/ver/windows/Runner.vcxproj.filters b/dart/packages/ver/windows/Runner.vcxproj.filters new file mode 100644 index 000000000..292ae14a0 --- /dev/null +++ b/dart/packages/ver/windows/Runner.vcxproj.filters @@ -0,0 +1,34 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + {2761a4b5-57b2-4d50-a677-d20ddc17a7f1} + + + + + Source Files + + + Source Files\Client Wrapper + + + Source Files\Client Wrapper + + + Source Files\Client Wrapper + + + diff --git a/dart/packages/ver/windows/flutter_embedder_example.cpp b/dart/packages/ver/windows/flutter_embedder_example.cpp new file mode 100644 index 000000000..7253faacf --- /dev/null +++ b/dart/packages/ver/windows/flutter_embedder_example.cpp @@ -0,0 +1,73 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include + +#include "flutter/flutter_window_controller.h" + +// Include windows.h last, to minimize potential conflicts. The CreateWindow +// macro needs to be undefined because it prevents calling +// FlutterWindowController's method. +#include +#undef CreateWindow + +namespace { + +// Returns the path of the directory containing this executable, or an empty +// string if the directory cannot be found. +std::string GetExecutableDirectory() { + char buffer[MAX_PATH]; + if (GetModuleFileName(nullptr, buffer, MAX_PATH) == 0) { + std::cerr << "Couldn't locate executable" << std::endl; + return ""; + } + std::string executable_path(buffer); + size_t last_separator_position = executable_path.find_last_of('\\'); + if (last_separator_position == std::string::npos) { + std::cerr << "Unabled to find parent directory of " << executable_path + << std::endl; + return ""; + } + return executable_path.substr(0, last_separator_position); +} + +} // namespace + +int main(int argc, char **argv) { + // Resources are located relative to the executable. + std::string base_directory = GetExecutableDirectory(); + if (base_directory.empty()) { + base_directory = "."; + } + std::string data_directory = base_directory + "\\data"; + std::string assets_path = data_directory + "\\flutter_assets"; + std::string icu_data_path = data_directory + "\\icudtl.dat"; + + // Arguments for the Flutter Engine. + std::vector arguments; + + flutter::FlutterWindowController flutter_controller(icu_data_path); + + // Start the engine. + if (!flutter_controller.CreateWindow(800, 600, "ver - lbry workbench", + assets_path, arguments)) { + return EXIT_FAILURE; + } + + // Run until the window is closed. + flutter_controller.RunEventLoop(); + return EXIT_SUCCESS; +} diff --git a/dart/packages/ver/windows/scripts/bundle_assets_and_deps.bat b/dart/packages/ver/windows/scripts/bundle_assets_and_deps.bat new file mode 100644 index 000000000..7b5b1d8ce --- /dev/null +++ b/dart/packages/ver/windows/scripts/bundle_assets_and_deps.bat @@ -0,0 +1,43 @@ +:: Copyright 2018 Google LLC +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +@echo off + +set FLUTTER_CACHE_DIR=%~1 +set BUNDLE_DIR=%~2 +set EXE_NAME=%~3 + +set DATA_DIR=%BUNDLE_DIR%data + +if not exist "%DATA_DIR%" call mkdir "%DATA_DIR%" +if %errorlevel% neq 0 exit /b %errorlevel% + +:: Write the executable name to the location expected by the Flutter tool. +echo %EXE_NAME%>"%FLUTTER_CACHE_DIR%exe_filename" + +:: Copy the Flutter assets to the data directory. +set FLUTTER_APP_DIR=%~dp0..\.. +set ASSET_DIR_NAME=flutter_assets +set TARGET_ASSET_DIR=%DATA_DIR%\%ASSET_DIR_NAME% +if exist "%TARGET_ASSET_DIR%" call rmdir /s /q "%TARGET_ASSET_DIR%" +if %errorlevel% neq 0 exit /b %errorlevel% +call xcopy /s /e /i /q "%FLUTTER_APP_DIR%\build\%ASSET_DIR_NAME%" "%TARGET_ASSET_DIR%" +if %errorlevel% neq 0 exit /b %errorlevel% + +:: Copy the icudtl.dat file from the Flutter tree to the data directory. +call xcopy /y /d /q "%FLUTTER_CACHE_DIR%icudtl.dat" "%DATA_DIR%" +if %errorlevel% neq 0 exit /b %errorlevel% + +:: Copy the Flutter DLL to the target location. +call xcopy /y /d /q "%FLUTTER_CACHE_DIR%flutter_windows.dll" "%BUNDLE_DIR%" +if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/dart/packages/ver/windows/scripts/prepare_dependencies.bat b/dart/packages/ver/windows/scripts/prepare_dependencies.bat new file mode 100644 index 000000000..5ce2d74aa --- /dev/null +++ b/dart/packages/ver/windows/scripts/prepare_dependencies.bat @@ -0,0 +1,17 @@ +:: Copyright 2018 Google LLC +:: +:: Licensed under the Apache License, Version 2.0 (the "License"); +:: you may not use this file except in compliance with the License. +:: You may obtain a copy of the License at +:: +:: http://www.apache.org/licenses/LICENSE-2.0 +:: +:: Unless required by applicable law or agreed to in writing, software +:: distributed under the License is distributed on an "AS IS" BASIS, +:: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +:: See the License for the specific language governing permissions and +:: limitations under the License. +@echo off + +set BUILD_MODE=%~1 +"%FLUTTER_ROOT%\packages\flutter_tools\bin\tool_backend" windows-x64 %BUILD_MODE%