diff --git a/.gitmodules b/.gitmodules index 9771272dba..6b19db2151 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1211,6 +1211,9 @@ [submodule "vendor/grammars/vscode-antlers-language-server"] path = vendor/grammars/vscode-antlers-language-server url = https://github.com/Stillat/vscode-antlers-language-server.git +[submodule "vendor/grammars/vscode-bitbake"] + path = vendor/grammars/vscode-bitbake + url = https://github.com/yoctoproject/vscode-bitbake.git [submodule "vendor/grammars/vscode-brightscript-language"] path = vendor/grammars/vscode-brightscript-language url = https://github.com/rokucommunity/vscode-brightscript-language.git diff --git a/grammars.yml b/grammars.yml index 6524607b63..bc861738fd 100644 --- a/grammars.yml +++ b/grammars.yml @@ -1089,6 +1089,8 @@ vendor/grammars/vscode-TalonScript: - source.talon vendor/grammars/vscode-antlers-language-server: - text.html.statamic +vendor/grammars/vscode-bitbake: +- source.bb vendor/grammars/vscode-brightscript-language: - source.brs vendor/grammars/vscode-cadence: diff --git a/lib/linguist/heuristics.yml b/lib/linguist/heuristics.yml index ef0d00ca89..f7191404c1 100644 --- a/lib/linguist/heuristics.yml +++ b/lib/linguist/heuristics.yml @@ -103,7 +103,7 @@ disambiguations: - language: BlitzBasic pattern: '(<^\s*; |End Function)' - language: BitBake - pattern: '^\s*(# |include|require)\b' + pattern: '^(# |include|require|inherit)\b' - language: Clojure pattern: '\((def|defn|defmacro|let)\s' - extensions: ['.bf'] @@ -371,6 +371,8 @@ disambiguations: pattern: - '(?i:^\s*\{\$(?:mode|ifdef|undef|define)[ ]+[a-z0-9_]+\})' - '^\s*end[.;]\s*$' + - language: BitBake + pattern: '^inherit(\s+[\w.-]+)+\s*$' - extensions: ['.json'] rules: - language: OASv2-json diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 6f7b3b6c36..0cc08cc539 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -599,9 +599,12 @@ Bison: BitBake: type: programming color: "#00bce4" - tm_scope: none + tm_scope: source.bb extensions: - ".bb" + - ".bbappend" + - ".bbclass" + - ".inc" ace_mode: text language_id: 32 Blade: diff --git a/samples/BitBake/cmake.bbclass b/samples/BitBake/cmake.bbclass new file mode 100644 index 0000000000..d978b88944 --- /dev/null +++ b/samples/BitBake/cmake.bbclass @@ -0,0 +1,233 @@ +# +# Copyright OpenEmbedded Contributors +# +# SPDX-License-Identifier: MIT +# + +# Path to the CMake file to process. +OECMAKE_SOURCEPATH ??= "${S}" + +DEPENDS:prepend = "cmake-native " +B = "${WORKDIR}/build" + +# What CMake generator to use. +# The supported options are "Unix Makefiles" or "Ninja". +OECMAKE_GENERATOR ?= "Ninja" + +python() { + generator = d.getVar("OECMAKE_GENERATOR") + if "Unix Makefiles" in generator: + args = "-G '" + generator + "' -DCMAKE_MAKE_PROGRAM=" + d.getVar("MAKE") + d.setVar("OECMAKE_GENERATOR_ARGS", args) + d.setVarFlag("do_compile", "progress", "percent") + elif "Ninja" in generator: + args = "-G '" + generator + "' -DCMAKE_MAKE_PROGRAM=ninja" + d.appendVar("DEPENDS", " ninja-native") + d.setVar("OECMAKE_GENERATOR_ARGS", args) + d.setVarFlag("do_compile", "progress", r"outof:^\[(\d+)/(\d+)\]\s+") + else: + bb.fatal("Unknown CMake Generator %s" % generator) +} +OECMAKE_AR ?= "${AR}" + +# Compiler flags +OECMAKE_C_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CFLAGS}" +OECMAKE_CXX_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS}" +OECMAKE_C_FLAGS_RELEASE ?= "-DNDEBUG" +OECMAKE_CXX_FLAGS_RELEASE ?= "-DNDEBUG" +OECMAKE_C_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CPPFLAGS} ${LDFLAGS}" +OECMAKE_CXX_LINK_FLAGS ?= "${HOST_CC_ARCH} ${TOOLCHAIN_OPTIONS} ${CXXFLAGS} ${LDFLAGS}" + +def oecmake_map_compiler(compiler, d): + args = d.getVar(compiler).split() + if args[0] == "ccache": + return args[1], args[0] + return args[0], "" + +# C/C++ Compiler (without cpu arch/tune arguments) +OECMAKE_C_COMPILER ?= "${@oecmake_map_compiler('CC', d)[0]}" +OECMAKE_C_COMPILER_LAUNCHER ?= "${@oecmake_map_compiler('CC', d)[1]}" +OECMAKE_CXX_COMPILER ?= "${@oecmake_map_compiler('CXX', d)[0]}" +OECMAKE_CXX_COMPILER_LAUNCHER ?= "${@oecmake_map_compiler('CXX', d)[1]}" + +# clear compiler vars for allarch to avoid sig hash difference +OECMAKE_C_COMPILER:allarch = "" +OECMAKE_C_COMPILER_LAUNCHER:allarch = "" +OECMAKE_CXX_COMPILER:allarch = "" +OECMAKE_CXX_COMPILER_LAUNCHER:allarch = "" + +OECMAKE_RPATH ?= "" +OECMAKE_PERLNATIVE_DIR ??= "" +OECMAKE_EXTRA_ROOT_PATH ?= "" + +OECMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "ONLY" + +EXTRA_OECMAKE:append = " ${PACKAGECONFIG_CONFARGS}" + +export CMAKE_BUILD_PARALLEL_LEVEL +CMAKE_BUILD_PARALLEL_LEVEL:task-compile = "${@oe.utils.parallel_make(d, False)}" +CMAKE_BUILD_PARALLEL_LEVEL:task-install = "${@oe.utils.parallel_make(d, True)}" + +OECMAKE_TARGET_COMPILE ?= "all" +OECMAKE_TARGET_INSTALL ?= "install" + +def map_host_os_to_system_name(host_os): + if host_os.startswith('mingw'): + return 'Windows' + if host_os.startswith('linux'): + return 'Linux' + return host_os + +# CMake expects target architectures in the format of uname(2), +# which do not always match TARGET_ARCH, so all the necessary +# conversions should happen here. +def map_host_arch_to_uname_arch(host_arch): + if host_arch == "powerpc": + return "ppc" + if host_arch == "powerpc64le": + return "ppc64le" + if host_arch == "powerpc64": + return "ppc64" + return host_arch + + +cmake_do_generate_toolchain_file() { + if [ "${BUILD_SYS}" = "${HOST_SYS}" ]; then + cmake_crosscompiling="set( CMAKE_CROSSCOMPILING FALSE )" + else + cmake_sysroot="set( CMAKE_SYSROOT \"${RECIPE_SYSROOT}\" )" + fi + + cat > ${WORKDIR}/toolchain.cmake <> ${S}/mkspecs/oe-device-extra.pri + fi +} +RDEPENDS:${PN}:append:rpi = "${@bb.utils.contains('MACHINE_FEATURES', 'vc4graphics', '', ' userland', d)}" +DEPENDS:append:rpi = "${@bb.utils.contains('MACHINE_FEATURES', 'vc4graphics', '', ' userland', d)}" diff --git a/samples/BitBake/tclibc-newlib.inc b/samples/BitBake/tclibc-newlib.inc new file mode 100644 index 0000000000..238b430e49 --- /dev/null +++ b/samples/BitBake/tclibc-newlib.inc @@ -0,0 +1,47 @@ +# +# Newlib configuration +# + +LIBCEXTENSION = "-newlib" +LIBCOVERRIDE = ":libc-newlib" + +PREFERRED_PROVIDER_virtual/libc ?= "newlib" +PREFERRED_PROVIDER_virtual/libiconv ?= "newlib" +PREFERRED_PROVIDER_virtual/libintl ?= "newlib" +PREFERRED_PROVIDER_virtual/nativesdk-libintl ?= "nativesdk-glibc" +PREFERRED_PROVIDER_virtual/nativesdk-libiconv ?= "nativesdk-glibc" + +DISTRO_FEATURES_BACKFILL_CONSIDERED += "ldconfig" + +#USE_NLS ?= "no" + +IMAGE_LINGUAS = "" + +LIBC_DEPENDENCIES = "\ + newlib-dbg \ + newlib-dev \ + libgloss \ + libgloss-dev \ + libgloss-dbg \ + libgcc-dev \ + libgcc-dbg \ + libstdc++-dev \ + libstdc++-staticdev \ + " + +ASSUME_PROVIDED += "virtual/crypt" + +# Its useful to be able to extend newlib, but we dont provide a native variant of libgloss +NEWLIB_EXTENDED ?= "libgloss libgcc" +BASE_DEFAULT_DEPS:append:class-target = " ${NEWLIB_EXTENDED}" + +TARGET_OS = "elf" +TARGET_OS:arm = "eabi" + +TOOLCHAIN_HOST_TASK ?= "packagegroup-cross-canadian-${MACHINE} nativesdk-qemu nativesdk-sdk-provides-dummy" +TOOLCHAIN_TARGET_TASK ?= "${LIBC_DEPENDENCIES}" +TOOLCHAIN_NEED_CONFIGSITE_CACHE:remove = "zlib ncurses" + +# disable pie security flags by default +SECURITY_CFLAGS:libc-newlib = "${SECURITY_NOPIE_CFLAGS}" +SECURITY_LDFLAGS:libc-newlib = "" diff --git a/samples/BitBake/xorg-driver-common.inc b/samples/BitBake/xorg-driver-common.inc new file mode 100644 index 0000000000..8b3f19426b --- /dev/null +++ b/samples/BitBake/xorg-driver-common.inc @@ -0,0 +1,44 @@ +SUMMARY = "X driver" +HOMEPAGE = "http://www.x.org" +BUGTRACKER = "https://bugs.freedesktop.org" +SECTION = "x11/drivers" +LICENSE = "MIT" + +PE = "2" + +DEPENDS = "virtual/xserver xorgproto util-macros" + +XORG_DRIVER_COMPRESSOR ?= ".tar.bz2" +SRC_URI = "${XORG_MIRROR}/individual/driver/${BPN}-${PV}${XORG_DRIVER_COMPRESSOR}" + +FILES:${PN} += " ${libdir}/xorg/modules/drivers/*.so" + +XORGBUILDCLASS ??= "autotools" +inherit ${XORGBUILDCLASS} pkgconfig features_check + +# depends on virtual/xserver +REQUIRED_DISTRO_FEATURES = "x11" + +# FIXME: We don't want to include the libtool archives (*.la) from modules +# directory, as they serve no useful purpose. Upstream should fix Makefile.am +do_install:append() { + find ${D}${libdir}/xorg/modules -regex ".*\.la$" | xargs rm -f -- +} + +# Function to add the relevant ABI dependency to drivers, which should be called +# from a PACKAGEFUNC. +def _add_xorg_abi_depends(d, name): + # Map of ABI names exposed in the dependencies to pkg-config variables + abis = { + "video": "abi_videodrv", + "input": "abi_xinput" + } + + output = os.popen("pkg-config xorg-server --variable=%s" % abis[name]).read() + mlprefix = d.getVar('MLPREFIX') or '' + abi = "%sxorg-abi-%s-%s" % (mlprefix, name, output.split(".")[0]) + + pn = d.getVar("PN") + d.appendVar('RDEPENDS:' + pn, ' ' + abi) + +SECURITY_LDFLAGS = "${SECURITY_X_LDFLAGS}" diff --git a/vendor/README.md b/vendor/README.md index 63e96de12e..b62133744f 100644 --- a/vendor/README.md +++ b/vendor/README.md @@ -57,6 +57,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting - **Bicep:** [azure/bicep](https://github.com/azure/bicep) - **Bikeshed:** [tabatkins/bikeshed](https://github.com/tabatkins/bikeshed) - **Bison:** [Alhadis/language-grammars](https://github.com/Alhadis/language-grammars) +- **BitBake:** [yoctoproject/vscode-bitbake](https://github.com/yoctoproject/vscode-bitbake) - **Blade:** [jawee/language-blade](https://github.com/jawee/language-blade) - **BlitzBasic:** [textmate/blitzmax.tmbundle](https://github.com/textmate/blitzmax.tmbundle) - **BlitzMax:** [textmate/blitzmax.tmbundle](https://github.com/textmate/blitzmax.tmbundle) diff --git a/vendor/grammars/vscode-bitbake b/vendor/grammars/vscode-bitbake new file mode 160000 index 0000000000..aa82827bfc --- /dev/null +++ b/vendor/grammars/vscode-bitbake @@ -0,0 +1 @@ +Subproject commit aa82827bfc25cbb08da262b75162981f0ca3773e diff --git a/vendor/licenses/git_submodule/vscode-bitbake.dep.yml b/vendor/licenses/git_submodule/vscode-bitbake.dep.yml new file mode 100644 index 0000000000..4cc44e99a1 --- /dev/null +++ b/vendor/licenses/git_submodule/vscode-bitbake.dep.yml @@ -0,0 +1,26 @@ +--- +name: vscode-bitbake +version: aa82827bfc25cbb08da262b75162981f0ca3773e +type: git_submodule +homepage: https://github.com/yoctoproject/vscode-bitbake.git +license: mit +licenses: +- sources: LICENSE + text: "MIT License\n\nCopyright (c) 2023 Savoir-faire Linux. \n\nPermission is hereby + granted, free of charge, to any person obtaining a copy\nof this software and + associated documentation files (the \"Software\"), to deal\nin the Software without + restriction, including without limitation the rights\nto use, copy, modify, merge, + publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit + persons to whom the Software is\nfurnished to do so, subject to the following + conditions:\n\nThe above copyright notice and this permission notice shall be + included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE + IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING + BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR + PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS + BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF + CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE + OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\nThe syntax settings used in + this project are forked from \n\nhttps://github.com/mholo65/vscode-bitbake\n\nOriginal + work Copyright (c) 2016 Richard Leitner\nModified work Copyright (c) 2017 Martin + Björkström\nModified work Copyright (c) 2018 Eugen Wiens\n" +notices: []