]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Add simple WAF commands for building Rust bininaries
authorDavid Mulder <dmulder@samba.org>
Fri, 5 Jul 2024 20:23:09 +0000 (14:23 -0600)
committerDavid Mulder <dmulder@samba.org>
Wed, 23 Oct 2024 14:21:33 +0000 (14:21 +0000)
Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
31 files changed:
.gitlab-ci-main.yml
bootstrap/config.py
bootstrap/generated-dists/centos9s/bootstrap.sh
bootstrap/generated-dists/centos9s/packages.yml
bootstrap/generated-dists/debian11-32bit/bootstrap.sh
bootstrap/generated-dists/debian11-32bit/packages.yml
bootstrap/generated-dists/debian11/bootstrap.sh
bootstrap/generated-dists/debian11/packages.yml
bootstrap/generated-dists/debian12-32bit/bootstrap.sh
bootstrap/generated-dists/debian12-32bit/packages.yml
bootstrap/generated-dists/debian12/bootstrap.sh
bootstrap/generated-dists/debian12/packages.yml
bootstrap/generated-dists/fedora40/bootstrap.sh
bootstrap/generated-dists/fedora40/packages.yml
bootstrap/generated-dists/opensuse155/bootstrap.sh
bootstrap/generated-dists/opensuse155/packages.yml
bootstrap/generated-dists/rocky8/bootstrap.sh
bootstrap/generated-dists/rocky8/packages.yml
bootstrap/generated-dists/ubuntu1804-32bit/bootstrap.sh
bootstrap/generated-dists/ubuntu1804-32bit/packages.yml
bootstrap/generated-dists/ubuntu1804/bootstrap.sh
bootstrap/generated-dists/ubuntu1804/packages.yml
bootstrap/generated-dists/ubuntu2004/bootstrap.sh
bootstrap/generated-dists/ubuntu2004/packages.yml
bootstrap/generated-dists/ubuntu2204/bootstrap.sh
bootstrap/generated-dists/ubuntu2204/packages.yml
bootstrap/sha1sum.txt
buildtools/wafsamba/samba_rust.py [new file with mode: 0644]
buildtools/wafsamba/wafsamba.py
buildtools/wafsamba/wscript
wscript

index 660cb6e973580d2881b7086452a81b564271c51f..52d50f1c58b182a7ad0caead5301a704992ef2ef 100644 (file)
@@ -47,7 +47,7 @@ variables:
   # Set this to the contents of bootstrap/sha1sum.txt
   # which is generated by bootstrap/template.py --render
   #
-  SAMBA_CI_CONTAINER_TAG: d1ce7e10953d16253a34b8e58077fd32c1dbd59c
+  SAMBA_CI_CONTAINER_TAG: 8845099b492ab9888181df3e094e00ae8916ddb7
   #
   # We use the ubuntu2204 image as default as
   # it matches what we have on atb-devel-224
index 7e6c0f47d676b3dd5c2bba951da295862e889723..1f0eba24b0b48e322f67812c985f250885e5bc84 100644 (file)
@@ -64,6 +64,7 @@ COMMON = [
     'tar',
     'tree',
     'wget',
+    'cargo',
 ]
 
 
index 40894b3f3acfc215eadb810634b22063ad38237d..d4684e9cf472ff892c2c36a6a5553a08cabc3bd3 100755 (executable)
@@ -27,6 +27,7 @@ dnf install -y \
     bind-utils \
     binutils \
     bison \
+    cargo \
     ccache \
     chrpath \
     crypto-policies-scripts \
index 19b480e67e17635c04751f292912751d8818b1d2..22f79700ddf367eded935c5432712914191494a3 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - bind-utils
   - binutils
   - bison
+  - cargo
   - ccache
   - chrpath
   - crypto-policies-scripts
index 82d2705c092420a54e1c6f15f5fd39201c23cadd..db982ada06783f31d6fa1432004d14e33e745117 100755 (executable)
@@ -19,6 +19,7 @@ apt-get -y install \
     binutils \
     bison \
     build-essential \
+    cargo \
     ccache \
     chrpath \
     codespell \
index dab6a93e10c8f8840279115352678b8fd3f2e08c..492344da465c4feaf177518cf74794d80bbbff3e 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - binutils
   - bison
   - build-essential
+  - cargo
   - ccache
   - chrpath
   - codespell
index 82d2705c092420a54e1c6f15f5fd39201c23cadd..db982ada06783f31d6fa1432004d14e33e745117 100755 (executable)
@@ -19,6 +19,7 @@ apt-get -y install \
     binutils \
     bison \
     build-essential \
+    cargo \
     ccache \
     chrpath \
     codespell \
index dab6a93e10c8f8840279115352678b8fd3f2e08c..492344da465c4feaf177518cf74794d80bbbff3e 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - binutils
   - bison
   - build-essential
+  - cargo
   - ccache
   - chrpath
   - codespell
index 033061ad7e62ac78cc59bf7c8411b4c9cb46d4cf..e85b15d6692b4b26ce4c18858b7e48fb85aa7063 100755 (executable)
@@ -19,6 +19,7 @@ apt-get -y install \
     binutils \
     bison \
     build-essential \
+    cargo \
     ccache \
     chrpath \
     codespell \
index bd9a558ffbb1724a807f2f7d9529d63c569a3698..b2a027541f1bf7d7f88fc637e09fc3af111ecc7c 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - binutils
   - bison
   - build-essential
+  - cargo
   - ccache
   - chrpath
   - codespell
index 033061ad7e62ac78cc59bf7c8411b4c9cb46d4cf..e85b15d6692b4b26ce4c18858b7e48fb85aa7063 100755 (executable)
@@ -19,6 +19,7 @@ apt-get -y install \
     binutils \
     bison \
     build-essential \
+    cargo \
     ccache \
     chrpath \
     codespell \
index bd9a558ffbb1724a807f2f7d9529d63c569a3698..b2a027541f1bf7d7f88fc637e09fc3af111ecc7c 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - binutils
   - bison
   - build-essential
+  - cargo
   - ccache
   - chrpath
   - codespell
index e3b36468ca597822c1479761b3e831d053fb3f03..99aad7c8c27c99daaccd413aed3329377f643ac8 100755 (executable)
@@ -20,6 +20,7 @@ dnf install -y \
     bind-utils \
     binutils \
     bison \
+    cargo \
     ccache \
     chrpath \
     codespell \
index 1fbe3988e078332ef4f8d055fa404f97d10467df..7bdb86e11b43ad7e5b3347262010ada8b668445e 100644 (file)
@@ -9,6 +9,7 @@ packages:
   - bind-utils
   - binutils
   - bison
+  - cargo
   - ccache
   - chrpath
   - codespell
index 45d11ef6c4bd5de5980a6b91331b36275e58cd3a..687f30ff7bea4622f09c9946243bcd16d41a0212 100755 (executable)
@@ -20,6 +20,7 @@ zypper --non-interactive install \
     bind-utils \
     binutils \
     bison \
+    cargo \
     ccache \
     chrpath \
     codespell \
index 519b62c33a9f36a0e904a39cc0954814b5f40987..ca1a96efebde00ca1303203207cb63ff06b7fe9c 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - bind-utils
   - binutils
   - bison
+  - cargo
   - ccache
   - chrpath
   - codespell
index 4b2c62c66d9a5cfd8b92dbdc9035765264a757fa..639ab513ecd7c44d9462ab34fc961bbf891eb7b3 100755 (executable)
@@ -26,6 +26,7 @@ yum install -y \
     bind-utils \
     binutils \
     bison \
+    cargo \
     ccache \
     chrpath \
     crypto-policies-scripts \
index f416dea4f5ebcacc0c553e56181ec2e1b15dc4c3..bc34825f9acf1afbdf6e8451323b229f6ae16f52 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - bind-utils
   - binutils
   - bison
+  - cargo
   - ccache
   - chrpath
   - crypto-policies-scripts
index da249a8724c3ac6df4f93048064ce026d5e9ba6e..b74a5e0e7e1bdc077d5fa3f3226a16faa4bdd882 100755 (executable)
@@ -19,6 +19,7 @@ apt-get -y install \
     binutils \
     bison \
     build-essential \
+    cargo \
     ccache \
     chrpath \
     codespell \
index 94957fc07b2761092e19eff9c414e847ebc7f06f..bca52528f6b69d7ca7a296a6f56ad1a1677165a1 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - binutils
   - bison
   - build-essential
+  - cargo
   - ccache
   - chrpath
   - codespell
index da249a8724c3ac6df4f93048064ce026d5e9ba6e..b74a5e0e7e1bdc077d5fa3f3226a16faa4bdd882 100755 (executable)
@@ -19,6 +19,7 @@ apt-get -y install \
     binutils \
     bison \
     build-essential \
+    cargo \
     ccache \
     chrpath \
     codespell \
index 94957fc07b2761092e19eff9c414e847ebc7f06f..bca52528f6b69d7ca7a296a6f56ad1a1677165a1 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - binutils
   - bison
   - build-essential
+  - cargo
   - ccache
   - chrpath
   - codespell
index da249a8724c3ac6df4f93048064ce026d5e9ba6e..b74a5e0e7e1bdc077d5fa3f3226a16faa4bdd882 100755 (executable)
@@ -19,6 +19,7 @@ apt-get -y install \
     binutils \
     bison \
     build-essential \
+    cargo \
     ccache \
     chrpath \
     codespell \
index 94957fc07b2761092e19eff9c414e847ebc7f06f..bca52528f6b69d7ca7a296a6f56ad1a1677165a1 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - binutils
   - bison
   - build-essential
+  - cargo
   - ccache
   - chrpath
   - codespell
index 1a3c3b14efbc6fe9414f77b4ffe8b7ca2144bada..72802d40cf1d1147b4add2c9abe5cae59ffcb089 100755 (executable)
@@ -19,6 +19,7 @@ apt-get -y install \
     binutils \
     bison \
     build-essential \
+    cargo \
     ccache \
     chrpath \
     codespell \
index c3b741fbc69493b61d00fa545813451e975dd953..c58b08f917482dcfcddd0989680bcc02a1e538bb 100644 (file)
@@ -8,6 +8,7 @@ packages:
   - binutils
   - bison
   - build-essential
+  - cargo
   - ccache
   - chrpath
   - codespell
index e71a040595ba08acd75c4866a2e403951f8f6ded..cdb48c417153bf28567985b5772743744eafe50c 100644 (file)
@@ -1 +1 @@
-d1ce7e10953d16253a34b8e58077fd32c1dbd59c
+8845099b492ab9888181df3e094e00ae8916ddb7
diff --git a/buildtools/wafsamba/samba_rust.py b/buildtools/wafsamba/samba_rust.py
new file mode 100644 (file)
index 0000000..c58bf89
--- /dev/null
@@ -0,0 +1,38 @@
+from waflib.Configure import conf
+from waflib import Build
+import os.path
+
+@conf
+def SAMBA_CHECK_RUST(conf):
+    conf.find_program('cargo', var='CARGO',
+                      mandatory=not conf.env.disable_rust)
+
+def SAMBA_RUST(bld, name, source, 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:
+        enabled = False
+
+    # Save time, no need to build rust when fuzzing
+    if bld.env.enable_fuzzing:
+        enabled = False
+
+    release_flag = ''
+    if bld.env.debug or bld.env.developer:
+        target = os.path.join('debug', name)
+    else:
+        release_flag = '--release'
+        target = os.path.join('release', name)
+    target = bld.path.find_or_declare(target)
+    rust_vars = 'CARGO_TARGET_DIR=%s' % bld.path.find_or_declare('./')
+
+    rule = [rust_vars, '${CARGO}', 'build',
+            '--manifest-path=${SRC[0].abspath(env)}', release_flag]
+    bld.SAMBA_GENERATOR(name,
+                        ' '.join(rule),
+                        source='Cargo.toml %s' % source,
+                        target=target,
+                        group='final',
+                        enabled=enabled)
+Build.BuildContext.SAMBA_RUST_LIBRARY = SAMBA_RUST
+Build.BuildContext.SAMBA_RUST_BINARY = SAMBA_RUST
index 250da072c508987d1e23c50fa2eab8a46b49f5bd..1a4943d6c5cb2b5ff5d27ed7a66588002686ae65 100644 (file)
@@ -19,6 +19,7 @@ from samba_autoproto import *
 from samba_python import *
 from samba_perl import *
 from samba_deps import *
+from samba_rust import *
 from samba_bundled import *
 from samba_third_party import *
 import samba_cross
index e18bc4fd7416462cf8c4687a6382e708bf4669c3..505e77a5ca7a142b20ca9fc5131d6b22bbef1706 100644 (file)
@@ -288,6 +288,9 @@ Currently the only tested value is 'smbtorture,smbd/smbd' for Samba'''),
     opt.add_option('--disable-python',
                     help='do not generate python modules',
                     action='store_true', dest='disable_python', default=False)
+    opt.add_option('--disable-rust',
+                    help='do not build rust modules',
+                    action='store_true', dest='disable_rust', default=False)
 
 
 @Utils.run_once
@@ -351,6 +354,7 @@ def configure(conf):
     conf.env.AUTOCONF_PROGRAM_PREFIX = Options.options.AUTOCONF_PROGRAM_PREFIX
 
     conf.env.disable_python = Options.options.disable_python
+    conf.env.disable_rust = Options.options.disable_rust
 
     if (conf.env.AUTOCONF_HOST and
         conf.env.AUTOCONF_BUILD and
diff --git a/wscript b/wscript
index 8dd6599cdd7e615392ef6d794450126fb7bb7e68..62e5107f00dd102f35aa35431ec9e918e8e21253 100644 (file)
--- a/wscript
+++ b/wscript
@@ -218,6 +218,8 @@ def configure(conf):
     conf.SAMBA_CHECK_PYTHON()
     conf.SAMBA_CHECK_PYTHON_HEADERS()
 
+    conf.SAMBA_CHECK_RUST()
+
     if sys.platform == 'darwin' and not conf.env['HAVE_ENVIRON_DECL']:
         # Mac OSX needs to have this and it's also needed that the python is compiled with this
         # otherwise you face errors about common symbols
@@ -502,6 +504,9 @@ def configure(conf):
     if Options.options.with_smb1server is not False:
         conf.DEFINE('WITH_SMB1SERVER', '1')
 
+    conf.env.debug = Options.options.debug
+    conf.env.developer = Options.options.developer
+
     #
     # FreeBSD is broken. It doesn't include 'extern char **environ'
     # in any shared library, but statically inside crt0.o.