Skip to content

Commit

Permalink
build: Trigger cargo build on rust sub-projects from meson.build
Browse files Browse the repository at this point in the history
  • Loading branch information
htejun committed Dec 1, 2023
1 parent 6ec509b commit a55fc68
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 1 deletion.
6 changes: 5 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ project('sched_ext schedulers', 'c',
license: 'GPL2')

cc = meson.get_compiler('c')
fs = import('fs')

bpf_clang = find_program(get_option('bpf_clang'))
bpftool = find_program(get_option('bpftool'))
cargo = find_program(get_option('cargo'))

get_clang_ver = find_program(join_paths(meson.current_source_dir(),
'meson-scripts/get_clang_ver'))
bpftool_build_skel = find_program(join_paths(meson.current_source_dir(),
Expand Down Expand Up @@ -88,4 +89,7 @@ gen_bpf_skel = generator(bpftool_build_skel,
output: ['@BASENAME@.skel.h', '@BASENAME@.subskel.h' ],
arguments: [bpftool.full_path(), '@INPUT@', '@OUTPUT0@', '@OUTPUT1@'])

cargo_extra_args = ['--quiet']

subdir('rust')
subdir('scheds')
2 changes: 2 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ option('libbpf_a', type: 'string',
description: 'Static libbpf.a to use')
option('libbpf_h', type: 'array',
description: 'libbpf header directories, only meaning with libbpf_a option')
option('cargo', type: 'string', value: 'cargo',
description: 'cargo to use when building rust sub-projects')
1 change: 1 addition & 0 deletions rust/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
subdir('scx_utils')
6 changes: 6 additions & 0 deletions rust/scx_utils/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
custom_target('scx_utils',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_extra_args],
build_by_default: true)
1 change: 1 addition & 0 deletions scheds/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ bpf_includes = ['-I', join_paths(meson.current_source_dir(), 'include/common'),
user_c_includes = include_directories('include/common')

subdir('kernel-examples')
subdir('rust-user')
2 changes: 2 additions & 0 deletions scheds/rust-user/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
subdir('scx_layered')
subdir('scx_rusty')
6 changes: 6 additions & 0 deletions scheds/rust-user/scx_layered/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
custom_target('scx_layered',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_extra_args],
build_by_default: true)
6 changes: 6 additions & 0 deletions scheds/rust-user/scx_rusty/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
custom_target('scx_rusty',
output: '@PLAINNAME@.__PHONY__',
input: 'Cargo.toml',
command: [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
cargo_extra_args],
build_by_default: true)

0 comments on commit a55fc68

Please sign in to comment.