diff mbox series

[v3] gn: Add recipe

Message ID 20250929153647.1258488-1-raj.khem@gmail.com
State Accepted, archived
Commit e8dbf41f1f40ae3a5f9641429cad974f716f1f3e
Headers show
Series [v3] gn: Add recipe | expand

Commit Message

Khem Raj Sept. 29, 2025, 3:36 p.m. UTC
gn is a commonly used build tool to generate ninja files, used
in a lot of recipes e.g. chromium, qtwebengine, perfetto, hafnium etc.
these recipes come from different layers e.g. meta-qt6/meta-arm/meta-oe

since not all layers depend on meta-oe ( meta-arm does not ), its not
a possible option.

Given the usecases, putting it in core will benefit the ecosystem
and reduce some duplication. This recipe is taken from meta-arm

Disable maybe-initialized is a gcc specific option as error

Disable format warnings as errors, it adds -Wno-format explictly in
its build system

Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
v2:
 * Disable shallow clone, build fails gen.py does not work with it
 * Add build progress for do_compile
 * Update to latest commit on main
v3:
 * Make maybe-intialized opton to be gcc specific
 * Disable format string warnings as errors

 meta/conf/distro/include/maintainers.inc    |  1 +
 meta/conf/distro/include/security_flags.inc |  1 +
 meta/recipes-devtools/gn/gn_git.bb          | 52 +++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 meta/recipes-devtools/gn/gn_git.bb

Comments

Jon Mason Oct. 3, 2025, 7:08 p.m. UTC | #1
On Mon, Sep 29, 2025 at 11:36 AM Khem Raj via lists.openembedded.org
<raj.khem=gmail.com@lists.openembedded.org> wrote:
>
> gn is a commonly used build tool to generate ninja files, used
> in a lot of recipes e.g. chromium, qtwebengine, perfetto, hafnium etc.
> these recipes come from different layers e.g. meta-qt6/meta-arm/meta-oe
>
> since not all layers depend on meta-oe ( meta-arm does not ), its not
> a possible option.
>
> Given the usecases, putting it in core will benefit the ecosystem
> and reduce some duplication. This recipe is taken from meta-arm
>
> Disable maybe-initialized is a gcc specific option as error
>
> Disable format warnings as errors, it adds -Wno-format explictly in
> its build system
>
> Signed-off-by: Khem Raj <raj.khem@gmail.com>
> ---
> v2:
>  * Disable shallow clone, build fails gen.py does not work with it
>  * Add build progress for do_compile
>  * Update to latest commit on main
> v3:
>  * Make maybe-intialized opton to be gcc specific

I'm seeing this causing issues with qemuarm64-secureboot and clang,
and needs to be added back.  See
https://gitlab.com/jonmason00/meta-arm/-/jobs/11586703411/viewer#L10702

Want me to send a patch to remove the gcc specificity?

Thanks,
Jon

>  * Disable format string warnings as errors
>
>  meta/conf/distro/include/maintainers.inc    |  1 +
>  meta/conf/distro/include/security_flags.inc |  1 +
>  meta/recipes-devtools/gn/gn_git.bb          | 52 +++++++++++++++++++++
>  3 files changed, 54 insertions(+)
>  create mode 100644 meta/recipes-devtools/gn/gn_git.bb
>
> diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc
> index 0988bf50a72..85a9914469b 100644
> --- a/meta/conf/distro/include/maintainers.inc
> +++ b/meta/conf/distro/include/maintainers.inc
> @@ -224,6 +224,7 @@ RECIPE_MAINTAINER:pn-glibc-scripts = "Khem Raj <raj.khem@gmail.com>"
>  RECIPE_MAINTAINER:pn-glibc-testsuite = "Khem Raj <raj.khem@gmail.com>"
>  RECIPE_MAINTAINER:pn-gmp = "Khem Raj <raj.khem@gmail.com>"
>  RECIPE_MAINTAINER:pn-glslang = "Jose Quaresma <quaresma.jose@gmail.com>"
> +RECIPE_MAINTAINER:pn-gn = "Khem Raj <raj.khem@gmail.com>"
>  RECIPE_MAINTAINER:pn-gnome-desktop-testing = "Ross Burton <ross.burton@arm.com>"
>  RECIPE_MAINTAINER:pn-gnu-config = "Robert Yang <liezhi.yang@windriver.com>"
>  RECIPE_MAINTAINER:pn-gnu-efi = "Yi Zhao <yi.zhao@windriver.com>"
> diff --git a/meta/conf/distro/include/security_flags.inc b/meta/conf/distro/include/security_flags.inc
> index f713a994651..824ba2c0e3f 100644
> --- a/meta/conf/distro/include/security_flags.inc
> +++ b/meta/conf/distro/include/security_flags.inc
> @@ -46,6 +46,7 @@ SECURITY_LDFLAGS:pn-sysklogd = ""
>  # Recipes which fail to compile when elevating -Wformat-security to an error
>  SECURITY_STRINGFORMAT:pn-busybox = ""
>  SECURITY_STRINGFORMAT:pn-gcc = ""
> +SECURITY_STRINGFORMAT:pn-gn = ""
>
>  TARGET_CC_ARCH:append:class-target = " ${SECURITY_CFLAGS}"
>  TARGET_LDFLAGS:append:class-target = " ${SECURITY_LDFLAGS}"
> diff --git a/meta/recipes-devtools/gn/gn_git.bb b/meta/recipes-devtools/gn/gn_git.bb
> new file mode 100644
> index 00000000000..d8896609b19
> --- /dev/null
> +++ b/meta/recipes-devtools/gn/gn_git.bb
> @@ -0,0 +1,52 @@
> +SUMMARY = "GN is a meta-build system that generates build files for Ninja"
> +HOMEPAGE = "https://gn.googlesource.com/gn/"
> +LICENSE = "BSD-3-Clause"
> +LIC_FILES_CHKSUM = "file://LICENSE;md5=0fca02217a5d49a14dfe2d11837bb34d"
> +
> +DEPENDS += "ninja-native"
> +UPSTREAM_CHECK_COMMITS = "1"
> +
> +SRC_URI = "git://gn.googlesource.com/gn;protocol=https;branch=main"
> +SRCREV = "81b24e01531ecf0eff12ec9359a555ec3944ec4e"
> +PV = "0+git"
> +
> +BB_GIT_SHALLOW = ""
> +
> +B = "${WORKDIR}/build"
> +
> +# Map from our _OS strings to the GN's platform values.
> +def gn_platform(variable, d):
> +    os = d.getVar(variable)
> +    if "linux" in os:
> +        return "linux"
> +    elif "mingw" in os:
> +        return "mingw"
> +    else:
> +        return os
> +
> +do_configure[cleandirs] += "${B}"
> +do_configure() {
> +    python3 ${S}/build/gen.py \
> +        --platform=${@gn_platform("TARGET_OS", d)} \
> +        --out-path=${B} \
> +        --no-static-libstdc++ \
> +        --no-strip
> +}
> +
> +# Catch build progress from ninja
> +do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
> +
> +do_compile() {
> +    ninja -C ${B} --verbose
> +}
> +
> +do_install() {
> +    install -d ${D}${bindir}
> +    install ${B}/gn ${D}${bindir}
> +}
> +
> +BBCLASSEXTEND = "native"
> +
> +COMPATIBLE_HOST = "^(?!riscv32).*"
> +
> +CFLAGS:append:toolchain-gcc = " -Wno-error=maybe-uninitialized"
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#224149): https://lists.openembedded.org/g/openembedded-core/message/224149
> Mute This Topic: https://lists.openembedded.org/mt/115497351/3616920
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [jdmason@kudzu.us]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/conf/distro/include/maintainers.inc b/meta/conf/distro/include/maintainers.inc
index 0988bf50a72..85a9914469b 100644
--- a/meta/conf/distro/include/maintainers.inc
+++ b/meta/conf/distro/include/maintainers.inc
@@ -224,6 +224,7 @@  RECIPE_MAINTAINER:pn-glibc-scripts = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-glibc-testsuite = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-gmp = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-glslang = "Jose Quaresma <quaresma.jose@gmail.com>"
+RECIPE_MAINTAINER:pn-gn = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-gnome-desktop-testing = "Ross Burton <ross.burton@arm.com>"
 RECIPE_MAINTAINER:pn-gnu-config = "Robert Yang <liezhi.yang@windriver.com>"
 RECIPE_MAINTAINER:pn-gnu-efi = "Yi Zhao <yi.zhao@windriver.com>"
diff --git a/meta/conf/distro/include/security_flags.inc b/meta/conf/distro/include/security_flags.inc
index f713a994651..824ba2c0e3f 100644
--- a/meta/conf/distro/include/security_flags.inc
+++ b/meta/conf/distro/include/security_flags.inc
@@ -46,6 +46,7 @@  SECURITY_LDFLAGS:pn-sysklogd = ""
 # Recipes which fail to compile when elevating -Wformat-security to an error
 SECURITY_STRINGFORMAT:pn-busybox = ""
 SECURITY_STRINGFORMAT:pn-gcc = ""
+SECURITY_STRINGFORMAT:pn-gn = ""
 
 TARGET_CC_ARCH:append:class-target = " ${SECURITY_CFLAGS}"
 TARGET_LDFLAGS:append:class-target = " ${SECURITY_LDFLAGS}"
diff --git a/meta/recipes-devtools/gn/gn_git.bb b/meta/recipes-devtools/gn/gn_git.bb
new file mode 100644
index 00000000000..d8896609b19
--- /dev/null
+++ b/meta/recipes-devtools/gn/gn_git.bb
@@ -0,0 +1,52 @@ 
+SUMMARY = "GN is a meta-build system that generates build files for Ninja"
+HOMEPAGE = "https://gn.googlesource.com/gn/"
+LICENSE = "BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=0fca02217a5d49a14dfe2d11837bb34d"
+
+DEPENDS += "ninja-native"
+UPSTREAM_CHECK_COMMITS = "1"
+
+SRC_URI = "git://gn.googlesource.com/gn;protocol=https;branch=main"
+SRCREV = "81b24e01531ecf0eff12ec9359a555ec3944ec4e"
+PV = "0+git"
+
+BB_GIT_SHALLOW = ""
+
+B = "${WORKDIR}/build"
+
+# Map from our _OS strings to the GN's platform values.
+def gn_platform(variable, d):
+    os = d.getVar(variable)
+    if "linux" in os:
+        return "linux"
+    elif "mingw" in os:
+        return "mingw"
+    else:
+        return os
+
+do_configure[cleandirs] += "${B}"
+do_configure() {
+    python3 ${S}/build/gen.py \
+        --platform=${@gn_platform("TARGET_OS", d)} \
+        --out-path=${B} \
+        --no-static-libstdc++ \
+        --no-strip
+}
+
+# Catch build progress from ninja
+do_compile[progress] = "outof:^\[(\d+)/(\d+)\]\s+"
+
+do_compile() {
+    ninja -C ${B} --verbose
+}
+
+do_install() {
+    install -d ${D}${bindir}
+    install ${B}/gn ${D}${bindir}
+}
+
+BBCLASSEXTEND = "native"
+
+COMPATIBLE_HOST = "^(?!riscv32).*"
+
+CFLAGS:append:toolchain-gcc = " -Wno-error=maybe-uninitialized"