From 019f82001b3e4954e5d15eb4be06f2edd6f5c9a5 Mon Sep 17 00:00:00 2001 From: "C.Lee Taylor" Date: Mon, 7 Oct 2024 11:53:48 +0200 Subject: [PATCH] chore(fix): add risv64 cross-compile build option --- CHANGELOG.md | 5 +++++ Cargo.toml | 2 +- build.rs | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 088869d..85685d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [1.3.1](https://github.com/tari-project/randomx-rs/compare/v1.3.1...v1.3.0) (2024-10-07) +### Feature + +* add cross-compile target ```make``` arguments for riscv64 (riscv64gc-unknown-linux-gnu) + ## [1.3.0](https://github.com/tari-project/randomx-rs/compare/v1.3.0...v1.2.1) (2023-11-01) ### Feature diff --git a/Cargo.toml b/Cargo.toml index 27526af..27a51a5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ repository = "https://github.com/tari-project/randomx-rs" homepage = "https://tari.com" readme = "README.md" license = "BSD-3-Clause" -version = "1.3.0" +version = "1.3.1" edition = "2018" build = "build.rs" diff --git a/build.rs b/build.rs index aaa08bd..8c9b350 100644 --- a/build.rs +++ b/build.rs @@ -19,6 +19,7 @@ // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + use std::{ env, fs, @@ -95,6 +96,39 @@ fn main() { std::io::stderr().write_all(&c.stderr).unwrap(); assert!(c.status.success()); + let m = Command::new("cmake") + .arg("--build") + .arg(".") + .arg("--config") + .arg("Release") + .output() + .expect("failed to execute Make"); + println!("status: {}", m.status); + std::io::stdout().write_all(&m.stdout).unwrap(); + std::io::stderr().write_all(&m.stderr).unwrap(); + assert!(m.status.success()); + } else if target.contains("riscv64gc-unknown-linux-gnu") { + let c = Command::new("cmake") + .arg("-D") + .arg("ARCH=rv64gc") + .arg("-D") + .arg("ARCH_ID=riscv64") + .arg("-D") + .arg("CMAKE_CROSSCOMPILING=true") + .arg("-D") + .arg("CMAKE_SYSTEM_PROCESSOR=riscv64") + .arg("-D") + .arg("CMAKE_C_COMPILER=/usr/bin/riscv64-linux-gnu-gcc") + .arg("-D") + .arg("CMAKE_CXX_COMPILER=/usr/bin/riscv64-linux-gnu-g++") + .arg(repo_dir.to_str().unwrap()) + .output() + .expect("failed to execute CMake"); + println!("status: {}", c.status); + std::io::stdout().write_all(&c.stdout).unwrap(); + std::io::stderr().write_all(&c.stderr).unwrap(); + assert!(c.status.success()); + let m = Command::new("cmake") .arg("--build") .arg(".")