Merge pull request #275 from krsh/riscv64-arch

Add riscv64 architecture support to xtask/codegen
pull/277/head
Dave Tucker 2 years ago committed by GitHub
commit 3acd8d3650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,7 @@ jobs:
- name: Install headers - name: Install headers
run: | run: |
sudo apt -y update sudo apt -y update
sudo apt -y install libc6-dev libc6-dev-{arm64,armel}-cross sudo apt -y install libc6-dev libc6-dev-{arm64,armel,riscv64}-cross
- name: Run codegen - name: Run codegen
run: | run: |

@ -171,6 +171,7 @@ fn codegen_bindings(opts: &Options) -> Result<(), anyhow::Error> {
Architecture::X86_64 => "x86_64-unknown-linux-gnu", Architecture::X86_64 => "x86_64-unknown-linux-gnu",
Architecture::ARMv7 => "armv7-unknown-linux-gnu", Architecture::ARMv7 => "armv7-unknown-linux-gnu",
Architecture::AArch64 => "aarch64-unknown-linux-gnu", Architecture::AArch64 => "aarch64-unknown-linux-gnu",
Architecture::RISCV64 => "riscv64-unknown-linux-gnu",
}; };
bindgen = bindgen.clang_args(&["-target", target]); bindgen = bindgen.clang_args(&["-target", target]);
@ -180,6 +181,7 @@ fn codegen_bindings(opts: &Options) -> Result<(), anyhow::Error> {
Architecture::X86_64 => &opts.x86_64_sysroot, Architecture::X86_64 => &opts.x86_64_sysroot,
Architecture::ARMv7 => &opts.armv7_sysroot, Architecture::ARMv7 => &opts.armv7_sysroot,
Architecture::AArch64 => &opts.aarch64_sysroot, Architecture::AArch64 => &opts.aarch64_sysroot,
Architecture::RISCV64 => &opts.riscv64_sysroot,
}; };
bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]); bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]);

@ -78,6 +78,7 @@ pub fn codegen(opts: &Options) -> Result<(), anyhow::Error> {
Architecture::X86_64 => "x86_64-unknown-linux-gnu", Architecture::X86_64 => "x86_64-unknown-linux-gnu",
Architecture::ARMv7 => "armv7-unknown-linux-gnu", Architecture::ARMv7 => "armv7-unknown-linux-gnu",
Architecture::AArch64 => "aarch64-unknown-linux-gnu", Architecture::AArch64 => "aarch64-unknown-linux-gnu",
Architecture::RISCV64 => "riscv64-unknown-linux-gnu",
}; };
bindgen = bindgen.clang_args(&["-target", target]); bindgen = bindgen.clang_args(&["-target", target]);
@ -87,6 +88,7 @@ pub fn codegen(opts: &Options) -> Result<(), anyhow::Error> {
Architecture::X86_64 => &opts.x86_64_sysroot, Architecture::X86_64 => &opts.x86_64_sysroot,
Architecture::ARMv7 => &opts.armv7_sysroot, Architecture::ARMv7 => &opts.armv7_sysroot,
Architecture::AArch64 => &opts.aarch64_sysroot, Architecture::AArch64 => &opts.aarch64_sysroot,
Architecture::RISCV64 => &opts.riscv64_sysroot,
}; };
bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]); bindgen = bindgen.clang_args(&["-I", &*sysroot.to_string_lossy()]);

@ -10,6 +10,7 @@ const SUPPORTED_ARCHS: &[Architecture] = &[
Architecture::X86_64, Architecture::X86_64,
Architecture::ARMv7, Architecture::ARMv7,
Architecture::AArch64, Architecture::AArch64,
Architecture::RISCV64,
]; ];
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
@ -17,6 +18,7 @@ pub enum Architecture {
X86_64, X86_64,
ARMv7, ARMv7,
AArch64, AArch64,
RISCV64,
} }
impl Architecture { impl Architecture {
@ -33,6 +35,7 @@ impl std::str::FromStr for Architecture {
"x86_64" => Architecture::X86_64, "x86_64" => Architecture::X86_64,
"armv7" => Architecture::ARMv7, "armv7" => Architecture::ARMv7,
"aarch64" => Architecture::AArch64, "aarch64" => Architecture::AArch64,
"riscv64" => Architecture::RISCV64,
_ => return Err("invalid architecture".to_owned()), _ => return Err("invalid architecture".to_owned()),
}) })
} }
@ -44,6 +47,7 @@ impl std::fmt::Display for Architecture {
Architecture::X86_64 => "x86_64", Architecture::X86_64 => "x86_64",
Architecture::ARMv7 => "armv7", Architecture::ARMv7 => "armv7",
Architecture::AArch64 => "aarch64", Architecture::AArch64 => "aarch64",
Architecture::RISCV64 => "riscv64",
}) })
} }
} }
@ -64,6 +68,9 @@ pub struct Options {
#[structopt(long, default_value = "/usr/arm-linux-gnueabi/include")] #[structopt(long, default_value = "/usr/arm-linux-gnueabi/include")]
armv7_sysroot: PathBuf, armv7_sysroot: PathBuf,
#[structopt(long, default_value = "/usr/riscv64-linux-gnu/include")]
riscv64_sysroot: PathBuf,
#[structopt(subcommand)] #[structopt(subcommand)]
command: Option<Command>, command: Option<Command>,
} }

Loading…
Cancel
Save