fast_excel 0.2.3 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +4 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +16 -16
- data/README.md +1 -1
- data/Rakefile +1 -1
- data/fast_excel.gemspec +1 -1
- data/lib/fast_excel.rb +21 -5
- data/lib/fast_excel/binding/format.rb +3 -3
- data/libxlsxwriter/.drone.yml +27 -0
- data/libxlsxwriter/.indent.pro +3 -0
- data/libxlsxwriter/.travis.yml +12 -0
- data/libxlsxwriter/CMakeLists.txt +348 -0
- data/libxlsxwriter/Changes.txt +78 -0
- data/libxlsxwriter/LICENSE.txt +65 -4
- data/libxlsxwriter/Makefile +27 -7
- data/libxlsxwriter/Readme.md +2 -0
- data/libxlsxwriter/appveyor.yml +65 -0
- data/libxlsxwriter/cmake/FindMINIZIP.cmake +121 -0
- data/libxlsxwriter/cmake/FindPackage.cmake +183 -0
- data/libxlsxwriter/cmake/FindZLIB.cmake +123 -0
- data/libxlsxwriter/cmake/i686-toolchain.cmake +7 -0
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +1 -1
- data/libxlsxwriter/cocoapods/libxlsxwriter.modulemap +2 -2
- data/libxlsxwriter/include/xlsxwriter.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/app.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/chart.h +109 -8
- data/libxlsxwriter/include/xlsxwriter/common.h +10 -2
- data/libxlsxwriter/include/xlsxwriter/content_types.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/drawing.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/format.h +6 -6
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/packager.h +6 -1
- data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/styles.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/utility.h +11 -5
- data/libxlsxwriter/include/xlsxwriter/workbook.h +3 -3
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +517 -39
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +2 -2
- data/libxlsxwriter/libxlsxwriter.podspec +4 -2
- data/libxlsxwriter/src/Makefile +30 -5
- data/libxlsxwriter/src/app.c +1 -1
- data/libxlsxwriter/src/chart.c +76 -19
- data/libxlsxwriter/src/content_types.c +1 -1
- data/libxlsxwriter/src/core.c +10 -10
- data/libxlsxwriter/src/custom.c +2 -2
- data/libxlsxwriter/src/drawing.c +1 -1
- data/libxlsxwriter/src/format.c +3 -3
- data/libxlsxwriter/src/hash_table.c +1 -1
- data/libxlsxwriter/src/packager.c +20 -7
- data/libxlsxwriter/src/relationships.c +1 -1
- data/libxlsxwriter/src/shared_strings.c +1 -1
- data/libxlsxwriter/src/styles.c +4 -4
- data/libxlsxwriter/src/theme.c +1 -1
- data/libxlsxwriter/src/utility.c +41 -1
- data/libxlsxwriter/src/workbook.c +8 -6
- data/libxlsxwriter/src/worksheet.c +748 -31
- data/libxlsxwriter/src/xmlwriter.c +2 -2
- data/libxlsxwriter/third_party/minizip/Makefile +6 -1
- data/libxlsxwriter/version.txt +1 -1
- data/test/reopen_test.rb +22 -0
- data/test/test_helper.rb +8 -5
- data/test/validations_test.rb +27 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0913c4454d805190410b1ba3657913a0f5dc9c1
|
4
|
+
data.tar.gz: a1d3fe3a3f3ee227fcaa900791bb34c0320709e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b6761029c771b2fcc9444e5b896c64282e12ee4dc19b9eb316481f86aca2543f70156c79159966dd50b6488dccd8bc32292725101bfd6068044b1d938b709e9
|
7
|
+
data.tar.gz: 7d89bc8a36f46ab01cd74826dc411233e6b1f532d0eaa1762e296e4c1f71b7b5d9f42ba706c2445d98ff87d919cf91bcf2e4b8c9a6f299991eb7aa27b37c3a13
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
#### Version 0.2.5 - 22 jun 2018
|
2
|
+
|
3
|
+
* Update libxlsxwriter to 0.7.7
|
4
|
+
|
5
|
+
#### Version 0.2.4 - 13 mar 2018
|
6
|
+
|
7
|
+
* Update libxlsxwriter to 0.7.6
|
8
|
+
* Don’t crash process when duplicated worksheet name
|
9
|
+
|
1
10
|
#### Version 0.2.3 - 27 oct 2017
|
2
11
|
|
3
12
|
* Allow Date along with DateTime in write_value (thanks to @noxern)
|
data/Gemfile.lock
CHANGED
@@ -6,17 +6,17 @@ GIT
|
|
6
6
|
|
7
7
|
GIT
|
8
8
|
remote: https://github.com/randym/axlsx.git
|
9
|
-
revision:
|
9
|
+
revision: 73d9477fc33706f4a186e92794134248fb389183
|
10
10
|
specs:
|
11
|
-
axlsx (
|
12
|
-
htmlentities (~> 4.3.4)
|
11
|
+
axlsx (3.0.0.pre)
|
12
|
+
htmlentities (~> 4.3, >= 4.3.4)
|
13
13
|
mimemagic (~> 0.3)
|
14
|
-
nokogiri (>= 1.
|
15
|
-
rubyzip (>= 1.2.1)
|
14
|
+
nokogiri (~> 1.8, >= 1.8.2)
|
15
|
+
rubyzip (~> 1.2, >= 1.2.1)
|
16
16
|
|
17
17
|
GIT
|
18
18
|
remote: https://github.com/roo-rb/roo.git
|
19
|
-
revision:
|
19
|
+
revision: 3ed05e1caef0ce3c5db5c19f1fa14e6f74193079
|
20
20
|
specs:
|
21
21
|
roo (2.7.1)
|
22
22
|
nokogiri (~> 1)
|
@@ -28,24 +28,24 @@ GEM
|
|
28
28
|
ansi (1.5.0)
|
29
29
|
benchmark-ips (2.7.2)
|
30
30
|
builder (3.2.3)
|
31
|
-
ffi (1.9.
|
31
|
+
ffi (1.9.23)
|
32
32
|
ffi_gen (1.2.0)
|
33
33
|
ffi (~> 1.0)
|
34
34
|
htmlentities (4.3.4)
|
35
35
|
mimemagic (0.3.2)
|
36
|
-
mini_portile2 (2.
|
37
|
-
minitest (5.
|
38
|
-
minitest-reporters (1.1.
|
36
|
+
mini_portile2 (2.3.0)
|
37
|
+
minitest (5.11.3)
|
38
|
+
minitest-reporters (1.1.19)
|
39
39
|
ansi
|
40
40
|
builder
|
41
41
|
minitest (>= 5.0)
|
42
42
|
ruby-progressbar
|
43
|
-
nokogiri (1.8.
|
44
|
-
mini_portile2 (~> 2.
|
45
|
-
rake (12.
|
46
|
-
ruby-progressbar (1.
|
43
|
+
nokogiri (1.8.2)
|
44
|
+
mini_portile2 (~> 2.3.0)
|
45
|
+
rake (12.3.0)
|
46
|
+
ruby-progressbar (1.9.0)
|
47
47
|
rubyzip (1.2.1)
|
48
|
-
write_xlsx (0.85.
|
48
|
+
write_xlsx (0.85.3)
|
49
49
|
rubyzip (>= 1.0.0)
|
50
50
|
zip-zip
|
51
51
|
zip-zip (0.3)
|
@@ -67,4 +67,4 @@ DEPENDENCIES
|
|
67
67
|
write_xlsx
|
68
68
|
|
69
69
|
BUNDLED WITH
|
70
|
-
1.
|
70
|
+
1.16.1
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/fast_excel.gemspec
CHANGED
data/lib/fast_excel.rb
CHANGED
@@ -13,16 +13,16 @@ module FastExcel
|
|
13
13
|
|
14
14
|
def self.open(filename = nil, constant_memory: false, default_format: nil)
|
15
15
|
tmp_file = false
|
16
|
-
|
16
|
+
if filename
|
17
|
+
if File.exist?(filename)
|
18
|
+
raise ArgumentError, "File '#{filename}' already exists. FastExcel can not open existing files, only create new files"
|
19
|
+
end
|
20
|
+
else
|
17
21
|
require 'tmpdir'
|
18
22
|
filename = "#{Dir.mktmpdir}/fast_excel.xlsx"
|
19
23
|
tmp_file = true
|
20
24
|
end
|
21
25
|
|
22
|
-
unless filename
|
23
|
-
raise ArgumentError, "filename is required"
|
24
|
-
end
|
25
|
-
|
26
26
|
filename = filename.to_s if defined?(Pathname) && filename.is_a?(Pathname)
|
27
27
|
|
28
28
|
workbook = if constant_memory
|
@@ -323,6 +323,7 @@ module FastExcel
|
|
323
323
|
|
324
324
|
def initialize(struct)
|
325
325
|
@is_open = true
|
326
|
+
@sheet_names = Set.new
|
326
327
|
super(struct)
|
327
328
|
end
|
328
329
|
|
@@ -347,8 +348,23 @@ module FastExcel
|
|
347
348
|
end
|
348
349
|
|
349
350
|
def add_worksheet(sheetname = nil)
|
351
|
+
sheetname = nil if sheetname == ""
|
352
|
+
|
353
|
+
if !sheetname.nil? && @sheet_names.include?(sheetname)
|
354
|
+
raise ArgumentError, "Worksheet name '#{sheetname}' is already in use"
|
355
|
+
end
|
356
|
+
@sheet_names << sheetname
|
357
|
+
|
350
358
|
sheet = super
|
351
359
|
sheet.workbook = self
|
360
|
+
|
361
|
+
sheet
|
362
|
+
end
|
363
|
+
|
364
|
+
def get_worksheet_by_name(name)
|
365
|
+
sheet = super(name)
|
366
|
+
sheet.workbook = self
|
367
|
+
|
352
368
|
sheet
|
353
369
|
end
|
354
370
|
|
@@ -700,7 +700,7 @@ module Libxlsxwriter
|
|
700
700
|
:font_index, :uint16,
|
701
701
|
:has_font, :uchar,
|
702
702
|
:has_dxf_font, :uchar,
|
703
|
-
:font_size, :
|
703
|
+
:font_size, :double,
|
704
704
|
:bold, :uchar,
|
705
705
|
:italic, :uchar,
|
706
706
|
:font_color, :int,
|
@@ -786,7 +786,7 @@ module Libxlsxwriter
|
|
786
786
|
# (Integer)
|
787
787
|
class Font < FFI::Struct
|
788
788
|
layout :font_name, [:char, 128],
|
789
|
-
:font_size, :
|
789
|
+
:font_size, :double,
|
790
790
|
:bold, :uchar,
|
791
791
|
:italic, :uchar,
|
792
792
|
:underline, :uchar,
|
@@ -904,7 +904,7 @@ module Libxlsxwriter
|
|
904
904
|
# @param [Integer] size
|
905
905
|
# @return [nil]
|
906
906
|
# @scope class
|
907
|
-
attach_function :format_set_font_size, :format_set_font_size, [Format, :
|
907
|
+
attach_function :format_set_font_size, :format_set_font_size, [Format, :double], :void
|
908
908
|
|
909
909
|
# @method format_set_font_color(format, color)
|
910
910
|
# @param [Format] format
|
@@ -0,0 +1,27 @@
|
|
1
|
+
build:
|
2
|
+
image: teaci/msys$$arch
|
3
|
+
pull: true
|
4
|
+
shell: msys$$arch
|
5
|
+
commands:
|
6
|
+
- if [ $$arch = 32 ]; then target=i686; fi
|
7
|
+
- if [ $$arch = 64 ]; then target=x86_64; fi
|
8
|
+
- pacman -S --needed --noconfirm --noprogressbar mingw-w64-${target}-pkg-config cmake zlib-devel
|
9
|
+
- git submodule update --init --recursive
|
10
|
+
- cmake -DBUILD_STATIC=$STATIC -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DBUILD_TESTS=ON -DIOAPI_NO_64=ON .
|
11
|
+
- make -j 8
|
12
|
+
- make install
|
13
|
+
- ctest -C $BUILD_TYPE -V
|
14
|
+
|
15
|
+
matrix:
|
16
|
+
arch:
|
17
|
+
# Bug with 64-bit MSYS2 on WINE currently, disable temporarily.
|
18
|
+
# - 64
|
19
|
+
- 32
|
20
|
+
|
21
|
+
STATIC:
|
22
|
+
- OFF
|
23
|
+
- ON
|
24
|
+
|
25
|
+
BUILD_TYPE:
|
26
|
+
- Debug
|
27
|
+
- Release
|
data/libxlsxwriter/.indent.pro
CHANGED
@@ -53,7 +53,9 @@
|
|
53
53
|
-T lxw_chart_axis_label_position
|
54
54
|
-T lxw_chart_axis_tick_mark
|
55
55
|
-T lxw_chart_axis_tick_position
|
56
|
+
-T lxw_chart_axis_type
|
56
57
|
-T lxw_chart_blank
|
58
|
+
-T lxw_chart_error_bar_axis
|
57
59
|
-T lxw_chart_error_bar_cap
|
58
60
|
-T lxw_chart_error_bar_direction
|
59
61
|
-T lxw_chart_error_bar_type
|
@@ -82,6 +84,7 @@
|
|
82
84
|
-T lxw_core
|
83
85
|
-T lxw_custom
|
84
86
|
-T lxw_custom_property
|
87
|
+
-T lxw_data_validation
|
85
88
|
-T lxw_datetime
|
86
89
|
-T lxw_defined_name
|
87
90
|
-T lxw_doc_properties
|
data/libxlsxwriter/.travis.yml
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
language: c
|
2
|
+
dist: trusty
|
2
3
|
|
3
4
|
compiler:
|
4
5
|
- clang
|
@@ -8,18 +9,29 @@ env:
|
|
8
9
|
- CFLAGS='-Werror'
|
9
10
|
- NO_VALGRIND=1 USE_STANDARD_TMPFILE=1 CFLAGS='-Werror'
|
10
11
|
- NO_VALGRIND=1 CFLAGS='-Werror -m32'
|
12
|
+
- NO_VALGRIND=1 USE_SYSTEM_MINIZIP=1 CFLAGS='-Werror'
|
13
|
+
- NO_VALGRIND=1 USE_DOUBLE_FUNCTION=1 CFLAGS='-Werror'
|
11
14
|
|
12
15
|
install:
|
13
16
|
- sudo pip install pytest
|
14
17
|
- sudo apt-get update
|
18
|
+
- sudo apt-get remove -y oracle-java9-installer
|
15
19
|
- sudo apt-get install -y gcc-multilib
|
16
20
|
- sudo apt-get install -y zlib1g-dev
|
17
21
|
- sudo apt-get install -y zlib1g-dev:i386
|
18
22
|
- sudo apt-get install -y gcc
|
19
23
|
- sudo apt-get install -y valgrind
|
20
24
|
|
25
|
+
- wget http://mirrors.kernel.org/ubuntu/pool/universe/m/minizip/libminizip-dev_1.1-8_amd64.deb
|
26
|
+
- wget http://mirrors.kernel.org/ubuntu/pool/universe/m/minizip/libminizip1_1.1-8_amd64.deb
|
27
|
+
- sudo dpkg -i libminizip1_1.1-8_amd64.deb
|
28
|
+
- sudo dpkg -i libminizip-dev_1.1-8_amd64.deb
|
29
|
+
|
21
30
|
script:
|
22
31
|
- make V=1
|
23
32
|
- make test_functional V=1
|
24
33
|
- make test_unit V=1
|
34
|
+
- make examples V=1
|
25
35
|
- make test_valgrind V=1
|
36
|
+
- sudo make install V=1
|
37
|
+
- sudo make uninstall V=1
|
@@ -0,0 +1,348 @@
|
|
1
|
+
# :copyright: (c) 2017 Alex Huszagh.
|
2
|
+
# :license: FreeBSD, see LICENSE.txt for more details.
|
3
|
+
|
4
|
+
# Description
|
5
|
+
# ===========
|
6
|
+
#
|
7
|
+
# Use:
|
8
|
+
# Move to a custom directory, ideally out of source, and
|
9
|
+
# type `cmake $LXW_SOURCE $FLAGS`, where `LXW_SOURCE` is the
|
10
|
+
# path to the libxlsxwriter project, and `FLAGS` are custom
|
11
|
+
# flags to pass to the compiler.
|
12
|
+
#
|
13
|
+
# Example:
|
14
|
+
# For example, in the project directory, to build libxlsxwriter
|
15
|
+
# and the unittests in release mode, type:
|
16
|
+
# mkdir build && cd build
|
17
|
+
# cmake .. -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
|
18
|
+
# cmake --build . --config Release
|
19
|
+
# ctest -C Release -V
|
20
|
+
# cmake --build . --config Release --target install
|
21
|
+
#
|
22
|
+
# If using a Makefile generator, you may use the simpler
|
23
|
+
# mkdir build && cd build
|
24
|
+
# cmake .. -DBUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release
|
25
|
+
# make
|
26
|
+
# make test
|
27
|
+
# make install
|
28
|
+
#
|
29
|
+
# Flags:
|
30
|
+
# ZLIB_ROOT
|
31
|
+
# The ZLIB root directory can be specified either through
|
32
|
+
# an environment variable (`export ZLIB_ROOT=/usr/include`)
|
33
|
+
# or using a flag with CMake (`-DZLIB_ROOT:STRING=/usr/include`).
|
34
|
+
# This sets the preferred search path for the ZLIB installation.
|
35
|
+
#
|
36
|
+
# BUILD_TESTS
|
37
|
+
# Build unittests (default off). To build the unittests,
|
38
|
+
# pass `-DBUILD_TESTS=ON` during configuration.
|
39
|
+
#
|
40
|
+
# BUILD_EXAMPLES
|
41
|
+
# Build example files (default off). To build the examples,
|
42
|
+
# pass `-DBUILD_EXAMPLES=ON` during configuration.
|
43
|
+
#
|
44
|
+
# USE_STANDARD_TMPFILE
|
45
|
+
# Use the standard tmpfile() function (default off). To enable
|
46
|
+
# the standard tmpfile, pass `-DUSE_STANDARD_TMPFILE=ON`
|
47
|
+
# during configuration. This may produce bugs while cross-
|
48
|
+
# compiling or using MinGW/MSYS.
|
49
|
+
#
|
50
|
+
# USE_STATIC_MSVC_RUNTIME
|
51
|
+
# Use the static msvc runtime library when compiling with msvc (default off)
|
52
|
+
# To enable, pass `-DUSE_STATIC_MSVC_RUNTIME` during configuration.
|
53
|
+
#
|
54
|
+
# Toolchains:
|
55
|
+
# On multiarch Linux systems, which can build and run multiple
|
56
|
+
# binary targets on the same system, we include an `i686-toolchain`
|
57
|
+
# file to enable building i686 (x86 32-bit) targets on x86_64 systems.
|
58
|
+
# To use the i686 toolchain, pass the `-DCMAKE_TOOLCHAIN_FILE` option
|
59
|
+
# during CMake configuration. For example, from the build directory,
|
60
|
+
# you would use:
|
61
|
+
# cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/i686-toolchain.cmake
|
62
|
+
#
|
63
|
+
# CMake Options:
|
64
|
+
# CMake sets debug and release builds with the `CMAKE_BUILD_TYPE`
|
65
|
+
# option, which can be set as a flag during configuration.
|
66
|
+
# To build in release mode, pass `-DCMAKE_BUILD_TYPE=Release`
|
67
|
+
# during configuration.
|
68
|
+
#
|
69
|
+
# CMake sets the creation of static and shared libraries with the
|
70
|
+
# `BUILD_SHARED_LIBS` option, which can be set as a flag during
|
71
|
+
# configuration. To build a static library, pass
|
72
|
+
# `-DBUILD_SHARED_LIBS=OFF` during configuration.
|
73
|
+
#
|
74
|
+
# Generators:
|
75
|
+
# CMake also supports custom build generators, such as MakeFiles,
|
76
|
+
# Ninja, Visual Studio, and XCode. For example, to generate
|
77
|
+
# a Visual Studio solution, configure with:
|
78
|
+
# cmake .. -G "Visual Studio 14 2015 Win64"
|
79
|
+
#
|
80
|
+
# For more information on using generators, see:
|
81
|
+
# https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html
|
82
|
+
#
|
83
|
+
|
84
|
+
set(CMAKE_LEGACY_CYGWIN_WIN32 1)
|
85
|
+
if(MSVC)
|
86
|
+
cmake_minimum_required(VERSION 3.4)
|
87
|
+
else()
|
88
|
+
cmake_minimum_required(VERSION 3.1)
|
89
|
+
endif()
|
90
|
+
|
91
|
+
SET(PROJECT_NAME "xlsxwriter" CACHE STRING "Optional project and binary name")
|
92
|
+
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
93
|
+
project(${PROJECT_NAME} C)
|
94
|
+
enable_testing()
|
95
|
+
|
96
|
+
# OPTIONS
|
97
|
+
# -------
|
98
|
+
|
99
|
+
SET(ZLIB_ROOT "" CACHE STRING "Optional root for the ZLIB installation")
|
100
|
+
|
101
|
+
option(BUILD_TESTS "Build libxlsxwriter tests" OFF)
|
102
|
+
option(BUILD_EXAMPLES "Build libxlsxwriter examples" OFF)
|
103
|
+
option(USE_SYSTEM_MINIZIP "Use system minizip installation" OFF)
|
104
|
+
option(USE_STANDARD_TMPFILE "Use the C standard library's tmpfile()" OFF)
|
105
|
+
option(IOAPI_NO_64 "Disable 64-bit filesystem support" OFF)
|
106
|
+
if(MSVC)
|
107
|
+
option(USE_STATIC_MSVC_RUNTIME "Use the static runtime library" OFF)
|
108
|
+
endif()
|
109
|
+
if(DEFINED ENV{${ZLIB_ROOT}})
|
110
|
+
set(ZLIB_ROOT $ENV{ZLIB_ROOT})
|
111
|
+
endif()
|
112
|
+
|
113
|
+
if(IOAPI_NO_64)
|
114
|
+
list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS IOAPI_NO_64=1)
|
115
|
+
endif()
|
116
|
+
|
117
|
+
# CONFIGURATIONS
|
118
|
+
# --------------
|
119
|
+
|
120
|
+
if(USE_SYSTEM_MINIZIP)
|
121
|
+
list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_SYSTEM_MINIZIP)
|
122
|
+
endif()
|
123
|
+
|
124
|
+
if(USE_STANDARD_TMPFILE)
|
125
|
+
list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_STANDARD_TMPFILE)
|
126
|
+
endif()
|
127
|
+
|
128
|
+
if(NOT BUILD_SHARED_LIBS)
|
129
|
+
if(UNIX)
|
130
|
+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
131
|
+
elseif(MINGW OR MSYS)
|
132
|
+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc -Wno-char-subscripts -Wno-long-long")
|
133
|
+
list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_FILE32API)
|
134
|
+
elseif(MSVC)
|
135
|
+
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /O0 /Fd${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb")
|
136
|
+
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Ox /Zi /Fd${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb")
|
137
|
+
set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /Zi /Fd${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb")
|
138
|
+
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Fd${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb")
|
139
|
+
endif()
|
140
|
+
endif()
|
141
|
+
|
142
|
+
message(status "BEFORE: ${CMAKE_C_FLAGS_DEBUG}")
|
143
|
+
|
144
|
+
if(MSVC AND USE_STATIC_MSVC_RUNTIME)
|
145
|
+
foreach(flag_var CMAKE_C_FLAGS
|
146
|
+
CMAKE_C_FLAGS_DEBUG
|
147
|
+
CMAKE_C_FLAGS_RELEASE
|
148
|
+
CMAKE_C_FLAGS_MINSIZEREL
|
149
|
+
CMAKE_C_FLAGS_RELWITHDEBINFO)
|
150
|
+
if(${flag_var} MATCHES "/MD")
|
151
|
+
string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
152
|
+
endif()
|
153
|
+
endforeach()
|
154
|
+
endif()
|
155
|
+
|
156
|
+
# INCLUDES
|
157
|
+
# --------
|
158
|
+
|
159
|
+
enable_language(CXX)
|
160
|
+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
161
|
+
|
162
|
+
# ZLIB
|
163
|
+
find_package(ZLIB REQUIRED "1.0")
|
164
|
+
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
|
165
|
+
message("zlib version: " ${ZLIB_VERSION})
|
166
|
+
|
167
|
+
# MINIZIP
|
168
|
+
if (USE_SYSTEM_MINIZIP)
|
169
|
+
find_package(MINIZIP REQUIRED "1.0")
|
170
|
+
list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS})
|
171
|
+
endif()
|
172
|
+
|
173
|
+
# LIBRARY
|
174
|
+
# -------
|
175
|
+
|
176
|
+
list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS NOCRYPT NOUNCRYPT)
|
177
|
+
|
178
|
+
# Fix for modified zconf.h on Gentoo.
|
179
|
+
if(${CMAKE_HOST_SYSTEM} MATCHES gentoo)
|
180
|
+
list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS OF=_Z_OF)
|
181
|
+
endif()
|
182
|
+
|
183
|
+
# Ensure CRT Secure warnings are disabled
|
184
|
+
if(MSVC)
|
185
|
+
list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
|
186
|
+
endif()
|
187
|
+
|
188
|
+
# Ensure "TESTING" macro is defined if building tests
|
189
|
+
if(BUILD_TESTS)
|
190
|
+
list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS TESTING)
|
191
|
+
endif()
|
192
|
+
|
193
|
+
file(GLOB LXW_SOURCES src/*.c)
|
194
|
+
file(GLOB_RECURSE LXW_HEADERS RELATIVE include *.h)
|
195
|
+
if(NOT USE_SYSTEM_MINIZIP)
|
196
|
+
list(APPEND LXW_SOURCES third_party/minizip/ioapi.c third_party/minizip/zip.c)
|
197
|
+
if(MSVC)
|
198
|
+
list(APPEND LXW_SOURCES third_party/minizip/iowin32.c)
|
199
|
+
endif()
|
200
|
+
endif()
|
201
|
+
if (NOT USE_STANDARD_TMPFILE)
|
202
|
+
list(APPEND LXW_SOURCES third_party/tmpfileplus/tmpfileplus.c)
|
203
|
+
endif()
|
204
|
+
|
205
|
+
set(LXW_PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
|
206
|
+
set(LXW_LIB_DIR "${LXW_PROJECT_DIR}/lib")
|
207
|
+
add_library(${PROJECT_NAME} "")
|
208
|
+
target_sources(${PROJECT_NAME}
|
209
|
+
PRIVATE ${LXW_SOURCES}
|
210
|
+
PUBLIC ${LXW_HEADERS}
|
211
|
+
)
|
212
|
+
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES})
|
213
|
+
target_compile_definitions(${PROJECT_NAME} PRIVATE ${LXW_PRIVATE_COMPILE_DEFINITIONS})
|
214
|
+
target_include_directories(${PROJECT_NAME}
|
215
|
+
PRIVATE ${LXW_PRIVATE_INCLUDE_DIRS}
|
216
|
+
PUBLIC include include/xlsxwriter
|
217
|
+
)
|
218
|
+
|
219
|
+
if(MSVC)
|
220
|
+
if (NOT BUILD_SHARED_LIBS)
|
221
|
+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
222
|
+
COMMAND ${CMAKE_COMMAND} -E rename
|
223
|
+
${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb
|
224
|
+
$<TARGET_FILE_DIR:${PROJECT_NAME}>/${PROJECT_NAME}.pdb
|
225
|
+
)
|
226
|
+
endif()
|
227
|
+
endif()
|
228
|
+
|
229
|
+
# TESTS
|
230
|
+
# -----
|
231
|
+
|
232
|
+
# Create test and runner.
|
233
|
+
#
|
234
|
+
# Args:
|
235
|
+
# sources Name of variable holding source files
|
236
|
+
# target Test name
|
237
|
+
#
|
238
|
+
macro(CreateTest sources target)
|
239
|
+
set(output_name xlsxwriter_${target})
|
240
|
+
set(dependencies ${output_name})
|
241
|
+
|
242
|
+
add_executable(${output_name} ${${sources}})
|
243
|
+
target_link_libraries(${output_name} ${PROJECT_NAME})
|
244
|
+
target_compile_definitions(${output_name} PRIVATE TESTING COLOR_OK)
|
245
|
+
add_test(NAME ${output_name}
|
246
|
+
COMMAND ${output_name}
|
247
|
+
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
248
|
+
)
|
249
|
+
endmacro(CreateTest)
|
250
|
+
|
251
|
+
|
252
|
+
file(GLOB LXW_UTILITY_SOURCES test/unit/utility/test*.c)
|
253
|
+
file(GLOB LXW_XMLWRITER_SOURCES test/unit/xmlwriter/test*.c)
|
254
|
+
file(GLOB LXW_WORKSHEET_SOURCES test/unit/worksheet/test*.c)
|
255
|
+
file(GLOB LXW_SST_SOURCES test/unit/sst/test*.c)
|
256
|
+
file(GLOB LXW_WORKBOOK_SOURCES test/unit/workbook/test*.c)
|
257
|
+
file(GLOB LXW_APP_SOURCES test/unit/app/test*.c)
|
258
|
+
file(GLOB LXW_CONTENTTYPES_SOURCES test/unit/content_types/test*.c)
|
259
|
+
file(GLOB LXW_CORE_SOURCES test/unit/core/test*.c)
|
260
|
+
file(GLOB LXW_RELATIONSHIPS_SOURCES test/unit/relationships/test*.c)
|
261
|
+
file(GLOB LXW_FORMAT_SOURCES test/unit/format/test*.c)
|
262
|
+
file(GLOB LXW_STYLES_SOURCES test/unit/styles/test*.c)
|
263
|
+
file(GLOB LXW_DRAWING_SOURCES test/unit/drawing/test*.c)
|
264
|
+
file(GLOB LXW_CHART_SOURCES test/unit/chart/test*.c)
|
265
|
+
file(GLOB LXW_CUSTOM_SOURCES test/unit/custom/test*.c)
|
266
|
+
file(GLOB LXW_FUNCTIONAL_SOURCES test/functional/src/*.c)
|
267
|
+
|
268
|
+
set(LXW_UNIT_SOURCES
|
269
|
+
test/unit/test_all.c
|
270
|
+
${LXW_UTILITY_SOURCES}
|
271
|
+
${LXW_XMLWRITER_SOURCES}
|
272
|
+
${LXW_WORKSHEET_SOURCES}
|
273
|
+
${LXW_SST_SOURCES}
|
274
|
+
${LXW_WORKBOOK_SOURCES}
|
275
|
+
${LXW_APP_SOURCES}
|
276
|
+
${LXW_CONTENTTYPES_SOURCES}
|
277
|
+
${LXW_CORE_SOURCES}
|
278
|
+
${LXW_RELATIONSHIPS_SOURCES}
|
279
|
+
${LXW_FORMAT_SOURCES}
|
280
|
+
${LXW_STYLES_SOURCES}
|
281
|
+
${LXW_DRAWING_SOURCES}
|
282
|
+
${LXW_CHART_SOURCES}
|
283
|
+
${LXW_CUSTOM_SOURCES}
|
284
|
+
)
|
285
|
+
|
286
|
+
if(BUILD_TESTS)
|
287
|
+
# unit tests
|
288
|
+
CreateTest(LXW_UNIT_SOURCES unit)
|
289
|
+
|
290
|
+
# functional tests
|
291
|
+
# WARNING: currently doesn't work, since the Python tests expect
|
292
|
+
# in-source builds
|
293
|
+
#find_program(PYTHON python)
|
294
|
+
#foreach(source ${LXW_FUNCTIONAL_SOURCES})
|
295
|
+
# get_filename_component(basename ${source} NAME_WE)
|
296
|
+
# add_executable(${basename} ${source})
|
297
|
+
# target_link_libraries(${basename} xlsxwriter)
|
298
|
+
#endforeach(source)
|
299
|
+
endif()
|
300
|
+
|
301
|
+
# EXAMPLES
|
302
|
+
# --------
|
303
|
+
|
304
|
+
file(GLOB LXW_EXAMPLE_SOURCES examples/*.c)
|
305
|
+
|
306
|
+
if(BUILD_EXAMPLES)
|
307
|
+
foreach(source ${LXW_EXAMPLE_SOURCES})
|
308
|
+
get_filename_component(basename ${source} NAME_WE)
|
309
|
+
add_executable(${basename} ${source})
|
310
|
+
target_link_libraries(${basename} ${PROJECT_NAME})
|
311
|
+
endforeach(source)
|
312
|
+
endif()
|
313
|
+
|
314
|
+
# INSTALL
|
315
|
+
# -------
|
316
|
+
|
317
|
+
include(GNUInstallDirs)
|
318
|
+
|
319
|
+
if(MSVC)
|
320
|
+
if(CMAKE_CL_64)
|
321
|
+
set(MSVC_FOLDER_PREFIX x64)
|
322
|
+
else()
|
323
|
+
set(MSVC_FOLDER_PREFIX Win32)
|
324
|
+
endif()
|
325
|
+
|
326
|
+
install(TARGETS ${PROJECT_NAME}
|
327
|
+
LIBRARY DESTINATION "lib/${MSVC_FOLDER_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}"
|
328
|
+
ARCHIVE DESTINATION "lib/${MSVC_FOLDER_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}"
|
329
|
+
RUNTIME DESTINATION "bin/${MSVC_FOLDER_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}"
|
330
|
+
)
|
331
|
+
if (NOT BUILD_SHARED_LIBS)
|
332
|
+
install(FILES $<TARGET_FILE_DIR:${PROJECT_NAME}>/${PROJECT_NAME}.pdb
|
333
|
+
DESTINATION "lib/${MSVC_FOLDER_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}"
|
334
|
+
)
|
335
|
+
endif()
|
336
|
+
|
337
|
+
else(MSVC)
|
338
|
+
install(TARGETS ${PROJECT_NAME}
|
339
|
+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
340
|
+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
341
|
+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
342
|
+
)
|
343
|
+
endif(MSVC)
|
344
|
+
install(FILES include/xlsxwriter.h DESTINATION include)
|
345
|
+
install(DIRECTORY include/xlsxwriter
|
346
|
+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
347
|
+
FILES_MATCHING PATTERN "*.h"
|
348
|
+
)
|