diff --git a/.gitlab-ci/container.yml b/.gitlab-ci/container.yml index 99d76e8f5efa1a16a79577eaca0ec6f1d7cbb25d..8c3cf40a67a1939f42b2def264468caeac02373e 100644 --- a/.gitlab-ci/container.yml +++ b/.gitlab-ci/container.yml @@ -14,7 +14,7 @@ # limitations under the License. variables: - BITBAKE_CONTAINER_VERSION: "0.6" + BITBAKE_CONTAINER_VERSION: "0.7" OPENHARMONY_CONTAINER_VERSION: "0.1" .kaniko: diff --git a/.gitlab-ci/container/bitbake-builder/Dockerfile b/.gitlab-ci/container/bitbake-builder/Dockerfile index c5285ac0b02520ec2877b804ca5d91264b5db592..0a2f61a60afdeb2d9860d18c5212cc2e78d02b96 100644 --- a/.gitlab-ci/container/bitbake-builder/Dockerfile +++ b/.gitlab-ci/container/bitbake-builder/Dockerfile @@ -28,7 +28,6 @@ COPY --chown=root:root ppa/zyga-ubuntu-oh-tools.gpg /etc/apt/trusted.gpg.d/ RUN eatmydata apt-get update -qq \ && eatmydata apt-get install -qq -y \ bash git-repo apt-utils build-essential chrpath cpio diffstat gawk git sudo wget \ - flex bison \ language-pack-en-base time locales python-is-python3 python3-distutils libssl-dev \ iproute2 iputils-ping curl jq ca-certificates git-lfs \ lz4 zstd git-restore-mtime \ diff --git a/conf/distro/include/openharmony.inc b/conf/distro/include/openharmony.inc new file mode 100644 index 0000000000000000000000000000000000000000..c5e3a5ca17417d50ae58a642e24f1ca7307584ef --- /dev/null +++ b/conf/distro/include/openharmony.inc @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +# OpenHarmony OS version +OPENHARMONY_VERSION ?= "3.1" +OPENHARMONY_OVERRIDES = "openharmony-${OPENHARMONY_VERSION}:openharmony" +OPENHARMONY_VERSION_FULL = "${OPENHARMONY_VERSION}" +OPENHARMONY_VERSION_FULL:openharmony-3.1 = "3.1.1" + +PREFERRED_VERSION_openharmony-standard = "${OPENHARMONY_VERSION}" diff --git a/conf/distro/oniro-openharmony-linux.conf b/conf/distro/oniro-openharmony-linux.conf index 7036ac9a2436b314b497b8b8984d5d3da1a110bb..d75f9c54f954e0e1bc1bdb195410f1a0bcfcd447 100644 --- a/conf/distro/oniro-openharmony-linux.conf +++ b/conf/distro/oniro-openharmony-linux.conf @@ -7,13 +7,8 @@ DISTRO_NAME = "Oniro/OpenHarmony Linux Distro" DISTRO_VERSION = "1.99.99" # OpenHarmony OS version -OPENHARMONY_VERSION ?= "3.1" - -DISTROOVERRIDES:append = ":openharmony-${OPENHARMONY_VERSION}" -OPENHARMONY_VERSION_FULL = "${OPENHARMONY_VERSION}" -OPENHARMONY_VERSION_FULL:openharmony-3.1 = "3.1.1" - -PREFERRED_VERSION_openharmony-standard = "${OPENHARMONY_VERSION}" +require include/openharmony.inc +DISTROOVERRIDES:append = ":${OPENHARMONY_OVERRIDES}" # LLVM/Clang toolchain TOOLCHAIN = "clang" diff --git a/recipes-core/musl/musl_%.bbappend b/recipes-core/musl/musl_%.bbappend index 82812d403be5ef0d0adb31bf8d7db50148986caf..460b14ab8ca15677a550bf77af3e3714a8a992ce 100644 --- a/recipes-core/musl/musl_%.bbappend +++ b/recipes-core/musl/musl_%.bbappend @@ -2,14 +2,14 @@ # # SPDX-License-Identifier: Apache-2.0 -BASEVER:oniro-openharmony-linux = "1.2.0" -SRCREV:oniro-openharmony-linux = "040c1d16b468c50c04fc94edff521f1637708328" -LIC_FILES_CHKSUM:oniro-openharmony-linux = "file://COPYRIGHT;md5=f95ee848a08ad253c04723da00cedb01" -FILESEXTRAPATHS:prepend:oniro-openharmony-linux := "${THISDIR}/openharmony-${OPENHARMONY_VERSION}:" -SRC_URI:append:oniro-openharmony-linux = " file://openharmony-common.patch" -SRC_URI:append:oniro-openharmony-linux = " file://openharmony-linux-user.patch" +BASEVER:openharmony = "1.2.0" +SRCREV:openharmony = "040c1d16b468c50c04fc94edff521f1637708328" +LIC_FILES_CHKSUM:openharmony = "file://COPYRIGHT;md5=f95ee848a08ad253c04723da00cedb01" +FILESEXTRAPATHS:prepend:openharmony := "${THISDIR}/openharmony-${OPENHARMONY_VERSION}:" +SRC_URI:append:openharmony = " file://openharmony-common.patch" +SRC_URI:append:openharmony = " file://openharmony-linux-user.patch" # This conflicts with libcap, so we have to go with libcap instead -#SRC_URI:append:oniro-openharmony-linux = " file://openharmony-linux-user-capability_h.patch" +#SRC_URI:append:openharmony = " file://openharmony-linux-user-capability_h.patch" # As musl links with -nostdlib, we need to add linking with # libclang_rt.builtins.a manually as needed @@ -22,9 +22,9 @@ LDFLAGS:append:toolchain-clang = " ${@bb.utils.contains('COMPILER_RT', '-rtlib=c # with `-nostdinc` argument. # Possible fix is to rewrite the hooks implementation to use the musl internal # atomic.h functions instead. -#CFLAGS:append:oniro-openharmony-linux = "-DHOOK_ENABLE" +#CFLAGS:append:openharmony = "-DHOOK_ENABLE" -do_install:append:oniro-openharmony-linux () { +do_install:append:openharmony () { for folder in ${MUSL_LDSO_PATHS}; do echo "${libdir}/${folder}" >> ${D}${sysconfdir}/ld-musl-${MUSL_LDSO_ARCH}.path done diff --git a/recipes-devtools/gn/gn_%.bbappend b/recipes-devtools/gn/gn_%.bbappend index 2851293d67a07a2b0ecea6fbb3018e3f2bdcf49f..ecc3b2e44fead86d3f2b44a9fb9f9a4f18a457cf 100644 --- a/recipes-devtools/gn/gn_%.bbappend +++ b/recipes-devtools/gn/gn_%.bbappend @@ -6,4 +6,4 @@ # GN function which was recently dropped, therefore downgrading GN to revision # compatible with OpenHarmony -SRCREV:oniro-openharmony-linux = "5da62d5e9d0f10cb8ece7c30563a6a214c78b68d" +SRCREV:openharmony = "5da62d5e9d0f10cb8ece7c30563a6a214c78b68d" diff --git a/recipes-kernel/linux-libc-headers/linux-libc-headers_%.bbappend b/recipes-kernel/linux-libc-headers/linux-libc-headers_%.bbappend index fd3034d80db5b8ef06b70e746f432cf1208a7227..d6290f8afd1d76c171cd0e5e9cae8d9645d2fc4e 100644 --- a/recipes-kernel/linux-libc-headers/linux-libc-headers_%.bbappend +++ b/recipes-kernel/linux-libc-headers/linux-libc-headers_%.bbappend @@ -4,6 +4,6 @@ # OpenHarmony relies on Android's ashmem, which is in staging and therefore # the header is not installed by default -do_install:append:oniro-openharmony-linux() { +do_install:append:openharmony() { install ${S}/drivers/staging/android/uapi/ashmem.h ${D}${includedir}/linux } diff --git a/recipes-kernel/linux-yocto/linux-yocto_%.bbappend b/recipes-kernel/linux-yocto/linux-yocto_%.bbappend index 00b5569402dc3da108909f5e7d72d9c0992d3862..572820bd36383b6c6e175ab824b8f87fea75eb6b 100644 --- a/recipes-kernel/linux-yocto/linux-yocto_%.bbappend +++ b/recipes-kernel/linux-yocto/linux-yocto_%.bbappend @@ -4,10 +4,10 @@ FILESEXTRAPATHS:prepend := "${THISDIR}/linux-yocto:" -SRC_URI:append:oniro-openharmony-linux = " file://ashmem.cfg" -SRC_URI:append:oniro-openharmony-linux = " file://driver-add-hilog-and-hievent-buffer-management-drive.patch" -SRC_URI:append:oniro-openharmony-linux = " file://driver-add-hilog-and-hievent-buffer-management-drive.cfg" -SRC_URI:append:oniro-openharmony-linux = " file://android_binder_ipc.cfg" +SRC_URI:append:openharmony = " file://ashmem.cfg" +SRC_URI:append:openharmony = " file://driver-add-hilog-and-hievent-buffer-management-drive.patch" +SRC_URI:append:openharmony = " file://driver-add-hilog-and-hievent-buffer-management-drive.cfg" +SRC_URI:append:openharmony = " file://android_binder_ipc.cfg" # # QEMU ARM Cortex-A7 diff --git a/recipes-openharmony/openharmony/java-tools.inc b/recipes-openharmony/openharmony/java-tools.inc index 98e2859eb14eac9ea90e7b9f249fdc75c4a734e1..f2c6fff1809f699d99c8ee029ee4e82d39c55d78 100644 --- a/recipes-openharmony/openharmony/java-tools.inc +++ b/recipes-openharmony/openharmony/java-tools.inc @@ -2,11 +2,12 @@ # # SPDX-License-Identifier: Apache-2.0 -# Make sure we have java tools in $PATH +# This is needed for the STAGING_LIBDIR_JVM_NATIVE variable used below +inherit java -DEPENDS:append:oniro-openharmony-linux = " openjdk-8-native" -INHERIT:append:oniro-openharmony-linux = " java" -JAVA_BUILD_VERSION:oniro-openharmony-linux = "openjdk-8-native" -export JAVA_HOME:oniro-openharmony-linux = "${STAGING_LIBDIR_JVM_NATIVE}/${JAVA_BUILD_VERSION}" -export CLASSPATH:oniro-openharmony-linux += "${STAGING_LIBDIR_JVM_NATIVE}/${JAVA_BUILD_VERSION}/lib/tools.jar" -EXTRANATIVEPATH:append:oniro-openharmony-linux = " ../${baselib}/jvm/${JAVA_BUILD_VERSION}/bin" +# Make sure we have java tools in $PATH +DEPENDS:append = " openjdk-8-native" +JAVA_BUILD_VERSION = "openjdk-8-native" +export JAVA_HOME = "${STAGING_LIBDIR_JVM_NATIVE}/${JAVA_BUILD_VERSION}" +export CLASSPATH += "${STAGING_LIBDIR_JVM_NATIVE}/${JAVA_BUILD_VERSION}/lib/tools.jar" +EXTRANATIVEPATH:append = " ../${baselib}/jvm/${JAVA_BUILD_VERSION}/bin" diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.1/foundation_graphic_standard-flexlexer-h.patch b/recipes-openharmony/openharmony/openharmony-standard-3.1/foundation_graphic_standard-flexlexer-h.patch new file mode 100644 index 0000000000000000000000000000000000000000..0bc8a388ba6fbf4ab2680c8e4c989ec70c118c2c --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.1/foundation_graphic_standard-flexlexer-h.patch @@ -0,0 +1,52 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +Fix host OS dependency on flex package by copying the FlexLexer.h file from recipe-sysroot-native. + +Apply to foundation/graphic/standard repository. + +Signed-off-by: Esben Haabendal <esben.haabendal@huawei.com> +Upstream-Status: Pending + +diff --git a/utils/lex_yacc/gen_flexlexer_header.py b/utils/lex_yacc/gen_flexlexer_header.py +index cde71464bfe8..f32c7e68184d 100755 +--- a/utils/lex_yacc/gen_flexlexer_header.py ++++ b/utils/lex_yacc/gen_flexlexer_header.py +@@ -22,10 +22,11 @@ import sys + def parse_args(args): + parser = optparse.OptionParser() + parser.add_option("--output") ++ parser.add_option("--includedir", default="/usr/include") + opts, _ = parser.parse_args(args) + return opts + + if __name__ == '__main__': + options = parse_args(sys.argv[1:]) + parse_scripts = subprocess.check_call( +- ["cp", "-f", "/usr/include/FlexLexer.h", options.output]) ++ ["cp", "-f", "%s/FlexLexer.h"%(options.includedir,), options.output]) +diff --git a/utils/lex_yacc/lex_yacc.gni b/utils/lex_yacc/lex_yacc.gni +index 5c27743c507e..905252a93cf7 100644 +--- a/utils/lex_yacc/lex_yacc.gni ++++ b/utils/lex_yacc/lex_yacc.gni +@@ -15,6 +15,10 @@ import("//build/ohos.gni") + + gni_filepath = "//foundation/graphic/standard/utils/lex_yacc" + ++declare_args() { ++ flex_includedir = "/usr/include" ++} ++ + template("lex_yacc") { + lex_name = invoker.lex + yacc_name = invoker.yacc +@@ -33,6 +37,8 @@ template("lex_yacc") { + args = [ + "--output", + flexlexer_pathname, ++ "--includedir", ++ rebase_path(flex_includedir) + ] + } + diff --git a/recipes-openharmony/openharmony/openharmony-standard-3.1/third_party_selinux-flex-bison-path.patch b/recipes-openharmony/openharmony/openharmony-standard-3.1/third_party_selinux-flex-bison-path.patch new file mode 100644 index 0000000000000000000000000000000000000000..d79e492434f449ea4ef6007db837d4d09fd5f897 --- /dev/null +++ b/recipes-openharmony/openharmony/openharmony-standard-3.1/third_party_selinux-flex-bison-path.patch @@ -0,0 +1,48 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +Patch for //third_party/selinux git repository of OpenHarmony 3.1 codebase. + +This allows overriding the path to flex and bison tools using GN arguments. + +Signed-off-by: Esben Haabendal <esben.haabendal@huawei.com> +Upstream-Status: Pending + +diff --git a/BUILD.gn b/BUILD.gn +index 34616600fac4..a8fb10dbc96c 100644 +--- a/BUILD.gn ++++ b/BUILD.gn +@@ -20,8 +20,13 @@ SECILC_ROOT_DIR = "//third_party/selinux/secilc" + LIBFTS_ROOT_DIR = "//third_party/FreeBSD" + LIBPCRE2_ROOT_DIR = "//third_party/pcre2" + ++declare_args() { ++ flex_path = "/usr/bin/flex" ++ bison_path = "/usr/bin/bison" ++} ++ + ohos_shared_library("libsepol") { +- exec_script("/usr/bin/flex", ++ exec_script(flex_path, + [ + "-o", + rebase_path("libsepol/cil/src/cil_lexer.c"), +@@ -314,7 +319,7 @@ ohos_executable("getpidcon") { + } + + ohos_executable("checkpolicy") { +- exec_script("/usr/bin/bison", ++ exec_script(bison_path, + [ + "-y", + "-d", +@@ -323,7 +328,7 @@ ohos_executable("checkpolicy") { + rebase_path("checkpolicy/y.tab.c"), + ], + "") +- exec_script("/usr/bin/flex", ++ exec_script(flex_path, + [ + "-o", + rebase_path("checkpolicy/policy_scan.c"), diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb index 1c82fdb578cb90cba47be7e7dcbfcdf14a762463..1a8a349a5ff801b33729d74388654da5eb8d470d 100644 --- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb +++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb @@ -95,6 +95,12 @@ GN_ARGS += 'node_path="${RECIPE_SYSROOT_NATIVE}/usr/bin"' GN_ARGS += 'host_toolchain="//oniro:host_toolchain"' GN_ARGS += 'install_oniro_third_party=false' +# OpenHarmony build system needs a bit of help to be able to find the right +# ld-musl-*.so path +inherit linuxloader +MUSL_LDSO_ARCH = "${@get_musl_loader_arch(d)}" +GN_ARGS += 'musl_arch="${MUSL_LDSO_ARCH}"' + # OpenHarmony unit tests are statically linked and therefore not stripped # binaries sum up to almost 80GB which makes it difficult to build OpenHarmony # with tests on a normal desktop, let alone the CI runner diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.1.bb b/recipes-openharmony/openharmony/openharmony-standard_3.1.bb index 99cd4d145f95c71c6102ef3b78db451e30ee64c4..eddcc674cd680a8a83b9d0b767f457db96d78e6c 100644 --- a/recipes-openharmony/openharmony/openharmony-standard_3.1.bb +++ b/recipes-openharmony/openharmony/openharmony-standard_3.1.bb @@ -65,6 +65,8 @@ SRC_URI += "file://ace_engine-openssl-legacy-provider.patch;patchdir=${S}/founda SRC_URI += "file://developtools_hdc_standard-gcc.patch;patchdir=${S}/developtools/hdc_standard" SRC_URI += "file://foundation_graphic_standard-hdi-display-layer.patch;patchdir=${S}/foundation/graphic/standard" SRC_URI += "file://third_party_weston-hdi-display-layer.patch;patchdir=${S}/third_party/weston" +SRC_URI += "file://third_party_selinux-flex-bison-path.patch;patchdir=${S}/third_party/selinux" +SRC_URI += "file://foundation_graphic_standard-flexlexer-h.patch;patchdir=${S}/foundation/graphic/standard" SRC_URI += "file://features.json;subdir=${OHOS_BUILD_CONFIGS_DIR}" # Patch to allow /system/profile and /system/usr to be symlinks to /usr/lib/openharmony @@ -111,6 +113,15 @@ GN_ARGS += 'treat_warnings_as_errors=false' GN_ARGS += 'node_path="${RECIPE_SYSROOT_NATIVE}/usr/bin"' GN_ARGS += 'host_toolchain="//oniro:clang_x64"' GN_ARGS += 'install_oniro_third_party=false' +GN_ARGS += 'flex_path="${RECIPE_SYSROOT_NATIVE}/usr/bin/flex"' +GN_ARGS += 'bison_path="${RECIPE_SYSROOT_NATIVE}/usr/bin/bison"' +GN_ARGS += 'flex_includedir="${RECIPE_SYSROOT_NATIVE}/usr/include"' + +# OpenHarmony build system needs a bit of help to be able to find the right +# ld-musl-*.so path +inherit linuxloader +MUSL_LDSO_ARCH = "${@get_musl_loader_arch(d)}" +GN_ARGS += 'musl_arch="${MUSL_LDSO_ARCH}"' # OpenHarmony unit tests are statically linked and therefore not stripped # binaries sum up to almost 80GB which makes it difficult to build OpenHarmony diff --git a/recipes-openharmony/prebuilts/files/build/common/musl/BUILD.gn b/recipes-openharmony/prebuilts/files/build/common/musl/BUILD.gn index 1393e369d5e863469e2d3926fb7961f6ec59706c..2099b7023016b2b6afa2266a0ceb4d829fbe3405 100644 --- a/recipes-openharmony/prebuilts/files/build/common/musl/BUILD.gn +++ b/recipes-openharmony/prebuilts/files/build/common/musl/BUILD.gn @@ -4,7 +4,7 @@ group("musl_install") { deps = [ - "//third_party/musl:ld-musl-arm.so", + "//third_party/musl:ld-musl.so", "//third_party/musl:libc.so", ] } diff --git a/recipes-openharmony/prebuilts/files/third_party/musl/BUILD.gn b/recipes-openharmony/prebuilts/files/third_party/musl/BUILD.gn index 266afcde886bb06187a06aeaca1b0119129c3b53..7b2ea067eb850a091268202c7f8f3ba430a3e6ae 100644 --- a/recipes-openharmony/prebuilts/files/third_party/musl/BUILD.gn +++ b/recipes-openharmony/prebuilts/files/third_party/musl/BUILD.gn @@ -4,9 +4,10 @@ import("//build/ohos.gni") import("//oniro/third_party.gni") +import("musl_config.gni") -ohos_prebuilt_executable("ld-musl-arm.so") { - source = "//oniro/sysroots/target/lib/ld-musl-arm.so.1" +ohos_prebuilt_executable("ld-musl.so") { + source = "//oniro/sysroots/target/lib/ld-musl-${musl_arch}.so.1" subsystem_name = "common" part_name = "common" install_enable = install_oniro_third_party