Debian Codegraph @

debian/patches/use_bwa_from_component.patch

raw
1 Description: bwa headers are got through a component tarball, not by
2 downloading anything.
3 Also loading the JNI from the canonical path.
4 Author: Pierre Gruet <[email protected]>
5 Forwarded: not-needed
6 Last-Update: 2022-03-30
7
8 --- a/src/main/java/org/broadinstitute/hellbender/utils/bwa/BwaMemIndex.java
9 +++ b/src/main/java/org/broadinstitute/hellbender/utils/bwa/BwaMemIndex.java
10 @@ -435,41 +435,7 @@
11 if ( !nativeLibLoaded ) {
12 synchronized(BwaMemIndex.class) {
13 if ( !nativeLibLoaded ) {
14 - final String libNameOverride = System.getProperty("LIBBWA_PATH");
15 - if ( libNameOverride != null ) {
16 - System.load(libNameOverride);
17 - }
18 - else {
19 - final String osName = System.getProperty("os.name", "unknown").toUpperCase();
20 - final String osArch = System.getProperty("os.arch");
21 - final String libName;
22 - if ( !"x86_64".equals(osArch) && !"amd64".equals(osArch) ) {
23 - throw new IllegalStateException(
24 - "We have pre-built fermi-lite binaries only for x86_64 and amd64. "+
25 - "Your os.arch is "+osArch+"."+
26 - "Set property LIBBWA_PATH to point to a native library for your architecture.");
27 - }
28 - if ( osName.startsWith("MAC") ) libName = "/libbwa.Darwin.dylib";
29 - else if ( osName.startsWith("LINUX") ) libName = "/libbwa.Linux.so";
30 - else {
31 - throw new IllegalStateException(
32 - "We have pre-built fermi-lite binaries only for Linux and Mac. "+
33 - "Your os.name is "+osName+"."+
34 - "Set property LIBBWA_PATH to point to a native library for your operating system.");
35 - }
36 - try ( final InputStream is = BwaMemIndex.class.getResourceAsStream(libName) ) {
37 - if ( is == null ) {
38 - throw new IllegalStateException("Can't find resource "+libName);
39 - }
40 - final File tmpFile = File.createTempFile("libbwa.",".jnilib");
41 - tmpFile.deleteOnExit();
42 - Files.copy(is, tmpFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
43 - System.load(tmpFile.getPath());
44 - }
45 - catch (IOException ioe ) {
46 - throw new IllegalStateException("Misconfiguration: Unable to load fermi-lite native library "+libName, ioe);
47 - }
48 - }
49 + System.loadLibrary("bwa");
50 nativeLibLoaded = true;
51 }
52 }
53 --- a/src/main/c/org_broadinstitute_hellbender_utils_bwa_BwaMemIndex.c
54 +++ b/src/main/c/org_broadinstitute_hellbender_utils_bwa_BwaMemIndex.c
55 @@ -2,7 +2,6 @@
56 #include <fcntl.h>
57 #include <stdlib.h>
58 #include "jnibwa.h"
59 -#include "bwa/bwa_commit.h"
60
61
62 char * jstring_to_chars(JNIEnv* env, jstring in) {
63 --- a/src/main/c/Makefile
64 +++ b/src/main/c/Makefile
65 @@ -7,33 +7,26 @@
66 CC=gcc
67
68 #OS-dependent extension lookup
69 -UNAME := $(shell uname)
70 -ifeq ($(UNAME),Darwin)
71 -LIB_EXT=Darwin.dylib
72 -else
73 -LIB_EXT=Linux.so
74 -endif
75 +LIB_EXT=so
76
77 -BWA_MEM_COMMIT=cb950614ce7217788780b9a8d445c64cd4d8f62e
78 JNI_BASE_NAME=org_broadinstitute_hellbender_utils_bwa_BwaMemIndex
79
80 all: libbwa.$(LIB_EXT)
81
82 -libbwa.$(LIB_EXT): $(JNI_BASE_NAME).o jnibwa.o bwa/libbwa.a
83 +libbwa.$(LIB_EXT): $(JNI_BASE_NAME).o jnibwa.o bwaComponent/libbwa.a
84 $(CC) -ggdb -dynamiclib -shared -o $@ $^ -lm -lz -lpthread
85
86 -bwa:
87 - git clone https://github.com/lh3/bwa && cd bwa && git checkout $(BWA_MEM_COMMIT) && echo '#define BWA_COMMIT "'$(BWA_MEM_COMMIT)'"' > bwa_commit.h
88 - sed -i.bak -e's/\(LOBJS=.*\)/\1 bwtindex.o rle.o rope.o bwt.o is.o/g' bwa/Makefile
89 +bwaComponent:
90 + sed -i.bak -e's/\(LOBJS=.*\)/\1 bwtindex.o rle.o rope.o bwt.o is.o/g' bwaComponent/Makefile
91
92 -bwa/libbwa.a: bwa
93 - $(MAKE) CFLAGS="$(CFLAGS)" -C bwa libbwa.a
94 +bwaComponent/libbwa.a: bwaComponent
95 + $(MAKE) CFLAGS="$(CFLAGS)" -C bwaComponent libbwa.a
96
97 -$(JNI_BASE_NAME).o: $(JNI_BASE_NAME).c jnibwa.h bwa
98 +$(JNI_BASE_NAME).o: $(JNI_BASE_NAME).c jnibwa.h bwaComponent
99
100 -jnibwa.o: jnibwa.c jnibwa.h bwa
101 +jnibwa.o: jnibwa.c jnibwa.h bwaComponent
102
103 clean:
104 - rm -rf bwa *.o *.$(LIB_EXT)
105 + rm -rf bwaComponent *.o *.$(LIB_EXT)
106
107 .PHONY: all clean
108 --- a/src/main/c/jnibwa.c
109 +++ b/src/main/c/jnibwa.c
110 @@ -15,12 +15,12 @@
111 #include <errno.h>
112
113 #include "jnibwa.h"
114 -#include "bwa/kstring.h"
115 -#include "bwa/bntseq.h"
116 -#include "bwa/bwt.h"
117 -#include "bwa/utils.h"
118 -#include "bwa/rle.h"
119 -#include "bwa/rope.h"
120 +#include "bwaComponent/kstring.h"
121 +#include "bwaComponent/bntseq.h"
122 +#include "bwaComponent/bwt.h"
123 +#include "bwaComponent/utils.h"
124 +#include "bwaComponent/rle.h"
125 +#include "bwaComponent/rope.h"
126
127
128 static inline void kput32( int32_t val, kstring_t* str ) {
129 --- a/src/main/c/jnibwa.h
130 +++ b/src/main/c/jnibwa.h
131 @@ -5,7 +5,7 @@
132 #ifndef JNIBWA_H_
133 #define JNIBWA_H_
134
135 -#include "bwa/bwamem.h"
136 +#include "bwaComponent/bwamem.h"
137
138
139 int jnibwa_createReferenceIndex( char const* refFileName, char const* indexPrefix, char const* algoName);