From 5e6401559ada7ff3cc9326b11903fa62c529a921 Mon Sep 17 00:00:00 2001 From: Joel Winarske Date: Sun, 26 Apr 2020 18:13:50 -0700 Subject: [PATCH] building arm, need to add toolchain file for other apps --- .gitignore | 2 +- .travis.yml | 32 --- CMakeLists.txt | 41 ++-- README.md | 73 +++---- cmake/build_dependencies.cmake | 138 ------------- .../{llvm_config.cmake => depot_tools.cmake} | 44 ++--- cmake/engine.cmake | 66 +++++++ cmake/engine_options.cmake | 184 +++++++++++------- cmake/hello_pi.cmake | 2 +- cmake/options.cmake | 55 ++++++ cmake/patches/custom_BUILD_gn.patch | 50 +++++ cmake/patches/dart.patch | 13 -- cmake/patches/engine.patch | 0 cmake/patches/engine_compiler_build.patch.in | 36 ---- cmake/patches/flutter_platform.patch | 22 --- cmake/patches/icu.patch | 13 ++ cmake/rpi.cmake | 20 +- cmake/rpi.flutter.cmake | 2 +- cmake/skia.gclient.in | 8 - cmake/sysroot.cmake | 176 +++++++++++++++++ cmake/wayland.cmake | 37 +++- 21 files changed, 561 insertions(+), 453 deletions(-) delete mode 100644 .travis.yml delete mode 100755 cmake/build_dependencies.cmake rename cmake/{llvm_config.cmake => depot_tools.cmake} (50%) create mode 100644 cmake/engine.cmake create mode 100644 cmake/options.cmake create mode 100644 cmake/patches/custom_BUILD_gn.patch delete mode 100644 cmake/patches/dart.patch delete mode 100644 cmake/patches/engine.patch delete mode 100644 cmake/patches/engine_compiler_build.patch.in delete mode 100644 cmake/patches/flutter_platform.patch create mode 100644 cmake/patches/icu.patch delete mode 100644 cmake/skia.gclient.in create mode 100644 cmake/sysroot.cmake diff --git a/.gitignore b/.gitignore index 08551077..631bee80 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .vscode build -sdk third_party +sysroot \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d8f9783b..00000000 --- a/.travis.yml +++ /dev/null @@ -1,32 +0,0 @@ -language: cpp -os: linux -#dist: xenial -compiler: gcc #compiler used to build host compoments of toolchain - -env: - - CMAKE_ARGS="" - -install: - # there is no way these are all required. Upstream needs to optimize this. - - sudo apt-get install bison cdbs curl devscripts dpkg-dev elfutils fakeroot flex g++ git git-svn gperf libasound2 libasound2-dev libatk1.0-dev libbrlapi-dev libbz2-dev libc6 libcairo2 libcairo2-dev libcap2 libcap-dev libcups2 libcups2-dev libcurl4-gnutls-dev libdrm-dev libelf-dev libexif12 libexif-dev libexpat1 libfontconfig1 libfreetype6 libgbm-dev libgconf2-dev libgl1-mesa-dev libgles2-mesa-dev libglib2.0-0 libglib2.0-dev libglu1-mesa-dev libgnome-keyring0 libgnome-keyring-dev libgtk2.0-0 libgtk2.0-dev libjpeg-dev libkrb5-dev libnspr4 libnspr4-dev libnss3 libnss3-dev libpam0g libpam0g-dev libpango1.0-0 libpci3 libpci-dev libpcre3 libpixman-1-0 libpng12-0 libpulse-dev libsctp-dev libspeechd2 libspeechd-dev libsqlite3-0 libsqlite3-dev libssl-dev libstdc++6 libudev1 libudev-dev libwww-perl libx11-6 libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1 libxslt1-dev libxss-dev libxt-dev libxtst6 libxtst-dev mesa-common-dev patch perl pkg-config python python-cherrypy3 python-crypto python-dev python-numpy python-opencv python-openssl python-psutil python-yaml rpm ruby subversion texinfo wdiff zip zlib1g > /dev/null - - - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - - mkdir ${DEPS_DIR} && cd ${DEPS_DIR} && pwd - - - git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git - - export PATH=${DEPS_DIR}/depot_tools:$PATH - - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then travis_retry wget --no-check-certificate https://cmake.org/files/v3.11/cmake-3.11.0-Linux-x86_64.tar.gz; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then echo "96d67e21f0983ebf0fffc5b106ec338c *cmake-3.11.0-Linux-x86_64.tar.gz" > cmake_md5.txt; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then md5sum -c cmake_md5.txt; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then tar -xf cmake-3.11.0-Linux-x86_64.tar.gz > /dev/null; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then mv cmake-3.11.0-Linux-x86_64 cmake-install; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export PATH=${DEPS_DIR}/cmake-install:${DEPS_DIR}/cmake-install/bin:$PATH; fi - -before_script: - - cd ${TRAVIS_BUILD_DIR} - - mkdir build && cd build - - cmake .. ${CMAKE_ARGS} - -script: - - make -j`grep -c ^processor /proc/cpuinfo` diff --git a/CMakeLists.txt b/CMakeLists.txt index aefd9383..4cc24dc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # # MIT License # -# Copyright (c) 2018 Joel Winarske +# Copyright (c) 2018-2020 Joel Winarske # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,18 +24,9 @@ cmake_minimum_required(VERSION 3.11) -if(POLICY CMP0068) - cmake_policy(SET CMP0068 NEW) - set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON) -endif() - -if(POLICY CMP0075) - cmake_policy(SET CMP0075 NEW) -endif() - if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE) - message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to MinSizeRel.") + set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE) + message(STATUS "CMAKE_BUILD_TYPE not set, defaulting to Release.") endif() set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake") @@ -51,25 +42,19 @@ project(${PACKAGE_NAME} VERSION "${FLUTTER_EMBEDDED_VERSION}" LANGUAGES CXX C) message(STATUS "Generator .............. ${CMAKE_GENERATOR}") message(STATUS "Build Type ............. ${CMAKE_BUILD_TYPE}") -option(BUILD_PLATFORM_SYSROOT "Build Platform sysroot" ON) - -option(BUILD_RPI_FLUTTER "Build Flutter for Raspberry Pi" ON) -option(BUILD_WAYLAND_FLUTTER "Build Flutter for Wayland" OFF) +include(ProcessorCount) +ProcessorCount(NUM_PROC) -include(build_dependencies) -if(ANDROID) - set(FLUTTER_TARGET_NAME "Android") -else() +include(options) +include(sysroot) +include(depot_tools) +include(engine) - if(BUILD_RPI_FLUTTER) - include(rpi) - - elseif(BUILD_WAYLAND_FLUTTER) - include(wayland) - endif() +if(BUILD_FLUTTER_RPI) + include(rpi) +elseif(BUILD_FLUTTER_WAYLAND) + include(wayland) endif() - -message(STATUS "Flutter ................ ${FLUTTER_TARGET_NAME}") diff --git a/README.md b/README.md index 20004c39..1efd9a5a 100644 --- a/README.md +++ b/README.md @@ -1,64 +1,54 @@ # flutter_embedded -This repo is currently about build automation for Tip of the Tree Clang, Binutils, and Flutter Engine artifacts. The useage target is for an embedded system. +This repo is currently about build automation for Tip of the Tree Flutter Engine, and alternative Linux shells. -# Motivation -See if Embedded Flutter is a compeling alternative to Chromium ContentShell+JS+CSS, and QT. +# Project Status -Areas of interest are memory footprint, stack latency, and where does it fit in the UI Framework landscape. +**Note: armv6 is not supported by Google** -I can build a ContentShell browser that with the smallest of pages, only has a 15MB system heap footprint. As the HTML5 application complexity increases, the memory usage ballons. We're looking for controlled predictability. +I have refactored things to take advantage of the Fuchsia Clang Toolchain (CIPD). -In regards to latency, one test case will be CAN bus signal from an Automotive ODBC-II connector, rendering a gauge. +This is building very close to tip of tree. It may be too new for your SDK. To regress engine build will most likely involve some hair pulling. +I need people to test their desired configuration and provide feedback. -# Project Status +I aam considering a new branch for each Engine milestones. -### I'm planning to refactor this repo to eliminate the Clang toolchain build, as Clang 8.0 is pulled in via the Engine build. The only external deps in case of Linux building the Embedder Engine is fontconfig, and crtstartS/crtendS. The actual runtime doesn't need Clang, and can be built with GCC. For building the Engine with Yocto I have a solution that doesn't involve CMake; easier/cleaner/faster - [flutter_wayland](https://github.com/jwinarske/meta-flutter) +When building with fontconfig enabled, you need to have PKG_CONFIG_PATH set to find `freetype2.pc`. -## * Raspberry PI bits * +My current focus has been evolving Wayland Client as part of Yocto based images: -The default build configuration (provided a properly configured sysroot), will generate bits that execute on a Raspberry Pi. +[meta-flutter](https://github.com/jwinarske/meta-flutter) -Planned Work Items - - 1. Memory Profiling and optimization. With Debug engine running a simple app on the PI, it's allocating around 150MB, with 12 threads. - 2. Platform Channel handler. This will allow Dart to call C/C++ code. Think CAN bus, I2C, SPI, RS-232, RS-485, MIDI, Audio, Espresso Machine I/O, etc. - 3. Support all 4 machine architectures to build on Linux. Currently only ARM has been tested. - 4. Depending on demand and use cases, add support for building on Mac and Windows (although it may already work)... +[flutter_wayland](https://github.com/jwinarske/flutter_wayland) -# Pre-requisites -1. CMake 3.11 or greater -2. Setup depot_tools and add to path. This provides gclient, ninja, autoninja, etc. - http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up +## * Raspberry PI bits * -3. Confirm you can build the engine repo standalone +The default build configuration (provided a properly configured sysroot), will generate bits that execute on a Raspberry Pi. - https://github.com/flutter/flutter/wiki/Setting-up-the-Engine-development-environment +# Pre-requisites - https://github.com/flutter/flutter/wiki/Compiling-the-engine +1. CMake 3.11 or greater - Install build dependencies with this shell script: +2. (Engine) fontconfig if enabled and building on Linux - install-build-deps.sh +3. Sysroot compatible with the Clang runtime flavors -4. Raspberry Pi prior to generating sysroot +4. (Wayland flutter) handful of dependencies. Read the CMakeLists.txt for fluttr_wayland. - sudo apt-get install libx11-dev - -# Build Tip-Of-Tree Clang, Latest Binutils, and Flutter Engine master branch for Linux arm +# Build Tip-Of-Tree Flutter Engine master branch for Linux arm git clone https://github.com/jwinarske/flutter_embedded cd flutter_embedded mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -GNinja - autoninja + autoninja engine Note: Your build folder can be wherever you want... @@ -82,22 +72,6 @@ This is the target architecture of your build. It must match your toolchain, a ### ENGINE_REPO This is the repo of the flutter engine. The default value is https://github.com/flutter/engine.git. If you want to use your own fork, set this variable to point to your fork's url. -### LLVM_TARGETS_TO_BUILD -List of Targets LLVM should be built with. Relavant to Flutter the options are: -"AArch64;ARM;X86". Host architecture (x86_64) is implicit, as that is the expected build host. If crosscompiling compiler-rt, libcxxabi, and libcxx the current scheme expects only a single value for LLVM_TARGETS_TO_BUILD. - -### BUILD_COMPILER_RT -Checks out and builds compiler-rt for host and target. Default value is ON, and valid only when TOOLCHAIN_DIR is not set. - -### BUILD_LIBCXXABI -Checks out and builds libcxxabi for host and target. Default value is ON, and valid only when TOOLCHAIN_DIR is not set. - -### BUILD_LIBCXX -Checks out and builds libcxx. Default value is ON, and valid only when TOOLCHAIN_DIR is not set. - -### BUILD_LLD -Checks out and builds lld. Default value is OFF, and valid only when TOOLCHAIN_DIR is not set. This option enables the use of "-fuse-ld=lld". - ### ENGINE_UNOPTIMIZED Unoptimized flag, defaults to OFF @@ -229,8 +203,7 @@ When adding in Linux support to the Dart code, start by adding "case TargetPlatf cd {flutter app project folder} flutter build bundle -*Note: You either need to override debugDefaultTargetPlatformOverride, or -"Enable Linux as a Platform in your Flutter Repo"* +*Note: You either need to override TargetPlatform prior to running the app* ## Tested Flutter Examples @@ -241,13 +214,11 @@ Tested apps post Flutter Dart "linux" platfrom add flutter/examples/flutter_view flutter/examples/hello_world flutter/examples/layers * Generates rendered text: "Instead run", "flutter run lib/xxx.dart" - flutter/examples/platform_channel *requires MessageCallback impl for 100% + flutter/examples/platform_channel flutter/examples/platform_view * Android view not impl.. no-op btn flutter/examples/stocks flutter-desktop-embedding/example/flutter_app -Depending on the app, be preapred for Dart runtime exceptions. Refer to https://github.com/flutter/flutter/issues - ### Push built Flutter Application to Target scp -r {flutter app root }/build/* pi@raspberrypi.local:/home/pi diff --git a/cmake/build_dependencies.cmake b/cmake/build_dependencies.cmake deleted file mode 100755 index fc6b0821..00000000 --- a/cmake/build_dependencies.cmake +++ /dev/null @@ -1,138 +0,0 @@ -# -# MIT License -# -# Copyright (c) 2018 Joel Winarske -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. -# - -include (ExternalProject) - -if(NOT ANDROID) - - if(NOT TARGET_ARCH) - set(TARGET_ARCH arm) - endif() - - if(NOT TOOLCHAIN_DIR) - set(BUILD_TOOLCHAIN true) - set(TOOLCHAIN_DIR ${CMAKE_SOURCE_DIR}/sdk/toolchain) - - if(NOT LLVM_TARGETS_TO_BUILD) - set(LLVM_TARGETS_TO_BUILD ARM) #ARM|AArch64|X86 - endif() - endif() - - if(NOT TARGET_SYSROOT) - set(TARGET_SYSROOT ${CMAKE_SOURCE_DIR}/sdk/sysroot) - endif() - - if(NOT TARGET_TRIPLE) - set(TARGET_TRIPLE ${TARGET_ARCH}-linux-gnueabihf) - endif() - - if(NOT LLVM_VERSION) - set(LLVM_VERSION tags/RELEASE_900/final/) - endif() - - if(NOT LLVM_VER_DIR) - set(LLVM_VER_DIR 9.0.0) - endif() - - if(BUILD_TOOLCHAIN) - ExternalProject_Add(toolchain - GIT_REPOSITORY https://github.com/jwinarske/clang_toolchain.git - GIT_TAG master - UPDATE_COMMAND "" - BUILD_IN_SOURCE 0 - LIST_SEPARATOR | - CMAKE_ARGS - -DCMAKE_INSTALL_PREFIX=${TOOLCHAIN_DIR} - -DCMAKE_BUILD_TYPE=MinSizeRel - -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} - -DBUILD_PLATFORM_SYSROOT=${BUILD_PLATFORM_SYSROOT} - -DBUILD_PLATFORM_RPI=${BUILD_RPI_FLUTTER} - -DTHIRD_PARTY_DIR=${CMAKE_SOURCE_DIR}/third_party - -DTOOLCHAIN_DIR=${TOOLCHAIN_DIR} - -DTOOLCHAIN_FILE_DIR=${CMAKE_BINARY_DIR} - -DTARGET_SYSROOT=${TARGET_SYSROOT} - -DTARGET_TRIPLE=${TARGET_TRIPLE} - -DLLVM_TARGETS_TO_BUILD=${LLVM_TARGETS_TO_BUILD} - -DLLVM_VERSION=${LLVM_VERSION} - -DLLVM_VER_DIR=${LLVM_VER_DIR} - -DBUILD_PLATFORM_RPI_HELLO=OFF - -DBUILD_MRAA=ON - INSTALL_COMMAND ${CMAKE_COMMAND} -E copy - ${TOOLCHAIN_DIR}/lib/clang/${LLVM_VER_DIR}/${TARGET_TRIPLE}/lib/libc++${CMAKE_SHARED_LIBRARY_SUFFIX}.1.0 - ${CMAKE_BINARY_DIR}/target/lib/libc++${CMAKE_SHARED_LIBRARY_SUFFIX}.1 && - ${CMAKE_COMMAND} -E copy - ${TOOLCHAIN_DIR}/lib/clang/${LLVM_VER_DIR}/${TARGET_TRIPLE}/lib/libc++abi${CMAKE_SHARED_LIBRARY_SUFFIX}.1.0 - ${CMAKE_BINARY_DIR}/target/lib/libc++abi${CMAKE_SHARED_LIBRARY_SUFFIX}.1 && - chmod +x ${CMAKE_BINARY_DIR}/target/lib/libc++${CMAKE_SHARED_LIBRARY_SUFFIX}.1 && - chmod +x ${CMAKE_BINARY_DIR}/target/lib/libc++abi${CMAKE_SHARED_LIBRARY_SUFFIX}.1 - ) - endif() -endif() - - -if(NOT ENGINE_REPO) - set(ENGINE_REPO https://github.com/flutter/engine.git) -endif() - -set(ENGINE_SRC_PATH ${CMAKE_BINARY_DIR}/engine-prefix/src/engine) -include(engine_options) - -set(ENGINE_INCLUDE_DIR ${ENGINE_SRC_PATH}/src/${ENGINE_OUT_DIR}) -set(ENGINE_LIBRARIES_DIR ${ENGINE_SRC_PATH}/src/${ENGINE_OUT_DIR}) - -# update patch file with toolchain dirs -configure_file(cmake/patches/engine_compiler_build.patch.in ${CMAKE_BINARY_DIR}/engine_compiler_build.patch @ONLY) - -if(NOT ANDROID) - set(DISABLE_ANDROID_HOOKS --custom-var=download_android_deps=false) -endif() - -find_program(gclient REQUIRED) -ExternalProject_Add(engine - DOWNLOAD_COMMAND - cd ${ENGINE_SRC_PATH} && - gclient config --name=src/flutter --unmanaged ${DISABLE_ANDROID_HOOKS} https://github.com/flutter/engine.git && - gclient sync -j8 - PATCH_COMMAND - cd ${ENGINE_SRC_PATH} && - cd src && git checkout build/config/compiler/BUILD.gn && git apply ${CMAKE_BINARY_DIR}/engine_compiler_build.patch && - cd flutter && git apply ${CMAKE_SOURCE_DIR}/cmake/patches/engine.patch && cd .. && - cd third_party/dart && git checkout runtime/BUILD.gn && git apply ${CMAKE_SOURCE_DIR}/cmake/patches/dart.patch && - cd ../../.. - UPDATE_COMMAND "" - BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND src/flutter/tools/gn ${ENGINE_FLAGS} - BUILD_COMMAND autoninja -C src/${ENGINE_OUT_DIR} - INSTALL_COMMAND - ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/target/lib && - ${CMAKE_COMMAND} -E copy ${ENGINE_LIBRARIES_DIR}/icudtl.dat ${CMAKE_BINARY_DIR}/target/bin && - ${CMAKE_COMMAND} -E copy ${ENGINE_LIBRARIES_DIR}/libflutter_engine${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/target/lib && - ${CMAKE_COMMAND} -E copy ${ENGINE_LIBRARIES_DIR}/libflutter_linux${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/target/lib -) -if(BUILD_TOOLCHAIN) - add_dependencies(engine toolchain) -endif() - -include_directories(${ENGINE_INCLUDE_DIR}) -link_directories(${ENGINE_LIBRARIES_DIR}) diff --git a/cmake/llvm_config.cmake b/cmake/depot_tools.cmake similarity index 50% rename from cmake/llvm_config.cmake rename to cmake/depot_tools.cmake index aac24e10..6a215738 100644 --- a/cmake/llvm_config.cmake +++ b/cmake/depot_tools.cmake @@ -1,7 +1,7 @@ # # MIT License # -# Copyright (c) 2018 Joel Winarske +# Copyright (c) 2018-2020 Joel Winarske # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,36 +22,16 @@ # SOFTWARE. # -message(STATUS "llvm-config ............ ${LLVM_CONFIG_PATH}") +include (ExternalProject) -set(CONFIG_COMMAND ${LLVM_CONFIG_PATH} - "--version" - "--cflags" - "--cxxflags" - "--ldflags" - ) - -execute_process( - COMMAND ${CONFIG_COMMAND} - RESULT_VARIABLE HAD_ERROR - OUTPUT_VARIABLE CONFIG_OUTPUT +ExternalProject_Add(depot_tools + GIT_REPOSITORY https://chromium.googlesource.com/chromium/tools/depot_tools.git + GIT_TAG master + GIT_SHALLOW 1 + SOURCE_DIR ${DEPOT_TOOLS_DIR} + UPDATE_COMMAND "" + BUILD_IN_SOURCE 0 + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" ) - -if(NOT HAD_ERROR) - string(REGEX REPLACE "[ \t]*[\r\n]+[ \t]*" ";" CONFIG_OUTPUT ${CONFIG_OUTPUT}) -else() - string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}") - message(STATUS "${CONFIG_COMMAND_STR}") - message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}") -endif() - -list(GET CONFIG_OUTPUT 0 __VERSION) -list(GET CONFIG_OUTPUT 1 __CFLAGS) -list(GET CONFIG_OUTPUT 2 __CXXFLAGS) -list(GET CONFIG_OUTPUT 3 __LDFLAGS) - -string(REGEX REPLACE "svn" "" __VERSION ${__VERSION}) -set(LLVM_VERSION ${__VERSION} CACHE PATH "llvm version") -set(LLVM_CFLAGS ${__CFLAGS} CACHE PATH "llvm c flags") -set(LLVM_CXXFLAGS ${__CXXFLAGS} CACHE PATH "llvm cxx flags") -set(LLVM_LDFLAGS ${__LDFLAGS} CACHE PATH "llvm linker flags") diff --git a/cmake/engine.cmake b/cmake/engine.cmake new file mode 100644 index 00000000..2e478aa5 --- /dev/null +++ b/cmake/engine.cmake @@ -0,0 +1,66 @@ +# +# MIT License +# +# Copyright (c) 2018-2020 Joel Winarske +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +if(NOT ENGINE_COMMIT) + set(ENGINE_COMMIT 9e5072f0ce81206b99db3598da687a19ce57a863) +endif() +MESSAGE(STATUS "Engine Commit .......... ${ENGINE_COMMIT}") + +set(ENGINE_SRC_PATH ${THIRD_PARTY_DIR}/engine) + +include(engine_options) + +ExternalProject_Add(engine + DOWNLOAD_COMMAND + ${CMAKE_COMMAND} -E make_directory ${ENGINE_SRC_PATH} && + cd ${ENGINE_SRC_PATH} && + gclient config --spec ${GCLIENT_CONFIG} && + gclient sync --nohooks --no-history --revision ${ENGINE_COMMIT} -j ${NUM_PROC} -v + PATCH_COMMAND + cd ${ENGINE_SRC_PATH}/src && + git apply ${CMAKE_SOURCE_DIR}/cmake/patches/custom_BUILD_gn.patch && + cd third_party/icu && + git apply ${CMAKE_SOURCE_DIR}/cmake/patches/icu.patch + UPDATE_COMMAND "" + BUILD_IN_SOURCE 0 + CONFIGURE_COMMAND + cd ${ENGINE_SRC_PATH}/src && + PKG_CONFIG_PATH=${PKG_CONFIG_PATH} ./flutter/tools/gn ${ENGINE_FLAGS} && + echo "custom_lib_flags = \"${ENGINE_CUSTOM_LIB_FLAGS}\"" >> ${ENGINE_OUT_DIR}/args.gn + BUILD_COMMAND "" + cd ${ENGINE_SRC_PATH}/src && + ninja -j ${NUM_PROC} -C ${ENGINE_OUT_DIR} + INSTALL_COMMAND + cd ${ENGINE_SRC_PATH}/src && + ${CMAKE_COMMAND} -E copy ${ENGINE_OUT_DIR}/icudtl.dat ${CMAKE_BINARY_DIR} && + ${CMAKE_COMMAND} -E copy ${ENGINE_OUT_DIR}/libflutter_engine${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR} && + ${CMAKE_COMMAND} -E copy ${ENGINE_OUT_DIR}/flutter_embedder.h ${CMAKE_BINARY_DIR} +) +add_dependencies(engine sysroot depot_tools) + +set(ENGINE_INCLUDE_DIR ${ENGINE_SRC_PATH}/src/${ENGINE_OUT_DIR}) +set(ENGINE_LIBRARIES_DIR ${ENGINE_SRC_PATH}/src/${ENGINE_OUT_DIR}) + +include_directories(${ENGINE_INCLUDE_DIR}) +link_directories(${ENGINE_LIBRARIES_DIR}) diff --git a/cmake/engine_options.cmake b/cmake/engine_options.cmake index 38d72843..fe476237 100644 --- a/cmake/engine_options.cmake +++ b/cmake/engine_options.cmake @@ -1,7 +1,7 @@ # # MIT License # -# Copyright (c) 2018 Joel Winarske +# Copyright (c) 2018-2020 Joel Winarske # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,78 +22,101 @@ # SOFTWARE. # + option(ENGINE_UNOPTIMIZED "Unoptimized flag" OFF) +option(ENGINE_INTERPRETER "Enable interpreter" OFF) +option(ENGINE_DART_DEBUG "Enable dart-debug" OFF) +option(ENGINE_FULL_DART_DEBUG "Enable full-dart-debug" OFF) +option(ENGINE_SIMULATOR "Enable Simulator" OFF) +option(ENGINE_GOMA "Enable goma" OFF) +option(ENGINE_LTO "Enable lto" ON) +option(ENGINE_CLANG "Enable clang" ON) +option(ENGINE_EMBEDDER_FOR_TARGET "Embedder for Target" ON) +option(ENGINE_ENABLE_VULCAN "Enable Vulcan" OFF) +option(ENGINE_ENABLE_FONTCONFIG "Enable Font Config" ON) +option(ENGINE_ENABLE_SKSHAPER "Enable skshaper" OFF) +option(ENGINE_ENABLE_VULCAN_VALIDATION_LAYERS "Enable Vulcan Validation Layers" OFF) +option(ENGINE_COVERAGE "Enable Code Coverage" OFF) +option(ENGINE_FULL_DART_SDK "Enable Full Dart SDK" ON) +option(ENGINE_DISABLE_DESKTOP "Disable Desktop" ON) + + if(ENGINE_UNOPTIMIZED) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --unoptimized) - set(APPEND_UNOPT _unopt) + list(APPEND ENGINE_FLAGS --unoptimized) endif() if(NOT ENGINE_RUNTIME_MODE) - set(ENGINE_RUNTIME_MODE "release" CACHE STRING "Choose the runtime mode, options are: debug, profile, or release." FORCE) - message(STATUS "ENGINE_RUNTIME_MODE not set, defaulting to release.") + set(ENGINE_RUNTIME_MODE "debug" CACHE STRING "Choose the runtime mode, options are: debug, profile, release, or jit_release." FORCE) + message(STATUS "ENGINE_RUNTIME_MODE not set, defaulting to debug.") endif() -set(ENGINE_FLAGS ${ENGINE_FLAGS} --runtime-mode ${ENGINE_RUNTIME_MODE}) -set(APPEND_RUNTIME_MODE _${ENGINE_RUNTIME_MODE}) +list(APPEND ENGINE_FLAGS --runtime-mode ${ENGINE_RUNTIME_MODE}) +if(ENGINE_INTERPRETER) + list(APPEND ENGINE_FLAGS --interpreter) +endif() -option(ENGINE_DYNAMIC "Enable dynamic" ON) -if(ENGINE_DYNAMIC) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --dynamic) - if(TARGET_ARCH MATCHES "$arm") - set(APPEND_DYNAMIC ) - else() - if(ENGINE_RUNTIME_MODE MATCHES "^debug") - set(APPEND_DYNAMIC ) - else() - set(APPEND_DYNAMIC _dynamic) - endif() - endif() +if(ENGINE_DART_DEBUG) + list(APPEND ENGINE_FLAGS --dart-debug) +endif() + +if(ENGINE_FULL_DART_DEBUG) + list(APPEND ENGINE_FLAGS --full-dart-debug) endif() -option(ENGINE_SIMULATOR "Enable simulator" OFF) if(ENGINE_SIMULATOR) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --simulator) + list(APPEND ENGINE_FLAGS --simulator) endif() -option(ENGINE_INTERPRETER "Enable interpreter" OFF) -if(ENGINE_INTERPRETER) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --interpreter) +if(ENGINE_GOMA) + list(APPEND ENGINE_FLAGS --goma) +else() + list(APPEND ENGINE_FLAGS --no-goma) endif() -option(ENGINE_DART_DEBUG "Enable dart-debug" OFF) -if(ENGINE_DART_DEBUG) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --dart-debug) +if(ENGINE_LTO) + list(APPEND ENGINE_FLAGS --lto) +else() + list(APPEND ENGINE_FLAGS --no-lto) endif() -option(ENGINE_CLANG "Enable clang" ON) if(ENGINE_CLANG) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --clang) + list(APPEND ENGINE_FLAGS --clang) else() - set(ENGINE_FLAGS ${ENGINE_FLAGS} --no-clang) + list(APPEND ENGINE_FLAGS --no-clang) endif() -option(ENGINE_GOMA "Enable goma" OFF) -if(ENGINE_GOMA) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --goma) -else() - set(ENGINE_FLAGS ${ENGINE_FLAGS} --no-goma) +if(ENGINE_ENABLE_VULCAN) + list(APPEND ENGINE_FLAGS --enable-vulkan) endif() -option(ENGINE_LTO "Enable lto" ON) -if(ENGINE_LTO) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --lto) -else() - set(ENGINE_FLAGS ${ENGINE_FLAGS} --no-lto) +if(ENGINE_ENABLE_FONTCONFIG) + list(APPEND ENGINE_FLAGS --enable-fontconfig) +endif() + +if(ENGINE_ENABLE_SKSHAPER) + list(APPEND ENGINE_FLAGS --enable-skshaper) +endif() + +if(ENGINE_ENABLE_VULCAN_VALIDATION_LAYERS) + list(APPEND ENGINE_FLAGS --enable-vulkan-validation-layers) endif() -option(ENGINE_EMBEDDER_FOR_TARGET "Embedder for Target" ON) if(ENGINE_EMBEDDER_FOR_TARGET) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --embedder-for-target) + list(APPEND ENGINE_FLAGS --embedder-for-target) endif() -option(ENGINE_ENABLE_VULCAN "Enable Vulcan" OFF) -if(ENGINE_ENABLE_VULCAN) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --enable-vulkan) +if(ENGINE_COVERAGE) + list(APPEND ENGINE_FLAGS --coverage) +endif() + +if(ENGINE_FULL_DART_SDK) + list(APPEND ENGINE_FLAGS --full-dart-sdk) +else() + list(APPEND ENGINE_FLAGS --no-full-dart-sdk) +endif() + +if(ENGINE_DISABLE_DESKTOP) + list(APPEND ENGINE_FLAGS --disable-desktop-embeddings) endif() @@ -109,48 +132,79 @@ if(ANDROID) # arm,x64,x86,arm64 if(ANDROID_SYSROOT_ABI STREQUAL "x86_64") set(TARGET_ARCH x64) - set(APPEND_ARCH "_${TARGET_ARCH}") else() set(TARGET_ARCH ${ANDROID_SYSROOT_ABI}) - if(ANDROID_SYSROOT_ABI STREQUAL "arm") - set(APPEND_ARCH "") # default architecture - else() - set(APPEND_ARCH "_${TARGET_ARCH}") - endif() endif() - set(ENGINE_FLAGS ${ENGINE_FLAGS} --${TARGET_OS} --android-cpu ${TARGET_ARCH}) + list(APPEND ENGINE_FLAGS --android --android-cpu ${TARGET_ARCH}) elseif(DARWIN) - set(ENGINE_FLAGS ${ENGINE_FLAGS} --ios --ios-cpu ${TARGET_ARCH}) # arm,arm64 + list(APPEND ENGINE_FLAGS --ios --ios-cpu ${TARGET_ARCH}) # arm,arm64 set(TARGET_OS ios) else() - set(ENGINE_FLAGS ${ENGINE_FLAGS} - --target-sysroot ${TARGET_SYSROOT} - --target-toolchain ${TOOLCHAIN_DIR} - --target-triple ${TARGET_TRIPLE} - --target-os linux - --linux-cpu ${TARGET_ARCH} # x64,x86,arm64,arm - ) + if(${TARGET_ARCH} STREQUAL "arm") + set(TARGET_TRIPLE armv7-unknown-linux-gnueabihf) + elseif(${TARGET_ARCH} STREQUAL "arm64") + set(TARGET_TRIPLE aarch64-unknown-linux-gnu) + elseif(${TARGET_ARCH} STREQUAL "x64") + set(TARGET_TRIPLE x86_64-unknown-linux-gnu) + elseif(${TARGET_ARCH} STREQUAL "x86") + set(TARGET_TRIPLE i386-unknown-linux-gnu) + endif() + + list(APPEND ENGINE_FLAGS --target-os linux) + list(APPEND ENGINE_FLAGS --linux-cpu ${TARGET_ARCH}) + list(APPEND ENGINE_FLAGS --target-sysroot ${TARGET_SYSROOT}) + list(APPEND ENGINE_FLAGS --target-toolchain ${TOOLCHAIN_DIR}) + list(APPEND ENGINE_FLAGS --target-triple ${TARGET_TRIPLE}) set(TARGET_OS linux) - set(APPEND_ARCH "_${TARGET_ARCH}") endif() if(TARGET_ARCH MATCHES "^arm") if(NOT ENGINE_ARM_FP) if(${TARGET_TRIPLE} MATCHES "hf$") - set(ENGINE_FLAGS ${ENGINE_FLAGS} --arm-float-abi hard) + list(APPEND ENGINE_FLAGS --arm-float-abi hard) elseif(${TARGET_TRIPLE} MATCHES "eabi$") - set(ENGINE_FLAGS ${ENGINE_FLAGS} --arm-float-abi soft) + list(APPEND ENGINE_FLAGS --arm-float-abi soft) endif() elseif(ENGINE_ARM_FP) if(ENGINE_ARM_FP STREQUAL "hard" OR ENGINE_ARM_FP STREQUAL "soft" OR ENGINE_ARM_FP STREQUAL "softfp") - set(ENGINE_FLAGS ${ENGINE_FLAGS} --arm-float-abi ${ENGINE_ARM_FP}) + list(APPEND ENGINE_FLAGS --arm-float-abi ${ENGINE_ARM_FP}) endif() endif() endif() -set(ENGINE_OUT_DIR out/${TARGET_OS}${APPEND_DYNAMIC}${APPEND_RUNTIME_MODE}${APPEND_UNOPT}${APPEND_ARCH}) +if(NOT ANDROID) + set(DOWNLOAD_ANDROID_DEPS "False") +else() + set(DOWNLOAD_ANDROID_DEPS "True") +endif() + +if(NOT MSVC) + set(DOWNLOAD_MSVC_DEPS "False") +else() + set(DOWNLOAD_MSVC_DEPS "True") +endif() + +set(GCLIENT_CONFIG "solutions=[{\"managed\":False,\"name\":\"src/flutter\",\"url\":\"git@github.com:flutter/engine.git\",\"custom_vars\":{\"download_android_deps\":${DOWNLOAD_ANDROID_DEPS},\"download_windows_deps\":${DOWNLOAD_MSVC_DEPS},}}]") + +if(NOT PKG_CONFIG_PATH) + set(PKG_CONFIG_PATH "/usr/lib/x86_64-linux-gnu/pkgconfig") +else() + set(PKG_CONFIG_PATH "${PKG_CONFIG_PATH}") +endif() + +string(REPLACE ";" " " ENGINE_FLAGS_PRETTY "${ENGINE_FLAGS}") +MESSAGE(STATUS "Engine Flags ........... ${ENGINE_FLAGS_PRETTY}") + +if(NOT ENGINE_CUSTOM_LIB_FLAGS) + # TODO - if rpi sysroot + set(ENGINE_CUSTOM_LIB_FLAGS "$target_sysroot/usr/lib/arm-linux-gnueabihf/libpthread.a $target_sysroot/usr/lib/gcc/arm-linux-gnueabihf/8/libgcc_eh.a $target_sysroot/usr/lib/arm-linux-gnueabihf/libc.a -Wl,-z,notext") +endif() +MESSAGE(STATUS "custom_lib_flags ....... ${ENGINE_CUSTOM_LIB_FLAGS}") + +# TODO - dynamically detect this path +set(ENGINE_OUT_DIR out/linux_debug_arm) diff --git a/cmake/hello_pi.cmake b/cmake/hello_pi.cmake index 2e7784a0..9c01c51e 100644 --- a/cmake/hello_pi.cmake +++ b/cmake/hello_pi.cmake @@ -1,7 +1,7 @@ # # MIT License # -# Copyright (c) 2018 Joel Winarske +# Copyright (c) 2018-2020 Joel Winarske # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/cmake/options.cmake b/cmake/options.cmake new file mode 100644 index 00000000..61f09f3c --- /dev/null +++ b/cmake/options.cmake @@ -0,0 +1,55 @@ +# +# MIT License +# +# Copyright (c) 2018-2020 Joel Winarske +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +option(BUILD_PLATFORM_SYSROOT "Build Platform sysroot" ON) +option(BUILD_PLATFORM_SYSROOT_RPI "Build Raspberry Pi Sysroot" ON) + +option(BUILD_FLUTTER_RPI "Build RPI Flutter Shell" OFF) +option(BUILD_PI_USERLAND "Build Pi userland repo - !!replaces sysroot/opt/vc!!" OFF) +option(BUILD_HELLO_PI "Build the apps in {sysroot}/opt/vc/src/hello_pi" ON) +option(BUILD_TSLIB "Checkout and build tslib for target" ON) + +option(BUILD_FLUTTER_WAYLAND "Build Wayland Flutter Shell" ON) + +if(NOT TARGET_ARCH) + set(TARGET_ARCH "arm" CACHE STRING "Choose the target arch, options are: x64, x86, arm64, or arm." FORCE) + message(STATUS "ENGINE_RUNTIME_MODE not set, defaulting to arm.") +endif() + +if(NOT TARGET_SYSROOT) + set(TARGET_SYSROOT "${CMAKE_SOURCE_DIR}/sysroot") +endif() + +if(NOT THIRD_PARTY_DIR) + SET(THIRD_PARTY_DIR "${CMAKE_SOURCE_DIR}/third_party") +endif() + +if(NOT TOOLCHAIN_DIR) + # TODO - only tested with linux + set(TOOLCHAIN_DIR "${THIRD_PARTY_DIR}/engine/src/buildtools/linux-x64/clang") +endif() + +if(NOT DEPOT_TOOLS_DIR) + SET(DEPOT_TOOLS_DIR "${THIRD_PARTY_DIR}/depot_tools") +endif() diff --git a/cmake/patches/custom_BUILD_gn.patch b/cmake/patches/custom_BUILD_gn.patch new file mode 100644 index 00000000..1657a183 --- /dev/null +++ b/cmake/patches/custom_BUILD_gn.patch @@ -0,0 +1,50 @@ +diff --git a/build/config/sysroot.gni b/build/config/sysroot.gni +index fb0f3c3..69bbf7e 100644 +--- a/build/config/sysroot.gni ++++ b/build/config/sysroot.gni +@@ -27,7 +27,7 @@ if (current_toolchain == default_toolchain && target_sysroot != "") { + } else if (is_linux && !is_chromeos) { + if (current_cpu == "mipsel") { + sysroot = rebase_path("//mipsel-sysroot/sysroot") +- } else if (use_default_linux_sysroot && !is_fuchsia && current_cpu == "x64") { ++ } else if (use_default_linux_sysroot && !is_fuchsia && target_cpu == "x64") { + sysroot = rebase_path("//build/linux/debian_sid_amd64-sysroot") + assert( + exec_script("//build/dir_exists.py", [ sysroot ], "string") == "True", +diff --git a/build/toolchain/custom/BUILD.gn b/build/toolchain/custom/BUILD.gn +index 65b1623..9de1f04 100644 +--- a/build/toolchain/custom/BUILD.gn ++++ b/build/toolchain/custom/BUILD.gn +@@ -12,16 +12,15 @@ toolchain("custom") { + # these values in our scope. + cc = "${toolchain_bin}/clang" + cxx = "${toolchain_bin}/clang++" +- ar = "${toolchain_bin}/${custom_target_triple}-ar" ++ ar = "${toolchain_bin}/llvm-ar" + ld = "${toolchain_bin}/clang++" +- readelf = "${toolchain_bin}/${custom_target_triple}-readelf" +- nm = "${toolchain_bin}/${custom_target_triple}-nm" +- strip = "${toolchain_bin}/${custom_target_triple}-strip" ++ readelf = "${toolchain_bin}/llvm-readelf" ++ nm = "${toolchain_bin}/llvm-nm" ++ strip = "${toolchain_bin}/llvm-strip" + + target_triple_flags = "--target=${custom_target_triple}" + sysroot_flags = "--sysroot ${custom_sysroot}" + +- custom_lib_flags = "-L${custom_toolchain}/lib" + + # These library switches can apply to all tools below. + lib_switch = "-l" +diff --git a/build/toolchain/custom/custom.gni b/build/toolchain/custom/custom.gni +index 6d7bc6c..f1ea197 100644 +--- a/build/toolchain/custom/custom.gni ++++ b/build/toolchain/custom/custom.gni +@@ -14,4 +14,7 @@ declare_args() { + + # The target triple. For example: arm-linux-gnueabihf. + custom_target_triple = "" ++ ++ # Values to pass to the linker ++ custom_lib_flags = "" + } diff --git a/cmake/patches/dart.patch b/cmake/patches/dart.patch deleted file mode 100644 index 03bb5035..00000000 --- a/cmake/patches/dart.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn -index ecf8a5d55c..a754002a6b 100644 ---- a/runtime/BUILD.gn -+++ b/runtime/BUILD.gn -@@ -150,7 +150,7 @@ config("dart_config") { - - if (!is_win) { - cflags = [ -- "-Werror", -+ #"-Werror", - "-Wall", - "-Wextra", # Also known as -W. - "-Wno-unused-parameter", diff --git a/cmake/patches/engine.patch b/cmake/patches/engine.patch deleted file mode 100644 index e69de29b..00000000 diff --git a/cmake/patches/engine_compiler_build.patch.in b/cmake/patches/engine_compiler_build.patch.in deleted file mode 100644 index 7aa90355..00000000 --- a/cmake/patches/engine_compiler_build.patch.in +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn -index e6fb53d4c..037c3759c 100644 ---- a/build/config/compiler/BUILD.gn -+++ b/build/config/compiler/BUILD.gn -@@ -608,11 +608,26 @@ config("runtime_library") { - # gen_snapshot) where this is not supported. - if (is_linux) { - if (current_cpu != "x86") { -- cflags_cc += [ "-nostdinc++" ] -- include_dirs = [ -- "//third_party/libcxx/include", -- "//third_party/libcxxabi/include", -+ cflags_cc += [ -+ #"-ggdb", -+ #"-ggdb3", -+ "-stdlib=libc++", -+ "-I@CMAKE_SOURCE_DIR@/third_party/libcxx/include", -+ "-I@CMAKE_SOURCE_DIR@/third_party/libcxxabi/include", -+ "-fno-exceptions", -+ "-D_GNU_SOURCE", "-D__STDC_CONSTANT_MACROS", "-D__STDC_FORMAT_MACROS", "-D__STDC_LIMIT_MACROS" - ] -+ -+ ldflags += [ -+ "-L@TOOLCHAIN_DIR@/lib", -+ "-stdlib=libc++", -+ "--rtlib=compiler-rt", -+ "-fuse-ld=gold", -+ ] -+ -+ libs += [ -+ "c++abi", -+ ] - } else { - cflags_cc += [ "-stdlib=libstdc++" ] - ldflags += [ "-stdlib=libstdc++" ] - diff --git a/cmake/patches/flutter_platform.patch b/cmake/patches/flutter_platform.patch deleted file mode 100644 index 79cb7d9a..00000000 --- a/cmake/patches/flutter_platform.patch +++ /dev/null @@ -1,22 +0,0 @@ -diff --git a/packages/flutter/lib/src/foundation/platform.dart b/packages/flutter/lib/src/foundation/platform.dart -index b3ede1c85..205fe9c00 100644 ---- a/packages/flutter/lib/src/foundation/platform.dart -+++ b/packages/flutter/lib/src/foundation/platform.dart -@@ -18,6 +18,8 @@ enum TargetPlatform { - - /// iOS: - iOS, -+ -+ linux, - } - - /// The [TargetPlatform] that matches the platform on which the framework is -@@ -56,6 +58,8 @@ TargetPlatform get defaultTargetPlatform { - result = TargetPlatform.android; - } else if (Platform.isFuchsia) { - result = TargetPlatform.fuchsia; -+ } else if (Platform.isLinux) { -+ result = TargetPlatform.linux; - } - assert(() { - if (Platform.environment.containsKey('FLUTTER_TEST')) diff --git a/cmake/patches/icu.patch b/cmake/patches/icu.patch new file mode 100644 index 00000000..28bad4cb --- /dev/null +++ b/cmake/patches/icu.patch @@ -0,0 +1,13 @@ +diff --git a/source/i18n/plurrule.cpp b/source/i18n/plurrule.cpp +index fd193560..09200fb8 100644 +--- a/source/i18n/plurrule.cpp ++++ b/source/i18n/plurrule.cpp +@@ -1661,7 +1661,7 @@ int64_t FixedDecimal::getFractionalDigits(double n, int32_t v) { + case 3: return (int64_t)(fract*1000.0 + 0.5); + default: + double scaled = floor(fract * pow(10.0, (double)v) + 0.5); +- if (scaled > U_INT64_MAX) { ++ if ((int64_t)scaled > U_INT64_MAX) { + return U_INT64_MAX; + } else { + return (int64_t)scaled; diff --git a/cmake/rpi.cmake b/cmake/rpi.cmake index aa651a9f..23e4aa04 100644 --- a/cmake/rpi.cmake +++ b/cmake/rpi.cmake @@ -1,7 +1,7 @@ # # MIT License # -# Copyright (c) 2018 Joel Winarske +# Copyright (c) 2018-2020 Joel Winarske # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,6 @@ # SOFTWARE. # -option(BUILD_PI_USERLAND "Build Pi userland repo - !!replaces sysroot/opt/vc!!" OFF) if(BUILD_PI_USERLAND) ExternalProject_Add(pi_userland @@ -39,13 +38,10 @@ if(BUILD_PI_USERLAND) -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} ) - if(BUILD_TOOLCHAIN) - add_dependencies(pi_userland toolchain) - endif() + add_dependencies(pi_userland engine) endif() -option(BUILD_HELLO_PI "Build the apps in {sysroot}/opt/vc/src/hello_pi" ON) if(BUILD_HELLO_PI) # These are C apps... @@ -63,16 +59,13 @@ if(BUILD_HELLO_PI) -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} ) - if(BUILD_TOOLCHAIN) - add_dependencies(hello_pi toolchain) - endif() + add_dependencies(hello_pi engine) if(BUILD_PI_USERLAND) add_dependencies(hello_pi pi_userland) endif() endif() -option(BUILD_TSLIB "Checkout and build tslib for target" ON) if(BUILD_TSLIB AND NOT ANDROID) ExternalProject_Add(tslib GIT_REPOSITORY https://github.com/kergoth/tslib.git @@ -86,20 +79,17 @@ if(BUILD_TSLIB AND NOT ANDROID) -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_VERBOSE_MAKEFILE=${CMAKE_VERBOSE_MAKEFILE} ) - if(BUILD_TOOLCHAIN) - add_dependencies(tslib toolchain) - endif() + add_dependencies(tslib engine) endif() # # build flutter executable # -set(FLUTTER_TARGET_NAME "Raspberry Pi") ExternalProject_Add(rpi_flutter GIT_REPOSITORY https://github.com/jwinarske/flutter_from_scratch.git GIT_TAG clang_fixes - GIT_SHALLOW true + GIT_SHALLOW 1 PATCH_COMMAND "" BUILD_IN_SOURCE 0 UPDATE_COMMAND "" diff --git a/cmake/rpi.flutter.cmake b/cmake/rpi.flutter.cmake index 7688a1ba..dbeff59f 100644 --- a/cmake/rpi.flutter.cmake +++ b/cmake/rpi.flutter.cmake @@ -1,7 +1,7 @@ # # MIT License # -# Copyright (c) 2018 Joel Winarske +# Copyright (c) 2018-2020 Joel Winarske # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal diff --git a/cmake/skia.gclient.in b/cmake/skia.gclient.in deleted file mode 100644 index 59fff274..00000000 --- a/cmake/skia.gclient.in +++ /dev/null @@ -1,8 +0,0 @@ -solutions = [ - { - "url": "@SKIA_REPO@", - "managed": False, - "name": "skia", - "deps_file": "DEPS", - }, -] \ No newline at end of file diff --git a/cmake/sysroot.cmake b/cmake/sysroot.cmake new file mode 100644 index 00000000..7d31f0d9 --- /dev/null +++ b/cmake/sysroot.cmake @@ -0,0 +1,176 @@ +# +# MIT License +# +# Copyright (c) 2018-2020 Joel Winarske +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# + +include(ExternalProject) + +find_program(RSYNC rsync) + +# +# Avoid downloading img file, and the ensuing su mount. +# Useful when you don't have the target available. +# +if(BUILD_PLATFORM_SYSROOT) + + + if(BUILD_PLATFORM_SYSROOT_RPI) + + # Shop for Raspbian rootfs releases here: + # https://downloads.raspberrypi.org/raspbian/archive/ + # + if(NOT ROOTFS_ARCHIVE_VERSION) + set(ROOTFS_ARCHIVE_VERSION 2020-02-14-13:48) + endif() + + if(NOT ROOTFS_ARCHIVE_MD5) + set(ROOTFS_ARCHIVE_MD5 922e717dd1f2968e41c9f7c6b17dda13) + endif() + + if(NOT ROOTFS_ARCHIVE_BASE_URL) + set(ROOTFS_ARCHIVE_BASE_URL http://director.downloads.raspberrypi.org/raspbian/archive/) + endif() + + if(NOT ROOTFS_ARCHIVE_NAME) + set(ROOTFS_ARCHIVE_NAME root) + endif() + + if(NOT ROOTFS_ARCHIVE_EXT) + set(ROOTFS_ARCHIVE_EXT tar.xz) + endif() + + set(ROOTFS_ARCHIVE_URL ${ROOTFS_ARCHIVE_BASE_URL}${ROOTFS_ARCHIVE_VERSION}/${ROOTFS_ARCHIVE_NAME}.${ROOTFS_ARCHIVE_EXT}) + MESSAGE(STATUS "ROOTFS_ARCHIVE_URL ..... ${ROOTFS_ARCHIVE_URL}") + + find_program(tar REQUIRED) + + # limit what is extracted saving time and space + set(ARCHIVE_FILE_PATH ${CMAKE_BINARY_DIR}/sysroot-prefix/src/${ROOTFS_ARCHIVE_NAME}.${ROOTFS_ARCHIVE_EXT}) + set(ARCHIVE_EXTRACT_CMD + cd ${TARGET_SYSROOT} && + tar -xf ${ARCHIVE_FILE_PATH} ./lib/ > /dev/null && + tar -xf ${ARCHIVE_FILE_PATH} ./usr/ > /dev/null && + tar -xf ${ARCHIVE_FILE_PATH} ./opt/vc/ > /dev/null + ) + + endif() + + ExternalProject_Add(sysroot + URL ${ROOTFS_ARCHIVE_URL} + URL_MD5 ${ROOTFS_ARCHIVE_MD5} + DOWNLOAD_NO_EXTRACT true + PATCH_COMMAND ${CMAKE_COMMAND} -E make_directory ${TARGET_SYSROOT} + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND ${ARCHIVE_EXTRACT_CMD} + ) + +# +# rsync sysroot +# +elseif(RSYNC AND TARGET_HOSTNAME) + + MESSAGE(STATUS "Syncing sysroot from '${TARGET_HOSTNAME}'") + + set(TARGET_SYSROOT_RSYNC + COMMAND mkdir -p ${TARGET_SYSROOT} && cd ${TARGET_SYSROOT} + COMMAND rsync -avz + --exclude=firmware + --exclude=modules + ${TARGET_HOSTNAME}:/lib/ lib/ + COMMAND rsync -avz + --exclude=lib/chromium-browser/ + --exclude=lib/debug/ + --exclude=lib/firefox/ + --exclude=lib/gcc/ + --exclude=share/doc/ + --exclude=local/${QT_TARGET_FOLDER_NAME}/ + ${TARGET_HOSTNAME}:/usr/ usr/) + + if(BUILD_PLATFORM_RPI) + set(TARGET_SYSROOT_RSYNC ${TARGET_SYSROOT_RSYNC} + COMMAND mkdir -p ${TARGET_SYSROOT}/opt + COMMAND rsync -avz ${TARGET_HOSTNAME}:/opt/vc opt/) + endif() + + if(NOT TARGET_SYSROOT_DEPS) + set(TARGET_SYSROOT_DEPS + ttf-mscorefonts-installer fontconfig upower + libjpeg62-turbo-dev libpng-dev libfreetype6-dev + libssl-dev libicu-dev libxslt1-dev libdbus-1-dev + libfontconfig1-dev libcap-dev libudev-dev libpci-dev + libnss3-dev libasound2-dev libbz2-dev libgcrypt20-dev + libdrm-dev libcups2-dev libevent-dev libinput-dev + libts-dev libmtdev-dev libpcre3-dev libre2-dev + libwebp-dev libopus-dev unixodbc-dev libsqlite0-dev + libxcursor-dev libxcomposite-dev libxdamage-dev + libxrandr-dev libxtst-dev libxss-dev libxkbcommon-dev + libdouble-conversion-dev libbluetooth-dev + libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev + libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev + libatspi2.0-dev + ) + endif() + + if(UPDATE_TARGET) + find_program(ssh REQUIRED) + set(SYSROOT_CONFIGURE_COMMAND + ssh ${TARGET_HOSTNAME} sudo mkdir -p ${QT_TARGET_FOLDER_PATH} && + ssh ${TARGET_HOSTNAME} sudo apt-get update && + ssh ${TARGET_HOSTNAME} sudo apt-get install ${TARGET_SYSROOT_DEPS} -y && + ssh ${TARGET_HOSTNAME} sudo apt-get upgrade -y && + ssh ${TARGET_HOSTNAME} sudo apt autoremove -y + ) + set(SYSROOT_INSTALL_COMMAND + COMMAND ssh ${TARGET_HOSTNAME} sudo reboot > /dev/null) + else() + set(SYSROOT_CONFIGURE_COMMAND "") + set(SYSROOT_INSTALL_COMMAND "") + endif() + + ExternalProject_Add(sysroot + DOWNLOAD_COMMAND "" + CONFIGURE_COMMAND ${SYSROOT_CONFIGURE_COMMAND} + BUILD_COMMAND ${TARGET_SYSROOT_RSYNC} + INSTALL_COMMAND "" + ) + +endif() + + +find_program(python REQUIRED) +find_program(chmod REQUIRED) +set(SYMLINK_FIXUP_SCRIPT ${CMAKE_BINARY_DIR}/symlink_fixups-prefix/src/sysroot-relativelinks.py) +ExternalProject_Add(symlink_fixups + URL https://raw.githubusercontent.com/Kukkimonsuta/rpi-buildqt/master/scripts/utils/sysroot-relativelinks.py + DOWNLOAD_NO_EXTRACT true + CONFIGURE_COMMAND chmod +x ${SYMLINK_FIXUP_SCRIPT} + BUILD_COMMAND ${SYMLINK_FIXUP_SCRIPT} ${TARGET_SYSROOT} + INSTALL_COMMAND "" +) + +if(BUILD_PLATFORM_SYSROOT OR (RSYNC AND TARGET_HOSTNAME)) + add_dependencies(symlink_fixups sysroot) +endif() + + +MESSAGE(STATUS "TARGET_SYSROOT = ${TARGET_SYSROOT}") \ No newline at end of file diff --git a/cmake/wayland.cmake b/cmake/wayland.cmake index 3f4b06bb..270d3dc3 100644 --- a/cmake/wayland.cmake +++ b/cmake/wayland.cmake @@ -1,17 +1,34 @@ -#TODO place holder +# +# MIT License +# +# Copyright (c) 2018-2020 Joel Winarske +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# set(FLUTTER_TARGET_NAME "Wayland") ExternalProject_Add(wayland_flutter - GIT_REPOSITORY https://github.com/chinmaygarde/flutter_wayland.git - GIT_TAG master - BUILD_IN_SOURCE 1 + GIT_REPOSITORY https://github.com/jwinarske/flutter_wayland.git + GIT_TAG waylandpp + GIT_SHALLOW 1 + BUILD_IN_SOURCE 0 PATCH_COMMAND "" UPDATE_COMMAND "" - CONFIGURE_COMMAND "" - BUILD_COMMAND autoninja -C out - INSTALL_COMMAND "" ) -if(BUILD_TOOLCHAIN) - add_dependencies(wayland_flutter toolchain) -endif() add_dependencies(wayland_flutter engine)