Skip to content

Merge from google/flutter-desktop-embedding@master #4

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 13 commits into from
Jan 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 35 additions & 0 deletions .travis.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
matrix:
include:
- os: linux
languge: cpp
before_install:
- sudo apt-get update
install:
- build/travis/linux/install_dependencies
- build/travis/install_flutter $TRAVIS_BUILD_DIR/..
before_script:
- export PATH=$PATH:$TRAVIS_BUILD_DIR/../flutter/bin:$TRAVIS_BUILD_DIR/bin
script:
- make -C example/linux

- os: linux
languge: cpp
before_install:
- sudo apt-get update
install:
- build/travis/linux/install_dependencies
- build/travis/install_flutter $TRAVIS_BUILD_DIR/..
- sudo apt-get install -y ninja-build
- build/travis/linux/install_gn bin
before_script:
- export PATH=$PATH:$TRAVIS_BUILD_DIR/bin
script:
- make -C example/linux USE_GN=1

- os: osx
language: objective-c
xcode_project: example/macos/ExmapleEmbedder.xcodeproj
xcode_scheme: ExampleEmbedder
install:
- build/travis/install_flutter $TRAVIS_BUILD_DIR/..

16 changes: 16 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,19 @@ All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

## Project Standards

- C++ code should follow
[Google's C++ style guide](https://google.github.io/styleguide/cppguide.html).
- Objective-C code should follow
[Google's Objective-C style guide](http://google.github.io/styleguide/objcguide.html).
- For C++ and Objective-C code, please run `clang-format -style=file` on files
you have changed if possible. If you don't have `clang-format`, don't worry;
a project member can do it prior to submission.
- Dart code should follow the
[Dart style guide](https://www.dartlang.org/guides/language/effective-dart/style)
and use `dartfmt`.
- Build scripts and other tooling should be written it Dart. (Some existing
scripts are `bash` or `.bat` scripts; if you need to make non-trivial changes
to one of those scripts, please convert it to Dart first if possible.)
2 changes: 1 addition & 1 deletion Debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ There are two options:
1. **Hard-code the port**. In your embedder code, add `--observatory-port=49494`
(substituting a port of your choice) to the list of arguments passed to the
engine. If you are using `example/`, or code based on it, look for the
line that adds `--dart-non-checked-mode` for an example of adding arguments.
line that adds `--disable-dart-asserts` for an example of adding arguments.
(Be sure not to add the `observatory-port` argument inside the `#if`,
however.)

Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Desktop Embedding for Flutter

This purpose of this project is to support building
The purpose of this project is to support building
applications that use [Flutter](https://github.com/flutter/flutter)
on Windows, macOS, and Linux.

It consists of libraries that implement [Flutter's embedding
API](https://github.com/flutter/engine/wiki/Custom-Flutter-Engine-Embedders),
API](https://github.com/flutter/flutter/wiki/Custom-Flutter-Engine-Embedders),
handling drawing and mouse/keyboard input, as well as
optional plugins to access other native platform functionality.

Expand All @@ -25,7 +25,7 @@ a Flutter tree in the same parent directory as the clone of this project:
Alternately, you can place a `.flutter_location_config` file in the directory
containing flutter-desktop-embedding, containing a path to the Flutter tree to
use, if you prefer not to have the Flutter tree next to
flutter-desktop-emebbing.
flutter-desktop-embedding.

### Repository Structure

Expand Down Expand Up @@ -82,4 +82,3 @@ speed up the debugging process.
request, or [write a plugin](plugins/README.md#writing-your-own-plugins)!
* The Linux and Windows implementations currently use GLFW. This is not going
to be the final implementation for either platform.
* Plugins and text input do not yet work on Windows.
40 changes: 40 additions & 0 deletions build/travis/install_flutter
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# 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.

set -e

readonly CHANNEL="stable"
readonly VERSION="1.0.0"

if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
readonly FLUTTER_OS="linux"
readonly ARCHIVE_EXTENSION="tar.xz"
else
readonly FLUTTER_OS="macos"
readonly ARCHIVE_EXTENSION="zip"
fi
readonly DOWNLOAD_BASE="https://storage.googleapis.com/flutter_infra/releases"
readonly DOWNLOAD_URI="${DOWNLOAD_BASE}/${CHANNEL}/${FLUTTER_OS}/flutter_${FLUTTER_OS}_v${VERSION}-${CHANNEL}.${ARCHIVE_EXTENSION}"
readonly TEMP_LOCATION="/tmp/flutter.${ARCHIVE_EXTENSION}"

echo "Downloading ${DOWNLOAD_URI}"
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
wget "${DOWNLOAD_URI}" -O "${TEMP_LOCATION}"
tar xf "${TEMP_LOCATION}" -C "$1"
else
curl -o "${TEMP_LOCATION}" "${DOWNLOAD_URI}"
unzip "${TEMP_LOCATION}" -d "$1"
fi
20 changes: 20 additions & 0 deletions build/travis/linux/install_dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
#
# 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.

set -e

sudo apt-get install -y libglfw3-dev libepoxy-dev libjsoncpp-dev libgtk-3-dev \
libx11-dev pkg-config
23 changes: 23 additions & 0 deletions build/travis/linux/install_gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
#
# 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.

set -e

readonly DOWNLOAD_URI=https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest
readonly TEMP_LOCATION=/tmp/gn.zip

wget -O "${TEMP_LOCATION}" "${DOWNLOAD_URI}"
unzip -d "$1" "${TEMP_LOCATION}"
5 changes: 4 additions & 1 deletion example/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ ALL_LIBS=$(FLUTTER_EMBEDDER_LIB) $(FLUTTER_ENGINE_LIB) $(PLUGIN_LIBS)
# Headers
PLUGIN_DIRS=$(patsubst %,$(PLUGINS_DIR)/%/linux,$(PLUGIN_NAMES))
LIBRARY_DIRS=$(FLUTTER_EMBEDDER_LIB_DIR) $(PLUGIN_DIRS)
INCLUDE_DIRS=$(patsubst %,%/include,$(LIBRARY_DIRS))
INCLUDE_DIRS=$(patsubst %,%/include,$(LIBRARY_DIRS)) $(PROJECT_ROOT)/library/include

# Tools
BUILD_ASSETS_BIN=$(TOOLS_DIR)/build_flutter_assets
Expand Down Expand Up @@ -85,6 +85,9 @@ endif
CXX=g++ -std=c++14
CXXFLAGS=-Wall -Werror $(shell pkg-config --cflags jsoncpp)
CPPFLAGS=$(patsubst %,-I%,$(INCLUDE_DIRS))
ifdef USE_GN
CPPFLAGS+=-DUSE_FLATTENED_INCLUDES
endif
LDFLAGS=-L$(OUT_LIB_DIR) \
-lglfw \
$(shell pkg-config --libs jsoncpp) \
Expand Down
13 changes: 9 additions & 4 deletions example/linux/flutter_embedder_example.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@

#include <color_panel/color_panel_plugin.h>
#include <file_chooser/file_chooser_plugin.h>
#include <flutter_desktop_embedding/embedder.h>
#include <menubar/menubar_plugin.h>

#ifdef USE_FLATTENED_INCLUDES
#include <flutter_desktop_embedding/embedder.h>
#else
#include <flutter_desktop_embedding/glfw/embedder.h>
#endif

namespace {

// Returns the path of the directory containing this executable, or an empty
Expand All @@ -48,7 +53,7 @@ std::string GetExecutableDirectory() {
} // namespace

int main(int argc, char **argv) {
if (!glfwInit()) {
if (!flutter_desktop_embedding::FlutterInit()) {
std::cerr << "Couldn't init GLFW" << std::endl;
}

Expand All @@ -67,13 +72,13 @@ int main(int argc, char **argv) {
// args.
arguments.push_back(argv[0]);
#ifdef NDEBUG
arguments.push_back("--dart-non-checked-mode");
arguments.push_back("--disable-dart-asserts");
#endif
// Start the engine.
auto window = flutter_desktop_embedding::CreateFlutterWindowInSnapshotMode(
640, 480, assets_path, icu_data_path, arguments);
if (window == nullptr) {
glfwTerminate();
flutter_desktop_embedding::FlutterTerminate();
return EXIT_FAILURE;
}

Expand Down
10 changes: 7 additions & 3 deletions example/macos/ExampleEmbedder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@
33CC10EC2044A3C60003C045 = {
CreatedOnToolsVersion = 9.2;
LastSwiftMigration = 0920;
ProvisioningStyle = Automatic;
ProvisioningStyle = Manual;
};
33CC111A2044C6BA0003C045 = {
CreatedOnToolsVersion = 9.2;
Expand Down Expand Up @@ -526,12 +526,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.google.FlutterEmbedderMacExample.Example-Embedder";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Example Embedder-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
Expand All @@ -543,12 +545,14 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.google.FlutterEmbedderMacExample.Example-Embedder";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OBJC_BRIDGING_HEADER = "Example Embedder-Bridging-Header.h";
SWIFT_VERSION = 4.0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "Example Embedder.app"
BlueprintName = "Example Embedder"
ReferencedContainer = "container:ExampleEmbedder.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "Example Embedder.app"
BlueprintName = "Example Embedder"
ReferencedContainer = "container:ExampleEmbedder.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "Example Embedder.app"
BlueprintName = "Example Embedder"
ReferencedContainer = "container:ExampleEmbedder.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
BuildableName = "Example Embedder.app"
BlueprintName = "Example Embedder"
ReferencedContainer = "container:ExampleEmbedder.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion example/macos/ExampleWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ExampleWindow: NSWindow {
// command line string.
var arguments = [CommandLine.arguments[0]];
#if !DEBUG
arguments.append("--dart-non-checked-mode");
arguments.append("--disable-dart-asserts");
#endif
flutterViewController.launchEngine(
withAssetsPath: assets,
Expand Down
Loading