Skip to content

Commit

Permalink
lint and travis
Browse files Browse the repository at this point in the history
  • Loading branch information
tqchen committed Jul 3, 2015
1 parent ceedf4e commit 3cc49ad
Show file tree
Hide file tree
Showing 27 changed files with 423 additions and 296 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@
*tmp*
*.rabit
*.mock
dmlc-core
48 changes: 48 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# disable sudo to use container based build
sudo: false

# Use Build Matrix to do lint and build seperately
env:
matrix:
- TASK=lint LINT_LANG=cpp
- TASK=lint LINT_LANG=python
- TASK=doc
- TASK=build CXX=g++

# dependent apt packages
addons:
apt:
packages:
- doxygen
- wget
- git
- libcurl4-openssl-dev
- unzip

before_install:
- git clone https://github.com/dmlc/dmlc-core
- export TRAVIS=dmlc-core/scripts/travis/
- source ${TRAVIS}/travis_setup_env.sh

install:
- pip install cpplint pylint --user `whoami`

script: scripts/travis_script.sh


before_cache:
- ${TRAVIS}/travis_before_cache.sh


cache:
directories:
- ${HOME}/.cache/usr


notifications:
# Emails are sent to the committer's git-configured email address by default,
email:
on_success: change
on_failure: always


24 changes: 18 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@ export CXX = g++
endif
export MPICXX = mpicxx
export LDFLAGS= -Llib -lrt
export WARNFLAGS= -Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas
export CFLAGS = -O3 -msse2 $(WARNFLAGS)
export WARNFLAGS= -Wall -Wextra -Wno-unused-parameter -Wno-unknown-pragmas
export CFLAGS = -O3 -msse2 $(WARNFLAGS)

ifndef WITH_FPIC
WITH_FPIC = 1
endif
ifeq ($(WITH_FPIC), 1)
CFLAGS += -fPIC
CFLAGS += -fPIC
endif

ifndef LINT_LANG
LINT_LANG="all"
endif

# build path
Expand All @@ -22,7 +26,9 @@ OBJ= $(BPATH)/allreduce_base.o $(BPATH)/allreduce_robust.o $(BPATH)/engine.o $(B
SLIB= wrapper/librabit_wrapper.so wrapper/librabit_wrapper_mock.so wrapper/librabit_wrapper_mpi.so
ALIB= lib/librabit.a lib/librabit_mpi.a lib/librabit_empty.a lib/librabit_mock.a lib/librabit_base.a
HEADERS=src/*.h include/*.h include/rabit/*.h
.PHONY: clean all install mpi python
DMLC=dmlc-core

.PHONY: clean all install mpi python lint doc

all: lib/librabit.a lib/librabit_mock.a wrapper/librabit_wrapper.so wrapper/librabit_wrapper_mock.so lib/librabit_base.a
mpi: lib/librabit_mpi.a wrapper/librabit_wrapper_mpi.so
Expand All @@ -47,10 +53,10 @@ wrapper/librabit_wrapper.so: $(BPATH)/rabit_wrapper.o lib/librabit.a
wrapper/librabit_wrapper_mock.so: $(BPATH)/rabit_wrapper.o lib/librabit_mock.a
wrapper/librabit_wrapper_mpi.so: $(BPATH)/rabit_wrapper.o lib/librabit_mpi.a

$(OBJ) :
$(OBJ) :
$(CXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c %.cc, $^) )

$(MPIOBJ) :
$(MPIOBJ) :
$(MPICXX) -c $(CFLAGS) -o $@ $(firstword $(filter %.cpp %.c %.cc, $^) )

$(ALIB):
Expand All @@ -59,6 +65,12 @@ $(ALIB):
$(SLIB) :
$(CXX) $(CFLAGS) -shared -o $@ $(filter %.cpp %.o %.c %.cc %.a, $^) $(LDFLAGS)

lint:
$(DMLC)/scripts/lint.py rabit $(LINT_LANG) src include wrapper

doc:
cd include; doxygen ../doc/Doxyfile; cd -

clean:
$(RM) $(OBJ) $(MPIOBJ) $(ALIB) $(MPIALIB) *~ src/*~ include/*~ include/*/*~ wrapper/*~

4 changes: 2 additions & 2 deletions doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ FILE_PATTERNS =
RECURSIVE = NO
EXCLUDE =
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = *-inl.hpp
EXCLUDE_SYMBOLS =
EXCLUDE_PATTERNS = *-inl.hpp
EXCLUDE_SYMBOLS =
EXAMPLE_PATH =
EXAMPLE_PATTERNS =
EXAMPLE_RECURSIVE = NO
Expand Down
2 changes: 1 addition & 1 deletion doc/mkdoc.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
cd ../include
doxygen ../doc/Doxyfile
doxygen ../doc/Doxyfile
cd ../doc
36 changes: 19 additions & 17 deletions include/dmlc/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

// include uint64_t only to make io standalone
#ifdef _MSC_VER
/*! \brief uint64 */
typedef unsigned __int64 uint64_t;
#else
#include <inttypes.h>
Expand All @@ -24,7 +25,7 @@ namespace dmlc {
/*!
* \brief interface of stream I/O for serialization
*/
class Stream {
class Stream { // NOLINT(*)
public:
/*!
* \brief reads data from a stream
Expand Down Expand Up @@ -71,7 +72,7 @@ class Stream {
/*!
* \brief writes a string
* \param str the string to be written/serialized
*/
*/
inline void Write(const std::string &str);
/*!
* \brief loads a string
Expand All @@ -94,7 +95,7 @@ class SeekStream: public Stream {
* \brief generic factory function
* create an SeekStream for read only,
* the stream will close the underlying files upon deletion
* error will be reported and the system will exit when create failed
* error will be reported and the system will exit when create failed
* \param uri the uri of the input currently we support
* hdfs://, s3://, and file:// by default file:// will be used
* \param allow_null whether NULL can be returned, or directly report error
Expand All @@ -107,12 +108,12 @@ class SeekStream: public Stream {
/*! \brief interface for serializable objects */
class Serializable {
public:
/*!
/*!
* \brief load the model from a stream
* \param fi stream where to load the model from
*/
virtual void Load(Stream *fi) = 0;
/*!
/*!
* \brief saves the model to a stream
* \param fo stream where to save the model to
*/
Expand All @@ -123,7 +124,7 @@ class Serializable {
* \brief input split creates that allows reading
* of records from split of data,
* independent part that covers all the dataset
*
*
* see InputSplit::Create for definition of record
*/
class InputSplit {
Expand All @@ -141,7 +142,7 @@ class InputSplit {
* this is a hint so may not be enforced,
* but InputSplit will try adjust its internal buffer
* size to the hinted value
* \param chunk_size the chunk size
* \param chunk_size the chunk size
*/
virtual void HintChunkSize(size_t chunk_size) {}
/*! \brief reset the position of InputSplit to beginning */
Expand All @@ -150,7 +151,7 @@ class InputSplit {
* \brief get the next record, the returning value
* is valid until next call to NextRecord or NextChunk
* caller can modify the memory content of out_rec
*
*
* For text, out_rec contains a single line
* For recordio, out_rec contains one record content(with header striped)
*
Expand All @@ -161,11 +162,11 @@ class InputSplit {
*/
virtual bool NextRecord(Blob *out_rec) = 0;
/*!
* \brief get a chunk of memory that can contain multiple records,
* \brief get a chunk of memory that can contain multiple records,
* the caller needs to parse the content of the resulting chunk,
* for text file, out_chunk can contain data of multiple lines
* for recordio, out_chunk can contain multiple records(including headers)
*
*
* This function ensures there won't be partial record in the chunk
* caller can modify the memory content of out_chunk,
* the memory is valid until next call to NextRecord or NextChunk
Expand All @@ -192,9 +193,10 @@ class InputSplit {
* List of possible types: "text", "recordio"
* - "text":
* text file, each line is treated as a record
* input split will split on \n or \r
* input split will split on '\\n' or '\\r'
* - "recordio":
* binary recordio file, see recordio.h
* \return a new input split
* \sa InputSplit::Type
*/
static InputSplit* Create(const char *uri,
Expand Down Expand Up @@ -224,7 +226,7 @@ class ostream : public std::basic_ostream<char> {
* \param buffer_size internal streambuf size
*/
explicit ostream(Stream *stream,
size_t buffer_size = 1 << 10)
size_t buffer_size = (1 << 10))
: std::basic_ostream<char>(NULL), buf_(buffer_size) {
this->set_stream(stream);
}
Expand All @@ -240,7 +242,7 @@ class ostream : public std::basic_ostream<char> {
buf_.set_stream(stream);
this->rdbuf(&buf_);
}

private:
// internal streambuf
class OutBuf : public std::streambuf {
Expand All @@ -251,7 +253,7 @@ class ostream : public std::basic_ostream<char> {
}
// set stream to the buffer
inline void set_stream(Stream *stream);

private:
/*! \brief internal stream by StreamBuf */
Stream *stream_;
Expand Down Expand Up @@ -287,7 +289,7 @@ class istream : public std::basic_istream<char> {
* \param buffer_size internal buffer size
*/
explicit istream(Stream *stream,
size_t buffer_size = 1 << 10)
size_t buffer_size = (1 << 10))
: std::basic_istream<char>(NULL), buf_(buffer_size) {
this->set_stream(stream);
}
Expand Down Expand Up @@ -325,7 +327,7 @@ class istream : public std::basic_istream<char> {
Stream *stream_;
/*! \brief how many bytes we read so far */
size_t bytes_read_;
/*! \brief internal buffer */
/*! \brief internal buffer */
std::vector<char> buffer_;
// override underflow
inline int_type underflow();
Expand Down Expand Up @@ -402,7 +404,7 @@ inline int ostream::OutBuf::overflow(int c) {
// implementations for istream
inline void istream::InBuf::set_stream(Stream *stream) {
stream_ = stream;
this->setg(&buffer_[0], &buffer_[0], &buffer_[0]);
this->setg(&buffer_[0], &buffer_[0], &buffer_[0]);
}
inline int istream::InBuf::underflow() {
char *bhead = &buffer_[0];
Expand Down

0 comments on commit 3cc49ad

Please sign in to comment.