diff --git a/README.md b/README.md index b63d7cb3e4085530c4efe853633de2c5a1fc67ff..143d828cf226a1570788bf7dac9ca8281b8c55ae 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,14 @@ quickly building and running OpenHarmony code in QEMU ARM simulator. See [recipes-openharmony/images/README.md](recipes-openharmony/images/README.md) for more information. +## OpenHarmony host tools + +To facilitate working with OpenHarmony systems, an image with various host tools +is provided. + +See [recipes-openharmony/tools/README.rst](recipes-openharmony/tools/README.rst) +for more information. + ## OpenHarmony prebuilts The meta-openharmony layer enables building of prebuilts for use with the diff --git a/recipes-openharmony/tools/README.rst b/recipes-openharmony/tools/README.rst new file mode 100644 index 0000000000000000000000000000000000000000..94f14cb5e2704b2604901dbfef66388c25ad2983 --- /dev/null +++ b/recipes-openharmony/tools/README.rst @@ -0,0 +1,48 @@ +.. SPDX-FileCopyrightText: Huawei Inc. +.. +.. SPDX-License-Identifier: CC-BY-4.0 + +.. _OpenHarmony SDK: + +OpenHarmony Tools +################# + +OpenHarmony provides a number of dedicated host tools for working with +OpenHarmony systems. + +The `openharmony-tools` recipe bundles up these tools for easy installation of these on a Linux host OS. + + +Building +******** + +To build `openharmony-tools` for OpenHarmony 3.0.1, an initialized build +environment is required:: + + TEMPLATECONF=../meta-openharmony/conf source oe-core/oe-init-build-env + +Once that is in place, the `bitbake` command is simply:: + + DISTRO=oniro-openharmony-linux MACHINE=qemuarma7 bitbake openharmony-tools + + +Installation +************ + +To install the tools on a Linux host OS, you need to use the shell script +installer. To install into /opt/openharmony-tools do something like this: + +.. code-block:: console + + $ ./openharmony-tools-3.0-cortexa7-neon-vfpv4-1.99.99.sh -y -d /opt/openharmony-tools + +As the installation above will explain, in order to use the tools you need to do the following: + +In order to use the installed tools, you need to setup your shell environment +(this needs to be done each time you create a new shell): + +.. code-block:: console + + $ . /opt/openharmony-tools/environment-setup-x86_64-oesdk-linux + +And with that, you will have access to `hdc` and `xdevice` commands. diff --git a/recipes-openharmony/tools/openharmony-tools.bb b/recipes-openharmony/tools/openharmony-tools.bb new file mode 100644 index 0000000000000000000000000000000000000000..4660f81ab2f45fcf088a748b3f36f76b01760e30 --- /dev/null +++ b/recipes-openharmony/tools/openharmony-tools.bb @@ -0,0 +1,67 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +SUMMARY = "OpenHarmony development tools" +LICENSE = "Apache-2.0" + +require sanity-check.inc + +TOOLCHAIN_HOST_TASK = "nativesdk-hdc nativesdk-xdevice" + +TOOLCHAIN_TARGET_TASK = "" + +TOOLCHAIN_OUTPUTNAME = "${PN}-${OPENHARMONY_VERSION}-${TUNE_PKGARCH}-${SDK_VERSION}" +SDK_TITLE = "OpenHarmony tools" +SDK_VERSION ?= "${DISTRO_VERSION}" + +RDEPENDS = "${TOOLCHAIN_HOST_TASK}" + +inherit populate_sdk +inherit toolchain-scripts-base +inherit nopackages + +deltask install +deltask populate_sysroot + +do_populate_sdk[stamp-extra-info] = "${PACKAGE_ARCH}" + +create_sdk_files:append () { + rm -f ${SDK_OUTPUT}/${SDKPATH}/site-config-* + rm -f ${SDK_OUTPUT}/${SDKPATH}/environment-setup-* + rm -f ${SDK_OUTPUT}/${SDKPATH}/version-* + + # Generate new (mini) sdk-environment-setup file + script=${1:-${SDK_OUTPUT}/${SDKPATH}/environment-setup-${SDK_SYS}} + touch $script + echo 'export PATH=${SDKPATHNATIVE}${bindir_nativesdk}:${SDKPATHNATIVE}${sbindir_nativesdk}:${SDKPATHNATIVE}${base_bindir_nativesdk}:${SDKPATHNATIVE}${base_sbindir_nativesdk}:$PATH' >> $script + echo 'export PYTHONPATH=${SDKPATHNATIVE}${libdir_nativesdk}/python*/site-packages:$PYTHONPATH' >> $script + echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script + if [ -e "${SDK_OUTPUT}${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt" ]; then + echo 'export GIT_SSL_CAINFO="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script + echo 'export SSL_CERT_FILE="${SDKPATHNATIVE}${sysconfdir}/ssl/certs/ca-certificates.crt"' >>$script + fi + + toolchain_create_sdk_version ${SDK_OUTPUT}/${SDKPATH}/version-${SDK_SYS} + + cat >> $script <<EOF +if [ -d "\$OECORE_NATIVE_SYSROOT/environment-setup.d" ]; then + for envfile in \$OECORE_NATIVE_SYSROOT/environment-setup.d/*.sh; do + . \$envfile + done +fi +# We have to unset this else it can confuse oe-selftest and other tools +# which may also use the overlapping namespace. +unset OECORE_NATIVE_SYSROOT +EOF + + if [ "${SDKMACHINE}" = "i686" ]; then + echo 'export NO32LIBS="0"' >>$script + echo 'echo "$BB_ENV_PASSTHROUGH_ADDITIONS" | grep -q "NO32LIBS"' >>$script + echo '[ $? != 0 ] && export BB_ENV_PASSTHROUGH_ADDITIONS="NO32LIBS $BB_ENV_PASSTHROUGH_ADDITIONS"' >>$script + fi +} + +TOOLCHAIN_NEED_CONFIGSITE_CACHE = "" + +INHIBIT_DEFAULT_DEPS = "1" diff --git a/recipes-openharmony/tools/sanity-check.inc b/recipes-openharmony/tools/sanity-check.inc new file mode 100644 index 0000000000000000000000000000000000000000..bba5400419912d2be181e6bab413cb565b58e91c --- /dev/null +++ b/recipes-openharmony/tools/sanity-check.inc @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: Apache-2.0 + +# Skip recipe if openharmony is not in DISTRO_FEATURES +inherit features_check +REQUIRED_DISTRO_FEATURES = "openharmony"