Skip to content

Commit 54a407f

Browse files
committed
Merge branch 'ps/rust-cbindgen' into seen
* ps/rust-cbindgen: rust: generate bindings via cbindgen meson: rename Rust library target ci: use Debian instead of deprecated i386/ubuntu
2 parents 2b34aba + 3d04ae8 commit 54a407f

11 files changed

Lines changed: 58 additions & 18 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,9 +395,8 @@ jobs:
395395
cc: gcc
396396
- jobname: linux-musl-meson
397397
image: alpine:latest
398-
# Supported until 2025-04-02.
399398
- jobname: linux32
400-
image: i386/ubuntu:focal
399+
image: i386/debian:latest
401400
# A RHEL 8 compatible distro. Supported until 2029-05-31.
402401
- jobname: almalinux-8
403402
image: almalinux:8

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@
198198
/gitweb/gitweb.cgi
199199
/gitweb/static/gitweb.js
200200
/gitweb/static/gitweb.min.*
201+
/c-bindings.h
201202
/config-list.h
202203
/command-list.h
203204
/hook-list.h

.gitlab-ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ test:linux:
6363
- jobname: linux-musl-meson
6464
image: alpine:latest
6565
- jobname: linux32
66-
image: i386/ubuntu:20.04
66+
image: i386/debian:latest
6767
- jobname: linux-meson
6868
image: ubuntu:rolling
6969
CC: gcc

Makefile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,9 +1334,7 @@ LIB_OBJS += urlmatch.o
13341334
LIB_OBJS += usage.o
13351335
LIB_OBJS += userdiff.o
13361336
LIB_OBJS += utf8.o
1337-
ifndef WITH_RUST
13381337
LIB_OBJS += varint.o
1339-
endif
13401338
LIB_OBJS += version.o
13411339
LIB_OBJS += versioncmp.o
13421340
LIB_OBJS += walker.o
@@ -1571,6 +1569,14 @@ ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND)
15711569
ifdef WITH_RUST
15721570
BASIC_CFLAGS += -DWITH_RUST
15731571
GITLIBS += $(RUST_LIB)
1572+
1573+
C_BINDINGS = c-bindings.h
1574+
1575+
GENERATED_H += $(C_BINDINGS)
1576+
1577+
$(C_BINDINGS): cbindgen.toml $(RUST_SOURCES)
1578+
$(QUIET_CBINDGEN)cbindgen --output $@
1579+
15741580
ifeq ($(uname_S),Windows)
15751581
EXTLIBS += -luserenv
15761582
endif
@@ -2633,6 +2639,8 @@ PAGER_ENV_CQ_SQ = $(subst ','\'',$(PAGER_ENV_CQ))
26332639
pager.sp pager.s pager.o: EXTRA_CPPFLAGS = \
26342640
-DPAGER_ENV='$(PAGER_ENV_CQ_SQ)'
26352641

2642+
varint.sp varint.s varint.o: $(C_BINDINGS)
2643+
26362644
version-def.h: version-def.h.in GIT-VERSION-GEN GIT-VERSION-FILE GIT-USER-AGENT
26372645
$(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@)
26382646

@@ -3820,7 +3828,7 @@ clean: profile-clean coverage-clean cocciclean
38203828
$(RM) $(FUZZ_PROGRAMS)
38213829
$(RM) $(SP_OBJ)
38223830
$(RM) $(HCC)
3823-
$(RM) -r Cargo.lock target/
3831+
$(RM) -r Cargo.lock target/ $(C_BINDINGS)
38243832
$(RM) version-def.h
38253833
$(RM) -r $(dep_dirs) $(compdb_dir) compile_commands.json
38263834
$(RM) $(test_bindir_programs)

cbindgen.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
language = "C"
2+
3+
# Don't include standard C headers. These are managed by "git-compat-util.h".
4+
no_includes = true
5+
6+
# Use plain structs instead of using typedefs.
7+
style = "tag"

ci/install-dependencies.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ fedora-*|almalinux-*)
3737
MESON_DEPS="meson ninja";;
3838
esac
3939
dnf -yq update >/dev/null &&
40-
dnf -yq install shadow-utils sudo make pkg-config gcc findutils diffutils perl python3 gawk gettext zlib-devel expat-devel openssl-devel curl-devel pcre2-devel $MESON_DEPS cargo >/dev/null
40+
dnf -yq install shadow-utils sudo make pkg-config gcc findutils diffutils perl python3 gawk gettext zlib-devel expat-devel openssl-devel curl-devel pcre2-devel $MESON_DEPS cargo cbindgen >/dev/null
4141
;;
42-
ubuntu-*|i386/ubuntu-*|debian-*)
42+
ubuntu-*|i386/debian-*|debian-*)
4343
# Required so that apt doesn't wait for user input on certain packages.
4444
export DEBIAN_FRONTEND=noninteractive
4545

@@ -48,9 +48,9 @@ ubuntu-*|i386/ubuntu-*|debian-*)
4848
SVN='libsvn-perl subversion'
4949
LANGUAGES='language-pack-is'
5050
;;
51-
i386/ubuntu-*)
51+
i386/debian-*)
5252
SVN=
53-
LANGUAGES='language-pack-is'
53+
LANGUAGES='locales-all'
5454
;;
5555
*)
5656
SVN='libsvn-perl subversion'
@@ -64,7 +64,7 @@ ubuntu-*|i386/ubuntu-*|debian-*)
6464
make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \
6565
tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \
6666
libemail-valid-perl libio-pty-perl libio-socket-ssl-perl libnet-smtp-ssl-perl libdbd-sqlite3-perl libcgi-pm-perl \
67-
libsecret-1-dev libpcre2-dev meson ninja-build pkg-config cargo \
67+
libsecret-1-dev libpcre2-dev meson ninja-build pkg-config cargo cbindgen \
6868
${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE
6969

7070
# Starting with Ubuntu 25.10, sudo can now be provided via either

ci/lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ then
250250
CI_OS_NAME=osx
251251
JOBS=$(nproc)
252252
;;
253-
*,alpine:*|*,fedora:*|*,ubuntu:*|*,i386/ubuntu:*)
253+
*,alpine:*|*,fedora:*|*,ubuntu:*|*,i386/debian:*)
254254
CI_OS_NAME=linux
255255
JOBS=$(nproc)
256256
;;

meson.build

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ libgit_sources = [
530530
'usage.c',
531531
'userdiff.c',
532532
'utf8.c',
533+
'varint.c',
533534
'version.c',
534535
'versioncmp.c',
535536
'walker.c',
@@ -1713,18 +1714,32 @@ version_def_h = custom_target(
17131714
libgit_sources += version_def_h
17141715

17151716
cargo = find_program('cargo', dirs: program_path, native: true, required: get_option('rust'))
1716-
rust_option = get_option('rust').disable_auto_if(not cargo.found())
1717+
cbindgen = find_program('cbindgen', dirs: program_path, native: true, required: get_option('rust'))
1718+
1719+
rust_option = get_option('rust').disable_auto_if(not cargo.found() or not cbindgen.found())
17171720
if rust_option.allowed()
17181721
subdir('src')
17191722
libgit_c_args += '-DWITH_RUST'
17201723

17211724
if host_machine.system() == 'windows'
17221725
libgit_dependencies += compiler.find_library('userenv')
17231726
endif
1724-
else
1725-
libgit_sources += [
1726-
'varint.c',
1727-
]
1727+
1728+
cbindgen_input = [ 'cbindgen.toml' ]
1729+
foreach source : libgit_rs_sources
1730+
cbindgen_input += 'src' / source
1731+
endforeach
1732+
1733+
libgit_sources += custom_target('c-bindings.h',
1734+
input: cbindgen_input,
1735+
output: 'c-bindings.h',
1736+
command: [
1737+
cbindgen,
1738+
'--output',
1739+
'@OUTPUT@',
1740+
meson.current_source_dir(),
1741+
],
1742+
)
17281743
endif
17291744

17301745
libgit = declare_dependency(

shared.mak

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ ifndef V
5757

5858
## Used in "Makefile"
5959
QUIET_CARGO = @echo ' ' CARGO $@;
60+
QUIET_CBINDGEN = @echo ' ' CBINDGEN $@;
6061
QUIET_CC = @echo ' ' CC $@;
6162
QUIET_AR = @echo ' ' AR $@;
6263
QUIET_LINK = @echo ' ' LINK $@;

src/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if get_option('buildtype') == 'release'
1717
cargo_command += '--release'
1818
endif
1919

20-
libgit_rs = custom_target('git_rs',
20+
libgit_rs = custom_target('rust',
2121
input: libgit_rs_sources + [
2222
meson.project_source_root() / 'Cargo.toml',
2323
],

0 commit comments

Comments
 (0)