Description: bwa headers are got through a component tarball, not by downloading anything. Also loading the JNI from the canonical path. Author: Pierre Gruet Forwarded: not-needed Last-Update: 2022-03-30 --- a/src/main/java/org/broadinstitute/hellbender/utils/bwa/BwaMemIndex.java +++ b/src/main/java/org/broadinstitute/hellbender/utils/bwa/BwaMemIndex.java @@ -435,41 +435,7 @@ if ( !nativeLibLoaded ) { synchronized(BwaMemIndex.class) { if ( !nativeLibLoaded ) { - final String libNameOverride = System.getProperty("LIBBWA_PATH"); - if ( libNameOverride != null ) { - System.load(libNameOverride); - } - else { - final String osName = System.getProperty("os.name", "unknown").toUpperCase(); - final String osArch = System.getProperty("os.arch"); - final String libName; - if ( !"x86_64".equals(osArch) && !"amd64".equals(osArch) ) { - throw new IllegalStateException( - "We have pre-built fermi-lite binaries only for x86_64 and amd64. "+ - "Your os.arch is "+osArch+"."+ - "Set property LIBBWA_PATH to point to a native library for your architecture."); - } - if ( osName.startsWith("MAC") ) libName = "/libbwa.Darwin.dylib"; - else if ( osName.startsWith("LINUX") ) libName = "/libbwa.Linux.so"; - else { - throw new IllegalStateException( - "We have pre-built fermi-lite binaries only for Linux and Mac. "+ - "Your os.name is "+osName+"."+ - "Set property LIBBWA_PATH to point to a native library for your operating system."); - } - try ( final InputStream is = BwaMemIndex.class.getResourceAsStream(libName) ) { - if ( is == null ) { - throw new IllegalStateException("Can't find resource "+libName); - } - final File tmpFile = File.createTempFile("libbwa.",".jnilib"); - tmpFile.deleteOnExit(); - Files.copy(is, tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING); - System.load(tmpFile.getPath()); - } - catch (IOException ioe ) { - throw new IllegalStateException("Misconfiguration: Unable to load fermi-lite native library "+libName, ioe); - } - } + System.loadLibrary("bwa"); nativeLibLoaded = true; } } --- a/src/main/c/org_broadinstitute_hellbender_utils_bwa_BwaMemIndex.c +++ b/src/main/c/org_broadinstitute_hellbender_utils_bwa_BwaMemIndex.c @@ -2,7 +2,6 @@ #include #include #include "jnibwa.h" -#include "bwa/bwa_commit.h" char * jstring_to_chars(JNIEnv* env, jstring in) { --- a/src/main/c/Makefile +++ b/src/main/c/Makefile @@ -7,33 +7,26 @@ CC=gcc #OS-dependent extension lookup -UNAME := $(shell uname) -ifeq ($(UNAME),Darwin) -LIB_EXT=Darwin.dylib -else -LIB_EXT=Linux.so -endif +LIB_EXT=so -BWA_MEM_COMMIT=cb950614ce7217788780b9a8d445c64cd4d8f62e JNI_BASE_NAME=org_broadinstitute_hellbender_utils_bwa_BwaMemIndex all: libbwa.$(LIB_EXT) -libbwa.$(LIB_EXT): $(JNI_BASE_NAME).o jnibwa.o bwa/libbwa.a +libbwa.$(LIB_EXT): $(JNI_BASE_NAME).o jnibwa.o bwaComponent/libbwa.a $(CC) -ggdb -dynamiclib -shared -o $@ $^ -lm -lz -lpthread -bwa: - git clone https://github.com/lh3/bwa && cd bwa && git checkout $(BWA_MEM_COMMIT) && echo '#define BWA_COMMIT "'$(BWA_MEM_COMMIT)'"' > bwa_commit.h - sed -i.bak -e's/\(LOBJS=.*\)/\1 bwtindex.o rle.o rope.o bwt.o is.o/g' bwa/Makefile +bwaComponent: + sed -i.bak -e's/\(LOBJS=.*\)/\1 bwtindex.o rle.o rope.o bwt.o is.o/g' bwaComponent/Makefile -bwa/libbwa.a: bwa - $(MAKE) CFLAGS="$(CFLAGS)" -C bwa libbwa.a +bwaComponent/libbwa.a: bwaComponent + $(MAKE) CFLAGS="$(CFLAGS)" -C bwaComponent libbwa.a -$(JNI_BASE_NAME).o: $(JNI_BASE_NAME).c jnibwa.h bwa +$(JNI_BASE_NAME).o: $(JNI_BASE_NAME).c jnibwa.h bwaComponent -jnibwa.o: jnibwa.c jnibwa.h bwa +jnibwa.o: jnibwa.c jnibwa.h bwaComponent clean: - rm -rf bwa *.o *.$(LIB_EXT) + rm -rf bwaComponent *.o *.$(LIB_EXT) .PHONY: all clean --- a/src/main/c/jnibwa.c +++ b/src/main/c/jnibwa.c @@ -15,12 +15,12 @@ #include #include "jnibwa.h" -#include "bwa/kstring.h" -#include "bwa/bntseq.h" -#include "bwa/bwt.h" -#include "bwa/utils.h" -#include "bwa/rle.h" -#include "bwa/rope.h" +#include "bwaComponent/kstring.h" +#include "bwaComponent/bntseq.h" +#include "bwaComponent/bwt.h" +#include "bwaComponent/utils.h" +#include "bwaComponent/rle.h" +#include "bwaComponent/rope.h" static inline void kput32( int32_t val, kstring_t* str ) { --- a/src/main/c/jnibwa.h +++ b/src/main/c/jnibwa.h @@ -5,7 +5,7 @@ #ifndef JNIBWA_H_ #define JNIBWA_H_ -#include "bwa/bwamem.h" +#include "bwaComponent/bwamem.h" int jnibwa_createReferenceIndex( char const* refFileName, char const* indexPrefix, char const* algoName);