2 Star 2 Fork 0

ArkUI-X/build_plugins

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

编译构建

简介

ArkUI-X项目编译构建提供了一个基于GN和Ninja的编译构建框架。基础构建流程Fork OpenHarmony build仓,并在OpenHarmony构建基础上新增Android SDK/NDK和iOS SDK编译支持。

目录

/build_plugins                     # 编译构建主目录
├── app                            # 应用编译相关配置
├── build_scripts                  # 编译相关的shell脚本
├── config                         # 编译相关的配置项
│   ├── aosp
│   ├── ios
│   └── ...
├── prebuilts_download_config.json # 预编译工具链下载配置
├── scripts                        # 编译相关的python脚本
├── sdk                            # ArkUI-X SDK自动打包配置
├── templates                      # c/c++/java编译模板定义
├── toolchain                      # 编译工具链配置
└── version.gni                    # ArkUI-X版本信息

约束与环境配置

  • 编译环境需要Ubuntu18.04及以上版本,macOS需要11.6.2及以上版本。

  • 安装编译所需的程序包。

    [Linux]

    sudo apt-get install binutils git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache libgl1-mesa-dev libxml2-utils xsltproc unzip m4

    [Mac]

    brew install wget coreutils

配置Java环境

说明: 建议下载JDK11.0.2以上版本,下载请点击此处

[Linux]

// 配置环境变量
export JAVA_HOME=/home/usrername/path-to-java-sdk
export PATH=${JAVA_HOME}/bin:${PATH}

[Mac]

// 配置环境变量
export JAVA_HOME=/Users/usrername/path-to-java-sdk
export PATH=$JAVA_HOME/bin:$PATH

配置Android SDK环境

[Linux]

通过命令行工具下载和管理Android SDK,命令行工具使用说明详见sdkmanager官方指导。SDK版本下载要求如下:

./sdkmanager --install "ndk;21.3.6528147" --sdk_root=/home/usrername/path-to-android-sdk
./sdkmanager --install "platforms;android-26" --sdk_root=/home/usrername/path-to-android-sdk
./sdkmanager --install "build-tools;28.0.3" --sdk_root=/home/usrername/path-to-android-sdk
// 配置环境变量
export ANDROID_HOME=/home/usrername/path-to-android-sdk
export PATH=${ANDROID_HOME}/tools:${ANDROID_HOME}/tools/bin:${ANDROID_HOME}/build-tools/28.0.3:${ANDROID_HOME}/platform-tools:${PATH}

[Mac]

通过IDE SDK管理器下载和管理Android SDK,NDK版本要求为:21.3.6528147,SDK Platform版本为:26。

// 配置环境变量
export ANDROID_HOME=/Users/usrername/path-to-android-sdk
export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/tools/bin:$ANDROID_HOME/build-tools/28.0.3:$ANDROID_HOME/platform-tools:$PATH

配置iOS SDK环境

  • Xcode和Command Line Tools for Xcode应用可前往苹果商店下载安装。

  • Command Line Tools也可使用命令方式安装:

    xcode-select --install

说明

  1. 代码根目录下执行ArkUI的跨平台编译命令,示例:

    ./build.sh --product-name arkui-x --target-os android
  2. 编译命令支持选项:

    --product-name    # 必须  编译的产品名称,如:arkui-x
    --target-os       # 必须  编译的跨平台目标,如:android或ios
    --build-target    # 可选  指定编译目标,可以指定多个
    --gn-args         # 可选  gn参数,支持指定多个
    --help, -h        # 可选  命令行help辅助命令
  3. 常用的gn参数:

    --gn-args enable_auto_pack=true     # 使能SDK自动打包
    --gn-args runtime_mode=release      # 编译指定版本SDK
  4. 支持模板类型

    ohos_executable
    ohos_shared_library
    ohos_static_library
    ohos_source_set
    ohos_combine_jars
    java_library
    
    # 预编译模板:
    ohos_prebuilt_executable
    ohos_prebuilt_shared_library
    aosp_system_java_prebuilt

    例子1:

    ohos_shared_library示例:

    import("//build/ohos.gni")
    ohos_shared_library("helloworld") {
      sources = []
      include_dirs = []
      cflags = []
      cflags_c = []
      cflags_cc = []
      ldflags = []
      configs = []
      deps =[]  # 部件内模块依赖
    
      output_name = "" # 可选,模块输出名
      output_extension = "" # 可选,模块名后缀
      part_name = "" # 必选,所属部件名称
    }

    例子2:

    java_library示例:

    import("//build/ohos.gni")
    java_library("foo_java") {
      java_files = [
        "ohos/ace/adapter/Foo.java",
        "ohos/ace/adapter/FooInterface.java",
        "ohos/ace/adapter/FooService.java"
      ]
      deps = [
        ":bar_java"
      ]
    }
Copyright (c) 2023 Huawei Device Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. *************************************************************** build, it is derived from the following: https://chromium.googlesource.com/chromium/src.git version 83.0.4098.1 *************************************************************** Copyright 2015 The Chromium Authors. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Google Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

Cross-platform builds of ArkUI-X | ArkUI-X跨平台工程编译构建 展开 收起
Python 等 3 种语言
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/arkui-x_recycle/build_plugins.git
git@gitee.com:arkui-x_recycle/build_plugins.git
arkui-x_recycle
build_plugins
build_plugins
master

搜索帮助

Cb406eda 1850385 E526c682 1850385