Skip to content

[linux] Improve example Makefile #244

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
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
9 changes: 8 additions & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ Run `make -C example/linux_fde/`. The example binary and its resources will be
in `example/build/linux_fde`, and can be run from there:

```
$ ./example/build/linux_fde/flutter_embedder_example
$ ./example/build/linux_fde/debug/flutter_embedder_example
```

To build a version with Dart asserts disabled (and thus no DEBUG banner),
run `make BUILD=release` instead, then launch it with:

```
$ ./example/build/linux_fde/release/flutter_embedder_example
```

### macOS
Expand Down
38 changes: 27 additions & 11 deletions example/linux_fde/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,30 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Example-specific variables.
# To modify this Makefile for a different application, these are the values
Copy link
Contributor

Choose a reason for hiding this comment

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

This is great! 👍

# that are mostly likely to need to be changed.

# The location of the flutter-desktop-embedding repository.
FDE_ROOT=$(CURDIR)/../..
# The C++ code for the embedder application.
SOURCES=flutter_embedder_example.cc
# Plugins to include (from the flutter-desktop-embedding plugins/ directory).
PLUGIN_NAMES=color_panel file_chooser menubar


# Default build type. For a release build, set BUILD=release.
# Currently this only sets NDEBUG, which is used to control the flags passed
# to the Flutter engine in the example shell, and not the complation settings
# (e.g., optimization level) of the C++ code.
BUILD:=debug

# Dependency locations
PROJECT_ROOT=$(CURDIR)/../..
FLUTTER_EMBEDDER_LIB_DIR=$(PROJECT_ROOT)/library/linux
FLUTTER_APP_DIR=$(CURDIR)/..
FLUTTER_APP_BUILD_DIR=$(FLUTTER_APP_DIR)/build
PLUGINS_DIR=$(PROJECT_ROOT)/plugins
TOOLS_DIR=$(PROJECT_ROOT)/tools
FLUTTER_EMBEDDER_LIB_DIR=$(FDE_ROOT)/library/linux
PLUGINS_DIR=$(FDE_ROOT)/plugins
TOOLS_DIR=$(FDE_ROOT)/tools
FLUTTER_DIR=$(shell $(TOOLS_DIR)/flutter_location)

# Libraries
Expand All @@ -28,7 +45,6 @@ FLUTTER_EMBEDDER_LIB=$(FLUTTER_EMBEDDER_LIB_DIR)/lib$(FLUTTER_EMBEDDER_LIB_NAME)
FLUTTER_ENGINE_LIB_NAME=flutter_engine
FLUTTER_ENGINE_LIB=$(FLUTTER_EMBEDDER_LIB_DIR)/lib$(FLUTTER_ENGINE_LIB_NAME).so

PLUGIN_NAMES=color_panel file_chooser menubar
PLUGIN_LIB_NAME_PREFIX=flutter_embedder_
PLUGIN_LIBS=$(foreach plugin,$(PLUGIN_NAMES)\
,$(PLUGINS_DIR)/$(plugin)/linux/lib$(PLUGIN_LIB_NAME_PREFIX)$(plugin).so)
Expand All @@ -38,7 +54,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)) $(PROJECT_ROOT)/library/include
INCLUDE_DIRS=$(patsubst %,%/include,$(LIBRARY_DIRS)) $(FDE_ROOT)/library/include

# Tools
BUILD_ASSETS_BIN=$(TOOLS_DIR)/build_flutter_assets
Expand All @@ -51,7 +67,7 @@ FLUTTER_ASSETS_NAME=flutter_assets
FLUTTER_ASSETS_SOURCE=$(FLUTTER_APP_BUILD_DIR)/$(FLUTTER_ASSETS_NAME)

# Output bundle structure and targets
OUT_DIR=$(FLUTTER_APP_BUILD_DIR)/linux_fde
OUT_DIR=$(FLUTTER_APP_BUILD_DIR)/linux_fde/$(BUILD)
OUT_DATA_DIR=$(OUT_DIR)/data
OUT_LIB_DIR=$(OUT_DIR)/lib

Expand All @@ -61,7 +77,7 @@ ALL_LIBS_OUT=$(foreach lib,$(ALL_LIBS),$(OUT_LIB_DIR)/$(notdir $(lib)))

# Overrides for the optional GN build.
ifdef USE_GN
GN_OUT_DIR=$(PROJECT_ROOT)/out
GN_OUT_DIR=$(FDE_ROOT)/out

# The GN build places all libraries at the top level of the output directory.
FLUTTER_EMBEDDER_LIB=$(GN_OUT_DIR)/lib$(FLUTTER_EMBEDDER_LIB_NAME).so
Expand All @@ -82,7 +98,9 @@ endif

# Build settings
CXX=g++ -std=c++14
CXXFLAGS=-Wall -Werror $(shell pkg-config --cflags jsoncpp glfw3)
CXXFLAGS.release=-DNDEBUG
CXXFLAGS=-Wall -Werror $(shell pkg-config --cflags jsoncpp glfw3) \
$(CXXFLAGS.$(BUILD))
CPPFLAGS=$(patsubst %,-I%,$(INCLUDE_DIRS))
ifdef USE_GN
CPPFLAGS+=-DUSE_FLATTENED_INCLUDES
Expand All @@ -94,8 +112,6 @@ LDFLAGS=-L$(OUT_LIB_DIR) \
$(patsubst %,-l$(PLUGIN_LIB_NAME_PREFIX)%,$(PLUGIN_NAMES)) \
-Wl,-rpath=\$$ORIGIN/lib

SOURCES=flutter_embedder_example.cc

# Targets

.PHONY: all
Expand Down