From b6850809fa8844de9f89fcb422e297c0e6426b7b Mon Sep 17 00:00:00 2001 From: Dusan Malusev Date: Sun, 6 Aug 2023 11:38:34 +0200 Subject: [PATCH] Init rust lib Signed-off-by: Dusan Malusev --- .gitignore | 6 +++++ Cargo.toml | 10 ++++++++ Dockerfile | 2 +- build.rs | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/lib.rs | 1 + 5 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 Cargo.toml create mode 100644 build.rs create mode 100644 src/lib.rs diff --git a/.gitignore b/.gitignore index 6c625fad3..12d557d32 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,9 @@ cassandra.log /**/vendor/ /**/.idea/ /**/.idea/ + + +# Added by cargo + +/target +/Cargo.lock diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 000000000..9e1f5c9cb --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "scylladb-php-driver" +version = "0.1.0" +edition = "2021" + +[dependencies] + + +[build-dependencies] +cc = { version = "1.0", features = ["parallel"] } diff --git a/Dockerfile b/Dockerfile index 2834f0979..acd64cbd7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ COPY ./scripts /tmp/scripts WORKDIR /tmp -RUN ./scripts/compile-php.sh -v $PHP_VERSION -o $HOME -s -d no -zts $PHP_ZTS \ +RUN ./scripts/compile-php.sh -v $PHP_VERSION -o $HOME -d no -zts $PHP_ZTS \ && $HOME/php/bin/php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ && $HOME/php/bin/php composer-setup.php --install-dir=/bin --filename=composer \ && $HOME/php/bin/php -r "unlink('composer-setup.php');" \ diff --git a/build.rs b/build.rs new file mode 100644 index 000000000..8e9155ef8 --- /dev/null +++ b/build.rs @@ -0,0 +1,71 @@ +use std::fs::read_dir; + +use cc::Build; + +fn main() { + let mut build = Build::new(); + + build + .cpp(true) + .include("include") + .include("util/include") + .include("ZendCPP") + .include("ZendCPP/String") + .include(".") + .define("HAVE_DLFCN_H", Some("1")) + .define("HAVE_STDIO_H", Some("1")) + .define("HAVE_STDINT_H", Some("1")) + .define("HAVE_INTTYPES_H", Some("1")) + .define("HAVE_SYS_STAT_H", Some("1")) + .define("HAVE_SYS_TYPES_H", Some("1")) + .define("HAVE_STRING_H", Some("1")) + .define("HAVE_UNISTD_H", Some("1")) + .extra_warnings(true); + + read_dir("src").unwrap().for_each(|entry| { + let entry = entry.unwrap(); + let path = entry.path(); + + println!("{:?}", path); + let ext = path.extension().unwrap().to_str(); + + if ext == Some("cpp") || ext == Some("c") { + build.file(path); + } + }); + + read_dir("util/src").unwrap().for_each(|entry| { + let entry = entry.unwrap(); + let path = entry.path(); + + let ext = path.extension().unwrap().to_str(); + + if ext == Some("cpp") || ext == Some("c") { + build.file(path); + } + }); + + read_dir("ZendCPP/String").unwrap().for_each(|entry| { + let entry = entry.unwrap(); + let path = entry.path(); + + let ext = path.extension().unwrap().to_str(); + + if ext == Some("cpp") || ext == Some("c") { + build.file(path); + } + }); + + read_dir("ZendCPP").unwrap().for_each(|entry| { + let entry = entry.unwrap(); + let path = entry.path(); + + let ext = path.extension().unwrap().to_str(); + + if ext == Some("cpp") || ext == Some("c") { + build.file(path); + } + }); + + build.compile("cassandra"); +} diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1 @@ +