Last active
October 24, 2023 21:39
-
-
Save ChadJPetersen/e5215da9c00b20fabff05b4a0e43e385 to your computer and use it in GitHub Desktop.
Revisions
-
ChadJPetersen revised this gist
Aug 26, 2020 . 1 changed file with 125 additions and 199 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,237 +1,163 @@ #In Powershell. # Install chocolatey https://chocolatey.org/install to be the software package manager. Right now the following line is the installer. But it would be good to go grab the new command from the site provided. #Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) choco install git ghostscript xpdf-utils gnuwin 7zip cyg-get msys2 graphviz activeperl choco install ruby --version=2.6.5.1 # This sets up ruby to be a dev kit ridk install 1 cyg-get install catdoc unrtf unzip antiword xlsx2csv libvisio-tools # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # SWITCH YOUR CONSOLE!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # In MSYS2 console pacman -Syu # close and reopen if prompted pacman -Su # Close and reopen if prompted # if getting errors on the below you can try the --force option. pacman -Syuu pacman -S base-devel --needed pacman -S mingw-w64-x86_64-toolchain zlib file pcre mingw64/mingw-w64-x86_64-file mingw64/mingw-w64-x86_64-pcre mingw-w64-x86_64-tesseract-ocr mingw-w64-x86_64-tesseract-data-eng git doxygen tcl mingw-w64-x86_64-graphviz mingw-w64-x86_64-python-docutils python3-pip python3-pygments pacman -R libtool pacman -S mingw64/mingw-w64-x86_64-libtool mingw-w64-x86_64-cmake gcc mingw64/mingw-w64-x86_64-zlib msys/zlib-devel msys/libuuid-devel pcre-devel pip3 install --upgrade pip pip install sphinx docutils pip3 install sphinx # i686 versions of pacman packages are for a 32 bit build. # pacman -S mingw-w64-i686-toolchain mingw64/mingw-w64-i686-libtool mingw32/mingw-w64-i686-file mingw32/mingw-w64-i686-pcre mingw-w64-i686-cmake mingw32/mingw-w64-i686-zlib git clone https://github.com/xapian/xapian.git /C/Tools/Xapian/src cd /C/Tools/Xapian/src # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # SWITCH YOUR CONSOLE!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # After installing things, switch from msys2 console to admin MINGW64 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # Go through all xapian projects and change /dev/null to NUL in file types: # *.cc, *.h, *.cpp, *.c # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # BE SURE TO UPDATE PATH'S TO WHERE YOU WANT THEM!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ./bootstrap # make distclean # can be helpful if a previous build was here. # You may also have to add the dot command to the path. This is part of graphviz and can be installed via chocolaty in powershell. PATH=$PATH:/c/ProgramData/chocolatey/bin # After running the next line you may get some issues about unexpected fi token. Open up the config file that was currently being configured and remove the empty else statement. # -L/C/Tools/msys64/mingw32/lib ./configure --prefix=/C/Tools/Xapian --with-ruby RUBY="/C/Tools/ruby26/bin/ruby.exe" RDOC="/C/Tools/Ruby26/bin/rdoc.cmd" RUBY_INC="/C/Tools/Ruby26/include/ruby-2.6.0" RUBY_INC_ARCH="/C/Tools/Ruby26/include/ruby-2.6.0/x64-mingw32" CPPFLAGS="-D_FORTIFY_SOURCE=0" # --enable-shared --disable-static # LDFLAGS="-Wl,--no-undefined -Wl,-ldxerr9 " CFLAGS=-fPIC CXXFLAGS=-fPIC # CC=x86_64-w64-mingw32-gcc CC_FOR_BUILD=x86_64-w64-mingw32-gcc CPP="x86_64-w64-mingw32-gcc -E" CXX=x86_64-w64-mingw32-g++ ac_ct_CC=x86_64-w64-mingw32-gcc ac_ct_CXX=x86_64-w64-mingw32-g++ CXXCPP="x86_64-w64-mingw32-g++ -E" # You may need to add a file for mingw for the time strip function. # you can do this by adding the line # #define _XOPEN_SOURCE 700 # before the includes in scriptindex.cc # You may also need to delete whitespace before some multi line commands if you get errors like 'recipe commences before first target. Stop.' # However I would suggest running make first before just changing things willy nilly. # to supress unused parameter errors use (void)(<unused parameter name>); make dist # This you may need to run as admin make install cd /C/Tools/Xapian mkdir ./xapian-ruby mkdir ./xapian-ruby/ext mkdir ./xapian-ruby/lib mkdir ./xapian-ruby/ext/lib mkdir ./xapian-ruby/ext/_xapian mkdir ./xapian-ruby/ext/_xapian/lib mkdir ./xapian-ruby/ext/_xapian/xapian echo "require 'rake/extensiontask' spec = Gem::Specification.load('xapian.gemspec') Rake::ExtensionTask.new do |ext| ext.name = '_xapian' # indicate the name of the extension. ext.ext_dir = 'ext/_xapian' # search for 'hello_world' inside it. # ext.lib_dir = 'lib/my_lib' # put binaries into this folder. # ext.config_script = 'extconf.rb' # use instead of the default 'extconf.rb'. ext.tmp_dir = 'tmp' # temporary folder used during compilation. ext.source_pattern = \"*.{c,cpp,cc}\" # monitor file changes to allow simple rebuild. # ext.config_options << 'CPPFLAGS=\"-I/C/Tools/Xapian/include\"' # supply additional options to configure script. ext.gem_spec = spec # optionally indicate which gem specification will be used. end" > ./xapian-ruby/Rakefile echo 'Gem::Specification.new do |s| s.name = "_xapian" s.version = "1.4.13" s.summary = "Xapian for Ruby" s.author = "Edited by Chad Petersen" s.files = Dir.glob("ext/**/*.{ c,rb}") + Dir.glob("lib/**/*.rb") s.extensions << "ext/_xapian/extconf.rb" s.add_development_dependency "rake-compiler" end' > ./xapian-ruby/xapian.gemspec # you will need to update your version number cp ./lib/libxapian.a ./xapian-ruby/ext/lib/libxapian.a cp ./lib/libxapian.a ./xapian-ruby/ext/_xapian/lib/libxapian.a echo "require \"mkmf\" LIBDIR = RbConfig::CONFIG['libdir'] INCLUDEDIR = RbConfig::CONFIG['includedir'] HEADER_DIRS = [INCLUDEDIR] # setup constant that is equal to that of the file path that holds that static libraries that will need to be compiled against LIB_DIRS = [LIBDIR, File.expand_path(File.join(File.dirname(__FILE__), \"lib\"))] # array of all libraries that the C extension should be compiled against libs = ['-lxapian','-lz','-lrpcrt4','-lws2_32','-luuid','-lstdc++'] #if xapian changes required libraries this line will have to change. Double check dependency_libs in C:\Tools\xapian-bindings-1.4.7\ruby\.libs\_xapian.la that the needed libraries are on this line. dir_config('_xapian', HEADER_DIRS, LIB_DIRS) # iterate though the libs array, and append them to the \$LOCAL_LIBS array used for the makefile creation libs.each do |lib| \$LOCAL_LIBS << \"#{lib} \" end create_makefile('_xapian/_xapian') " > ./xapian-ruby/ext/_xapian/extconf.rb #more version updating cp ./src/xapian-bindings/ruby/xapian_wrap.cc ./xapian-ruby/ext/_xapian/_xapian.cc cp ./src/xapian-bindings/ruby/xapian_wrap.h ./xapian-ruby/ext/_xapian/_xapian.h sed -i -e 's/xapian_wrap/_xapian/g' ./xapian-ruby/ext/_xapian/_xapian.cc #more version updating cp ./lib/libxapian.a ./xapian-ruby/ext/lib/libxapian.a cp -a ./include/. ./xapian-ruby/ext/_xapian/ cp ./src/xapian-bindings/ruby/xapian.rb ./xapian-ruby/lib/xapian.rb # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # !!!!!!Change shell to powershell!!!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! cd C:/Tools/Xapian/xapian-ruby gem install rake-compiler rake compile cp ./lib/_xapian.so C:/Tools/ruby26/lib/ruby/site_ruby/2.6.0/_xapian.so cp ./lib/xapian.rb C:/Tools/ruby26/lib/ruby/site_ruby/2.6.0/xapian.rb # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! # !!!!!!Change shell to mingw64!!!!!!!!!!! # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! cd /C/Tools/ruby26/lib/ruby/site_ruby/2.6.0 echo "Make sure the following files exist in the ruby bin folder." ldd * -
ChadJPetersen revised this gist
Sep 6, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -217,7 +217,7 @@ HEADER_DIRS = [INCLUDEDIR] LIB_DIRS = [LIBDIR, File.expand_path(File.join(File.dirname(__FILE__), "lib"))] # array of all libraries that the C extension should be compiled against libs = ['-lxapian','-lz','-lrpcrt4','-lws2_32'] #if xapian changes required libraries this line will have to change. Double check dependency_libs in C:\Tools\xapian-bindings-1.4.7\ruby\.libs\_xapian.la that the needed libraries are on this line. dir_config('_xapian', HEADER_DIRS, LIB_DIRS) -
ChadJPetersen created this gist
Sep 6, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,237 @@ # Install MSYS2 https://www.msys2.org/ # In MSYS2 console pacman -Syu # close and reopen pacman -Su # Close and reopen # if getting errors on the below you can try the --force option. # The commented out i686 versions of pacman packages are for a 32 bit build. pacman -Syuu pacman -S base-devel --needed pacman -S mingw-w64-x86_64-toolchain # pacman -S mingw-w64-i686-toolchain pacman -S zlib pacman -S file pacman -S pcre pacman -S mingw64/mingw-w64-x86_64-file pacman -S mingw64/mingw-w64-x86_64-pcre pacman -R libtool pacman -S mingw64/mingw-w64-x86_64-libtool # pacman -S mingw64/mingw-w64-i686-libtool # pacman -S mingw32/mingw-w64-i686-file # pacman -S mingw32/mingw-w64-i686-pcre # pacman -S mingw-w64-i686-cmake pacman -S mingw-w64-x86_64-cmake pacman -S gcc pacman -S mingw64/mingw-w64-x86_64-zlib pacman -S msys/zlib-devel # pacman -S mingw32/mingw-w64-i686-zlib # In MINGW64 or 32 Console depending on your need. # BE SURE TO UPDATE PATH'S TO WHERE YOU WANT THEM!!! cd /C/Tools/xapian-core-1.4.7 ./configure --prefix=/C/Tools/Xapian --enable-shared --disable-static LDFLAGS="-Wl,--no-undefined -Wl,-ldxerr9 -L/C/Tools/msys64/mingw64/lib" CFLAGS=-fPIC CXXFLAGS=-fPIC #patch lib tool using this bash function libtool_patch() { echo "Applying patch for libtool pe-x86_64 magic.." rm -f tmp.0lt.diff && touch tmp.0lt.diff lst="libtool.m4 aclocal.m4 ltmain.sh libtool configure" for i in $lst do j=`find . -type f -name $i` for f in $j do if test -f $f; then cp -p $f tmp.0lt sed -e "s|EGREP[-e ]*'file format pe-i386(\.\*architecture: i386)?' >|EGREP 'file format (pei\*-i386(.\*architecture:\ i386)?\|pe-arm-wince\|pe-x86-64)' >|" \ -e "s|EGREP[-e ]*'file format (pe-i386(\.\*architecture: i386)?\|pe-arm-wince\|pe-x86-64)' >|EGREP 'file format (pei\*-i386(.\*architecture:\ i386)?\|pe-arm-wince\|pe-x86-64)' >|" \ -e "s|deplibs_check_method='file_magic file format pei\*-i386(\.\*architecture: i386)?'|deplibs_check_method='file_magic file format (pei\*-i386(.\*architecture:\ i386)?\|pe-arm-wince\|pe-x86-64)'|" \ -e "s|deplibs_check_method='file_magic file format pe-i386(\.\*architecture: i386)?'|deplibs_check_method='file_magic file format (pei\*-i386(.\*architecture:\ i386)?\|pe-arm-wince\|pe-x86-64)'|" \ tmp.0lt > $f diff -up tmp.0lt $f >> tmp.0lt.diff # preserve the original file timestamp to avoid autotools' reconfiguration touch -r tmp.0lt $f rm -f tmp.0lt fi done done diffstat -l -p0 tmp.0lt.diff 2> /dev/null } libtool_patch make # If you run into an issue about linkers not being able to find dynamic libraries and only a static library will be created then use this addition to the libtools file # But libtool could also be installed somewhere else on the path. Just be sure to grab the one that is being run by make. # Added lines with + # *executable*) # but shell scripts are "executable" too... # case $win32_fileres in # *MS\ Windows\ PE\ Intel*) # win32_libid_type="x86 DLL" # ;; # + *MS-DOS\ executable*) # ugh! some DLLs built on Windows # + win32_libid_type="x86 DLL" # + ;; # esac # The path to this file is C:\Tools\xapian-core-1.4.7\libtool # about line 5487 # The other option to get arround the linker warning to output a dynamic library instead of a static library is to recompile the libraries on x86 windows instead of x86 dos. # More info can be found here. http://ricardo.ecn.wfu.edu/~cottrell/cross-gtk/libtool.html # There are also notes that msys may not like being any place other than c:/msys64 So you may also need to create a symlink if things do not work. # (admin powershell) # cd C:\ # new-item -itemtype symboliclink -name msys64 -target C:\Tools\msys64\ # It may also be a missmatch between linux and windows naming. If it's failing on any file starting with lib search the windows folder for everything after the lib. # e.g. if failing on libpcrt4 copy pcrt4.dll out of windows directory into lib directory and rename it libprct4.dll # I also had to download a different binary from the zlib site here. http://www.winimage.com/zLibDll/ # If all else fails when trying to compile. Look at where lib tool is finding canidates and edit the make file after the configure step to point directly at the dll names (e.g. libz.dll instead of -lz) # If you just cannot get the warning about static libraries to go away... sad but not the end of the world. You can just follow the extended instructions at the end of this file. # run as admin make install # back in normal mode cd /C/Tools/xapian-omega-1.4.7 ./configure --prefix=/C/Tools/Xapian XAPIAN_CONFIG=/C/Tools/Xapian/bin/xapian-config --enable-shared --disable-static LDFLAGS="-Wl,--no-undefined -L/C/Tools/msys64/mingw64/lib" CFLAGS=-fPIC CXXFLAGS=-fPIC # You may need to add a file for mingw for the time strip function which can be downloaded here # https://raw.githubusercontent.com/Alexpux/MINGW-packages/master/mingw-w64-libkml/strptime.c make # run as admin make install # back in normal mode cd /C/Tools/xapian-bindings-1.4.7 # I have found that not all of the documentation of required parameters was listed in the --help section. It may be helpful to just read the configure file if you're having troubles. ./configure --prefix=/C/Tools/Xapian XAPIAN_CONFIG=/C/Tools/Xapian/bin/xapian-config --with-ruby RUBY="/C/Ruby24-x64/bin/ruby.exe" RDOC="/C/Ruby24-x64/bin/rdoc.cmd" RUBY_INC="/C/Ruby24-x64/include/ruby-2.4.0" RUBY_INC_ARCH="/C/Ruby24-x64/include/ruby-2.4.0/x64-mingw32" --disable-static --enable-shared LDFLAGS="-Wl,--no-undefined -L/C/Tools/msys64/mingw64/lib" CFLAGS=-fPIC CXXFLAGS=-fPIC make # Run as admin make install # If you cannot get xapian to build as a shared object follow these steps. 1.) Create a new directory structure that looks like this. CustomRubyGemDirectoryRoot │ Rakefile (see content below) │ xapian.gemspec (see content below) │ ├───ext │ ├───lib │ │ libxapian.a (this file is coppied from C:\Tools\Xapian\lib) │ └───_xapian │ │ extconf.rb (see content below) │ │ xapian.h (This file can be found here C:\Tools\Xapian\include\xapian.h) │ │ _xapian.cc (this file is coppied from this file and renamed C:\Tools\xapian-bindings-1.4.7\ruby\xapian_wrap.cc) │ │ _xapian.h (this file is coppied from this file and renamed C:\Tools\xapian-bindings-1.4.7\ruby\xapian_wrap.h) │ │ │ ├───lib │ │ libxapian.a (this file is coppied from C:\Tools\Xapian\lib) │ │ │ └───xapian (This folder can be found hereC:\Tools\Xapian\include\xapian) │ attributes.h │ compactor.h │ constants.h │ constinfo.h │ database.h │ dbfactory.h │ deprecated.h │ derefwrapper.h │ document.h │ enquire.h │ error.h │ errorhandler.h │ eset.h │ expanddecider.h │ geospatial.h │ intrusive_ptr.h │ iterator.h │ keymaker.h │ matchspy.h │ mset.h │ positioniterator.h │ postingiterator.h │ postingsource.h │ query.h │ queryparser.h │ registry.h │ stem.h │ termgenerator.h │ termiterator.h │ types.h │ unicode.h │ valueiterator.h │ valuesetmatchdecider.h │ version.h │ visibility.h │ weight.h │ └───lib xapian.rb (coppied from C:\Tools\xapian-bindings-1.4.7\ruby\xapian.rb) #end tree # Rakefile require 'rake/extensiontask' spec = Gem::Specification.load('xapian.gemspec') Rake::ExtensionTask.new do |ext| ext.name = '_xapian' # indicate the name of the extension. ext.ext_dir = 'ext/_xapian' # search for 'hello_world' inside it. # ext.lib_dir = 'lib/my_lib' # put binaries into this folder. # ext.config_script = 'extconf.rb' # use instead of the default 'extconf.rb'. ext.tmp_dir = 'tmp' # temporary folder used during compilation. ext.source_pattern = "*.{c,cpp,cc}" # monitor file changes to allow simple rebuild. # ext.config_options << 'CPPFLAGS="-I/C/Tools/Xapian/include"' # supply additional options to configure script. ext.gem_spec = spec # optionally indicate which gem specification will be used. end #end rakefile # xapian.gemspec Gem::Specification.new do |s| s.name = "_xapian" s.version = "1.4.7" s.summary = "Xapian for Ruby" s.author = "Edited by Chad Petersen" s.files = Dir.glob("ext/**/*.{c,rb}") + Dir.glob("lib/**/*.rb") s.extensions << "ext/_xapian/extconf.rb" s.add_development_dependency "rake-compiler" end #end xapian.gemspec # extconf.rb require "mkmf" LIBDIR = RbConfig::CONFIG['libdir'] INCLUDEDIR = RbConfig::CONFIG['includedir'] HEADER_DIRS = [INCLUDEDIR] # setup constant that is equal to that of the file path that holds that static libraries that will need to be compiled against LIB_DIRS = [LIBDIR, File.expand_path(File.join(File.dirname(__FILE__), "lib"))] # array of all libraries that the C extension should be compiled against libs = ['-lxapian','-lz','-lrpcrt4','-lws2_32'] dir_config('_xapian', HEADER_DIRS, LIB_DIRS) # iterate though the libs array, and append them to the $LOCAL_LIBS array used for the makefile creation libs.each do |lib| $LOCAL_LIBS << "#{lib} " end create_makefile('_xapian/_xapian') # end extconf.rb # Continue instruction steps. 2.) in powershell gem.cmd install rake-compiler 3.) cd to the root of the directory made above (CustomRubyGemDirectoryRoot). 4.) run 'rake compile' without the quotes. 5.) get the _xapian.so file that was generated and the xapian.rb file and put them into the ruby directory here C:\Ruby24-x64\lib\ruby\site_ruby\2.4.0 where 2.4.0 is the version number. 6.) Enjoy xapian