Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support native builds on Windows with MinGW/UCRT #1104

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ endif
BT_LDFLAGS =
BT_LIBS = -lz -lm -lbz2 -llzma -lpthread

# Support building on MSYS2
UNAME := $(shell sh -c 'uname 2>/dev/null || echo Unknown')
ifeq (MINGW64_NT,$(findstring MINGW64_NT,$(UNAME)))
BT_CPPFLAGS += -D_GNU_SOURCE -D_DEFAULT_SOURCE
BT_LIBS += -lwsock32
endif

prefix ?= /usr/local

SUBDIRS = $(SRC_DIR)/annotateBed \
Expand Down
2 changes: 1 addition & 1 deletion src/complementFile/complementFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ComplementFile : public ToolBase {


protected:
FileRecordMergeMgr *_frm;
FileRecordMergeMgr *_frm{};
Bed3Interval _outRecord;
string _currChrom;
const NewGenomeFile *_genomeFile;
Expand Down
2 changes: 1 addition & 1 deletion src/mergeFile/mergeFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class MergeFile : public ToolBase {


protected:
FileRecordMergeMgr *_frm;
FileRecordMergeMgr *_frm{};

virtual ContextMerge *upCast(ContextBase *context) { return static_cast<ContextMerge *>(context); }

Expand Down
2 changes: 1 addition & 1 deletion src/randomBed/randomBed.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class BedRandom {
int _seed;
bool _haveSeed;

GenomeFile *_genome;
GenomeFile *_genome{};
CHRPOS _length;
uint32_t _numToGenerate;

Expand Down
4 changes: 4 additions & 0 deletions src/regressTest/RegressTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ bool RegressTest::init(int argc, char **argv)
}
}
_tmpDirname += timeStr;
#if (defined(_WIN32) || defined(__WIN32__))
int mkdirRetval = _mkdir(_tmpDirname.c_str()); //mkdir directory.
#else
int mkdirRetval = mkdir(_tmpDirname.c_str(), S_IRWXU | S_IRWXG | S_IRWXO ); //mkdir directory with all permissions allowed.
#endif
if (mkdirRetval != 0) {
fprintf(stderr, "Error: Unable to create temporary output directory %s.\n", _tmpDirname.c_str());
return false;
Expand Down
6 changes: 5 additions & 1 deletion src/regressTest/RegressTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#include <cstdio>
#include <vector>
#include <fstream>
#if (defined(_WIN32) || defined(__WIN32__))
#include <direct.h>
#endif


using namespace std;

Expand Down Expand Up @@ -42,7 +46,7 @@ class RegressTest {
int _filesPerRun;
vector<string> _filePrecessorOptions;

FILE *_fpReportFile;
FILE *_fpReportFile{};
ifstream _configFile;

typedef vector<pair<string, string> > fileListType;
Expand Down
2 changes: 1 addition & 1 deletion src/reldist/reldist.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class RelativeDistance {
size_t _tot_queries;

// instance of a bed file class.
BedFile *_bedA, *_bedB;
BedFile *_bedA{}, *_bedB{};
bool _summary;

//------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion src/spacingFile/spacingFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SpacingFile : public ToolBase {
Record *_currRec;
string _distance;

FileRecordMgr *_inputFile;
FileRecordMgr *_inputFile{};
virtual ContextSpacing *upCast(ContextBase *context) { return static_cast<ContextSpacing *>(context); }


Expand Down
2 changes: 1 addition & 1 deletion src/split/splitBed.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class BedSplit {
std::string bedFileName;
std::string outfileprefix;
unsigned int num_chuncks;
int bedType;
int bedType{};
std::vector<BED> items;

void usage(std::ostream& out);
Expand Down
4 changes: 2 additions & 2 deletions src/summaryFile/summaryFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ class SummaryFile : public ToolBase {


protected:
FileRecordMgr *_frm;
FileRecordMgr *_frm{};
Record *_currRec;
uint64_t _total_length;
uint64_t _total_intervals;
const NewGenomeFile *_genomeFile;
const vector<string> &_chromList;
map<string, vector<Interval>, std::less<string> > _chromData;

FileRecordMgr *_inputFile;
FileRecordMgr *_inputFile{};
virtual ContextSummary *upCast(ContextBase *context) { return static_cast<ContextSummary *>(context); }

};
Expand Down
1 change: 1 addition & 0 deletions src/utils/BamTools/include/api/BamAux.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <string>
#include <cstdint>

#ifndef BAMAUX_H
#define BAMAUX_H
Expand Down
3 changes: 2 additions & 1 deletion src/utils/Contexts/ContextBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ ContextBase::ContextBase()
_allFileHaveLeadingZeroInChromNames(UNTESTED),
_noEnforceCoordSort(false),
_inheader(false),
_nameConventionWarningTripped(false)
_nameConventionWarningTripped(false),
_runToQueryEnd(false)

{
_programNames["intersect"] = INTERSECT;
Expand Down
8 changes: 4 additions & 4 deletions src/utils/Contexts/ContextBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class ContextBase {
int _bamHeaderAndRefIdx;
int _maxNumDatabaseFields;
bool _useFullBamTags;
bool _isCram; // Used when a "BAM" type which is actually a CRAM
bool _isCram{}; // Used when a "BAM" type which is actually a CRAM

int _numOutputRecords;

Expand Down Expand Up @@ -247,9 +247,9 @@ class ContextBase {

//set cmd line params and counter, i, as members so code
//is more readable (as opposed to passing all 3 everywhere).
int _argc;
char **_argv;
int _i;
int _argc{};
char **_argv{};
int _i{};

//track whether each file has the letters chr in their chrom names.
//this is needed for enforcing consistent naming conventions across
Expand Down
2 changes: 2 additions & 0 deletions src/utils/Contexts/ContextClosest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ ContextClosest::ContextClosest()
_ignoreOverlaps(false),
_ignoreUpstream(false),
_ignoreDownstream(false),
_forceUpstream(false),
_forceDownstream(false),
_reportDistance(false),
_signDistance(false),
_haveStrandedDistMode(false),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Contexts/ContextComplement.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ContextComplement : public ContextBase {

private:
bool handle_limit_chroms();
bool _onlyChromsWithBedRecords;
bool _onlyChromsWithBedRecords{};
protected:

};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Contexts/ContextCoverage.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ContextCoverage : public ContextIntersect {
bool _count;
bool _perBase;
bool _showHist;
bool _mean;
bool _mean{};
coverageType _coverageType;

bool handle_c();
Expand Down
4 changes: 2 additions & 2 deletions src/utils/Contexts/ContextIntersect.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ class ContextIntersect : public ContextBase {

protected:

BlockMgr *_splitBlockMgr;
bool _shouldRunToDbEnd;
BlockMgr *_splitBlockMgr{};
bool _shouldRunToDbEnd{};

virtual bool handle_a();
virtual bool handle_abam();
Expand Down
4 changes: 3 additions & 1 deletion src/utils/Fasta/Fasta.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include "bedFile.h"
#include "htslib/faidx.h"
#include <sys/stat.h>
#if (!defined(_WIN32) || !defined(__WIN32__))
#include <sys/mman.h>
#endif
#include "split.h"
#include <stdlib.h>
#include <ctype.h>
Expand All @@ -34,7 +36,7 @@ class FastaIndexEntry {
FastaIndexEntry(void);
~FastaIndexEntry(void);
string name; // sequence name
CHRPOS length; // length of sequence
CHRPOS length{}; // length of sequence
void clear(void);
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/Fasta/LargeFileSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#define _FILE_OFFSET_BITS 64

#ifdef WIN32
#ifdef _MSC_VER
#define ftell64(a) _ftelli64(a)
#define fseek64(a,b,c) _fseeki64(a,b,c)
typedef __int64_t off_type;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/FileRecordTools/FileReaders/InputStreamMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ bool InputStreamMgr::init()
_isStdin = true;
}

_inputFileStream = new ifstream(_filename.c_str());
_inputFileStream = new ifstream(_filename.c_str(), std::ios::binary);
if (_inputFileStream->fail()) {
cerr << "Error: Unable to open file " << _filename << ". Exiting." << endl;
delete _inputFileStream;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/FileRecordTools/FileReaders/InputStreamMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class InputStreamMgr {
BTlist<int> _scanBuffer;
string _saveDataStr;
InflateStreamBuf *_infStreamBuf;
istream * _finalInputStream;
istream * _finalInputStream{};
istream *_oldInputStream;
bool _isStdin;
bool _isGzipped;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/FileRecordTools/Records/GffRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class GffRecord : public Bed6Interval {
protected:
void printRemainingFields(string &outbuf) const;

int _numFields;
int _numFields{};
string _source;
string _frame;
string _group;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/FileRecordTools/Records/PlusFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PlusFields {

protected:
vector<string> _fields;
int _numOffsetFields; //could be 3 for BedPlus, but GFF has 8 or 9
int _numOffsetFields{}; //could be 3 for BedPlus, but GFF has 8 or 9
};


Expand Down
2 changes: 1 addition & 1 deletion src/utils/FileRecordTools/Records/RecordList.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RecordListNode {

private:

Record * _val;
Record * _val{};
RecordListNode *_next;
};

Expand Down
2 changes: 1 addition & 1 deletion src/utils/GenomeFile/GenomeFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class GenomeFile {
vector<string> _chromList;

// projecting chroms into a single coordinate system
CHRPOS _genomeLength;
CHRPOS _genomeLength{};
vector<CHRPOS> _startOffsets;

};
Expand Down
8 changes: 4 additions & 4 deletions src/utils/GenomeFile/NewGenomeFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ class NewGenomeFile {

private:
string _genomeFileName;
istream *_genomeFile;
istream *_genomeFile{};
typedef map<string, pair<CHRPOS, int> > lookupType;
lookupType _chromSizeIds;
vector<string> _chromList;
int _maxId;

// projecting chroms onto a single coordinate system
CHRPOS _genomeLength;
CHRPOS _genomeLength{};
vector<CHRPOS> _startOffsets;

//cache members for quick lookup
string _currChromName;
CHRPOS _currChromSize;
int _currChromId;
CHRPOS _currChromSize{};
int _currChromId{};

};

Expand Down
4 changes: 2 additions & 2 deletions src/utils/KeyListOps/KeyListOpsMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ class KeyListOpsMethods {

typedef enum { UNSORTED, ASC, DESC} SORT_TYPE;

bool _nonNumErrFlag;
bool _nonNumErrFlag{};
string _errMsg;
bool _isBam;
bool _isBam{};

typedef multimap<int, string, less<int> > histAscType;
typedef multimap<int, string, greater<int> > histDescType;
Expand Down
20 changes: 10 additions & 10 deletions src/utils/bedFile/bedFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ struct BED {
*/
struct MATE {
BED bed;
int lineNum;
MATE *mate;
int lineNum{};
MATE *mate{};
};


Expand Down Expand Up @@ -483,10 +483,10 @@ class BedFile {

// the bedfile with which this instance is associated
string bedFile;
unsigned int bedType; // 3-6, 12 for BED
unsigned int bedType{}; // 3-6, 12 for BED
// 9 for GFF
bool isBed12; // is it file of true blocked BED12 records?
bool isZeroBased;
bool isBed12{}; // is it file of true blocked BED12 records?
bool isZeroBased{};

// Main data structures used by BEDTools
masterBedCovMap bedCovMap;
Expand All @@ -496,7 +496,7 @@ class BedFile {
masterBedMapNoBin bedMapNoBin;

BedLineStatus _status;
int _lineNum;
int _lineNum{};

private:

Expand All @@ -505,21 +505,21 @@ class BedFile {
bool _isVcf;
bool _typeIsKnown; // do we know the type? (i.e., BED, GFF, VCF)
FileType _fileType; // what is the file type? (BED? GFF? VCF?)
istream *_bedStream;
istream *_bedStream{};
string _bedLine;

BED _nullBed;
string _header;
bool _firstLine;
bool _firstLine{};
vector<string> _bedFields;
unsigned int _numFields;
unsigned int _numFields{};
CHRPOS _merged_start;
CHRPOS _merged_end;
string _merged_chrom;
CHRPOS _prev_start;
string _prev_chrom;
unsigned long _total_length;
unsigned long _total_flattened_length;
unsigned long _total_flattened_length{};

void setZeroBased(bool zeroBased);
void setGff (bool isGff);
Expand Down
4 changes: 2 additions & 2 deletions src/utils/bedFilePE/bedFilePE.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ class BedFilePE {


string bedFile;
unsigned int bedType;
unsigned int bedType{};

masterMateMap bedMapEnd1;
masterMateMap bedMapEnd2;

private:
istream *_bedStream;
istream *_bedStream{};

// methods
BedLineStatus parseLine (BEDPE &bedpe, const vector<string> &lineVector, int &lineNum);
Expand Down
Loading