mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
Rust WAF detect dependant files from crates
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
This commit is contained in:
parent
4a4304ecf7
commit
5a8b8a7799
@ -1,13 +1,21 @@
|
||||
from waflib.Configure import conf
|
||||
from waflib import Build
|
||||
import os.path
|
||||
import os
|
||||
|
||||
@conf
|
||||
def SAMBA_CHECK_RUST(conf):
|
||||
conf.find_program('cargo', var='CARGO',
|
||||
mandatory=not conf.env.disable_rust)
|
||||
|
||||
def SAMBA_RUST(bld, rust_subdir, target_name, source, enabled=True):
|
||||
def find_sources(source_dir, dep_crate):
|
||||
sources = []
|
||||
for root, dirs, files in os.walk(os.path.join(source_dir, dep_crate)):
|
||||
for file in files:
|
||||
if os.path.splitext(file)[-1] in ['.rs', '.c', '.h']:
|
||||
sources.append(os.path.join(root, file))
|
||||
return sources
|
||||
|
||||
def SAMBA_RUST(bld, rust_subdir, target_name, dep_crates=[], enabled=True):
|
||||
# force-disable when we can't build rust modules, so
|
||||
# every single call doesn't need to pass this in.
|
||||
if bld.env.disable_rust:
|
||||
@ -26,6 +34,15 @@ def SAMBA_RUST(bld, rust_subdir, target_name, source, enabled=True):
|
||||
target = bld.path.find_or_declare(target)
|
||||
# The Rust target directory is one directory above the located target
|
||||
target_dir = os.path.join(os.path.dirname('%s' % target), '../')
|
||||
# Try to determine the source directory
|
||||
source_dir = os.path.abspath(os.path.join(target_dir, '../../../rust'))
|
||||
if not os.path.exists(source_dir):
|
||||
raise Exception('Failed to determine rust source directory')
|
||||
# Now determine the sources of each local crate
|
||||
sources = find_sources(source_dir, rust_subdir)
|
||||
for dep_crate in dep_crates:
|
||||
sources.extend(find_sources(source_dir, dep_crate))
|
||||
sources = [os.path.relpath(p, source_dir) for p in sources]
|
||||
|
||||
rule = ['${CARGO}', 'build',
|
||||
'--manifest-path=${SRC[0].abspath(env)}',
|
||||
@ -33,7 +50,7 @@ def SAMBA_RUST(bld, rust_subdir, target_name, source, enabled=True):
|
||||
release_flag]
|
||||
bld.SAMBA_GENERATOR(target_name,
|
||||
' '.join(rule),
|
||||
source='%s/Cargo.toml %s' % (rust_subdir, source),
|
||||
source='%s/Cargo.toml %s' % (rust_subdir, ' '.join(sources)),
|
||||
target=target,
|
||||
group='final',
|
||||
enabled=enabled)
|
||||
|
@ -1,6 +1,20 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
if conf.env.enable_himmelblau:
|
||||
bld.SAMBA_RUST_BINARY('himmelblaud', 'himmelblaud', 'himmelblaud/src/main.rs param/src/lib.rs chelps/src/lib.rs dbg/src/lib.rs ntstatus_gen/src/lib.rs sock/src/lib.rs tdb/src/lib.rs version/src/lib.rs')
|
||||
bld.SAMBA_RUST_LIBRARY('nss', 'libnss_himmelblau.so', 'nss/src/lib.rs sock/src/lib.rs ntstatus_gen/src/lib.rs param/src/lib.rs version/src/lib.rs')
|
||||
bld.SAMBA_RUST_LIBRARY('pam', 'libpam_himmelblau.so', 'pam/src/lib.rs pam/src/pam/constants.rs pam/src/pam/conv.rs pam/src/pam/items.rs pam/src/pam/items.rs pam/src/pam/macros.rs pam/src/pam/mod.rs pam/src/pam/module.rs sock/src/lib.rs ntstatus_gen/src/lib.rs param/src/lib.rs version/src/lib.rs')
|
||||
bld.SAMBA_RUST_BINARY('himmelblaud', 'himmelblaud',
|
||||
['param',
|
||||
'chelps',
|
||||
'dbg',
|
||||
'ntstatus_gen',
|
||||
'sock',
|
||||
'tdb',
|
||||
'version',
|
||||
'idmap'])
|
||||
bld.SAMBA_RUST_LIBRARY('nss', 'libnss_himmelblau.so', ['sock',
|
||||
'ntstatus_gen',
|
||||
'param',
|
||||
'version'])
|
||||
bld.SAMBA_RUST_LIBRARY('pam', 'libpam_himmelblau.so', ['sock',
|
||||
'chelps',
|
||||
'param',
|
||||
'version'])
|
||||
|
Loading…
Reference in New Issue
Block a user