Skip to content

Commit c06222b

Browse files
authored
Merge pull request #4 from google/master
Merge from google/flutter-desktop-embedding@master
2 parents a33f8e3 + 370f17f commit c06222b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+764
-564
lines changed

.travis.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
matrix:
2+
include:
3+
- os: linux
4+
languge: cpp
5+
before_install:
6+
- sudo apt-get update
7+
install:
8+
- build/travis/linux/install_dependencies
9+
- build/travis/install_flutter $TRAVIS_BUILD_DIR/..
10+
before_script:
11+
- export PATH=$PATH:$TRAVIS_BUILD_DIR/../flutter/bin:$TRAVIS_BUILD_DIR/bin
12+
script:
13+
- make -C example/linux
14+
15+
- os: linux
16+
languge: cpp
17+
before_install:
18+
- sudo apt-get update
19+
install:
20+
- build/travis/linux/install_dependencies
21+
- build/travis/install_flutter $TRAVIS_BUILD_DIR/..
22+
- sudo apt-get install -y ninja-build
23+
- build/travis/linux/install_gn bin
24+
before_script:
25+
- export PATH=$PATH:$TRAVIS_BUILD_DIR/bin
26+
script:
27+
- make -C example/linux USE_GN=1
28+
29+
- os: osx
30+
language: objective-c
31+
xcode_project: example/macos/ExmapleEmbedder.xcodeproj
32+
xcode_scheme: ExampleEmbedder
33+
install:
34+
- build/travis/install_flutter $TRAVIS_BUILD_DIR/..
35+

CONTRIBUTING.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,19 @@ All submissions, including submissions by project members, require review. We
2121
use GitHub pull requests for this purpose. Consult
2222
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
2323
information on using pull requests.
24+
25+
## Project Standards
26+
27+
- C++ code should follow
28+
[Google's C++ style guide](https://google.github.io/styleguide/cppguide.html).
29+
- Objective-C code should follow
30+
[Google's Objective-C style guide](http://google.github.io/styleguide/objcguide.html).
31+
- For C++ and Objective-C code, please run `clang-format -style=file` on files
32+
you have changed if possible. If you don't have `clang-format`, don't worry;
33+
a project member can do it prior to submission.
34+
- Dart code should follow the
35+
[Dart style guide](https://www.dartlang.org/guides/language/effective-dart/style)
36+
and use `dartfmt`.
37+
- Build scripts and other tooling should be written it Dart. (Some existing
38+
scripts are `bash` or `.bat` scripts; if you need to make non-trivial changes
39+
to one of those scripts, please convert it to Dart first if possible.)

Debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ There are two options:
3030
1. **Hard-code the port**. In your embedder code, add `--observatory-port=49494`
3131
(substituting a port of your choice) to the list of arguments passed to the
3232
engine. If you are using `example/`, or code based on it, look for the
33-
line that adds `--dart-non-checked-mode` for an example of adding arguments.
33+
line that adds `--disable-dart-asserts` for an example of adding arguments.
3434
(Be sure not to add the `observatory-port` argument inside the `#if`,
3535
however.)
3636

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Desktop Embedding for Flutter
22

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

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

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

3030
### Repository Structure
3131

@@ -82,4 +82,3 @@ speed up the debugging process.
8282
request, or [write a plugin](plugins/README.md#writing-your-own-plugins)!
8383
* The Linux and Windows implementations currently use GLFW. This is not going
8484
to be the final implementation for either platform.
85-
* Plugins and text input do not yet work on Windows.

build/travis/install_flutter

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2018 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
readonly CHANNEL="stable"
20+
readonly VERSION="1.0.0"
21+
22+
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
23+
readonly FLUTTER_OS="linux"
24+
readonly ARCHIVE_EXTENSION="tar.xz"
25+
else
26+
readonly FLUTTER_OS="macos"
27+
readonly ARCHIVE_EXTENSION="zip"
28+
fi
29+
readonly DOWNLOAD_BASE="https://storage.googleapis.com/flutter_infra/releases"
30+
readonly DOWNLOAD_URI="${DOWNLOAD_BASE}/${CHANNEL}/${FLUTTER_OS}/flutter_${FLUTTER_OS}_v${VERSION}-${CHANNEL}.${ARCHIVE_EXTENSION}"
31+
readonly TEMP_LOCATION="/tmp/flutter.${ARCHIVE_EXTENSION}"
32+
33+
echo "Downloading ${DOWNLOAD_URI}"
34+
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
35+
wget "${DOWNLOAD_URI}" -O "${TEMP_LOCATION}"
36+
tar xf "${TEMP_LOCATION}" -C "$1"
37+
else
38+
curl -o "${TEMP_LOCATION}" "${DOWNLOAD_URI}"
39+
unzip "${TEMP_LOCATION}" -d "$1"
40+
fi
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2018 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
sudo apt-get install -y libglfw3-dev libepoxy-dev libjsoncpp-dev libgtk-3-dev \
20+
libx11-dev pkg-config

build/travis/linux/install_gn

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright 2018 Google LLC
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
readonly DOWNLOAD_URI=https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest
20+
readonly TEMP_LOCATION=/tmp/gn.zip
21+
22+
wget -O "${TEMP_LOCATION}" "${DOWNLOAD_URI}"
23+
unzip -d "$1" "${TEMP_LOCATION}"

example/linux/Makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ ALL_LIBS=$(FLUTTER_EMBEDDER_LIB) $(FLUTTER_ENGINE_LIB) $(PLUGIN_LIBS)
3737
# Headers
3838
PLUGIN_DIRS=$(patsubst %,$(PLUGINS_DIR)/%/linux,$(PLUGIN_NAMES))
3939
LIBRARY_DIRS=$(FLUTTER_EMBEDDER_LIB_DIR) $(PLUGIN_DIRS)
40-
INCLUDE_DIRS=$(patsubst %,%/include,$(LIBRARY_DIRS))
40+
INCLUDE_DIRS=$(patsubst %,%/include,$(LIBRARY_DIRS)) $(PROJECT_ROOT)/library/include
4141

4242
# Tools
4343
BUILD_ASSETS_BIN=$(TOOLS_DIR)/build_flutter_assets
@@ -85,6 +85,9 @@ endif
8585
CXX=g++ -std=c++14
8686
CXXFLAGS=-Wall -Werror $(shell pkg-config --cflags jsoncpp)
8787
CPPFLAGS=$(patsubst %,-I%,$(INCLUDE_DIRS))
88+
ifdef USE_GN
89+
CPPFLAGS+=-DUSE_FLATTENED_INCLUDES
90+
endif
8891
LDFLAGS=-L$(OUT_LIB_DIR) \
8992
-lglfw \
9093
$(shell pkg-config --libs jsoncpp) \

example/linux/flutter_embedder_example.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@
2121

2222
#include <color_panel/color_panel_plugin.h>
2323
#include <file_chooser/file_chooser_plugin.h>
24-
#include <flutter_desktop_embedding/embedder.h>
2524
#include <menubar/menubar_plugin.h>
2625

26+
#ifdef USE_FLATTENED_INCLUDES
27+
#include <flutter_desktop_embedding/embedder.h>
28+
#else
29+
#include <flutter_desktop_embedding/glfw/embedder.h>
30+
#endif
31+
2732
namespace {
2833

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

5055
int main(int argc, char **argv) {
51-
if (!glfwInit()) {
56+
if (!flutter_desktop_embedding::FlutterInit()) {
5257
std::cerr << "Couldn't init GLFW" << std::endl;
5358
}
5459

@@ -67,13 +72,13 @@ int main(int argc, char **argv) {
6772
// args.
6873
arguments.push_back(argv[0]);
6974
#ifdef NDEBUG
70-
arguments.push_back("--dart-non-checked-mode");
75+
arguments.push_back("--disable-dart-asserts");
7176
#endif
7277
// Start the engine.
7378
auto window = flutter_desktop_embedding::CreateFlutterWindowInSnapshotMode(
7479
640, 480, assets_path, icu_data_path, arguments);
7580
if (window == nullptr) {
76-
glfwTerminate();
81+
flutter_desktop_embedding::FlutterTerminate();
7782
return EXIT_FAILURE;
7883
}
7984

example/macos/ExampleEmbedder.xcodeproj/project.pbxproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@
254254
33CC10EC2044A3C60003C045 = {
255255
CreatedOnToolsVersion = 9.2;
256256
LastSwiftMigration = 0920;
257-
ProvisioningStyle = Automatic;
257+
ProvisioningStyle = Manual;
258258
};
259259
33CC111A2044C6BA0003C045 = {
260260
CreatedOnToolsVersion = 9.2;
@@ -526,12 +526,14 @@
526526
buildSettings = {
527527
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
528528
CLANG_ENABLE_MODULES = YES;
529-
CODE_SIGN_STYLE = Automatic;
529+
CODE_SIGN_STYLE = Manual;
530530
COMBINE_HIDPI_IMAGES = YES;
531+
DEVELOPMENT_TEAM = "";
531532
INFOPLIST_FILE = Info.plist;
532533
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
533534
PRODUCT_BUNDLE_IDENTIFIER = "com.google.FlutterEmbedderMacExample.Example-Embedder";
534535
PRODUCT_NAME = "$(TARGET_NAME)";
536+
PROVISIONING_PROFILE_SPECIFIER = "";
535537
SWIFT_OBJC_BRIDGING_HEADER = "Example Embedder-Bridging-Header.h";
536538
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
537539
SWIFT_VERSION = 4.0;
@@ -543,12 +545,14 @@
543545
buildSettings = {
544546
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
545547
CLANG_ENABLE_MODULES = YES;
546-
CODE_SIGN_STYLE = Automatic;
548+
CODE_SIGN_STYLE = Manual;
547549
COMBINE_HIDPI_IMAGES = YES;
550+
DEVELOPMENT_TEAM = "";
548551
INFOPLIST_FILE = Info.plist;
549552
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
550553
PRODUCT_BUNDLE_IDENTIFIER = "com.google.FlutterEmbedderMacExample.Example-Embedder";
551554
PRODUCT_NAME = "$(TARGET_NAME)";
555+
PROVISIONING_PROFILE_SPECIFIER = "";
552556
SWIFT_OBJC_BRIDGING_HEADER = "Example Embedder-Bridging-Header.h";
553557
SWIFT_VERSION = 4.0;
554558
};
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1000"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
18+
BuildableName = "Example Embedder.app"
19+
BlueprintName = "Example Embedder"
20+
ReferencedContainer = "container:ExampleEmbedder.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
<MacroExpansion>
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
36+
BuildableName = "Example Embedder.app"
37+
BlueprintName = "Example Embedder"
38+
ReferencedContainer = "container:ExampleEmbedder.xcodeproj">
39+
</BuildableReference>
40+
</MacroExpansion>
41+
<AdditionalOptions>
42+
</AdditionalOptions>
43+
</TestAction>
44+
<LaunchAction
45+
buildConfiguration = "Debug"
46+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
47+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
48+
launchStyle = "0"
49+
useCustomWorkingDirectory = "NO"
50+
ignoresPersistentStateOnLaunch = "NO"
51+
debugDocumentVersioning = "YES"
52+
debugServiceExtension = "internal"
53+
allowLocationSimulation = "YES">
54+
<BuildableProductRunnable
55+
runnableDebuggingMode = "0">
56+
<BuildableReference
57+
BuildableIdentifier = "primary"
58+
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
59+
BuildableName = "Example Embedder.app"
60+
BlueprintName = "Example Embedder"
61+
ReferencedContainer = "container:ExampleEmbedder.xcodeproj">
62+
</BuildableReference>
63+
</BuildableProductRunnable>
64+
<AdditionalOptions>
65+
</AdditionalOptions>
66+
</LaunchAction>
67+
<ProfileAction
68+
buildConfiguration = "Release"
69+
shouldUseLaunchSchemeArgsEnv = "YES"
70+
savedToolIdentifier = ""
71+
useCustomWorkingDirectory = "NO"
72+
debugDocumentVersioning = "YES">
73+
<BuildableProductRunnable
74+
runnableDebuggingMode = "0">
75+
<BuildableReference
76+
BuildableIdentifier = "primary"
77+
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
78+
BuildableName = "Example Embedder.app"
79+
BlueprintName = "Example Embedder"
80+
ReferencedContainer = "container:ExampleEmbedder.xcodeproj">
81+
</BuildableReference>
82+
</BuildableProductRunnable>
83+
</ProfileAction>
84+
<AnalyzeAction
85+
buildConfiguration = "Debug">
86+
</AnalyzeAction>
87+
<ArchiveAction
88+
buildConfiguration = "Release"
89+
revealArchiveInOrganizer = "YES">
90+
</ArchiveAction>
91+
</Scheme>

example/macos/ExampleWindow.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class ExampleWindow: NSWindow {
2727
// command line string.
2828
var arguments = [CommandLine.arguments[0]];
2929
#if !DEBUG
30-
arguments.append("--dart-non-checked-mode");
30+
arguments.append("--disable-dart-asserts");
3131
#endif
3232
flutterViewController.launchEngine(
3333
withAssetsPath: assets,

0 commit comments

Comments
 (0)