From fc92008a47bb226430160d46805df7f20fe29a35 Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Thu, 22 Feb 2024 22:55:20 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BAHOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- OAT.xml | 1 + README.en.md | 4 +-- README.md | 4 +-- attachment/repos/bootstrap/ohos.py | 50 ++++++++++++++---------------- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/OAT.xml b/OAT.xml index 2e84930ccc..32c103d0c2 100644 --- a/OAT.xml +++ b/OAT.xml @@ -92,6 +92,7 @@ used to filter file path. + +export HOS_SDK_HOME= ``` 5. Start building: In the engine directory, execute `./ohos` to start building the flutter engine that supports ohos devices. diff --git a/README.md b/README.md index e19e793031..7fdff825d8 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,10 @@ Flutter Engine 3. 同步代码:在engine目录,执行`gclient sync`;这里会同步engine源码、官方packages仓,还有执行ohos_setup任务; -4. 下载sdk: 在[每日构建](http://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist)下载ohos-sdk-full,配置以下环境变量: +4. 下载sdk: 从[鸿蒙套件列表](https://developer.harmonyos.com/deveco-developer-suite/enabling/kit?currentPage=1&pageSize=100)下载配套开发工具,暂不支持非该渠道下载的套件 ```sh -export OHOS_SDK_HOME= +export HOS_SDK_HOME= ``` 5. 开始构建:在engine目录,执行`./ohos`,即可开始构建支持ohos设备的flutter engine。 diff --git a/attachment/repos/bootstrap/ohos.py b/attachment/repos/bootstrap/ohos.py index f59d783c8f..6df73753d4 100644 --- a/attachment/repos/bootstrap/ohos.py +++ b/attachment/repos/bootstrap/ohos.py @@ -123,17 +123,16 @@ def findNativeInCurrentDir(): def getNdkHome(): - OHOS_NDK_HOME = os.getenv("OHOS_NDK_HOME") - if not OHOS_NDK_HOME: - OHOS_NDK_HOME = findNativeInCurrentDir() - if not OHOS_NDK_HOME: - OHOS_SDK_HOME = os.getenv("OHOS_SDK_HOME") + HOS_NDK_HOME = os.getenv("HOS_NDK_HOME") + if not HOS_NDK_HOME: + HOS_NDK_HOME = findNativeInCurrentDir() + if not HOS_NDK_HOME: + HOS_SDK_HOME = os.getenv("HOS_SDK_HOME") sdkInt = 0 if ('openharmony' in os.getenv("HOS_SDK_HOME")): - print('dddd') - OHOS_SDK_HOME = "%s/openharmony" % os.getenv("HOS_SDK_HOME") - if os.path.exists(OHOS_SDK_HOME): - for dir in os.listdir(OHOS_SDK_HOME): + HOS_SDK_HOME = "%s/openharmony" % os.getenv("HOS_SDK_HOME") + if os.path.exists(HOS_SDK_HOME): + for dir in os.listdir(HOS_SDK_HOME): try: tmpInt = int(dir) sdkInt = max(sdkInt, tmpInt) @@ -142,46 +141,45 @@ def getNdkHome(): if sdkInt == 0: logging.error( "Ohos sdkInt parse failed, please config the correct environment variable." - " Such as: 'export OHOS_SDK_HOME=~/ohos/sdk/openharmony'." + " Such as: 'export HOS_SDK_HOME=~/ohos/sdk/openharmony'." ) exit(20) - OHOS_NDK_HOME = os.path.join(OHOS_SDK_HOME, str(sdkInt), "native") + HOS_NDK_HOME = os.path.join(HOS_SDK_HOME, str(sdkInt), "native") else: - print('go here') - OHOS_NDK_HOME = "%s/HarmonyOS-NEXT-DP1/base/native" % os.getenv("HOS_SDK_HOME") - logging.info("OHOS_NDK_HOME = %s" % OHOS_NDK_HOME) + HOS_NDK_HOME = "%s/HarmonyOS-NEXT-DP1/base/native" % os.getenv("HOS_SDK_HOME") + logging.info("HOS_NDK_HOME = %s" % HOS_NDK_HOME) if ( - (not os.path.exists(OHOS_NDK_HOME)) - or (not os.path.exists(OHOS_NDK_HOME + "/sysroot")) - or (not os.path.exists(OHOS_NDK_HOME + "/llvm/bin")) - or (not os.path.exists(OHOS_NDK_HOME + "/build-tools/cmake/bin")) + (not os.path.exists(HOS_NDK_HOME)) + or (not os.path.exists(HOS_NDK_HOME + "/sysroot")) + or (not os.path.exists(HOS_NDK_HOME + "/llvm/bin")) + or (not os.path.exists(HOS_NDK_HOME + "/build-tools/cmake/bin")) ): logging.error( """ - Please set the environment variables for HarmonyOS SDK to "HOS_SDK_HOME" or "OHOS_SDK_HOME". + Please set the environment variables for HarmonyOS SDK to "HOS_SDK_HOME" or "HOS_SDK_HOME". We will use both native/llvm and native/sysroot. Please ensure that the file "native/llvm/bin/clang" exists and is executable.""" ) exit(10) - return OHOS_NDK_HOME + return HOS_NDK_HOME # 指定engine编译的配置参数 def engineConfig(buildInfo, extraParam=""): - OHOS_NDK_HOME = getNdkHome() - # export PATH=$OHOS_NDK_HOME/build-tools/cmake/bin:$OHOS_NDK_HOME/llvm/bin:$PATH + HOS_NDK_HOME = getNdkHome() + # export PATH=$HOS_NDK_HOME/build-tools/cmake/bin:$HOS_NDK_HOME/llvm/bin:$PATH lastPath = os.getenv("PATH") os.environ["PATH"] = ( - "%s%s" % (os.path.join(OHOS_NDK_HOME, "build-tools", "cmake", "bin"), PATH_SEP) - + "%s%s" % (os.path.join(OHOS_NDK_HOME, "build-tools", "llvm", "bin"), PATH_SEP) + "%s%s" % (os.path.join(HOS_NDK_HOME, "build-tools", "cmake", "bin"), PATH_SEP) + + "%s%s" % (os.path.join(HOS_NDK_HOME, "build-tools", "llvm", "bin"), PATH_SEP) + "%s%s" % (os.path.abspath("depot_tools"), PATH_SEP) + lastPath ) unixCommand = "" if not IS_WINDOWS: unixCommand = ( - "--target-sysroot %s " % os.path.join(OHOS_NDK_HOME, "sysroot") - + "--target-toolchain %s " % os.path.join(OHOS_NDK_HOME, "llvm") + "--target-sysroot %s " % os.path.join(HOS_NDK_HOME, "sysroot") + + "--target-toolchain %s " % os.path.join(HOS_NDK_HOME, "llvm") + "--target-triple %s " % buildInfo.targetTriple ) OPT = "--unoptimized --no-lto " if buildInfo.buildType == "debug" else "" -- Gitee From 4db7d45a2b56f2bc36e7d55a51ac9e7e68afce08 Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Fri, 15 Mar 2024 19:30:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96cpu=E8=AF=BB/=E5=86=99buf?= =?UTF-8?q?fer=EF=BC=8C=E5=87=8F=E5=B0=91=E7=BA=A640%cpu=E5=8D=A0=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zmf <279822581@qq.com> --- shell/platform/ohos/ohos_xcomponent_adapter.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/shell/platform/ohos/ohos_xcomponent_adapter.cpp b/shell/platform/ohos/ohos_xcomponent_adapter.cpp index a657f6b949..9c7fee2473 100644 --- a/shell/platform/ohos/ohos_xcomponent_adapter.cpp +++ b/shell/platform/ohos/ohos_xcomponent_adapter.cpp @@ -147,10 +147,7 @@ static int32_t SetNativeWindowOpt(OHNativeWindow* nativeWindow, int height) { // Set the read and write scenarios of the native window buffer. int code = SET_USAGE; - int32_t usage = - BUFFER_USAGE_CPU_READ | BUFFER_USAGE_CPU_WRITE | BUFFER_USAGE_MEM_DMA; - int32_t ret = - OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, usage); + int32_t ret = OH_NativeWindow_NativeWindowHandleOpt(nativeWindow, code, BUFFER_USAGE_MEM_DMA); if (ret) { LOGE( "Set NativeWindow Usage Failed :window:%{public}p ,w:%{public}d x " -- Gitee From 81159f50967e10c4ccf53e7bfbac167518250ebd Mon Sep 17 00:00:00 2001 From: zmf <279822581@qq.com> Date: Fri, 15 Mar 2024 19:38:24 +0800 Subject: [PATCH 3/3] =?UTF-8?q?Revert=20"=E4=BF=AE=E6=94=B9=E4=B8=BAHOS"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit fc92008a47bb226430160d46805df7f20fe29a35. Signed-off-by: zmf <279822581@qq.com> --- OAT.xml | 1 - README.en.md | 4 ++-- README.md | 4 ++-- attachment/repos/bootstrap/ohos.py | 16 ++++++++-------- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/OAT.xml b/OAT.xml index a9da868a88..d1c59fbe8b 100644 --- a/OAT.xml +++ b/OAT.xml @@ -92,7 +92,6 @@ used to filter file path. - +export OHOS_SDK_HOME= ``` 5. Start building: In the engine directory, execute `./ohos` to start building the flutter engine that supports ohos devices. diff --git a/README.md b/README.md index 5128877c77..46a7f3f1bc 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,10 @@ Flutter Engine 3. 同步代码:在engine目录,执行`gclient sync`;这里会同步engine源码、官方packages仓,还有执行ohos_setup任务; -4. 下载sdk: 从[鸿蒙套件列表](https://developer.harmonyos.com/deveco-developer-suite/enabling/kit?currentPage=1&pageSize=100)下载配套开发工具,暂不支持非该渠道下载的套件 +4. 下载sdk: 在[每日构建](http://ci.openharmony.cn/workbench/cicd/dailybuild/dailylist)下载ohos-sdk-full,配置以下环境变量: ```sh -export HOS_SDK_HOME= +export OHOS_SDK_HOME= ``` 5. 开始构建:在engine目录,执行`./ohos`,即可开始构建支持ohos设备的flutter engine。 diff --git a/attachment/repos/bootstrap/ohos.py b/attachment/repos/bootstrap/ohos.py index 03a736c3de..4b0395bd35 100644 --- a/attachment/repos/bootstrap/ohos.py +++ b/attachment/repos/bootstrap/ohos.py @@ -137,12 +137,12 @@ def getNdkHome(): if not isNdkValid(OHOS_NDK_HOME): logging.error( """ - Please set the environment variables for HarmonyOS SDK to "HOS_SDK_HOME" or "HOS_SDK_HOME". + Please set the environment variables for HarmonyOS SDK to "HOS_SDK_HOME" or "OHOS_SDK_HOME". We will use both native/llvm and native/sysroot. Please ensure that the file "native/llvm/bin/clang" exists and is executable.""" ) exit(10) - return HOS_NDK_HOME + return OHOS_NDK_HOME # 校验 native def isNdkValid(path): @@ -162,20 +162,20 @@ def isNdkValid(path): # 指定engine编译的配置参数 def engineConfig(buildInfo, extraParam=""): - HOS_NDK_HOME = getNdkHome() - # export PATH=$HOS_NDK_HOME/build-tools/cmake/bin:$HOS_NDK_HOME/llvm/bin:$PATH + OHOS_NDK_HOME = getNdkHome() + # export PATH=$OHOS_NDK_HOME/build-tools/cmake/bin:$OHOS_NDK_HOME/llvm/bin:$PATH lastPath = os.getenv("PATH") os.environ["PATH"] = ( - "%s%s" % (os.path.join(HOS_NDK_HOME, "build-tools", "cmake", "bin"), PATH_SEP) - + "%s%s" % (os.path.join(HOS_NDK_HOME, "build-tools", "llvm", "bin"), PATH_SEP) + "%s%s" % (os.path.join(OHOS_NDK_HOME, "build-tools", "cmake", "bin"), PATH_SEP) + + "%s%s" % (os.path.join(OHOS_NDK_HOME, "build-tools", "llvm", "bin"), PATH_SEP) + "%s%s" % (os.path.abspath("depot_tools"), PATH_SEP) + lastPath ) unixCommand = "" if not IS_WINDOWS: unixCommand = ( - "--target-sysroot %s " % os.path.join(HOS_NDK_HOME, "sysroot") - + "--target-toolchain %s " % os.path.join(HOS_NDK_HOME, "llvm") + "--target-sysroot %s " % os.path.join(OHOS_NDK_HOME, "sysroot") + + "--target-toolchain %s " % os.path.join(OHOS_NDK_HOME, "llvm") + "--target-triple %s " % buildInfo.targetTriple ) OPT = "--unoptimized --no-lto " if buildInfo.buildType == "debug" else "" -- Gitee