DEV Community

Euber Alexandre Barbosa
Euber Alexandre Barbosa

Posted on

Meson: Usando um projeto git sem meson.build como dependência

Eventualmente você vai achar um projeto bacana que não usa meson.build e o mantenedor demora anos para aceitar PR, se algum dia for.

Ou mesmo seu projeto está em contrato para sempre adicionar a LICENSE em todas as builds e o mantenedor se recusa.

Para resolver esse pepino você pode adicionar aos seus subprojects/*.wrap git patches.

Por exemplo, no meu projeto - onur - por ser uma pequena ferramenta CLI prefiro usar o ht do grande Hoyt ao invés do enorme GNOME glib, mas este projeto git não tem uma meson.build.

Uma simples wrap-git para esse projeto, que sequer tem tags também, seria usando o master:

./subprojects/ht.wrap

[wrap-git]
directory=ht
url=https://github.com/benhoyt/ht
revision=master
depth=1
Enter fullscreen mode Exit fullscreen mode

Primeiro vamos pegar todos subprojetos meson subprojects download, e adicionar a meson.build na raiz deste:

./subprojects/ht

cat <<EOF | tee -a ./subprojects/ht/meson.build
project('ht', 'c', version: '1.0')

ht_sources = [
    'ht.c',
    'ht.h',
]

ht_lib = static_library('ht', ht_sources)

ht_dep = declare_dependency(
    include_directories: include_directories('.'),
    link_with: ht_lib)
EOF

cat ./subprojects/ht/meson.build
Enter fullscreen mode Exit fullscreen mode

e criar o patch com:

mkdir -pv subprojects/{packagecache,packagefiles}
git -C ./subprojects/ht add meson.build
git -C ./subprojects/ht diff --cached > ./subprojects/packagefiles/ht-meson.patch
cat ./subprojects/packagefiles/ht-meson.patch
Enter fullscreen mode Exit fullscreen mode

uma vez com o patch devemos apontar sua presença ao ht.wrap:

echo "diff_files = ht-meson.patch" >> ./subprojects/ht.wrap
cat ./subprojects/ht.wrap
Enter fullscreen mode Exit fullscreen mode

Pronto, vamos aplicar o patch:

meson subprojects purge --confirm
meson subprojects download
Enter fullscreen mode Exit fullscreen mode

e compilar o projeto para confirmar:

CC=gcc meson setup ./build --wipe -D b_sanitize=none -D buildtype=release
meson compile -C ./build
Enter fullscreen mode Exit fullscreen mode

O executável vai aparecer em ./build como esperado.

Valeu!

Recomendação para leitura:

Informações gerais:

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

Top comments (0)

The discussion has been locked. New comments can't be added.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Engage with a sea of insights in this enlightening article, highly esteemed within the encouraging DEV Community. Programmers of every skill level are invited to participate and enrich our shared knowledge.

A simple "thank you" can uplift someone's spirits. Express your appreciation in the comments section!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found this useful? A brief thank you to the author can mean a lot.

Okay