Skip to content

Commit

Permalink
Windows continuous integration with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Sep 27, 2020
1 parent 566fb84 commit 0a01422
Show file tree
Hide file tree
Showing 14 changed files with 53 additions and 854 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Windows

on:
push:
branches: [win]
pull_request:
branches: [win]

jobs:
build:
runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- name: cmake
run: |
cmake -E make_directory build
cd build
cmake -DBOOST_ROOT="${env:BOOST_ROOT_1_72_0}" ..
- name: Compile
working-directory: build
run: cmake --build . -j2
- name: Test
working-directory: build
run: ctest -j2
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
cmake_minimum_required(VERSION 3.1)

IF( WIN32 )
SET(Boost_USE_STATIC_LIBS OFF)
# The auto-linking feature has problems with USE_STATIC_LIBS off, so we use
# BOOST_ALL_NO_LIB to turn it off.
# Several boost libraries headers aren't configured correctly if
# USE_STATIC_LIBS is off, so we explicitly say they are dynamic with the
# remaining definitions.
ADD_DEFINITIONS(-DBOOST_ALL_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK -DBOOST_THREAD_DYN_LINK)
ENDIF( )

# Define a single cmake project
project(kenlm)

Expand Down
2 changes: 1 addition & 1 deletion lm/builder/adjust_counts.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class StatCollector {
discounts_[i].amount[j] = static_cast<float>(j) - static_cast<float>(j + 1) * y * static_cast<float>(s.n[j+1]) / static_cast<float>(s.n[j]);
UTIL_THROW_IF(discounts_[i].amount[j] < 0.0 || discounts_[i].amount[j] > j, BadDiscountException, "ERROR: " << (i+1) << "-gram discount out of range for adjusted count " << j << ": " << discounts_[i].amount[j] << ". This means modified Kneser-Ney smoothing thinks something is weird about your data. To override this error for e.g. a class-based model, rerun with --discount_fallback\n");
}
} catch (const BadDiscountException &e) {
} catch (const BadDiscountException &) {
switch (config.bad_action) {
case THROW_UP:
throw;
Expand Down
2 changes: 1 addition & 1 deletion lm/filter/count_io.hh
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ template <class Output> void ReadCount(util::FilePiece &in_file, Output &out) {
}
out.AddNGram(*tabber, line);
}
} catch (const util::EndOfFileException &e) {}
} catch (const util::EndOfFileException &) {}
}

} // namespace lm
Expand Down
2 changes: 1 addition & 1 deletion lm/read_arpa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ void ReadEnd(util::FilePiece &in) {
line = in.ReadLine();
if (!IsEntirelyWhiteSpace(line)) UTIL_THROW(FormatLoadException, "Trailing line " << line);
}
} catch (const util::EndOfFileException &e) {}
} catch (const util::EndOfFileException &) {}
}

void PositiveProbWarn::Warn(float prob) {
Expand Down
14 changes: 11 additions & 3 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ set(KENLM_UTIL_SOURCE
usage.cc
)

if (WIN32)
set(KENLM_UTIL_SOURCE ${KENLM_UTIL_SOURCE} getopt.c)
endif()

set(READ_COMPRESSED_FLAGS)
set(READ_COMPRESSED_LIBS)
find_package(ZLIB)
Expand All @@ -49,9 +53,11 @@ if (LIBLZMA_FOUND)
set(READ_COMPRESSED_LIBS ${READ_COMPRESSED_LIBS} ${LIBLZMA_LIBRARIES})
include_directories(${LIBLZMA_INCLUDE_DIRS})
endif()
set_source_files_properties(read_compressed.cc PROPERTIES COMPILE_FLAGS ${READ_COMPRESSED_FLAGS})
set_source_files_properties(read_compressed_test.cc PROPERTIES COMPILE_FLAGS ${READ_COMPRESSED_FLAGS})
set_source_files_properties(file_piece_test.cc PROPERTIES COMPILE_FLAGS ${READ_COMPRESSED_FLAGS})
if (NOT "${READ_COMPRESSED_FLAGS}" STREQUAL "")
set_source_files_properties(read_compressed.cc PROPERTIES COMPILE_FLAGS ${READ_COMPRESSED_FLAGS})
set_source_files_properties(read_compressed_test.cc PROPERTIES COMPILE_FLAGS ${READ_COMPRESSED_FLAGS})
set_source_files_properties(file_piece_test.cc PROPERTIES COMPILE_FLAGS ${READ_COMPRESSED_FLAGS})
endif()

# This directory has children that need to be processed
add_subdirectory(double-conversion)
Expand All @@ -66,8 +72,10 @@ add_library(kenlm_util ${KENLM_UTIL_DOUBLECONVERSION_SOURCE} ${KENLM_UTIL_STREAM
set_target_properties(kenlm_util PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(kenlm_util PUBLIC ${Boost_LIBRARIES} ${READ_COMPRESSED_LIBS} Threads::Threads ${RT})

if (NOT WIN32)
AddExes(EXES probing_hash_table_benchmark
LIBRARIES kenlm_util ${Boost_LIBRARIES} Threads::Threads)
endif()

# Only compile and run unit tests if tests should be run
if(BUILD_TESTING)
Expand Down
2 changes: 1 addition & 1 deletion util/file_piece.cc
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ void FilePiece::MMapShift(uint64_t desired_begin) {
data_.reset();
try {
MapRead(POPULATE_OR_LAZY, *file_, mapped_offset, mapped_size, data_);
} catch (const util::ErrnoException &e) {
} catch (const util::ErrnoException &) {
if (desired_begin) {
SeekOrThrow(*file_, desired_begin);
}
Expand Down
4 changes: 2 additions & 2 deletions util/probing_hash_table_benchmark_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include <boost/thread/locks.hpp>

#ifdef WIN32
#include <windows.h>
#include <processthreadsapi.h>
#else
#include <sys/resource.h>
#endif

#include <sys/time.h>
#endif

#include <iostream>

Expand Down
2 changes: 1 addition & 1 deletion util/stream/sort.hh
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ template <class Compare> class MergeQueue {
// Try to free the space, but don't be disappointed if we can't.
try {
HolePunch(fd, offset_, amount);
} catch (const util::Exception &e) {}
} catch (const util::Exception &) {}
offset_ += amount;
assert(current_ <= buffer_end_);
remaining_ -= amount;
Expand Down
157 changes: 0 additions & 157 deletions windows/build_binary.vcxproj

This file was deleted.

60 changes: 0 additions & 60 deletions windows/kenlm.sln

This file was deleted.

Loading

0 comments on commit 0a01422

Please sign in to comment.