From d869fdda03900cafae0f4f60b033121dcd57b723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20M=C3=B6lder?= Date: Fri, 10 May 2024 13:15:15 +0200 Subject: [PATCH] fix: build for macOS (#431) * set host to macos-12 * set host to macos-13 * update hts-sys * set macos-latest * fix type * fix internal insert size naming (isize vs isize_) * fix type * fix * fix * fix * fmt * fix * fmt * bump hts-sys --------- Co-authored-by: Johannes Koester --- .github/workflows/rust.yml | 42 ++++++++++++++++---------------------- Cargo.toml | 2 +- src/bam/mod.rs | 8 ++++---- src/bam/record.rs | 8 ++++---- src/bam/record_serde.rs | 10 ++++----- src/bcf/record.rs | 2 +- src/bgzf/mod.rs | 15 +++----------- 7 files changed, 36 insertions(+), 51 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index df43edc40..2a9890772 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -125,29 +125,28 @@ jobs: strategy: matrix: target: - - intel-catalina - - intel-bigsur - - m1-bigsur + - intel-monterey + - intel-ventura + - silicon-sonoma include: - - target: intel-catalina - os: macOS-10.15 + - target: intel-monterey + os: macOS-12.0 toolchain_target: x86_64-apple-darwin toolchain: stable - aux_args: "" - default: false - - target: intel-bigsur - os: macOS-11.0 + aux_args: --target x86_64-apple-darwin + default: true + - target: intel-ventura + os: macOS-13.0 toolchain_target: x86_64-apple-darwin toolchain: stable + aux_args: --target x86_64-apple-darwin + default: true + - target: silicon-sonoma + os: macOS-14.0 + toolchain_target: aarch64-apple-darwin + toolchain: stable aux_args: "" default: false - # TODO enable again and try to find out why this fails - # - target: m1-bigsur - # os: macOS-11.0 - # toolchain_target: aarch64-apple-darwin - # toolchain: nightly - # aux_args: --target aarch64-apple-darwin - # default: true steps: - name: Checkout repository @@ -158,19 +157,14 @@ jobs: - name: Install stable toolchain uses: actions-rs/toolchain@v1.0.6 with: - toolchain: stable + toolchain: ${{ matrix.toolchain }} + target: ${{ matrix.toolchain_target }} override: true + default: ${{ matrix.default }} - name: Install htslib dependencies run: brew install bzip2 zlib xz curl-openssl - #- uses: actions-rs/toolchain@v1.0.6 - # with: - # toolchain: ${{ matrix.toolchain }} - # target: ${{ matrix.toolchain_target }} - # #override: true - # default: ${{ matrix.default }} - - name: Test uses: actions-rs/cargo@v1.0.1 with: diff --git a/Cargo.toml b/Cargo.toml index 65239b59b..b12df281b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ bio-types = ">=0.9" byteorder = "1.3" custom_derive = "0.1" derive-new = "0.5" -hts-sys = {version = "2.1.1", default-features = false} +hts-sys = {version = "2.1.4", default-features = false, features = ["bindgen"]} ieee754 = "0.2" lazy_static = "1.4" libc = "0.2" diff --git a/src/bam/mod.rs b/src/bam/mod.rs index daaf08351..f232401e5 100644 --- a/src/bam/mod.rs +++ b/src/bam/mod.rs @@ -1127,7 +1127,7 @@ impl Writer { ); (*rec).text = text as *mut c_char; - (*rec).l_text = l_text as u64; + (*rec).l_text = l_text; rec }; @@ -1392,9 +1392,9 @@ impl HeaderView { header_string.len(), ); - let rec = htslib::sam_hdr_parse((l_text + 1) as u64, text as *const c_char); + let rec = htslib::sam_hdr_parse((l_text + 1), text as *const c_char); (*rec).text = text as *mut c_char; - (*rec).l_text = l_text as u64; + (*rec).l_text = l_text; rec }; @@ -1580,7 +1580,7 @@ CCCCCCCCCCCCCCCCCCC"[..], assert_eq!(c1.inner().core.l_qname, b1.inner().core.l_qname); assert_eq!(c1.inner().core.n_cigar, b1.inner().core.n_cigar); assert_eq!(c1.inner().core.l_qseq, b1.inner().core.l_qseq); - assert_eq!(c1.inner().core.isize, b1.inner().core.isize); + assert_eq!(c1.inner().core.isize_, b1.inner().core.isize_); //... except m_data } } diff --git a/src/bam/record.rs b/src/bam/record.rs index 8ddd35c12..83aded002 100644 --- a/src/bam/record.rs +++ b/src/bam/record.rs @@ -152,8 +152,8 @@ impl Record { let mut sam_string = htslib::kstring_t { s: sam_copy.as_ptr() as *mut c_char, - l: sam_copy.len() as u64, - m: sam_copy.len() as u64, + l: sam_copy.len(), + m: sam_copy.len(), }; let succ = unsafe { @@ -286,12 +286,12 @@ impl Record { /// Get insert size. pub fn insert_size(&self) -> i64 { - self.inner().core.isize + self.inner().core.isize_ } /// Set insert size. pub fn set_insert_size(&mut self, insert_size: i64) { - self.inner_mut().core.isize = insert_size; + self.inner_mut().core.isize_ = insert_size; } fn qname_capacity(&self) -> usize { diff --git a/src/bam/record_serde.rs b/src/bam/record_serde.rs index 7d457c7b7..651867030 100644 --- a/src/bam/record_serde.rs +++ b/src/bam/record_serde.rs @@ -29,7 +29,7 @@ impl Serialize for Record { state.serialize_field("seq_len", &core.l_qseq)?; state.serialize_field("mtid", &core.mtid)?; state.serialize_field("mpos", &core.mpos)?; - state.serialize_field("isize", &core.isize)?; + state.serialize_field("isize", &core.isize_)?; state.serialize_field("data", Bytes::new(self.data()))?; state.end() } @@ -138,7 +138,7 @@ impl<'de> Deserialize<'de> for Record { let mpos = seq .next_element()? .ok_or_else(|| de::Error::invalid_length(0, &self))?; - let isize = seq + let isize_ = seq .next_element()? .ok_or_else(|| de::Error::invalid_length(0, &self))?; let data = seq @@ -159,7 +159,7 @@ impl<'de> Deserialize<'de> for Record { m.l_qseq = seq_len; m.mtid = mtid; m.mpos = mpos; - m.isize = isize; + m.isize_ = isize_; } rec.set_data(&data); @@ -271,7 +271,7 @@ impl<'de> Deserialize<'de> for Record { let seq_len = seq_len.ok_or_else(|| de::Error::missing_field("seq_len"))?; let mtid = mtid.ok_or_else(|| de::Error::missing_field("mtid"))?; let mpos = mpos.ok_or_else(|| de::Error::missing_field("mpos"))?; - let isize = isize.ok_or_else(|| de::Error::missing_field("isize"))?; + let isize_ = isize.ok_or_else(|| de::Error::missing_field("isize"))?; let data = data .ok_or_else(|| de::Error::missing_field("data"))? .into_vec(); @@ -289,7 +289,7 @@ impl<'de> Deserialize<'de> for Record { m.l_qseq = seq_len; m.mtid = mtid; m.mpos = mpos; - m.isize = isize; + m.isize_ = isize_; } rec.set_data(&data); diff --git a/src/bcf/record.rs b/src/bcf/record.rs index a5778d1ac..c1066cd30 100644 --- a/src/bcf/record.rs +++ b/src/bcf/record.rs @@ -1008,7 +1008,7 @@ impl Record { } pub fn remove_alleles(&mut self, remove: &[bool]) -> Result<()> { - let rm_set = unsafe { htslib::kbs_init(remove.len() as u64) }; + let rm_set = unsafe { htslib::kbs_init(remove.len()) }; for (i, &r) in remove.iter().enumerate() { if r { diff --git a/src/bgzf/mod.rs b/src/bgzf/mod.rs index a99af4de4..06d6ee7a1 100644 --- a/src/bgzf/mod.rs +++ b/src/bgzf/mod.rs @@ -112,11 +112,7 @@ impl Reader { impl std::io::Read for Reader { fn read(&mut self, buf: &mut [u8]) -> std::io::Result { let nbytes = unsafe { - htslib::bgzf_read( - self.inner, - buf.as_mut_ptr() as *mut libc::c_void, - buf.len() as u64, - ) + htslib::bgzf_read(self.inner, buf.as_mut_ptr() as *mut libc::c_void, buf.len()) }; if nbytes < 0 { Err(std::io::Error::new( @@ -257,13 +253,8 @@ impl Writer { impl std::io::Write for Writer { fn write(&mut self, buf: &[u8]) -> std::io::Result { - let nbytes = unsafe { - htslib::bgzf_write( - self.inner, - buf.as_ptr() as *mut libc::c_void, - buf.len() as u64, - ) - }; + let nbytes = + unsafe { htslib::bgzf_write(self.inner, buf.as_ptr() as *mut libc::c_void, buf.len()) }; if nbytes < 0 { Err(std::io::Error::new( std::io::ErrorKind::Other,