### Install: Flutter Engine Library Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Installs the main Flutter engine library into the library directory within the installation prefix. ```CMake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing Flutter Engine Library (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This command installs the Flutter engine library file specified by `FLUTTER_LIBRARY`. It copies this file to the `INSTALL_BUNDLE_LIB_DIR` (the base install directory) as part of the `Runtime` installation component, making the necessary engine library available to the application at runtime. ```CMake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configuring Installation Directories (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This block sets up variables for installation paths, defaulting the installation prefix to the build output directory for easy testing within the build environment. It also defines subdirectories for data and libraries within the determined installation prefix. ```CMake set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Install: Application Executable Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Installs the compiled application executable target into the root of the installation prefix (`CMAKE_INSTALL_PREFIX`), making it the main executable in the bundle. ```CMake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Installing Application Executable (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This command installs the main application executable, specified by the `BINARY_NAME` variable. It marks the target as a `RUNTIME` component and specifies its destination as the `CMAKE_INSTALL_PREFIX`, ensuring it's placed correctly during the installation step. ```CMake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install: Clean and Copy Flutter Assets Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Adds installation rules to first remove the existing assets directory in the installation location and then copy the latest built Flutter assets into the data directory within the installation prefix, ensuring assets are always up-to-date in the bundle. ```CMake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE "\n file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")\n " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing Flutter Assets (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This block handles the installation of application assets. It first removes the existing assets directory to prevent stale files and then copies the fresh assets from the build output directory to the installation data directory. This ensures the installed application always has the latest assets. ```CMake install(CODE "\n file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\")\n " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing AOT Library (Profile/Release) (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This command installs the Ahead-Of-Time (AOT) compiled Flutter library, which is used for performance-optimized builds. It is configured to install this library only for the `Profile` and `Release` configurations, placing it in the `INSTALL_BUNDLE_DATA_DIR` as part of the `Runtime` component. ```CMake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Configuring Installation Prefix for Bundling Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Sets the default installation prefix (`CMAKE_INSTALL_PREFIX`) to a directory named 'bundle' within the project's binary directory, configuring where the final application bundle will be created. ```CMake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Install: AOT Library (Conditional) Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Conditionally installs the Ahead-Of-Time (AOT) compiled Flutter snapshot library into the library directory within the installation prefix, but only for non-Debug build types. ```CMake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install: Clean Build Bundle Directory Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Adds an installation rule that removes the entire contents of the build bundle directory before installation begins, ensuring a clean state for the new bundle. ```CMake install(CODE "\n file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\")\n " COMPONENT Runtime) ``` -------------------------------- ### Install: Plugin Bundled Libraries Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Conditionally installs any bundled libraries provided by Flutter plugins into the library directory within the installation prefix, if the `PLUGIN_BUNDLED_LIBRARIES` variable is set. ```CMake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Installing Xcode CLI Tools (Shell) Source: https://github.com/flutter/gallery/blob/main/android/fastlane/README.md Installs or updates the Xcode command line tools, which are required for building and signing iOS applications and for using tools like fastlane on macOS. This is a prerequisite for many development workflows involving Xcode. ```sh xcode-select --install ``` -------------------------------- ### Defining Installation Path Variables Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Sets CMake variables for the standard data and library subdirectories within the installation prefix (`CMAKE_INSTALL_PREFIX`). ```CMake set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Generating Flutter Localizations (Bash) Source: https://github.com/flutter/gallery/blob/main/lib/l10n/README.md Provides the command-line instruction using `flutter gen-l10n` to generate the localization delegate Dart file from the template. It specifies the input template file, the desired output file name, and the name of the generated Dart class. ```bash flutter gen-l10n \ --template-arb-file=intl_en.arb \ --output-localization-file=gallery_localizations.dart \ --output-class=GalleryLocalizations ``` -------------------------------- ### Installing Flutter ICU Data File (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This command installs the file specified by the `FLUTTER_ICU_DATA_FILE` variable, which contains data essential for internationalization support in Flutter. It copies this file to the `INSTALL_BUNDLE_DATA_DIR` as part of the `Runtime` installation component. ```CMake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Installing Plugin Libraries (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This conditional block checks if the `PLUGIN_BUNDLED_LIBRARIES` variable is set (indicating that plugins require bundled libraries). If true, it installs these specified library files to the `INSTALL_BUNDLE_LIB_DIR` as part of the `Runtime` installation component, ensuring plugin dependencies are met. ```CMake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install: Flutter ICU Data File Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Installs the Flutter ICU data file (required for internationalization) into the data directory within the installation prefix. ```CMake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Setting Runtime Path for Installation Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Configures the runtime search path (RPATH) for installed executables and libraries to search relative to the executable's directory for dependent libraries, making the bundle relocatable. ```CMake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Creating ARB Message Format Source: https://github.com/flutter/gallery/blob/main/lib/l10n/README.md Demonstrates the required structure for defining new localizable messages within an .arb file. It shows how to link an English translation to a Dart getter variable name and provide a description for the message used by the localization delegate. ```arb "dartGetterVariableName": "english translation of the message", "@dartGetterVariableName": { "description": "description that the localizations delegate will use." }, ``` -------------------------------- ### Generate Flutter Gallery Localizations (Bash) Source: https://github.com/flutter/gallery/blob/main/DEVELOPING.md Runs the necessary Grinder task to generate localization code for the Flutter Gallery app. Requires `flutter pub get` to fetch dependencies first. This process creates a synthetic package with localization files based on source message definitions. ```bash flutter pub get flutter pub run grinder l10n ``` -------------------------------- ### Setting Minimum CMake Version and Project Details Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Specifies the minimum required version of CMake (3.10) and defines the project name ('runner') and the programming languages used (CXX). This is the standard starting point for any CMake project. ```CMake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) ``` -------------------------------- ### Generate Flutter Gallery Code Segments (Bash) Source: https://github.com/flutter/gallery/blob/main/DEVELOPING.md Executes the Grinder task to update highlighted code segments used within the Flutter Gallery's code viewer feature. `flutter pub get` is needed beforehand to ensure required tools and dependencies are available. ```bash flutter pub get flutter pub run grinder update-code-segments ``` -------------------------------- ### Defining Application Name and ID Variables Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Sets CMake variables to store the desired binary name and the application ID. These variables are used throughout the file for configuring the build and installation. ```CMake set(BINARY_NAME "flutter_gallery") set(APPLICATION_ID "io.flutter.demo.gallery") ``` -------------------------------- ### Resulting Highlighted Segment 'demoTwo' (Dart) Source: https://github.com/flutter/gallery/blob/main/tool/codeviewer_cli/README.md Shows the code content generated by the Codeviewer for the `demoTwo` segment based on the nested/overlapping example. This segment includes the code from the `demoTwo` block and any code following it before its closing `// END` marker. ```Dart b(); c(); ``` -------------------------------- ### Defining Executable Name (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This line sets the CMake variable `BINARY_NAME` to "gallery". This variable is used throughout the script to refer to the name of the final application executable that will be built and installed. ```CMake set(BINARY_NAME "gallery") ``` -------------------------------- ### Resulting Highlighted Segment 'demoOne' (Dart) Source: https://github.com/flutter/gallery/blob/main/tool/codeviewer_cli/README.md Shows the code content generated by the Codeviewer for the `demoOne` segment based on the nested/overlapping example. The segment includes code from the `demoOne` block and the `demoTwo` block because `demoTwo` is nested within `demoOne`. ```Dart a(); b(); ``` -------------------------------- ### Setting Flutter Artifact Paths (Parent Scope) - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Defines and exports CMake variables pointing to key Flutter build artifacts (library, ICU data, build directory, AOT library) to the parent scope. This makes these paths available to calling CMake scripts, useful for installation or further configuration. ```cmake set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) ``` -------------------------------- ### Promoting Android Beta to Production with fastlane (Shell) Source: https://github.com/flutter/gallery/blob/main/android/fastlane/README.md Executes the 'promote_to_production' action defined in the fastlane configuration for the Android platform. This action is used to promote an existing build from the beta track on Google Play Store to the production track, making it available to all users. The optional `bundle exec` is used when fastlane is managed via Bundler. ```sh [bundle exec] fastlane android promote_to_production ``` -------------------------------- ### Submitting Android Beta with fastlane (Shell) Source: https://github.com/flutter/gallery/blob/main/android/fastlane/README.md Executes the 'beta' action defined in the fastlane configuration for the Android platform. This action is used to build and submit a new beta version of the Android app to a distribution platform like Google Play Store's beta track. The optional `bundle exec` is used when fastlane is managed via Bundler. ```sh [bundle exec] fastlane android beta ``` -------------------------------- ### Finding PkgConfig and GTK Dependency Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Finds the PkgConfig package and uses it to locate the required GTK 3.0 library, creating an imported target `PkgConfig::GTK` for linking. ```CMake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) ``` -------------------------------- ### Applying Standard Settings to Executable Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Calls the previously defined `APPLY_STANDARD_SETTINGS` function to apply common compilation flags and features to the main application executable target. ```CMake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Linking Libraries to Executable Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Links the application executable target to the necessary libraries: the Flutter engine library (`flutter`) and the GTK library found via PkgConfig (`PkgConfig::GTK`). ```CMake target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) ``` -------------------------------- ### Defining Application Executable Target Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Adds an executable target named `${BINARY_NAME}` using the specified source files (`main.cc`, `my_application.cc`, and the generated plugin registrant). ```CMake add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) ``` -------------------------------- ### Finding System Dependencies with PkgConfig - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Uses `find_package` and `pkg_check_modules` to locate and import system-level libraries required by the Flutter engine on Linux, specifically GTK 3, GLib 2, and GIO 2. These are marked as `REQUIRED`, meaning the build will fail if they are not found. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Linking System Dependencies to Flutter Library - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Links the required system dependencies (GTK, GLIB, GIO), which were found using PkgConfig, to the `flutter` interface library. This propagates these linking requirements to any target using the `flutter` interface library. ```cmake target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) ``` -------------------------------- ### Including Application Runner Subdirectory (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This command includes the `CMakeLists.txt` file found in the "runner" subdirectory. This subdirectory typically contains the build rules specifically for the main application executable, linking it with the Flutter engine and other dependencies. ```CMake add_subdirectory("runner") ``` -------------------------------- ### Adding Build Dependencies Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Adds `flutter_assemble` as a dependency for the application executable. This ensures that the Flutter assembly step (which prepares assets, libraries, etc.) is completed before the executable is built. ```CMake add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Including Flutter Subdirectory Build Rules Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Includes the CMakeLists.txt file located in the directory specified by `FLUTTER_MANAGED_DIR`. This brings in build rules and targets defined by the Flutter build system. ```CMake add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Including Flutter Subdirectory Build Rules (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This snippet sets the `FLUTTER_MANAGED_DIR` variable to the path of the `flutter` subdirectory within the current source directory. It then includes the `CMakeLists.txt` file located in that subdirectory, incorporating the Flutter engine build rules into the main project build. ```CMake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) ``` -------------------------------- ### Adding Unicode Preprocessor Definitions (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This command adds the preprocessor definitions `UNICODE` and `_UNICODE` to all compilation units. These definitions are essential for enabling Unicode support in the application, particularly important for Windows development. ```CMake add_definitions(-DUNICODE -D_UNICODE) ``` -------------------------------- ### Including Generated Plugin Build Rules Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Includes a generated CMake file (`generated_plugins.cmake`) that contains build rules for any detected Flutter plugins, managing their compilation and integration into the application. ```CMake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Defining Custom Command for Flutter Tool Backend - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Defines a custom command named `flutter_assemble` that executes the Flutter tool's backend script (`tool_backend.sh`). This command is responsible for orchestrating the generation of Flutter build artifacts like the engine library, headers, and AOT snapshot. It uses a phony output file (`_phony_`) to ensure it runs every time, as the full list of generated outputs might not be known statically. ```cmake add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) ``` -------------------------------- ### Marking Single Code Block for Highlighting (Dart) Source: https://github.com/flutter/gallery/blob/main/tool/codeviewer_cli/README.md Demonstrates the basic syntax for marking a single block of Dart code for the Codeviewer tool to highlight. Use `// BEGIN yourDemoName` before the code block you want to capture and `// END` after the block. ```Dart // BEGIN yourDemoName // Your Dart code here... // END ``` -------------------------------- ### Running Android Tests with fastlane (Shell) Source: https://github.com/flutter/gallery/blob/main/android/fastlane/README.md Executes the 'test' action defined in the fastlane configuration for the Android platform. This typically runs unit tests, integration tests, or other verification steps for the Android application. The optional `bundle exec` is used when fastlane is managed via Bundler. ```sh [bundle exec] fastlane android test ``` -------------------------------- ### Setting Minimum CMake Version and Project Name (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This snippet specifies the minimum required CMake version (3.14) for the project and defines the project named "gallery", enabling support for CXX (C++) language compilation. This is typically the first block in a CMakeLists.txt file and sets the fundamental requirements for the build. ```CMake cmake_minimum_required(VERSION 3.14) project(gallery LANGUAGES CXX) ``` -------------------------------- ### Defining Standard Settings Function Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Defines a CMake function `APPLY_STANDARD_SETTINGS` that applies common compilation settings to a given target, including C++ standard (cxx_std_14), warning flags (-Wall, -Werror), optimization (-O3 for non-Debug), and debug definitions (NDEBUG for non-Debug). ```CMake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "$<$:NDEBUG>") endfunction() ``` -------------------------------- ### Configuring Flutter Windows Runner Build - CMake Source: https://github.com/flutter/gallery/blob/main/windows/runner/CMakeLists.txt Configures the CMake build process for the Windows runner executable. It sets the minimum required CMake version, defines the project name, adds source files for the executable, applies standard build settings, defines version macros, disables conflicting Windows macros, links dependent libraries (flutter, flutter_wrapper_app, dwmapi), includes source directories, and adds a dependency on the flutter_assemble target. ```CMake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add preprocessor definitions for the build version. target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### Setting Include Directories for Flutter Library - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Specifies include directories (`${EPHEMERAL_DIR}`) required by targets that link to the `flutter` interface library. This allows projects to include Flutter headers found in the ephemeral directory. ```cmake target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) ``` -------------------------------- ### Prepending Path to Header List - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Uses the custom `list_prepend` function to add the ephemeral directory path (`${EPHEMERAL_DIR}/flutter_linux/`) as a prefix to each header file name in the `FLUTTER_LIBRARY_HEADERS` list. This creates the full paths to where these headers are expected to be found. ```cmake list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") ``` -------------------------------- ### Copying Release Flags to Profile (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt These lines copy the compiler and linker flags set for the Release configuration to the Profile configuration. This ensures that the Profile build uses similar optimization and linking settings as Release, suitable for performance testing while still allowing some debugging features. ```CMake set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### Defining Standard Compilation Settings Function (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This CMake function `APPLY_STANDARD_SETTINGS` encapsulates common compilation requirements. When called with a target name, it sets the C++ standard to 17, adds specific warning options, enables synchronous exception handling, disables C++ exceptions, and adds the _DEBUG definition only in Debug builds. ```CMake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() ``` -------------------------------- ### Including Generated Plugins File (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This line includes the `generated_plugins.cmake` file, which is automatically created by the Flutter tooling. This file contains CMake code to manage the build process for any platform-specific plugins used by the Flutter application, ensuring they are built and linked correctly. ```CMake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Demonstrating Nested/Overlapping Code Block Marking (Dart) Source: https://github.com/flutter/gallery/blob/main/tool/codeviewer_cli/README.md Illustrates how the Codeviewer handles nested or overlapping `// BEGIN` and `// END` markers within a single Dart file. An `// END` marker can optionally specify the tag name (e.g., `// END demoOne`) to explicitly close a specific block. ```Dart // BEGIN demoOne a(); // BEGIN demoTwo b(); // END demoOne c(); // END demoTwo ``` -------------------------------- ### Opening Flutter iOS Project in Xcode (Shell) Source: https://github.com/flutter/gallery/blob/main/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md This command opens the iOS runner project directory (`ios/Runner.xcworkspace`) in Xcode. It is required to access Xcode's asset management features, such as the `Assets.xcassets` catalog, for customizing the launch screen or other app resources. ```Shell open ios/Runner.xcworkspace ``` -------------------------------- ### Setting Minimum CMake Version - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Specifies the minimum required version of CMake to build the project. Ensures that features used in the script are available. ```cmake cmake_minimum_required(VERSION 3.10) ``` -------------------------------- ### Including Generated Configuration - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Includes a CMake configuration file (`generated_config.cmake`) located in the ephemeral directory. This file is generated by the Flutter tool and contains build-specific variables and settings. ```cmake include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Adding Application ID Definition Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Adds a preprocessor definition `APPLICATION_ID` with the value of the `${APPLICATION_ID}` CMake variable. This makes the application ID available in the C++ source code. ```CMake add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") ``` -------------------------------- ### Defining list_prepend Function - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Defines a custom CMake function `list_prepend` that prepends a given prefix string to each element in a specified list. This function provides similar functionality to `list(TRANSFORM ... PREPEND ...)` but is compatible with older CMake versions (like 3.10) where `TRANSFORM` is not available. It modifies the list in the parent scope. ```cmake function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() ``` -------------------------------- ### Marking Multiple Code Blocks for Highlighting (Dart) Source: https://github.com/flutter/gallery/blob/main/tool/codeviewer_cli/README.md Shows how to mark multiple, potentially non-contiguous, blocks of Dart code that should be combined into a single highlighted segment. Blocks are identified by numbered tags (e.g., `#1`, `#2`) and are joined in ascending order of the tag number. ```Dart // BEGIN yourDemo#2 a(); // END b(); // BEGIN yourDemo#1 c(); // END ``` -------------------------------- ### Listing Flutter Library Headers - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Appends a list of header file names for the Flutter C API to the `FLUTTER_LIBRARY_HEADERS` variable. These headers are part of the Flutter engine's C/C++ interface for embedding applications. ```cmake list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) ``` -------------------------------- ### Configuring Sysroot for Cross-Compilation Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Sets CMake variables related to the system root directory (sysroot) and find root path modes when cross-compiling for a target platform specified by the FLUTTER_TARGET_PLATFORM_SYSROOT variable. ```CMake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### Defining Custom Target flutter_assemble - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Defines a custom target named `flutter_assemble` that depends on the outputs of the corresponding custom command. This target represents the build step that generates Flutter artifacts and is used as a dependency for other build targets (like the `flutter` library). ```cmake add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Defining Flutter Interface Library - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Creates a CMake INTERFACE library named `flutter`. Interface libraries do not compile source code but are used to propagate usage requirements like include directories and linked libraries to targets that link against them. ```cmake add_library(flutter INTERFACE) ``` -------------------------------- ### Setting Executable Output Directory Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Sets the output directory for the compiled executable to a subdirectory (`intermediates_do_not_run`) within the build directory. This prevents users from accidentally running the unbundled executable, which would not function correctly without its dependencies in the correct relative locations. ```CMake set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) ``` -------------------------------- ### Adding Dependency on flutter_assemble Target - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Adds a dependency on the custom target `flutter_assemble` to the `flutter` interface library. This ensures that the `flutter_assemble` target runs and generates the necessary Flutter artifacts (like the library and headers) before any target that depends on the `flutter` library is built. ```cmake add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Setting Flutter Artifact Paths - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Defines CMake variables pointing to key Flutter build artifacts generated by the Flutter tool backend, including the main Flutter Linux GTK shared library. These paths are set for use within the current scope. ```cmake set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") ``` -------------------------------- ### Linking Flutter Shared Library - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Links the main Flutter Linux GTK shared library (`${FLUTTER_LIBRARY}`) to the `flutter` interface library. This means any target linking to `flutter` will also link against this shared library. ```cmake target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") ``` -------------------------------- ### Setting Ephemeral Directory Path - CMake Source: https://github.com/flutter/gallery/blob/main/linux/flutter/CMakeLists.txt Defines a variable `EPHEMERAL_DIR` pointing to a directory used by the Flutter tool for generated files and temporary build artifacts. This directory is typically created and managed by the Flutter build process. ```cmake set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") ``` -------------------------------- ### Defining Flutter Managed Directory Variable Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Sets a CMake variable `FLUTTER_MANAGED_DIR` pointing to the location of the Flutter-managed build files within the source directory. ```CMake set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") ``` -------------------------------- ### Setting CMake Policy (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This command explicitly sets CMake policy `CMP0063` to `NEW`. This policy relates to managing properties on targets and helps avoid warnings with newer CMake versions by opting into updated behavior. ```CMake cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Setting CMake Policy Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Explicitly sets CMake policy CMP0063 to 'NEW'. This policy affects how include directories are handled when linking targets. ```CMake cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### Updating Golden Tests Bash Command Source: https://github.com/flutter/gallery/blob/main/test_goldens/README.md This bash command is used to update the golden screenshot reference files when UI changes cause tests to fail, but the changes are intended. It specifically targets the test_goldens directory or test suite and is recommended to be run on a macOS machine due to rendering differences. ```bash flutter test --update-goldens test_goldens ``` -------------------------------- ### Configuring Build Types (CMake) Source: https://github.com/flutter/gallery/blob/main/windows/CMakeLists.txt This block configures the available build types (Debug, Profile, Release) based on the capabilities of the CMake generator being used. For multi-config generators (like Visual Studio), it sets `CMAKE_CONFIGURATION_TYPES`; otherwise, it sets the default `CMAKE_BUILD_TYPE` and defines the valid string options for the cache variable. ```CMake get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) elif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### Setting Default Build Type Source: https://github.com/flutter/gallery/blob/main/linux/CMakeLists.txt Sets the default build type (Debug) if it hasn't been specified, and defines the available options (Debug, Profile, Release). This controls compilation flags and build behavior. ```CMake if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.