diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3db418a54f..9c35d7d50f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,7 +7,7 @@ on: jobs: create-release: name: Create draft release - runs-on: ubuntu-18.04 + runs-on: ubuntu-20.04 outputs: upload_url: ${{ steps.create_release.outputs.upload_url }} steps: @@ -26,20 +26,28 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - target: [macos, windows, linux, apk] + target: [macos, windows, linux, android] include: - - os: macos-10.15 + - os: macos-10.15 # Catalina target: macos path: build/macos/Build/Products/Release + asset_extension: .zip + asset_content_type: application/zip - os: windows-2019 target: windows path: build\windows\runner\Release - - os: ubuntu-18.04 + asset_extension: .zip + asset_content_type: application/zip + - os: ubuntu-20.04 target: linux - path: build/linux/release/bundle - - os: ubuntu-18.04 - target: apk - path: build/app/outputs/apk/release/ + path: build/linux/x64/release/bundle + asset_extension: .tar.gz + asset_content_type: application/gzip + - os: ubuntu-20.04 + target: android + path: build/app/outputs/flutter-apk + asset_extension: .apk + asset_content_type: application/vnd.android.package-archive # Disable fail-fast as we want results from all even if one fails. fail-fast: false needs: create-release @@ -52,23 +60,24 @@ jobs: ref: 'master' path: 'flutter' fetch-depth: 0 - - name: Add Flutter to the PATH for Linux and macOS - if: startsWith(matrix.os, 'macOS') || startsWith(matrix.os, 'ubuntu') + - name: Add Flutter to the PATH for Linux, macOS, Android + if: matrix.target != 'windows' run: echo "$GITHUB_WORKSPACE/flutter/bin" >> $GITHUB_PATH - name: Add Flutter to the PATH for Windows - if: startsWith(matrix.os, 'windows') + if: matrix.target == 'windows' run: echo "${env:GITHUB_WORKSPACE}\flutter\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - name: Install Linux dependencies - if: startsWith(matrix.target, 'linux') + if: matrix.target == 'linux' run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev libx11-dev pkg-config cmake ninja-build libblkid-dev - name: Install Android dependencies - if: startsWith(matrix.target, 'apk') + if: matrix.target == 'android' uses: actions/setup-java@v1 with: java-version: '12.x' - name: Enable desktop support + if: matrix.target != 'android' run: | flutter config --enable-linux-desktop flutter config --enable-macos-desktop @@ -81,31 +90,41 @@ jobs: uses: actions/checkout@v2 with: path: 'code' - - name: Get packages for the Flutter project - run: flutter pub get - working-directory: code - # Build the application for desktop. + # Build the application. - name: Build project run: | flutter create . + flutter pub get flutter build -v ${{ matrix.target }} --release working-directory: code - - name: Copy VC redistributables to release directory - if: startsWith(matrix.target, 'windows') + + # Package the build. + - name: Copy VC redistributables to release directory for Windows + if: matrix.target == 'windows' run: | - Copy-Item (vswhere -find 'VC\Redist\MSVC\14.27.29016\x64\Microsoft.VC142.CRT\msvcp140.dll') . - Copy-Item (vswhere -find 'VC\Redist\MSVC\14.27.29016\x64\Microsoft.VC142.CRT\vcruntime140.dll') . - Copy-Item (vswhere -find 'VC\Redist\MSVC\14.27.29016\x64\Microsoft.VC142.CRT\vcruntime140_1.dll') . + Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\msvcp140.dll') . + Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140.dll') . + Copy-Item (vswhere -latest -find 'VC\Redist\MSVC\*\x64\*\vcruntime140_1.dll') . working-directory: code\${{ matrix.path }} - - name: Compress build for Linux and macOS - if: startsWith(matrix.os, 'macOS') || startsWith(matrix.os, 'ubuntu') - run: zip -r $GITHUB_WORKSPACE/flutter_gallery_${{ matrix.target }} . + - name: Rename build for Android + if: matrix.target == 'android' + run: mv app-release.apk $GITHUB_WORKSPACE/flutter_gallery_${{ matrix.target }}.apk + working-directory: code/${{ matrix.path }} + - name: Compress build for Linux + if: matrix.target == 'linux' + run: tar czf $GITHUB_WORKSPACE/flutter_gallery_${{ matrix.target }}.tar.gz * + working-directory: code/${{ matrix.path }} + - name: Compress build for macOS + if: matrix.target == 'macos' + run: ditto -c -k --sequesterRsrc --keepParent Flutter\ Gallery.app $GITHUB_WORKSPACE/flutter_gallery_${{ matrix.target }}.zip working-directory: code/${{ matrix.path }} - name: Compress build for Windows - if: startsWith(matrix.os, 'windows') + if: matrix.target == 'windows' run: compress-archive -Path * -DestinationPath ${env:GITHUB_WORKSPACE}\flutter_gallery_${{ matrix.target }}.zip working-directory: code\${{ matrix.path }} + + # Upload the build. - name: Upload release asset id: upload_release_asset uses: actions/upload-release-asset@v1 @@ -113,6 +132,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ needs.create-release.outputs.upload_url }} - asset_path: ./flutter_gallery_${{ matrix.target }}.zip - asset_name: flutter_gallery_${{ matrix.target }}.zip - asset_content_type: application/zip + asset_path: ./flutter_gallery_${{ matrix.target }}${{ matrix.asset_extension }} + asset_name: flutter_gallery_${{ matrix.target }}${{ matrix.asset_extension }} + asset_content_type: ${{ matrix.asset_content_type }} diff --git a/golden_test/goldens/home_page_desktop_dark.png b/golden_test/goldens/home_page_desktop_dark.png index 221f809785..d31e619e88 100644 Binary files a/golden_test/goldens/home_page_desktop_dark.png and b/golden_test/goldens/home_page_desktop_dark.png differ diff --git a/golden_test/goldens/home_page_desktop_light.png b/golden_test/goldens/home_page_desktop_light.png index 320f95c1de..9d6da86bd0 100644 Binary files a/golden_test/goldens/home_page_desktop_light.png and b/golden_test/goldens/home_page_desktop_light.png differ diff --git a/golden_test/goldens/home_page_mobile_dark.png b/golden_test/goldens/home_page_mobile_dark.png index 2713f6abb2..9e71325106 100644 Binary files a/golden_test/goldens/home_page_mobile_dark.png and b/golden_test/goldens/home_page_mobile_dark.png differ diff --git a/golden_test/goldens/home_page_mobile_light.png b/golden_test/goldens/home_page_mobile_light.png index 1e1f465d06..67633277c7 100644 Binary files a/golden_test/goldens/home_page_mobile_light.png and b/golden_test/goldens/home_page_mobile_light.png differ diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 026851fa2f..f6f23bfe97 100644 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + #include "generated_plugin_registrant.h" #include diff --git a/linux/flutter/generated_plugin_registrant.h b/linux/flutter/generated_plugin_registrant.h index 9bf7478940..e0f0a47bc0 100644 --- a/linux/flutter/generated_plugin_registrant.h +++ b/linux/flutter/generated_plugin_registrant.h @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + #ifndef GENERATED_PLUGIN_REGISTRANT_ #define GENERATED_PLUGIN_REGISTRANT_ diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index fc6bf65d13..799722a06d 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + import FlutterMacOS import Foundation diff --git a/pubspec.lock b/pubspec.lock index 725fd84838..86dd02f52d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "16.0.0" + version: "17.0.0" adaptive_breakpoints: dependency: "direct main" description: @@ -21,14 +21,14 @@ packages: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.0" animations: dependency: "direct main" description: name: animations url: "https://pub.dartlang.org" source: hosted - version: "2.0.0-nullsafety.0" + version: "2.0.0" archive: dependency: transitive description: @@ -157,7 +157,7 @@ packages: name: flutter_gallery_assets url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "1.0.2" flutter_localizations: dependency: "direct main" description: flutter @@ -247,7 +247,7 @@ packages: name: io url: "https://pub.dartlang.org" source: hosted - version: "0.3.4" + version: "0.3.5" js: dependency: transitive description: @@ -324,35 +324,35 @@ packages: name: path_provider url: "https://pub.dartlang.org" source: hosted - version: "2.0.0-nullsafety.1" + version: "2.0.0" path_provider_linux: dependency: transitive description: name: path_provider_linux url: "https://pub.dartlang.org" source: hosted - version: "0.2.0-nullsafety" + version: "2.0.0" path_provider_macos: dependency: transitive description: name: path_provider_macos url: "https://pub.dartlang.org" source: hosted - version: "0.0.5-nullsafety" + version: "2.0.0" path_provider_platform_interface: dependency: transitive description: name: path_provider_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0-nullsafety" + version: "2.0.0" path_provider_windows: dependency: transitive description: name: path_provider_windows url: "https://pub.dartlang.org" source: hosted - version: "0.1.0-nullsafety.3" + version: "2.0.0" pedantic: dependency: "direct dev" description: @@ -373,7 +373,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.1" + version: "2.0.0" pool: dependency: transitive description: @@ -394,7 +394,7 @@ packages: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0-nullsafety.4" + version: "5.0.0-nullsafety.5" pub_semver: dependency: transitive description: @@ -443,7 +443,7 @@ packages: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "0.2.4" + version: "0.2.4+1" shrine_images: dependency: "direct main" description: @@ -518,7 +518,7 @@ packages: name: test url: "https://pub.dartlang.org" source: hosted - version: "1.16.2" + version: "1.16.4" test_api: dependency: transitive description: @@ -532,7 +532,7 @@ packages: name: test_core url: "https://pub.dartlang.org" source: hosted - version: "0.3.13" + version: "0.3.14" typed_data: dependency: transitive description: @@ -546,42 +546,42 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.0-nullsafety.7" + version: "6.0.1" url_launcher_linux: dependency: transitive description: name: url_launcher_linux url: "https://pub.dartlang.org" source: hosted - version: "0.1.0-nullsafety.3" + version: "2.0.0" url_launcher_macos: dependency: transitive description: name: url_launcher_macos url: "https://pub.dartlang.org" source: hosted - version: "0.1.0-nullsafety.2" + version: "2.0.0" url_launcher_platform_interface: dependency: transitive description: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0-nullsafety.1" + version: "2.0.1" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0-nullsafety" + version: "2.0.0" url_launcher_windows: dependency: transitive description: name: url_launcher_windows url: "https://pub.dartlang.org" source: hosted - version: "0.1.0-nullsafety.2" + version: "2.0.0" vector_math: dependency: "direct main" description: @@ -616,7 +616,7 @@ packages: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.0.0" webdriver: dependency: transitive description: @@ -651,7 +651,7 @@ packages: name: yaml url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.1.0" sdks: - dart: ">=2.12.0-259.9.beta <3.0.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=1.24.0-6.0.pre" diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index a0d2880455..cc31d66bd0 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.15) project(gallery LANGUAGES CXX) -set(BINARY_NAME "flutter_gallery") +set(BINARY_NAME "gallery") cmake_policy(SET CMP0063 NEW) diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt index c7a8c7607d..b02c5485c9 100644 --- a/windows/flutter/CMakeLists.txt +++ b/windows/flutter/CMakeLists.txt @@ -23,6 +23,7 @@ list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" + "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) @@ -91,6 +92,7 @@ add_custom_command( ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ + VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index ddfcf7c328..d9fdd53925 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + #include "generated_plugin_registrant.h" #include diff --git a/windows/flutter/generated_plugin_registrant.h b/windows/flutter/generated_plugin_registrant.h index 9846246b4d..dc139d85a9 100644 --- a/windows/flutter/generated_plugin_registrant.h +++ b/windows/flutter/generated_plugin_registrant.h @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + #ifndef GENERATED_PLUGIN_REGISTRANT_ #define GENERATED_PLUGIN_REGISTRANT_ diff --git a/windows/runner/Runner.rc b/windows/runner/Runner.rc index ae08c6d830..f479300784 100644 --- a/windows/runner/Runner.rc +++ b/windows/runner/Runner.rc @@ -93,7 +93,7 @@ BEGIN VALUE "FileDescription", "A new Flutter project." "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "InternalName", "gallery" "\0" - VALUE "LegalCopyright", "Copyright (C) 2020 io.flutter.demo. All rights reserved." "\0" + VALUE "LegalCopyright", "Copyright (C) 2021 io.flutter.demo. All rights reserved." "\0" VALUE "OriginalFilename", "gallery.exe" "\0" VALUE "ProductName", "gallery" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" diff --git a/windows/runner/main.cpp b/windows/runner/main.cpp index b433698437..01cdb323a1 100644 --- a/windows/runner/main.cpp +++ b/windows/runner/main.cpp @@ -21,6 +21,12 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, RunLoop run_loop; flutter::DartProject project(L"data"); + + std::vector command_line_arguments = + GetCommandLineArguments(); + + project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); + FlutterWindow window(&run_loop, project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp index 37501e5db7..d19bdbbcc3 100644 --- a/windows/runner/utils.cpp +++ b/windows/runner/utils.cpp @@ -20,3 +20,45 @@ void CreateAndAttachConsole() { FlutterDesktopResyncOutputStreams(); } } + +std::vector GetCommandLineArguments() { + // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. + int argc; + wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + if (argv == nullptr) { + return std::vector(); + } + + std::vector command_line_arguments; + + // Skip the first argument as it's the binary name. + for (int i = 1; i < argc; i++) { + command_line_arguments.push_back(Utf8FromUtf16(argv[i])); + } + + ::LocalFree(argv); + + return command_line_arguments; +} + +std::string Utf8FromUtf16(const wchar_t* utf16_string) { + if (utf16_string == nullptr) { + return std::string(); + } + int target_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, nullptr, 0, nullptr, nullptr); + if (target_length == 0) { + return std::string(); + } + std::string utf8_string; + utf8_string.resize(target_length); + int converted_length = ::WideCharToMultiByte( + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, + -1, utf8_string.data(), + target_length, nullptr, nullptr); + if (converted_length == 0) { + return std::string(); + } + return utf8_string; +} diff --git a/windows/runner/utils.h b/windows/runner/utils.h index d792603bb1..3879d54755 100644 --- a/windows/runner/utils.h +++ b/windows/runner/utils.h @@ -1,8 +1,19 @@ #ifndef RUNNER_UTILS_H_ #define RUNNER_UTILS_H_ +#include +#include + // Creates a console for the process, and redirects stdout and stderr to // it for both the runner and the Flutter library. void CreateAndAttachConsole(); +// Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string +// encoded in UTF-8. Returns an empty std::string on failure. +std::string Utf8FromUtf16(const wchar_t* utf16_string); + +// Gets the command line arguments passed in as a std::vector, +// encoded in UTF-8. Returns an empty std::vector on failure. +std::vector GetCommandLineArguments(); + #endif // RUNNER_UTILS_H_ diff --git a/windows/runner/win32_window.cpp b/windows/runner/win32_window.cpp index efc3eb9f22..c10f08dc7d 100644 --- a/windows/runner/win32_window.cpp +++ b/windows/runner/win32_window.cpp @@ -173,7 +173,7 @@ Win32Window::MessageHandler(HWND hwnd, return 0; } - case WM_SIZE: + case WM_SIZE: { RECT rect = GetClientArea(); if (child_content_ != nullptr) { // Size and position the child window. @@ -181,6 +181,7 @@ Win32Window::MessageHandler(HWND hwnd, rect.bottom - rect.top, TRUE); } return 0; + } case WM_ACTIVATE: if (child_content_ != nullptr) {