fast_excel 0.4.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +4 -6
  3. data/.gitignore +3 -0
  4. data/.octocov.yml +28 -0
  5. data/CHANGELOG.md +16 -0
  6. data/Gemfile +5 -3
  7. data/examples/comment_options.rb +39 -0
  8. data/examples/example.rb +2 -0
  9. data/examples/example_date_time.rb +38 -0
  10. data/fast_excel.gemspec +4 -3
  11. data/lib/fast_excel/binding/format.rb +17 -0
  12. data/lib/fast_excel/binding/workbook.rb +80 -20
  13. data/lib/fast_excel/binding/worksheet.rb +81 -13
  14. data/lib/fast_excel/binding.rb +107 -7
  15. data/lib/fast_excel.rb +40 -32
  16. data/libxlsxwriter/.github/FUNDING.yml +1 -0
  17. data/libxlsxwriter/.github/ISSUE_TEMPLATE.md +85 -0
  18. data/libxlsxwriter/.github/PULL_REQUEST_TEMPLATE.md +130 -0
  19. data/libxlsxwriter/.github/workflows/cmake_actions.yml +48 -0
  20. data/libxlsxwriter/.github/workflows/code_style.yml +23 -0
  21. data/libxlsxwriter/.github/workflows/coverity.yml +22 -0
  22. data/libxlsxwriter/.github/workflows/make_actions.yml +52 -0
  23. data/libxlsxwriter/.github/workflows/valgrind.yml +23 -0
  24. data/libxlsxwriter/.github/workflows/windows_build.yml +54 -0
  25. data/libxlsxwriter/.github/workflows/zig_build.yml +22 -0
  26. data/libxlsxwriter/.gitignore +16 -1
  27. data/libxlsxwriter/.indent.pro +24 -0
  28. data/libxlsxwriter/CMakeLists.txt +156 -56
  29. data/libxlsxwriter/CONTRIBUTING.md +2 -2
  30. data/libxlsxwriter/Changes.txt +344 -2
  31. data/libxlsxwriter/LICENSE.txt +66 -8
  32. data/libxlsxwriter/Makefile +151 -54
  33. data/libxlsxwriter/Package.swift +42 -0
  34. data/libxlsxwriter/Readme.md +4 -2
  35. data/libxlsxwriter/build.zig +324 -0
  36. data/libxlsxwriter/build.zig.zon +11 -0
  37. data/libxlsxwriter/cmake/FindMINIZIP.cmake +3 -3
  38. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +6 -0
  39. data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
  40. data/libxlsxwriter/include/xlsxwriter/chart.h +236 -32
  41. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +7 -7
  42. data/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  43. data/libxlsxwriter/include/xlsxwriter/common.h +111 -50
  44. data/libxlsxwriter/include/xlsxwriter/content_types.h +8 -1
  45. data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  46. data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  47. data/libxlsxwriter/include/xlsxwriter/drawing.h +11 -20
  48. data/libxlsxwriter/include/xlsxwriter/format.h +121 -8
  49. data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  50. data/libxlsxwriter/include/xlsxwriter/metadata.h +49 -0
  51. data/libxlsxwriter/include/xlsxwriter/packager.h +27 -16
  52. data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  53. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  54. data/libxlsxwriter/include/xlsxwriter/styles.h +13 -7
  55. data/libxlsxwriter/include/xlsxwriter/table.h +51 -0
  56. data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  57. data/libxlsxwriter/include/xlsxwriter/third_party/emyg_dtoa.h +26 -0
  58. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +27 -25
  59. data/libxlsxwriter/include/xlsxwriter/third_party/md5.h +45 -0
  60. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +155 -153
  61. data/libxlsxwriter/include/xlsxwriter/utility.h +70 -8
  62. data/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  63. data/libxlsxwriter/include/xlsxwriter/workbook.h +218 -47
  64. data/libxlsxwriter/include/xlsxwriter/worksheet.h +2770 -241
  65. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +12 -8
  66. data/libxlsxwriter/include/xlsxwriter.h +4 -2
  67. data/libxlsxwriter/libxlsxwriter.podspec +8 -5
  68. data/libxlsxwriter/src/Makefile +58 -21
  69. data/libxlsxwriter/src/app.c +5 -2
  70. data/libxlsxwriter/src/chart.c +396 -81
  71. data/libxlsxwriter/src/chartsheet.c +22 -22
  72. data/libxlsxwriter/src/comment.c +443 -0
  73. data/libxlsxwriter/src/content_types.c +40 -1
  74. data/libxlsxwriter/src/core.c +2 -2
  75. data/libxlsxwriter/src/custom.c +1 -1
  76. data/libxlsxwriter/src/drawing.c +160 -40
  77. data/libxlsxwriter/src/format.c +109 -25
  78. data/libxlsxwriter/src/hash_table.c +1 -1
  79. data/libxlsxwriter/src/metadata.c +283 -0
  80. data/libxlsxwriter/src/packager.c +794 -94
  81. data/libxlsxwriter/src/relationships.c +1 -1
  82. data/libxlsxwriter/src/shared_strings.c +2 -4
  83. data/libxlsxwriter/src/styles.c +353 -58
  84. data/libxlsxwriter/src/table.c +304 -0
  85. data/libxlsxwriter/src/theme.c +1 -1
  86. data/libxlsxwriter/src/utility.c +143 -43
  87. data/libxlsxwriter/src/vml.c +1062 -0
  88. data/libxlsxwriter/src/workbook.c +567 -77
  89. data/libxlsxwriter/src/worksheet.c +6668 -1462
  90. data/libxlsxwriter/src/xmlwriter.c +95 -5
  91. data/libxlsxwriter/third_party/dtoa/Makefile +42 -0
  92. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.c +461 -0
  93. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.h +26 -0
  94. data/libxlsxwriter/third_party/md5/Makefile +42 -0
  95. data/libxlsxwriter/third_party/md5/md5.c +291 -0
  96. data/libxlsxwriter/third_party/md5/md5.h +45 -0
  97. data/libxlsxwriter/third_party/minizip/Makefile +3 -8
  98. data/libxlsxwriter/third_party/minizip/Makefile.orig +8 -4
  99. data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +1 -1
  100. data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
  101. data/libxlsxwriter/third_party/minizip/crypt.h +13 -16
  102. data/libxlsxwriter/third_party/minizip/ioapi.c +31 -57
  103. data/libxlsxwriter/third_party/minizip/ioapi.h +31 -23
  104. data/libxlsxwriter/third_party/minizip/iowin32.c +29 -45
  105. data/libxlsxwriter/third_party/minizip/iowin32.h +4 -4
  106. data/libxlsxwriter/third_party/minizip/miniunz.c +29 -56
  107. data/libxlsxwriter/third_party/minizip/minizip.c +38 -49
  108. data/libxlsxwriter/third_party/minizip/mztools.c +1 -7
  109. data/libxlsxwriter/third_party/minizip/unzip.c +202 -342
  110. data/libxlsxwriter/third_party/minizip/unzip.h +74 -74
  111. data/libxlsxwriter/third_party/minizip/zip.c +165 -218
  112. data/libxlsxwriter/third_party/minizip/zip.h +164 -154
  113. data/libxlsxwriter/third_party/tmpfileplus/Makefile +3 -3
  114. data/libxlsxwriter/version.txt +1 -1
  115. data/sonar-project.properties +4 -0
  116. data/test/auto_width_test.rb +20 -0
  117. data/test/color_to_hex_test.rb +15 -0
  118. data/test/comment_opt_test.rb +76 -0
  119. data/test/date_test.rb +14 -0
  120. data/test/default_format_test.rb +1 -1
  121. data/test/format_test.rb +5 -1
  122. data/test/get_worksheet_test.rb +28 -0
  123. data/test/test_helper.rb +7 -4
  124. data/test/tmpdir_test.rb +32 -0
  125. data/test/validations_test.rb +25 -19
  126. data/test/worksheet_test.rb +6 -1
  127. metadata +62 -13
  128. data/libxlsxwriter/.travis.yml +0 -37
  129. data/test/reopen_test.rb +0 -22
@@ -0,0 +1,54 @@
1
+ name: Test Cmake build on Windows
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ name: CMake on Windows
8
+
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ cmake_flags: ["-DBUILD_EXAMPLES=ON -DBUILD_TESTS=ON",
13
+ "-DUSE_DTOA_LIBRARY=ON -DBUILD_TESTS=ON",
14
+ #"-DUSE_SYSTEM_MINIZIP=ON -DBUILD_TESTS=ON",
15
+ #"-DUSE_SYSTEM_MINIZIP=ON -DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON",
16
+ "-DUSE_OPENSSL_MD5=ON -DBUILD_TESTS=ON",
17
+ ]
18
+
19
+ runs-on: windows-latest
20
+
21
+ steps:
22
+ - uses: actions/checkout@v2
23
+
24
+ - name: Install dependencies
25
+ working-directory: ${{env.GITHUB_WORKSPACE}}
26
+ shell: cmd
27
+ run: |
28
+ vcpkg.exe install zlib:x64-windows minizip:x64-windows openssl:x64-windows
29
+ vcpkg.exe integrate install
30
+ pip install pytest
31
+
32
+ - name: Configure CMake
33
+ working-directory: ${{env.GITHUB_WORKSPACE}}
34
+ shell: cmd
35
+ run: |
36
+ cd cmake
37
+ call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
38
+ cmake .. -DCMAKE_BUILD_TYPE=Release ${{ matrix.cmake_flags }} -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -A x64
39
+
40
+ - name: Build
41
+ working-directory: ${{env.GITHUB_WORKSPACE}}
42
+ shell: cmd
43
+ run: |
44
+ cd cmake
45
+ call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
46
+ cmake --build . --config Release
47
+
48
+ - name: Test
49
+ working-directory: ${{env.GITHUB_WORKSPACE}}
50
+ shell: cmd
51
+ run: |
52
+ cd cmake
53
+ copy test\functional\src\Release\*.exe test\functional\src
54
+ pytest -v test/functional
@@ -0,0 +1,22 @@
1
+ name: Zig Build
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ runs-on: [ubuntu-latest, macos-latest, windows-latest]
11
+ runs-on: ${{ matrix.runs-on }}
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ with:
15
+ submodules: recursive
16
+ fetch-depth: 0
17
+ - uses: goto-bus-stop/setup-zig@v2
18
+ with:
19
+ version: 0.11.0
20
+
21
+ - name: Build Summary
22
+ run: zig build -DBUILD_TESTS -DBUILD_EXAMPLES -DUSE_SYSTEM_MINIZIP --summary all -freference-trace
@@ -1,11 +1,14 @@
1
1
  *.a
2
2
  *.o
3
3
  *.so
4
+ *.so.*
4
5
  *.to
5
6
  *.lo
6
7
  *.la
7
8
  *.dylib
8
9
  *.dll
10
+ *.gcno
11
+ *.gcda
9
12
  test_*
10
13
  !test_*.c
11
14
  !test_*.cpp
@@ -35,10 +38,12 @@ docs/latex
35
38
  _temp.c
36
39
  examples/*
37
40
  !examples/*.c
38
- !examples/logo.png
41
+ !examples/*.png
39
42
  !examples/Makefile
43
+ !examples/vbaProject.bin
40
44
  cov-int
41
45
  libxlsxwriter-coverity.tgz
46
+ build
42
47
 
43
48
  third_party/zlib-1.2.8/configure.log
44
49
  third_party/zlib-1.2.8/contrib/minizip/miniunz
@@ -48,3 +53,13 @@ third_party/zlib-1.2.8/examplesh
48
53
  third_party/zlib-1.2.8/minigzip
49
54
  third_party/zlib-1.2.8/minigzipsh
50
55
  third_party/zlib-1.2.8/zlib.pc
56
+
57
+ cmake
58
+ !cmake/FindMINIZIP.cmake
59
+ !cmake/FindPackage.cmake
60
+ !cmake/i686-toolchain.cmake
61
+
62
+ .vscode
63
+
64
+ zig-cache/
65
+ zig-out/
@@ -44,8 +44,10 @@
44
44
 
45
45
  /* libxlsxwriter typedefs. */
46
46
  -T lxw_app
47
+ -T lxw_author_id
47
48
  -T lxw_autofilter
48
49
  -T lxw_border
50
+ -T lxw_button_options
49
51
  -T lxw_cell
50
52
  -T lxw_chart
51
53
  -T lxw_chart_axis
@@ -56,6 +58,8 @@
56
58
  -T lxw_chart_axis_tick_position
57
59
  -T lxw_chart_axis_type
58
60
  -T lxw_chart_blank
61
+ -T lxw_chart_custom_label
62
+ -T lxw_chart_data_label
59
63
  -T lxw_chart_error_bar_axis
60
64
  -T lxw_chart_error_bar_cap
61
65
  -T lxw_chart_error_bar_direction
@@ -71,6 +75,7 @@
71
75
  -T lxw_chart_line_dash_type
72
76
  -T lxw_chart_marker
73
77
  -T lxw_chart_marker_type
78
+ -T lxw_chart_options
74
79
  -T lxw_chart_pattern
75
80
  -T lxw_chart_pattern_type
76
81
  -T lxw_chart_point
@@ -83,10 +88,16 @@
83
88
  -T lxw_col_options
84
89
  -T lxw_col_t
85
90
  -T lxw_color_t
91
+ -T lxw_comment
92
+ -T lxw_comment_options
93
+ -T lxw_cond_format_hash_element
94
+ -T lxw_cond_format_obj
95
+ -T lxw_conditional_format
86
96
  -T lxw_content_types
87
97
  -T lxw_core
88
98
  -T lxw_custom
89
99
  -T lxw_custom_property
100
+ -T lxw_data_val_obj
90
101
  -T lxw_data_validation
91
102
  -T lxw_datetime
92
103
  -T lxw_defined_name
@@ -94,21 +105,28 @@
94
105
  -T lxw_drawing
95
106
  -T lxw_drawing_coords
96
107
  -T lxw_drawing_object
108
+ -T lxw_drawing_rel_id
97
109
  -T lxw_error
98
110
  -T lxw_fill
111
+ -T lxw_filter_rule
112
+ -T lxw_filter_rule_obj
99
113
  -T lxw_font
100
114
  -T lxw_format
101
115
  -T lxw_hash_element
102
116
  -T lxw_hash_table
103
117
  -T lxw_header_footer_options
104
118
  -T lxw_heading_pair
119
+ -T lxw_image_md5
105
120
  -T lxw_image_options
106
121
  -T lxw_merged_range
122
+ -T lxw_metadata
123
+ -T lxw_object_properties
107
124
  -T lxw_packager
108
125
  -T lxw_panes
109
126
  -T lxw_part_name
110
127
  -T lxw_print_area
111
128
  -T lxw_protection
129
+ -T lxw_protection_obj
112
130
  -T lxw_rel_tuple
113
131
  -T lxw_relationships
114
132
  -T lxw_repeat_cols
@@ -124,8 +142,14 @@
124
142
  -T lxw_sheet
125
143
  -T lxw_sst
126
144
  -T lxw_styles
145
+ -T lxw_table
146
+ -T lxw_table_column
147
+ -T lxw_table_obj
148
+ -T lxw_table_options
127
149
  -T lxw_theme
128
150
  -T lxw_tuple
151
+ -T lxw_vml
152
+ -T lxw_vml_obj
129
153
  -T lxw_workbook
130
154
  -T lxw_workbook_options
131
155
  -T lxw_worksheet
@@ -47,6 +47,24 @@
47
47
  # during configuration. This may produce bugs while cross-
48
48
  # compiling or using MinGW/MSYS.
49
49
  #
50
+ # USE_DTOA_LIBRARY
51
+ # Use the third party emyg_dtoa() library (default off). The
52
+ # emyg_dtoa() library is used to avoid sprintf double issues with
53
+ # different locale settings. To enable this library, pass
54
+ # `-DUSE_DTOA_LIBRARY=ON` during configuration.
55
+ #
56
+ # USE_NO_MD5
57
+ # Compile without third party MD5 support. This will turn off the
58
+ # functionality of avoiding duplicate image files in the output xlsx
59
+ # file. To enable this option pass `-DUSE_NO_MD5=ON` during
60
+ # configuration.
61
+ #
62
+ # USE_OPENSSL_MD5 Compile with OpenSSL MD5 support. This will link
63
+ # against libcrypto for MD5 support rather than using the local MD5
64
+ # support. MD5 support is required to avoid duplicate image files in
65
+ # the output xlsx file. To enable this option pass
66
+ # `-DUSE_OPENSSL_MD5=ON` during configuration.
67
+ #
50
68
  # USE_STATIC_MSVC_RUNTIME
51
69
  # Use the static msvc runtime library when compiling with msvc (default off)
52
70
  # To enable, pass `-DUSE_STATIC_MSVC_RUNTIME` during configuration.
@@ -88,24 +106,39 @@ else()
88
106
  cmake_minimum_required(VERSION 3.1)
89
107
  endif()
90
108
 
91
- SET(PROJECT_NAME "xlsxwriter" CACHE STRING "Optional project and binary name")
109
+ SET(XLSX_PROJECT_NAME "xlsxwriter" CACHE STRING "Optional project and binary name")
92
110
  set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
93
- project(${PROJECT_NAME} C)
111
+ project(${XLSX_PROJECT_NAME} C)
94
112
  enable_testing()
95
113
 
114
+ # POLICY
115
+ # ------
116
+
117
+ # The use of the word ZLIB_ROOT should still work prior to "3.12.0",
118
+ # just it's been generalized for all packages now. Just set the policy
119
+ # to new, so we use it, and it will be used prior to 3.12 anyway.
120
+ if(${CMAKE_VERSION} VERSION_GREATER "3.12" OR ${CMAKE_VERSION} VERSION_EQUAL "3.12")
121
+ cmake_policy(SET CMP0074 NEW)
122
+ endif()
123
+
96
124
  # OPTIONS
97
125
  # -------
98
-
99
126
  SET(ZLIB_ROOT "" CACHE STRING "Optional root for the ZLIB installation")
100
127
 
101
128
  option(BUILD_TESTS "Build libxlsxwriter tests" OFF)
102
129
  option(BUILD_EXAMPLES "Build libxlsxwriter examples" OFF)
103
130
  option(USE_SYSTEM_MINIZIP "Use system minizip installation" OFF)
104
131
  option(USE_STANDARD_TMPFILE "Use the C standard library's tmpfile()" OFF)
132
+ option(USE_NO_MD5 "Build libxlsxwriter without third party MD5 lib" OFF)
133
+ option(USE_OPENSSL_MD5 "Build libxlsxwriter with the OpenSSL MD5 lib" OFF)
134
+ option(USE_MEM_FILE "Use fmemopen()/open_memstream() in place of temporary files" OFF)
105
135
  option(IOAPI_NO_64 "Disable 64-bit filesystem support" OFF)
136
+ option(USE_DTOA_LIBRARY "Use the locale independent third party Milo Yip DTOA library" OFF)
137
+
106
138
  if(MSVC)
107
139
  option(USE_STATIC_MSVC_RUNTIME "Use the static runtime library" OFF)
108
140
  endif()
141
+
109
142
  if(DEFINED ENV{${ZLIB_ROOT}})
110
143
  set(ZLIB_ROOT $ENV{ZLIB_ROOT})
111
144
  endif()
@@ -116,7 +149,6 @@ endif()
116
149
 
117
150
  # CONFIGURATIONS
118
151
  # --------------
119
-
120
152
  if(USE_SYSTEM_MINIZIP)
121
153
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_SYSTEM_MINIZIP)
122
154
  endif()
@@ -125,6 +157,25 @@ if(USE_STANDARD_TMPFILE)
125
157
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_STANDARD_TMPFILE)
126
158
  endif()
127
159
 
160
+ if(NOT USE_OPENSSL_MD5 AND USE_NO_MD5)
161
+ list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_NO_MD5)
162
+ endif()
163
+
164
+ if(USE_OPENSSL_MD5)
165
+ list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_OPENSSL_MD5)
166
+ if(NOT MSVC)
167
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations")
168
+ endif()
169
+ endif()
170
+
171
+ if(USE_MEM_FILE OR USE_FMEMOPEN)
172
+ list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_FMEMOPEN)
173
+ endif()
174
+
175
+ if(USE_DTOA_LIBRARY)
176
+ list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_DTOA_LIBRARY)
177
+ endif()
178
+
128
179
  if(NOT BUILD_SHARED_LIBS)
129
180
  if(UNIX)
130
181
  set(CMAKE_POSITION_INDEPENDENT_CODE ON)
@@ -132,15 +183,13 @@ if(NOT BUILD_SHARED_LIBS)
132
183
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static -static-libgcc -Wno-char-subscripts -Wno-long-long")
133
184
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS USE_FILE32API)
134
185
  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")
186
+ set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"")
187
+ set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Ox /Zi /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"")
188
+ set(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} /Zi /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"")
189
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Fd\"${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb\"")
139
190
  endif()
140
191
  endif()
141
192
 
142
- message(status "BEFORE: ${CMAKE_C_FLAGS_DEBUG}")
143
-
144
193
  if(MSVC AND USE_STATIC_MSVC_RUNTIME)
145
194
  foreach(flag_var CMAKE_C_FLAGS
146
195
  CMAKE_C_FLAGS_DEBUG
@@ -153,33 +202,37 @@ if(MSVC AND USE_STATIC_MSVC_RUNTIME)
153
202
  endforeach()
154
203
  endif()
155
204
 
205
+ # Configure pkg-config
206
+ file(READ "include/xlsxwriter.h" ver)
207
+
208
+ string(REGEX MATCH "LXW_VERSION \"([^\"]+)\"" _ ${ver})
209
+ set(VERSION ${CMAKE_MATCH_1})
210
+ string(REGEX MATCH "LXW_SOVERSION \"([^\"]+)\"" _ ${ver})
211
+ set(SOVERSION ${CMAKE_MATCH_1})
212
+ set(PREFIX ${CMAKE_INSTALL_PREFIX})
213
+
214
+ configure_file(dev/release/pkg-config.txt xlsxwriter.pc @ONLY)
215
+
156
216
  # INCLUDES
157
217
  # --------
158
-
159
218
  enable_language(CXX)
160
219
  list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
161
220
 
162
221
  # ZLIB
163
- find_package(ZLIB REQUIRED "1.0")
222
+ find_package(ZLIB "1.0" REQUIRED)
164
223
  list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
165
224
  message("zlib version: " ${ZLIB_VERSION})
166
225
 
167
226
  # MINIZIP
168
227
  if (USE_SYSTEM_MINIZIP)
169
- find_package(MINIZIP REQUIRED "1.0")
228
+ find_package(MINIZIP "1.0" REQUIRED)
170
229
  list(APPEND LXW_PRIVATE_INCLUDE_DIRS ${MINIZIP_INCLUDE_DIRS})
171
230
  endif()
172
231
 
173
232
  # LIBRARY
174
233
  # -------
175
-
176
234
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS NOCRYPT NOUNCRYPT)
177
235
 
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
236
  # Ensure CRT Secure warnings are disabled
184
237
  if(MSVC)
185
238
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS)
@@ -190,27 +243,64 @@ if(BUILD_TESTS)
190
243
  list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS TESTING)
191
244
  endif()
192
245
 
246
+ # Define "LXW_BIG_ENDIAN" macro on big-endian architectures
247
+ include(TestBigEndian)
248
+ TEST_BIG_ENDIAN(LXW_TARGET_BIG_ENDIAN)
249
+ if(LXW_TARGET_BIG_ENDIAN)
250
+ list(APPEND LXW_PRIVATE_COMPILE_DEFINITIONS LXW_BIG_ENDIAN)
251
+ endif()
252
+
193
253
  file(GLOB LXW_SOURCES src/*.c)
194
254
  file(GLOB_RECURSE LXW_HEADERS RELATIVE include *.h)
255
+
195
256
  if(NOT USE_SYSTEM_MINIZIP)
196
257
  list(APPEND LXW_SOURCES third_party/minizip/ioapi.c third_party/minizip/zip.c)
197
258
  if(MSVC)
198
259
  list(APPEND LXW_SOURCES third_party/minizip/iowin32.c)
199
260
  endif()
200
261
  endif()
262
+
201
263
  if (NOT USE_STANDARD_TMPFILE)
202
264
  list(APPEND LXW_SOURCES third_party/tmpfileplus/tmpfileplus.c)
203
265
  endif()
204
266
 
267
+ if(NOT USE_OPENSSL_MD5 AND NOT USE_NO_MD5)
268
+ list(APPEND LXW_SOURCES third_party/md5/md5.c)
269
+ endif()
270
+
271
+ if(USE_OPENSSL_MD5)
272
+ find_package(OpenSSL REQUIRED)
273
+ if(OpenSSL_FOUND)
274
+ include_directories(${OPENSSL_INCLUDE_DIR})
275
+ message(STATUS "OpenSSL version: ${OPENSSL_VERSION}")
276
+ endif()
277
+ endif()
278
+
279
+ if (USE_DTOA_LIBRARY)
280
+ list(APPEND LXW_SOURCES third_party/dtoa/emyg_dtoa.c)
281
+ endif()
282
+
205
283
  set(LXW_PROJECT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
206
284
  set(LXW_LIB_DIR "${LXW_PROJECT_DIR}/lib")
207
285
  add_library(${PROJECT_NAME} "")
286
+ set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${SOVERSION})
208
287
  target_sources(${PROJECT_NAME}
209
288
  PRIVATE ${LXW_SOURCES}
210
289
  PUBLIC ${LXW_HEADERS}
211
290
  )
212
- target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES})
291
+ target_link_libraries(${PROJECT_NAME} LINK_PUBLIC ${ZLIB_LIBRARIES} ${MINIZIP_LIBRARIES} ${LIB_CRYPTO} ${OPENSSL_CRYPTO_LIBRARY})
213
292
  target_compile_definitions(${PROJECT_NAME} PRIVATE ${LXW_PRIVATE_COMPILE_DEFINITIONS})
293
+
294
+ # /utf-8 needs VS2015 Update 2 or above.
295
+ # In CMake 3.7 and above, we can use (MSVC_VERSION GREATER_EQUAL 1900) here.
296
+ if(MSVC AND NOT (MSVC_VERSION LESS 1900))
297
+ target_compile_options(${PROJECT_NAME} PRIVATE /utf-8)
298
+ endif()
299
+
300
+ if (WINDOWSSTORE)
301
+ target_compile_definitions(${PROJECT_NAME} PRIVATE -DIOWIN32_USING_WINRT_API)
302
+ endif()
303
+
214
304
  target_include_directories(${PROJECT_NAME}
215
305
  PRIVATE ${LXW_PRIVATE_INCLUDE_DIRS}
216
306
  PUBLIC include include/xlsxwriter
@@ -225,6 +315,7 @@ target_include_directories(${PROJECT_NAME}
225
315
  # sources Name of variable holding source files
226
316
  # target Test name
227
317
  #
318
+
228
319
  macro(CreateTest sources target)
229
320
  set(output_name xlsxwriter_${target})
230
321
  set(dependencies ${output_name})
@@ -238,7 +329,6 @@ macro(CreateTest sources target)
238
329
  )
239
330
  endmacro(CreateTest)
240
331
 
241
-
242
332
  file(GLOB LXW_UTILITY_SOURCES test/unit/utility/test*.c)
243
333
  file(GLOB LXW_XMLWRITER_SOURCES test/unit/xmlwriter/test*.c)
244
334
  file(GLOB LXW_WORKSHEET_SOURCES test/unit/worksheet/test*.c)
@@ -255,6 +345,8 @@ file(GLOB LXW_CHART_SOURCES test/unit/chart/test*.c)
255
345
  file(GLOB LXW_CUSTOM_SOURCES test/unit/custom/test*.c)
256
346
  file(GLOB LXW_FUNCTIONAL_SOURCES test/functional/src/*.c)
257
347
 
348
+ if(NOT MSVC)
349
+ # Skip unit tests on Windows since ctest.h doesn't support it.
258
350
  set(LXW_UNIT_SOURCES
259
351
  test/unit/test_all.c
260
352
  ${LXW_UTILITY_SOURCES}
@@ -272,25 +364,52 @@ set(LXW_UNIT_SOURCES
272
364
  ${LXW_CHART_SOURCES}
273
365
  ${LXW_CUSTOM_SOURCES}
274
366
  )
367
+ else()
368
+ set(LXW_UNIT_SOURCES
369
+ test/cpp/test_compilation.cpp
370
+ )
371
+ endif()
275
372
 
276
373
  if(BUILD_TESTS)
277
374
  # unit tests
278
375
  CreateTest(LXW_UNIT_SOURCES unit)
279
376
 
280
377
  # functional tests
281
- # WARNING: currently doesn't work, since the Python tests expect
282
- # in-source builds
283
- #find_program(PYTHON python)
284
- #foreach(source ${LXW_FUNCTIONAL_SOURCES})
285
- # get_filename_component(basename ${source} NAME_WE)
286
- # add_executable(${basename} ${source})
287
- # target_link_libraries(${basename} xlsxwriter)
288
- #endforeach(source)
378
+ find_package(Python COMPONENTS Interpreter REQUIRED)
379
+ find_program(Pytest_EXECUTABLE NAMES pytest)
380
+
381
+ if (NOT Pytest_EXECUTABLE)
382
+ message("Please install the Python pytest library to run functional tests:")
383
+ message(" pip install pytest\n")
384
+ endif()
385
+
386
+ foreach(source ${LXW_FUNCTIONAL_SOURCES})
387
+ get_filename_component(basename ${source} NAME_WE)
388
+ add_executable(${basename} ${source})
389
+ target_link_libraries(${basename} xlsxwriter)
390
+ set_target_properties(${basename} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "test/functional/src")
391
+ endforeach(source)
392
+
393
+ add_custom_command(TARGET xlsxwriter_unit POST_BUILD
394
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_SOURCE_DIR}/test/functional test/functional
395
+ )
396
+
397
+ if(USE_NO_MD5)
398
+ add_test(NAME functional
399
+ COMMAND pytest -v test/functional -m "not skipif"
400
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
401
+ )
402
+ else()
403
+ add_test(NAME functional
404
+ COMMAND pytest -v test/functional
405
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
406
+ )
407
+ endif()
408
+
289
409
  endif()
290
410
 
291
411
  # EXAMPLES
292
412
  # --------
293
-
294
413
  file(GLOB LXW_EXAMPLE_SOURCES examples/*.c)
295
414
 
296
415
  if(BUILD_EXAMPLES)
@@ -298,41 +417,22 @@ if(BUILD_EXAMPLES)
298
417
  get_filename_component(basename ${source} NAME_WE)
299
418
  add_executable(${basename} ${source})
300
419
  target_link_libraries(${basename} ${PROJECT_NAME})
420
+ set_target_properties(${basename} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "examples")
301
421
  endforeach(source)
302
422
  endif()
303
423
 
304
424
  # INSTALL
305
425
  # -------
306
-
307
426
  include(GNUInstallDirs)
308
427
 
309
- if(MSVC)
310
- if(CMAKE_CL_64)
311
- set(MSVC_FOLDER_PREFIX x64)
312
- else()
313
- set(MSVC_FOLDER_PREFIX Win32)
314
- endif()
315
-
316
- install(TARGETS ${PROJECT_NAME}
317
- LIBRARY DESTINATION "lib/${MSVC_FOLDER_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}"
318
- ARCHIVE DESTINATION "lib/${MSVC_FOLDER_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}"
319
- RUNTIME DESTINATION "bin/${MSVC_FOLDER_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}"
320
- )
321
- if (NOT BUILD_SHARED_LIBS)
322
- install(FILES ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pdb
323
- DESTINATION "lib/${MSVC_FOLDER_PREFIX}/\${CMAKE_INSTALL_CONFIG_NAME}"
324
- )
325
- endif()
326
-
327
- else(MSVC)
328
- install(TARGETS ${PROJECT_NAME}
329
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
330
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
331
- RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
332
- )
333
- endif(MSVC)
428
+ install(TARGETS ${PROJECT_NAME}
429
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
430
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
431
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
432
+ )
334
433
  install(FILES include/xlsxwriter.h DESTINATION include)
335
434
  install(DIRECTORY include/xlsxwriter
336
435
  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
337
436
  FILES_MATCHING PATTERN "*.h"
338
437
  )
438
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/xlsxwriter.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
@@ -181,9 +181,9 @@ If you have `valgrind` installed you can use the test suite to check for memory
181
181
  ```
182
182
 
183
183
  When you push your changes they will also be tested automatically using
184
- [Travis CI][travis].
184
+ [GitHub Actions][actions].
185
185
 
186
- [Travis]: https://travis-ci.org/jmcnamara/libxlsxwriter/
186
+ [actions]: https://github.com/jmcnamara/libxlsxwriter/actions
187
187
  [pytest]: http://pytest.org/
188
188
 
189
189