Skip to content

Commit

Permalink
Pack all source code and compile on install
Browse files Browse the repository at this point in the history
  • Loading branch information
Paxa committed Mar 6, 2017
1 parent d751cd6 commit 0a59866
Show file tree
Hide file tree
Showing 93 changed files with 41,730 additions and 12 deletions.
7 changes: 5 additions & 2 deletions .gitignore
@@ -1,4 +1,3 @@
libxlsxwriter
.ruby-version
try.c
try.rb
Expand All @@ -7,4 +6,8 @@ gen_ffi.rb
*.xlsx
a.out
.DS_Store
*.gem
*.gem
libxlsxwriter/dev
libxlsxwriter/docs
libxlsxwriter/examples
libxlsxwriter/test
14 changes: 14 additions & 0 deletions Makefile
@@ -0,0 +1,14 @@
Q=@
ifdef V
Q=
endif

all :
@echo "Compiling libxlsxwriter ..."
$(Q)$(MAKE) -C libxlsxwriter

clean :
#$(Q)$(MAKE) clean -C libxlsxwriter

install :
@echo "Nothing to install"
9 changes: 7 additions & 2 deletions README.md
Expand Up @@ -2,7 +2,12 @@

```ruby
workbook = FastExcel.open("hello_world_ffi.xlsx", constant_memory: true)
worksheet = workbook.add_worksheet("Garuda Payments")
workbook.default_format.set(
font_size: 0, # user's default
font_family: "Arial"
)

worksheet = workbook.add_worksheet("Example Report")

bold = workbook.bold_cell_format
worksheet.set_column(0, 0, FastExcel::DEF_COL_WIDTH, bold)
Expand Down Expand Up @@ -34,5 +39,5 @@ end
workbook.close
```

This repositiry and gem contain precompiled [libxlsxwriter](https://github.com/jmcnamara/libxlsxwriter) for MacOs, Linux with glibc and Alpine Linux
This repositiry and gem contain sources of [libxlsxwriter](https://github.com/jmcnamara/libxlsxwriter)

10 changes: 10 additions & 0 deletions Rakefile
Expand Up @@ -24,4 +24,14 @@ namespace :build do
system("docker cp #{last_container_id}:/srv/libxlsxwriter/lib/libxlsxwriter.so ./binaries/libxlsxwriter-alpine.so")
system("docker rm #{last_container_id}")
end
end

task :sync do
require 'fileutils'
FileUtils.rm_rf("./libxlsxwriter")
system("git clone --depth 10 git@github.com:Paxa/libxlsxwriter.git")
Dir.chdir("./libxlsxwriter") do
system("git show --pretty='format:%cd %h' --date=iso --quiet > version.txt")
FileUtils.rm_rf("./.git")
end
end
Binary file removed binaries/libxlsxwriter-alpine.so
Binary file not shown.
Binary file removed binaries/libxlsxwriter-darwin.dylib
Binary file not shown.
Binary file removed binaries/libxlsxwriter-glibc.so
Binary file not shown.
Empty file added extconf.rb
Empty file.
4 changes: 3 additions & 1 deletion fast_excel.gemspec
@@ -1,18 +1,20 @@
Gem::Specification.new do |s|
s.name = "fast_excel"
s.version = "0.1.4"
s.version = "0.1.5"
s.author = ["Pavel Evstigneev"]
s.email = ["pavel.evst@gmail.com"]
s.homepage = "https://github.com/paxa/fast_excel"
s.summary = %q{Ultra Fast Excel Writter}
s.description = "Wrapper for libxlsxwriter using ffi"
s.license = 'MIT'
s.has_rdoc = false
s.required_ruby_version = '~> 2.0'

s.files = `git ls-files`.split("\n")
s.test_files = []

s.require_paths = ["lib"]
s.extensions = ["extconf.rb"]

s.add_runtime_dependency "ffi", ["> 1.9", "< 2"]
end
10 changes: 3 additions & 7 deletions lib/fast_excel/binding.rb
Expand Up @@ -6,16 +6,12 @@ module Libxlsxwriter
extend FFI::Library

LIB_FILENAME = if RUBY_PLATFORM =~ /darwin/
"libxlsxwriter-darwin.dylib"
"libxlsxwriter.dylib"
else
if File.exist?('/etc/alpine-release')
"libxlsxwriter-alpine.so"
else
"libxlsxwriter-glibc.so"
end
"libxlsxwriter.so"
end

ffi_lib File.expand_path("./../../../binaries/#{LIB_FILENAME}", __FILE__)
ffi_lib File.expand_path("./../../../libxlsxwriter/lib/#{LIB_FILENAME}", __FILE__)

def self.attach_function(name, *_)
begin; super; rescue FFI::NotFoundError => e
Expand Down
3 changes: 3 additions & 0 deletions lib/rubygems_plugin.rb
@@ -0,0 +1,3 @@
Gem.post_install do |installer|
puts "Post install message"
end
49 changes: 49 additions & 0 deletions libxlsxwriter/.gitignore
@@ -0,0 +1,49 @@
*.a
*.o
*.so
*.to
*.lo
*.la
*.dylib
*.dll
test_*
!test_*.c
!test_*.cpp
!test_*.py
*.tar.gz
*~
TAGS
.#*
*#
~*xlsx
*.xlsx
*.bak
!test/functional/xlsx_files/*.xlsx
*.pyc
.cproject
.project
.pydevproject
.settings/
.DS_Store
__pycache__
.cache
docs/html
docs/latex
.deps
.dirstamp
_temp.c
examples/*
!examples/*.c
!examples/logo.png
!examples/Makefile
cov-int
libxlsxwriter-coverity.tgz

third_party/zlib-1.2.8/configure.log
third_party/zlib-1.2.8/contrib/minizip/miniunz
third_party/zlib-1.2.8/contrib/minizip/minizip
third_party/zlib-1.2.8/example
third_party/zlib-1.2.8/examplesh
third_party/zlib-1.2.8/minigzip
third_party/zlib-1.2.8/minigzipsh
third_party/zlib-1.2.8/zlib.pc
125 changes: 125 additions & 0 deletions libxlsxwriter/.indent.pro
@@ -0,0 +1,125 @@
/*
* Indent rules for libxlsxwriter.
*
* The rules for user defined typedefs can be update as follows:
*
perl -i -pe 'print and last if /[l]ibxlsxwriter typedefs/' .indent.pro
ack -h typedef include/xlsxwriter/*.h src/*.c | perl -lne 'print "-T $1" if /\w+\s+\w+\s+(\w+)/' | sort >> .indent.pro
*
*/

/* Command line options used with GNU indent 2.2.10 */
--braces-on-if-line
--braces-on-struct-decl-line
--case-indentation 4
--continue-at-parentheses
--declaration-comment-column 0
--format-first-column-comments
--honour-newlines
--ignore-profile
--indent-label 0
--indent-level 4
--no-space-after-function-call-names
--no-tabs
--swallow-optional-blank-lines

/* Typedefs used in the code. */
-T int8_t
-T int16_t
-T int32_t
-T int64_t
-T uint8_t
-T uint16_t
-T uint32_t
-T uint64_t
-T ssize_t
-T size_t
-T time_t

-T LIST_ENTRY
-T RB_ENTRY
-T SLIST_ENTRY
-T STAILQ_ENTRY
-T TAILQ_ENTRY

/* libxlsxwriter typedefs. */
-T lxw_app
-T lxw_autofilter
-T lxw_border
-T lxw_cell
-T lxw_chart
-T lxw_chart_axis
-T lxw_chart_axis_display_unit
-T lxw_chart_axis_label_position
-T lxw_chart_axis_tick_mark
-T lxw_chart_axis_tick_position
-T lxw_chart_blank
-T lxw_chart_error_bar_cap
-T lxw_chart_error_bar_direction
-T lxw_chart_error_bar_type
-T lxw_chart_fill
-T lxw_chart_font
-T lxw_chart_gridline
-T lxw_chart_label_position
-T lxw_chart_label_separator
-T lxw_chart_legend
-T lxw_chart_legend_position
-T lxw_chart_line
-T lxw_chart_line_dash_type
-T lxw_chart_marker
-T lxw_chart_marker_type
-T lxw_chart_pattern
-T lxw_chart_pattern_type
-T lxw_chart_point
-T lxw_chart_series
-T lxw_chart_title
-T lxw_chart_trendline_type
-T lxw_chart_type
-T lxw_col_options
-T lxw_col_t
-T lxw_color_t
-T lxw_content_types
-T lxw_core
-T lxw_custom
-T lxw_custom_property
-T lxw_datetime
-T lxw_defined_name
-T lxw_doc_properties
-T lxw_drawing
-T lxw_drawing_coords
-T lxw_drawing_object
-T lxw_error
-T lxw_fill
-T lxw_font
-T lxw_format
-T lxw_hash_element
-T lxw_hash_table
-T lxw_header_footer_options
-T lxw_heading_pair
-T lxw_image_options
-T lxw_merged_range
-T lxw_packager
-T lxw_panes
-T lxw_part_name
-T lxw_print_area
-T lxw_protection
-T lxw_rel_tuple
-T lxw_relationships
-T lxw_repeat_cols
-T lxw_repeat_rows
-T lxw_row
-T lxw_row_col_options
-T lxw_row_t
-T lxw_selection
-T lxw_series_data_point
-T lxw_series_error_bars
-T lxw_series_range
-T lxw_sst
-T lxw_styles
-T lxw_theme
-T lxw_tuple
-T lxw_workbook
-T lxw_workbook_options
-T lxw_worksheet
-T lxw_worksheet_init_data
-T lxw_worksheet_name
25 changes: 25 additions & 0 deletions libxlsxwriter/.travis.yml
@@ -0,0 +1,25 @@
language: c

compiler:
- clang
- gcc

env:
- CFLAGS='-Werror'
- NO_VALGRIND=1 USE_STANDARD_TMPFILE=1 CFLAGS='-Werror'
- NO_VALGRIND=1 CFLAGS='-Werror -m32'

install:
- sudo pip install pytest
- sudo apt-get update
- sudo apt-get install -y gcc-multilib
- sudo apt-get install -y zlib1g-dev
- sudo apt-get install -y zlib1g-dev:i386
- sudo apt-get install -y gcc
- sudo apt-get install -y valgrind

script:
- make V=1
- make test_functional V=1
- make test_unit V=1
- make test_valgrind V=1

0 comments on commit 0a59866

Please sign in to comment.