Skip to content

Commit

Permalink
Update Appveyor script.
Browse files Browse the repository at this point in the history
Fix Windows paths inside quoted arguments.
  • Loading branch information
valeriuo committed Apr 15, 2019
1 parent ee30574 commit 55de504
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
7 changes: 5 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ install:
- set MSYSTEM=MINGW64
- set PATH=C:/msys64/usr/bin;C:/msys64/mingw64/bin;%PATH%
- set MINGWPREFIX=x86_64-w64-mingw32
- "sh -lc \"pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-zlib mingw-w64-x86_64-bzip2 mingw-w64-x86_64-xz mingw-w64-x86_64-curl mingw-w64-x86_64-dlfcn\""
- "sh -lc \"pacman -S --noconfirm --needed base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-zlib mingw-w64-x86_64-bzip2 mingw-w64-x86_64-xz mingw-w64-x86_64-curl\""

# The user may have e.g. jkbonfield/bcftools branch FOO and an associated
# jkbonfield/htslib branch FOO. If so use that related htslib, obtained by
# munging $APPVEYOR_REPO_NAME. Otherwise we assume this is a PR only to
# bcftools and should be linked against samtools(org)/htslib develop branch.
clone_script:
- "sh -lc \"git clone --branch=$APPVEYOR_REPO_BRANCH https://github.com/$APPVEYOR_REPO_NAME $APPVEYOR_BUILD_FOLDER\""
- "sh -lc \"if test x$APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME != x ; then git clone --branch=$APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH https://github.com/$APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME $APPVEYOR_BUILD_FOLDER ; else false ; fi || git clone --branch=$APPVEYOR_REPO_BRANCH https://github.com/$APPVEYOR_REPO_NAME $APPVEYOR_BUILD_FOLDER\""
- "sh -lc \"git show-branch --sha1-name HEAD"
- "sh -lc \"git clone --branch=$APPVEYOR_REPO_BRANCH https://github.com/`echo $APPVEYOR_REPO_NAME|sed 's#/bcftools#/htslib#'`.git $APPVEYOR_BUILD_FOLDER/htslib || git clone https://github.com/samtools/htslib.git $APPVEYOR_BUILD_FOLDER/htslib \""
- "sh -lc \"cd $APPVEYOR_BUILD_FOLDER/htslib && git show-branch --sha1-name HEAD\""

build_script:
- set HOME=.
Expand All @@ -49,4 +51,5 @@ test_script:
- set HOME=.
- set MSYSTEM=MINGW64
- set PATH=C:/msys64/usr/bin;C:/msys64/mingw64/bin;%PATH%
- set BCFTOOLS_PLUGINS=./plugins
- "sh -lc \"MSYS2_ARG_CONV_EXCL=* make test-plugins\""
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ PLUGIN_FLAGS = -fPIC -shared -Wl,-export-all-symbols
PLUGIN_LIBS = libbcftools.a $(HTSLIB_DLL) $(ALL_LIBS)
# On windows, plugins need to be fully linked, including bcftools_version() symbol
# from the application they will be loaded into.
BCFTOOLS_IMPLIB = -Wl,-out-implib,libbcftools.a
else
PLUGIN_FLAGS = -fPIC -shared
endif
Expand All @@ -182,7 +181,7 @@ libbcftools.a: $(OBJS)

vcfplugin.o: EXTRA_CPPFLAGS += -DPLUGINPATH='"$(pluginpath)"'

%.dll: %.c version.h version.c libbcftools.a
%.dll: %.c version.h version.c libbcftools.a $(HTSLIB_DLL)
$(CC) $(PLUGIN_FLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(EXTRA_CPPFLAGS) $(LDFLAGS) -o $@ version.c $< $(PLUGIN_LIBS)
%.so: %.c version.h version.c
$(CC) $(PLUGIN_FLAGS) $(CFLAGS) $(ALL_CPPFLAGS) $(EXTRA_CPPFLAGS) $(LDFLAGS) -o $@ version.c $< $(LIBS)
Expand Down Expand Up @@ -328,7 +327,7 @@ clean: testclean clean-plugins
-rm -rf *.dSYM plugins/*.dSYM test/*.dSYM

clean-plugins:
-rm -f plugins/*.so plugins/*.P
-rm -f plugins/*.so plugins/*.P plugins/*.dll
-rm -rf plugins/*.dSYM

testclean:
Expand Down
12 changes: 4 additions & 8 deletions filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -2013,15 +2013,15 @@ static void parse_tag_idx(bcf_hdr_t *hdr, int is_fmt, char *tag, char *tag_idx,
int *idxs2 = NULL, nidxs2 = 0, idx2 = 0;

int set_samples = 0;
#ifdef _WIN32
char *colon = strrchr(tag_idx, ';');
#else
char *colon = strrchr(tag_idx, ':');
#endif
if ( tag_idx[0]=='@' ) // file list with sample names
{
if ( !is_fmt ) error("Could not parse \"%s\". (Not a FORMAT tag yet a sample list provided.)\n", ori);
char *fname = expand_path(tag_idx+1);
#ifdef _WIN32
if (fname && strlen(fname) > 2 && fname[1] == ':') // Deal with Windows paths, such as 'C:\..'
colon = strrchr(fname+2, ':');
#endif
int nsmpl;
char **list = hts_readlist(fname, 1, &nsmpl);
if ( !list && colon )
Expand All @@ -2030,11 +2030,7 @@ static void parse_tag_idx(bcf_hdr_t *hdr, int is_fmt, char *tag, char *tag_idx,
tok->idxs = idxs2;
tok->nidxs = nidxs2;
tok->idx = idx2;
#ifdef _WIN32
colon = strrchr(fname, ';');
#else
colon = strrchr(fname, ':');
#endif
*colon = 0;
list = hts_readlist(fname, 1, &nsmpl);
}
Expand Down
14 changes: 10 additions & 4 deletions test/test.pl
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@
test_vcf_plugin($opts,in=>'plugin1',out=>'missing2ref.out',cmd=>'+missing2ref --no-version');
test_vcf_plugin($opts,in=>'plugin1',out=>'missing2ref.out',cmd=>'+setGT --no-version',args=>'-- -t . -n 0');
test_vcf_plugin($opts,in=>'setGT',out=>'setGT.1.out',cmd=>'+setGT --no-version',args=>'-- -t q -n 0 -i \'GT~"." && FMT/DP=30 && GQ=150\'');
test_vcf_plugin($opts,in=>'setGT.2',out=>'setGT.2.out',cmd=>'+setGT --no-version',args=>'-- -t q -n . -i \'GT[@{PATH}/setGT.samples.txt]="het"\'');
test_vcf_plugin($opts,in=>'setGT.2',out=>'setGT.3.out',cmd=>'+setGT --no-version',args=>'-- -t q -n . -i \'GT[@{PATH}/setGT.samples.txt]="het" & binom(AD[@{PATH}/setGT.samples.txt])<0.1\'');
test_vcf_plugin($opts,in=>'setGT.2',out=>'setGT.2.out',cmd=>'+setGT --no-version',args=>'-- -t q -n . -i \'GT[@{QPATH}/setGT.samples.txt]="het"\'');
test_vcf_plugin($opts,in=>'setGT.2',out=>'setGT.3.out',cmd=>'+setGT --no-version',args=>'-- -t q -n . -i \'GT[@{QPATH}/setGT.samples.txt]="het" & binom(AD[@{QPATH}/setGT.samples.txt])<0.1\'');
test_vcf_annotate($opts,in=>'annotate9',tab=>'annots9',out=>'annotate9.out',args=>'-c CHROM,POS,REF,ALT,+ID');
test_vcf_plugin($opts,in=>'plugin1',out=>'fill-AN-AC.out',cmd=>'+fill-AN-AC --no-version');
test_vcf_plugin($opts,in=>'dosage',out=>'dosage.1.out',cmd=>'+dosage',args=>'-- -t PL');
Expand Down Expand Up @@ -505,8 +505,8 @@ sub parse_params
$$opts{bin} = $FindBin::RealBin;
$$opts{bin} =~ s{/test/?$}{};
if ($^O =~ /^msys/) {
$$opts{path} = cygpath($$opts{path});
$$opts{bin} = cygpath($$opts{bin});
$$opts{path} = cygpath($$opts{path});
$$opts{bin} = cygpath($$opts{bin});
}
return $opts;
Expand Down Expand Up @@ -1043,6 +1043,12 @@ sub test_vcf_plugin
if ( !$$opts{test_plugins} ) { return; }
$ENV{BCFTOOLS_PLUGINS} = "$$opts{bin}/plugins";
if ( !exists($args{args}) ) { $args{args} = ''; }
my $wpath = $$opts{path};
if ($^O =~ /^msys/) {
$wpath = `cygpath -w $$opts{path}`;
$wpath =~ s/\r?\n//;
}
$args{args} =~ s/{QPATH}/$wpath/g;
$args{args} =~ s/{PATH}/$$opts{path}/g;
$args{cmd} =~ s/{PATH}/$$opts{path}/g;
$args{args} =~ s/{TMP}/$$opts{tmp}/g;
Expand Down

0 comments on commit 55de504

Please sign in to comment.