mirror of
https://github.com/JakeHillion/scx.git
synced 2024-11-28 20:30:24 +00:00
build: Use a single top-level rust workspace
Rust build was using two separate workspaces - rust/ and scheds/rust. There's no reason to separate them and it makes doc generation tricky. Use single top level workspace so that we can drive all rust building from cargo.
This commit is contained in:
parent
134846c366
commit
56bb963136
870
scheds/rust/Cargo.lock → Cargo.lock
generated
870
scheds/rust/Cargo.lock → Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
Normal file
13
Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
||||
[workspace]
|
||||
members = ["rust/scx_stats",
|
||||
"rust/scx_stats/scx_stats_derive",
|
||||
"rust/scx_utils",
|
||||
"rust/scx_rustland_core",
|
||||
"rust/scx_loader",
|
||||
"scheds/rust/scx_lavd",
|
||||
"scheds/rust/scx_bpfland",
|
||||
"scheds/rust/scx_rustland",
|
||||
"scheds/rust/scx_rlfifo",
|
||||
"scheds/rust/scx_rusty",
|
||||
"scheds/rust/scx_layered"] # scx_mitosis temporarily excluded
|
||||
resolver = "2"
|
@ -4,7 +4,7 @@ set -e
|
||||
|
||||
for manifest in "$MESON_SOURCE_ROOT"/scheds/rust/*/Cargo.toml; do
|
||||
source_dir="${manifest%/Cargo.toml}"
|
||||
target_dir="${MESON_BUILD_ROOT}/scheds/rust"
|
||||
target_dir="${MESON_BUILD_ROOT}"
|
||||
name="${source_dir##*/}"
|
||||
|
||||
# Skip scx_mitosis
|
||||
@ -29,7 +29,7 @@ done
|
||||
|
||||
for manifest in "$MESON_SOURCE_ROOT"/rust/*/Cargo.toml; do
|
||||
source_dir="${manifest%/Cargo.toml}"
|
||||
target_dir="${MESON_BUILD_ROOT}/rust"
|
||||
target_dir="${MESON_BUILD_ROOT}"
|
||||
name="${source_dir##*/}"
|
||||
|
||||
if [ ! -f "${target_dir}/"*"/${name}" ]; then
|
||||
|
143
meson.build
143
meson.build
@ -25,10 +25,6 @@ veristat_scheduler = get_option('veristat_scheduler')
|
||||
|
||||
veristat_diff_dir = get_option('veristat_diff_dir')
|
||||
|
||||
if enable_rust
|
||||
cargo = find_program(get_option('cargo'))
|
||||
endif
|
||||
|
||||
if enable_stress
|
||||
run_stress_tests = find_program(join_paths(meson.current_source_dir(),
|
||||
'meson-scripts/run_stress_tests'))
|
||||
@ -52,10 +48,6 @@ fetch_bpftool = find_program(join_paths(meson.current_source_dir(),
|
||||
'meson-scripts/fetch_bpftool'))
|
||||
build_bpftool = find_program(join_paths(meson.current_source_dir(),
|
||||
'meson-scripts/build_bpftool'))
|
||||
if enable_rust
|
||||
cargo_fetch = find_program(join_paths(meson.current_source_dir(),
|
||||
'meson-scripts/cargo_fetch'))
|
||||
endif
|
||||
|
||||
bpf_clang_ver = run_command(get_clang_ver, bpf_clang, check: true).stdout().strip()
|
||||
if bpf_clang_ver == ''
|
||||
@ -288,59 +280,94 @@ if get_option('offline')
|
||||
cargo_build_args += '--offline'
|
||||
endif
|
||||
|
||||
cargo_env = environment()
|
||||
cargo_env.set('BPF_CLANG', bpf_clang.full_path())
|
||||
|
||||
foreach flag: bpf_base_cflags
|
||||
cargo_env.append('BPF_BASE_CFLAGS', flag, separator: ' ')
|
||||
endforeach
|
||||
|
||||
if libbpf_a != ''
|
||||
foreach header: libbpf_h
|
||||
cargo_env.append('BPF_EXTRA_CFLAGS_PRE_INCL', '-I' + header, separator: ' ')
|
||||
endforeach
|
||||
|
||||
cargo_env.append('RUSTFLAGS',
|
||||
'-C relocation-model=pic -C link-args=-lelf -C link-args=-lz -C link-args=-lzstd -L '
|
||||
+ fs.parent(libbpf_a), separator: ' ')
|
||||
|
||||
#
|
||||
# XXX - scx_rusty's original Cargo.toml contained a dependency matching
|
||||
# the following. However, it doesn't seem necessary to enable linking to
|
||||
# libbpf.a. Ask Dan Schatzberg about the role the dependency line plays.
|
||||
#
|
||||
#cargo_build_args += ['--config',
|
||||
# 'dependencies.libbpf-sys.version="1.2"',
|
||||
# '--config',
|
||||
# 'dependencies.libbpf-sys.features=["novendor", "static"]']
|
||||
endif
|
||||
|
||||
if get_option('cargo_home') != ''
|
||||
cargo_env.set('CARGO_HOME', get_option('cargo_home'))
|
||||
endif
|
||||
|
||||
if enable_rust
|
||||
meson.add_install_script('meson-scripts/install_rust_user_scheds')
|
||||
run_target('fetch', command: [cargo_fetch, cargo], env: cargo_env)
|
||||
endif
|
||||
|
||||
if get_option('kernel') != ''
|
||||
kernel = get_option('kernel')
|
||||
endif
|
||||
|
||||
if enable_rust
|
||||
cargo = find_program(get_option('cargo'))
|
||||
cargo_fetch = find_program(join_paths(meson.current_source_dir(),
|
||||
'meson-scripts/cargo_fetch'))
|
||||
cargo_env = environment()
|
||||
cargo_env.set('BPF_CLANG', bpf_clang.full_path())
|
||||
|
||||
meson.add_install_script('meson-scripts/install_rust_user_scheds')
|
||||
|
||||
foreach flag: bpf_base_cflags
|
||||
cargo_env.append('BPF_BASE_CFLAGS', flag, separator: ' ')
|
||||
endforeach
|
||||
|
||||
if libbpf_a != ''
|
||||
foreach header: libbpf_h
|
||||
cargo_env.append('BPF_EXTRA_CFLAGS_PRE_INCL', '-I' + header, separator: ' ')
|
||||
endforeach
|
||||
|
||||
cargo_env.append('RUSTFLAGS',
|
||||
'-C relocation-model=pic -C link-args=-lelf -C link-args=-lz -C link-args=-lzstd -L '
|
||||
+ fs.parent(libbpf_a), separator: ' ')
|
||||
|
||||
#
|
||||
# XXX - scx_rusty's original Cargo.toml contained a dependency matching
|
||||
# the following. However, it doesn't seem necessary to enable linking to
|
||||
# libbpf.a. Ask Dan Schatzberg about the role the dependency line plays.
|
||||
#
|
||||
#cargo_build_args += ['--config',
|
||||
# 'dependencies.libbpf-sys.version="1.2"',
|
||||
# '--config',
|
||||
# 'dependencies.libbpf-sys.features=["novendor", "static"]']
|
||||
endif
|
||||
|
||||
if get_option('cargo_home') != ''
|
||||
cargo_env.set('CARGO_HOME', get_option('cargo_home'))
|
||||
endif
|
||||
|
||||
run_target('fetch', command: [cargo_fetch, cargo], env: cargo_env)
|
||||
|
||||
rust_scheds = ['scx_lavd', 'scx_bpfland', 'scx_rustland', 'scx_rlfifo',
|
||||
'scx_rusty',
|
||||
'scx_layered'] # scx_mitosis temporarily excluded
|
||||
rust_misc = ['scx_stats', 'scx_stats_derive', 'scx_utils',
|
||||
'scx_rustland_core',
|
||||
'scx_loader']
|
||||
|
||||
sched_deps = [libbpf, bpftool_target]
|
||||
cargo_cmd = [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
|
||||
cargo_build_args]
|
||||
|
||||
# target to compile all rust subprojects
|
||||
custom_target('rust_all',
|
||||
output: '@PLAINNAME@.__PHONY__',
|
||||
input: 'Cargo.toml',
|
||||
command: cargo_cmd,
|
||||
env: cargo_env,
|
||||
depends: sched_deps,
|
||||
build_by_default: true,
|
||||
build_always_stale: true)
|
||||
|
||||
# targets to build individual rust subprojects
|
||||
foreach p : rust_scheds + rust_misc
|
||||
custom_target(p,
|
||||
output: p + '@PLAINNAME@.__PHONY__',
|
||||
input: 'Cargo.toml',
|
||||
command: cargo_cmd + ['-p', p],
|
||||
env: cargo_env,
|
||||
depends: sched_deps,
|
||||
build_by_default: false,
|
||||
build_always_stale: true)
|
||||
endforeach
|
||||
else
|
||||
rust_scheds = []
|
||||
endif
|
||||
|
||||
run_target('test_sched', command: [test_sched, kernel])
|
||||
|
||||
SCHEDULERS = ['scx_lavd', 'scx_bpfland', 'scx_rustland', 'scx_rlfifo',
|
||||
'scx_rusty',
|
||||
'scx_layered'] # scx_mitosis temporarily excluded
|
||||
|
||||
foreach s : SCHEDULERS
|
||||
foreach s : rust_scheds
|
||||
run_target('test_sched_'+s, command: [test_sched, kernel, s])
|
||||
endforeach
|
||||
|
||||
run_target('veristat', command: [run_veristat, meson.current_build_dir(),
|
||||
get_option('veristat_scheduler'), get_option('kernel')])
|
||||
foreach s : SCHEDULERS
|
||||
foreach s : rust_scheds
|
||||
run_target('veristat_'+s, command: [run_veristat, meson.current_build_dir(),
|
||||
get_option('veristat_scheduler'), get_option('kernel'), s])
|
||||
endforeach
|
||||
@ -349,19 +376,17 @@ run_target('veristat_diff', command: [run_veristat_diff, meson.current_build_dir
|
||||
get_option('veristat_scheduler'), get_option('kernel'),
|
||||
get_option('veristat_diff_dir')])
|
||||
|
||||
subdir('scheds')
|
||||
# currently only scx_loader is located there as binary
|
||||
subdir('rust')
|
||||
|
||||
if enable_stress
|
||||
run_target('stress_tests', command: [run_stress_tests, '-k', kernel, '-b',
|
||||
meson.current_build_dir()])
|
||||
foreach s : SCHEDULERS
|
||||
run_target('stress_tests_'+s, command: [run_stress_tests, '-k', kernel, '-b',
|
||||
meson.current_build_dir(), '--sched', s])
|
||||
endforeach
|
||||
meson.current_build_dir()])
|
||||
foreach s : rust_scheds
|
||||
run_target('stress_tests_'+s, command: [run_stress_tests, '-k', kernel, '-b',
|
||||
meson.current_build_dir(), '--sched', s])
|
||||
endforeach
|
||||
endif
|
||||
|
||||
subdir('scheds')
|
||||
|
||||
systemd = dependency('systemd', required: get_option('systemd'))
|
||||
|
||||
if systemd.found()
|
||||
|
@ -1,3 +0,0 @@
|
||||
[workspace]
|
||||
members = ["scx_utils", "scx_stats", "scx_stats/scx_stats_derive", "scx_rustland_core", "scx_loader"]
|
||||
resolver = "2"
|
@ -8,7 +8,4 @@ bpf_includes = ['-I', join_paths(meson.current_source_dir(), 'include'),
|
||||
# passed in as executable::include_directories.
|
||||
user_c_includes = include_directories('include')
|
||||
|
||||
if get_option('enable_rust')
|
||||
subdir('rust')
|
||||
endif
|
||||
subdir('c')
|
||||
|
@ -1,5 +0,0 @@
|
||||
[workspace]
|
||||
members = ["scx_lavd", "scx_bpfland", "scx_rustland", "scx_rlfifo",
|
||||
"scx_rusty",
|
||||
"scx_layered"] # scx_mitosis temporarily excluded
|
||||
resolver = "2"
|
@ -1,24 +0,0 @@
|
||||
sched_deps = [libbpf, bpftool_target]
|
||||
cargo_cmd = [cargo, 'build', '--manifest-path=@INPUT@', '--target-dir=@OUTDIR@',
|
||||
cargo_build_args]
|
||||
|
||||
# the target to compile all rust schedulers
|
||||
custom_target('rust_scheds',
|
||||
output: '@PLAINNAME@.__PHONY__',
|
||||
input: 'Cargo.toml',
|
||||
command: cargo_cmd,
|
||||
env: cargo_env,
|
||||
depends: sched_deps,
|
||||
build_by_default: true,
|
||||
build_always_stale: true)
|
||||
|
||||
foreach sched: SCHEDULERS
|
||||
custom_target(sched,
|
||||
output: sched + '@PLAINNAME@.__PHONY__',
|
||||
input: 'Cargo.toml',
|
||||
command: cargo_cmd + ['-p', sched],
|
||||
env: cargo_env,
|
||||
depends: sched_deps,
|
||||
build_by_default: false,
|
||||
build_always_stale: true)
|
||||
endforeach
|
Loading…
Reference in New Issue
Block a user