Skip to content
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

Separate builds for profiles #67

Merged
Merged
Show file tree
Hide file tree
Changes from 17 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
48 changes: 9 additions & 39 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,39 +68,21 @@ jobs:
--runtime-mode $(mode) \
--embedder-for-target \
--disable-desktop-embeddings \
--build-tizen-shell \
--out-dir output/default
ninja -C output/default/out/linux_$(mode)_$(arch)
--build-tizen-shell
ninja -C out/linux_$(mode)_$(arch)
displayName: Build
workingDirectory: $(buildroot)
failOnStderr: true
- bash: |
flutter/tools/gn \
--target-os linux \
--linux-cpu $(arch) \
--target-toolchain `pwd`/tizen_tools/toolchains \
--target-sysroot `pwd`/tizen_tools/sysroot/$(arch)_40 \
--target-triple $(targetTriple) \
--runtime-mode $(mode) \
--embedder-for-target \
--disable-desktop-embeddings \
--build-tizen-shell \
--tizen-sdk-4 \
--out-dir output/tizen40
ninja -C output/tizen40/out/linux_$(mode)_$(arch)
displayName: Build for Tizen 4.0
workingDirectory: $(buildroot)
condition: ne(variables['arch'], 'arm64')
failOnStderr: true
- bash: |
OUTDIR=$(Build.StagingDirectory)
cp default/out/linux_$(mode)_$(arch)/libflutter_engine.so $OUTDIR
cp default/out/linux_$(mode)_$(arch)/libflutter_tizen.so $OUTDIR
if [[ "$(arch)" != "arm64" ]]; then
cp tizen40/out/linux_$(mode)_$(arch)/libflutter_tizen.so $OUTDIR/libflutter_tizen40.so
cp out/linux_$(mode)_$(arch)/libflutter_*.so $OUTDIR
if [[ $(System.JobName) == "tizen-arm-release" ]]; then
mkdir $OUTDIR/common
cp -r out/linux_$(mode)_$(arch)/{cpp_client_wrapper,icu,public} $OUTDIR/common
rm $OUTDIR/common/cpp_client_wrapper/engine_method_result.cc
fi
displayName: Copy artifacts
workingDirectory: $(buildroot)/output
workingDirectory: $(buildroot)
failOnStderr: true
- publish: $(Build.StagingDirectory)
artifact: $(System.JobName)
Expand All @@ -119,19 +101,7 @@ jobs:
path: src/flutter
- download: current
- bash: |
mkdir -p common/client_wrapper
ROOT=$(Pipeline.Workspace)/src/flutter/shell/platform
cp $ROOT/common/cpp/client_wrapper/*.{h,cc} common/client_wrapper
rm common/client_wrapper/{*_unittests.*,engine_method_result.cc}
cp -r $ROOT/common/cpp/public common
cp -r $ROOT/common/cpp/client_wrapper/include common/client_wrapper
cp $ROOT/tizen/public/*.h common/public
cp $ROOT/tizen/LICENSE .
displayName: Copy headers
workingDirectory: $(Build.BinariesDirectory)
failOnStderr: true
- bash: |
cp $(Pipeline.Workspace)/src/third_party/icu/flutter/icudtl.dat common
mv $(Pipeline.Workspace)/tizen-arm-release/common .
mv $(Pipeline.Workspace)/tizen-* .
for platform in linux windows darwin; do
for arch in arm arm64; do
Expand Down
270 changes: 182 additions & 88 deletions shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,73 +1,39 @@
# Copyright 2020 Samsung Electronics Co., Ltd. All rights reserved.
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//flutter/shell/platform/tizen/config.gni")

group("tizen") {
deps = [ ":flutter_tizen_library" ]
}

shared_library("flutter_tizen_library") {
output_name = "flutter_tizen"
import("//flutter/shell/platform/common/cpp/client_wrapper/publish.gni")
import("//flutter/shell/platform/tizen/config.gni")

# Sets the rpath of dependent targets (shared libs) to $ORIGIN.
# We assume that the flutter_engine library exists next to the embedder library
# when they are deployed on Tizen devices.
config("tizen_embedder_rpath") {
ldflags = [ "-Wl,-rpath,\$ORIGIN" ]

deps = [ ":flutter_tizen" ]

public_configs = [ "//flutter:config" ]
}

source_set("flutter_tizen_headers") {
public = [
"public/flutter_platform_view.h",
"public/flutter_tizen_texture_registrar.h",
"public/flutter_tizen.h",
]
source_set("flutter_engine") {
visibility = [ ":*" ]

public_deps =
[ "//flutter/shell/platform/common/cpp:common_cpp_library_headers" ]
libs = [ "flutter_engine" ]

configs +=
[ "//flutter/shell/platform/common/cpp:desktop_library_implementation" ]
lib_dirs = [ root_out_dir ]

public_configs =
[ "//flutter/shell/platform/common/cpp:relative_flutter_library_headers" ]
}

source_set("flutter_tizen") {
sources = [
"channels/key_event_channel.cc",
"channels/lifecycle_channel.cc",
"channels/localization_channel.cc",
"channels/navigation_channel.cc",
"channels/platform_channel.cc",
"channels/platform_view_channel.cc",
"channels/settings_channel.cc",
"channels/text_input_channel.cc",
"external_texture_gl.cc",
"flutter_tizen.cc",
"key_event_handler.cc",
"tizen_embedder_engine.cc",
"tizen_event_loop.cc",
"tizen_log.cc",
"tizen_renderer.cc",
"tizen_vsync_waiter.cc",
"touch_event_handler.cc",
]
public_configs = [ ":tizen_embedder_rpath" ]

configs +=
[ "//flutter/shell/platform/common/cpp:desktop_library_implementation" ]
deps = [ "//flutter/shell/platform/embedder:flutter_engine" ]
}

deps = [
":flutter_tizen_headers",
"//flutter/shell/platform/common/cpp:common_cpp",
"//flutter/shell/platform/common/cpp:common_cpp_input",
"//flutter/shell/platform/common/cpp/client_wrapper:client_wrapper",
"//flutter/shell/platform/embedder:flutter_engine",
"//third_party/rapidjson",
]
_public_headers = [
"public/flutter_platform_view.h",
"public/flutter_tizen_texture_registrar.h",
"public/flutter_tizen.h",
]

# Tizen native headers assume that the following include dirs are already
# added to the compiler's search paths. Since we are not using the Tizen CLI
# builder, we have to add them manually.
config("tizen_rootstrap_include_dirs") {
include_dirs = [
"$custom_sysroot/usr/include",
"$custom_sysroot/usr/include/appfw",
Expand All @@ -87,41 +53,169 @@ source_set("flutter_tizen") {
"$custom_sysroot/usr/include/eo-1",
"$custom_sysroot/usr/include/evas-1",
"$custom_sysroot/usr/include/system",
"$custom_sysroot/usr/include/wayland-extension"
"$custom_sysroot/usr/include/wayland-extension",
# For Evas_GL.
"$custom_sysroot/usr/include/ecore-con-1",
"$custom_sysroot/usr/include/ecore-file-1",
"$custom_sysroot/usr/include/edje-1",
"$custom_sysroot/usr/include/eet-1",
"$custom_sysroot/usr/include/efl-1/interfaces",
"$custom_sysroot/usr/include/efreet-1",
"$custom_sysroot/usr/include/elementary-1",
"$custom_sysroot/usr/include/ethumb-1",
"$custom_sysroot/usr/include/ethumb-client-1",
]

lib_dirs = [ root_out_dir, "$custom_sysroot/usr/lib" ]

cflags_cc = [
"-Wno-newline-eof",
"-Wno-macro-redefined",
]
lib_dirs = [ "$custom_sysroot/usr/lib" ]
}

libs = [
"base-utils-i18n",
"capi-appfw-application",
"capi-system-info",
"capi-system-system-settings",
"dlog",
"ecore",
"ecore_imf",
"ecore_input",
"eina",
"EGL",
"evas",
"flutter_engine",
"GLESv2",
"tbm",
"tdm-client",
"wayland-client",
]
# Template for the embedder build. Used to generate embedders for different
# device profiles. The output library name is "flutter_tizen_[profile]".
#
# If use_evas_gl_renderer is provided as true, the Evas_GL renderer is used,
# otherwise the Ecore_Wl2 renderer is used.
template("embedder_for_profile") {
forward_variables_from(invoker, [ "use_evas_gl_renderer" ])

if (tizen_sdk_4) {
sources += [ "tizen_renderer_ecore_wl.cc" ]
libs += [ "ecore_wayland", "wayland-egl" ]
defines = [ "FLUTTER_TIZEN_4" ]
} else {
sources += [ "tizen_renderer_ecore_wl2.cc" ]
libs += [ "ecore_wl2" ]
if (!defined(use_evas_gl_renderer)) {
use_evas_gl_renderer = false
}

shared_library("flutter_tizen_${target_name}") {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found something confusing (at least for gn novice): the value of target_name within the body of shared_library, i.e. between lines 85 and 164, is changed from mobile/werable/tv/common to flutter_tizen_mobile/flutter_tizen_werable/flutter_tizen_tv/flutter_tizen_common respectively.

I'm not sure, if it's an issue, but it causes "undefined reference" errors when using code similar to the one from the diff from this comment #65 (comment) to extend libs, i.e.:

+    if (target_name == "mobile") { # should be target_name == "flutter_tizen_mobile"
+      libs += [ "cbhm" ]
+    }

I've printed the target_name values before, within and after shared_library() call (using this code: pwasowski2@0a41130) and here's what gn uses as target_names:

target_name before 'shared_library()': mobile
target_name in 'shared_library()': flutter_tizen_mobile
target_name == "mobile" is FALSE
target_name == "flutter_tizen_mobile" is TRUE
target_name after 'shared_library()': mobile
...

@swift-kim, is this change of target_name value desired?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pwasowski2 You're right. My comment was misleading because I didn't test the change suggested in the comment.

You can either:

  • Use invoker.target_name (instead of target_name) inside shared_library()
  • Define a new variable (e.g. profile = target_name) outside shared_library() and use that inside shared_library()

Actually there is a caveat about this in the GN documentation: https://gn.googlesource.com/gn/+/master/docs/reference.md#var_target_name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation :)

public = _public_headers

sources = [
"channels/key_event_channel.cc",
"channels/lifecycle_channel.cc",
"channels/localization_channel.cc",
"channels/navigation_channel.cc",
"channels/platform_channel.cc",
"channels/platform_view_channel.cc",
"channels/settings_channel.cc",
"channels/text_input_channel.cc",
"external_texture_gl.cc",
"flutter_tizen.cc",
"key_event_handler.cc",
"tizen_embedder_engine.cc",
"tizen_event_loop.cc",
"tizen_log.cc",
"tizen_renderer.cc",
"touch_event_handler.cc",
]

libs = [
"base-utils-i18n",
"capi-appfw-application",
"capi-system-info",
"capi-system-system-settings",
"dlog",
"ecore",
"ecore_imf",
"ecore_input",
"eina",
"evas",
"EGL",
"GLESv2",
"tbm",
"tdm-client",
"wayland-client",
]

defines = invoker.defines

if (use_evas_gl_renderer) {
sources += [ "tizen_renderer_evas_gl.cc" ]

libs += [
"ecore_evas",
"elementary",
]

defines += [ "TIZEN_RENDERER_EVAS_GL" ]
} else {
sources += [
"tizen_renderer_ecore_wl2.cc",
"tizen_vsync_waiter.cc",
]

libs += [ "ecore_wl2" ]
}

cflags_cc = [
"-Wno-newline-eof",
"-Wno-macro-redefined",
]

configs += [
":tizen_rootstrap_include_dirs",
"//flutter/shell/platform/common/cpp:desktop_library_implementation"
]

public_configs = [ "//flutter:config" ]

public_deps = [ ":flutter_engine" ]

deps = [
"//flutter/shell/platform/common/cpp:common_cpp",
"//flutter/shell/platform/common/cpp:common_cpp_input",
"//flutter/shell/platform/common/cpp:common_cpp_library_headers",
"//flutter/shell/platform/common/cpp/client_wrapper:client_wrapper",
"//third_party/rapidjson",
]
}
}

embedder_for_profile("mobile") {
defines = [ "MOBILE_PROFILE" ]
}

embedder_for_profile("wearable") {
defines = [ "WEARABLE_PROFILE" ]

use_evas_gl_renderer = true
}

embedder_for_profile("tv") {
defines = [ "TV_PROFILE" ]
}

embedder_for_profile("common") {
defines = [ "COMMON_PROFILE" ]
}

publish_client_wrapper_core("publish_cpp_client_wrapper") {
visibility = [ ":*" ]
}

_common_cpp_public_headers = [
"//flutter/shell/platform/common/cpp/public/flutter_export.h",
"//flutter/shell/platform/common/cpp/public/flutter_messenger.h",
"//flutter/shell/platform/common/cpp/public/flutter_plugin_registrar.h",
"//flutter/shell/platform/common/cpp/public/flutter_texture_registrar.h",
]

copy("publish_headers_tizen") {
sources = _public_headers + _common_cpp_public_headers

outputs = [ "$root_out_dir/public/{{source_file_part}}" ]
}

copy("copy_icu") {
visibility = [ ":*" ]

sources = [ "//third_party/icu/flutter/icudtl.dat" ]

outputs = [ "$root_out_dir/icu/{{source_file_part}}" ]
}

group("tizen") {
deps = [
":flutter_tizen_mobile",
":flutter_tizen_wearable",
":flutter_tizen_tv",
":flutter_tizen_common",
":publish_cpp_client_wrapper",
":publish_headers_tizen",
":copy_icu",
]
}
Loading