Skip to content

Commit 2a38e7c

Browse files
committed
🎨 Standarize code ./ext directory
1 parent 378298a commit 2a38e7c

File tree

5 files changed

+73
-74
lines changed

5 files changed

+73
-74
lines changed

ext/nmatrix/extconf.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,43 +28,43 @@
2828
require File.expand_path("../../../lib/nmatrix/mkmf", __FILE__)
2929

3030
$INSTALLFILES = [
31-
['nmatrix.h' , '$(archdir)'],
32-
['nmatrix.hpp' , '$(archdir)'],
33-
['nmatrix_config.h', '$(archdir)'],
34-
['nm_memory.h' , '$(archdir)'],
35-
['ruby_constants.h', '$(archdir)']
31+
["nmatrix.h", "$(archdir)"],
32+
["nmatrix.hpp", "$(archdir)"],
33+
["nmatrix_config.h", "$(archdir)"],
34+
["nm_memory.h", "$(archdir)"],
35+
["ruby_constants.h", "$(archdir)"],
3636
]
3737

38-
if /cygwin|mingw/ =~ RUBY_PLATFORM
39-
$INSTALLFILES << ['libnmatrix.a', '$(archdir)']
38+
if /cygwin|mingw/.match?(RUBY_PLATFORM)
39+
$INSTALLFILES << ["libnmatrix.a", "$(archdir)"]
4040
end
4141

4242
$DEBUG = true
43-
$CFLAGS = ["-Wall -Werror=return-type",$CFLAGS].join(" ")
44-
$CXXFLAGS = ["-Wall -Werror=return-type",$CXXFLAGS].join(" ")
45-
$CPPFLAGS = ["-Wall -Werror=return-type",$CPPFLAGS].join(" ")
43+
$CFLAGS = ["-Wall -Werror=return-type", $CFLAGS].join(" ")
44+
$CXXFLAGS = ["-Wall -Werror=return-type", $CXXFLAGS].join(" ")
45+
$CPPFLAGS = ["-Wall -Werror=return-type", $CPPFLAGS].join(" ")
4646

4747
# When adding objects here, make sure their directories are included in CLEANOBJS down at the bottom of extconf.rb.
48-
basenames = %w{nmatrix ruby_constants data/data util/io math util/sl_list storage/common storage/storage storage/dense/dense storage/yale/yale storage/list/list}
48+
basenames = %w[nmatrix ruby_constants data/data util/io math util/sl_list storage/common storage/storage storage/dense/dense storage/yale/yale storage/list/list]
4949
$objs = basenames.map { |b| "#{b}.o" }
5050
$srcs = basenames.map { |b| "#{b}.cpp" }
5151

52-
#$libs += " -lprofiler "
52+
# $libs += " -lprofiler "
5353

5454
create_conf_h("nmatrix_config.h")
5555
create_makefile("nmatrix")
5656

57-
Dir.mkdir("data") unless Dir.exists?("data")
58-
Dir.mkdir("util") unless Dir.exists?("util")
59-
Dir.mkdir("storage") unless Dir.exists?("storage")
57+
Dir.mkdir("data") unless Dir.exist?("data")
58+
Dir.mkdir("util") unless Dir.exist?("util")
59+
Dir.mkdir("storage") unless Dir.exist?("storage")
6060
Dir.chdir("storage") do
61-
Dir.mkdir("yale") unless Dir.exists?("yale")
62-
Dir.mkdir("list") unless Dir.exists?("list")
63-
Dir.mkdir("dense") unless Dir.exists?("dense")
61+
Dir.mkdir("yale") unless Dir.exist?("yale")
62+
Dir.mkdir("list") unless Dir.exist?("list")
63+
Dir.mkdir("dense") unless Dir.exist?("dense")
6464
end
6565

6666
# to clean up object files in subdirectories:
67-
open('Makefile', 'a') do |f|
68-
clean_objs_paths = %w{data storage storage/dense storage/yale storage/list util}.map { |d| "#{d}/*.#{CONFIG["OBJEXT"]}" }
69-
f.write("CLEANOBJS := $(CLEANOBJS) #{clean_objs_paths.join(' ')}")
67+
open("Makefile", "a") do |f|
68+
clean_objs_paths = %w[data storage storage/dense storage/yale storage/list util].map { |d| "#{d}/*.#{CONFIG["OBJEXT"]}" }
69+
f.write("CLEANOBJS := $(CLEANOBJS) #{clean_objs_paths.join(" ")}")
7070
end

ext/nmatrix_atlas/extconf.rb

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,28 @@
2727

2828
require "nmatrix/mkmf"
2929

30-
#$INSTALLFILES = [['nmatrix.h', '$(archdir)'], ['nmatrix.hpp', '$(archdir)'], ['nmatrix_config.h', '$(archdir)'], ['nm_memory.h', '$(archdir)']]
31-
if /cygwin|mingw/ =~ RUBY_PLATFORM
32-
#$INSTALLFILES << ['libnmatrix.a', '$(archdir)']
30+
# $INSTALLFILES = [['nmatrix.h', '$(archdir)'], ['nmatrix.hpp', '$(archdir)'], ['nmatrix_config.h', '$(archdir)'], ['nm_memory.h', '$(archdir)']]
31+
if /cygwin|mingw/.match?(RUBY_PLATFORM)
32+
# $INSTALLFILES << ['libnmatrix.a', '$(archdir)']
3333
end
3434

3535
$DEBUG = true
36-
#not the right way to add this include directory
37-
$CFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix",$CFLAGS].join(" ")
38-
$CXXFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix",$CXXFLAGS].join(" ")
39-
$CPPFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix",$CPPFLAGS].join(" ")
36+
# not the right way to add this include directory
37+
$CFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix", $CFLAGS].join(" ")
38+
$CXXFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix", $CXXFLAGS].join(" ")
39+
$CPPFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix", $CPPFLAGS].join(" ")
4040

4141
# When adding objects here, make sure their directories are included in CLEANOBJS down at the bottom of extconf.rb.
4242
# Why not just autogenerate this list from all .c/.cpp files in directory?
43-
basenames = %w{nmatrix_atlas math_atlas}
43+
basenames = %w[nmatrix_atlas math_atlas]
4444
$objs = basenames.map { |b| "#{b}.o" }
4545
$srcs = basenames.map { |b| "#{b}.cpp" }
4646

4747
# The next line allows the user to supply --with-atlas-dir=/usr/local/atlas,
4848
# --with-atlas-lib or --with-atlas-include and tell the compiler where to look
4949
# for ATLAS. The same for all the others
5050
#
51-
#dir_config("clapack", ["/usr/local/atlas/include"], [])
51+
# dir_config("clapack", ["/usr/local/atlas/include"], [])
5252
#
5353
#
5454

@@ -60,14 +60,14 @@
6060

6161
idefaults = {lapack: ["/usr/include/atlas"],
6262
cblas: ["/usr/local/atlas/include", "/usr/include/atlas"],
63-
atlas: ["/usr/local/atlas/include", "/usr/include/atlas"]}
63+
atlas: ["/usr/local/atlas/include", "/usr/include/atlas"],}
6464

6565
# For some reason, if we try to look for /usr/lib64/atlas on a Mac OS X Mavericks system, and the directory does not
6666
# exist, it will give a linker error -- even if the lib dir is already correctly included with -L. So we need to check
6767
# that Dir.exists?(d) for each.
68-
ldefaults = {lapack: ["/usr/local/lib", "/usr/local/atlas/lib", "/usr/lib64/atlas"].delete_if { |d| !Dir.exists?(d) },
69-
cblas: ["/usr/local/lib", "/usr/local/atlas/lib", "/usr/lib64/atlas"].delete_if { |d| !Dir.exists?(d) },
70-
atlas: ["/usr/local/lib", "/usr/local/atlas/lib", "/usr/lib", "/usr/lib64/atlas"].delete_if { |d| !Dir.exists?(d) }}
68+
ldefaults = {lapack: ["/usr/local/lib", "/usr/local/atlas/lib", "/usr/lib64/atlas"].delete_if { |d| !Dir.exist?(d) },
69+
cblas: ["/usr/local/lib", "/usr/local/atlas/lib", "/usr/lib64/atlas"].delete_if { |d| !Dir.exist?(d) },
70+
atlas: ["/usr/local/lib", "/usr/local/atlas/lib", "/usr/lib", "/usr/lib64/atlas"].delete_if { |d| !Dir.exist?(d) },}
7171

7272
if have_library("clapack") # Usually only applies for Mac OS X
7373
$libs += " -lclapack "
@@ -94,7 +94,6 @@
9494
have_header("clapack.h")
9595
end
9696

97-
9897
# Although have_func is supposed to take a list as its second argument, I find that it simply
9998
# applies a :to_s to the second arg and doesn't actually check each one. We may want to put
10099
# have_func calls inside an :each block which checks atlas/clapack.h, cblas.h, clapack.h, and
@@ -105,20 +104,20 @@
105104

106105
have_func("cblas_dgemm", "cblas.h")
107106

108-
#have_func("rb_scan_args", "ruby.h")
107+
# have_func("rb_scan_args", "ruby.h")
109108

110-
#find_library("lapack", "clapack_dgetrf")
111-
#find_library("cblas", "cblas_dgemm")
112-
#find_library("atlas", "ATL_dgemmNN")
109+
# find_library("lapack", "clapack_dgetrf")
110+
# find_library("cblas", "cblas_dgemm")
111+
# find_library("atlas", "ATL_dgemmNN")
113112
# Order matters here: ATLAS has to go after LAPACK: http://mail.scipy.org/pipermail/scipy-user/2007-January/010717.html
114113
$libs += " -llapack -lcblas -latlas "
115-
#$libs += " -lprofiler "
114+
# $libs += " -lprofiler "
116115

117116
create_conf_h("nmatrix_atlas_config.h")
118117
create_makefile("nmatrix_atlas")
119118

120119
# to clean up object files in subdirectories:
121-
open('Makefile', 'a') do |f|
122-
clean_objs_paths = %w{ }.map { |d| "#{d}/*.#{CONFIG["OBJEXT"]}" }
123-
f.write("CLEANOBJS := $(CLEANOBJS) #{clean_objs_paths.join(' ')}")
120+
open("Makefile", "a") do |f|
121+
clean_objs_paths = %w[].map { |d| "#{d}/*.#{CONFIG["OBJEXT"]}" }
122+
f.write("CLEANOBJS := $(CLEANOBJS) #{clean_objs_paths.join(" ")}")
124123
end

ext/nmatrix_fftw/extconf.rb

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,29 @@
2424
#
2525
# This file checks FFTW3 and other necessary headers/shared objects.
2626

27-
require 'nmatrix/mkmf'
27+
require "nmatrix/mkmf"
2828

29-
fftw_libdir = RbConfig::CONFIG['libdir']
30-
fftw_incdir = RbConfig::CONFIG['includedir']
31-
fftw_srcdir = RbConfig::CONFIG['srcdir']
29+
fftw_libdir = RbConfig::CONFIG["libdir"]
30+
fftw_incdir = RbConfig::CONFIG["includedir"]
31+
fftw_srcdir = RbConfig::CONFIG["srcdir"]
3232

33-
$CFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include",$CFLAGS].join(" ")
34-
$CXXFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include -std=c++11",$CXXFLAGS].join(" ")
35-
$CPPFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include -std=c++11",$CPPFLAGS].join(" ")
33+
$CFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include", $CFLAGS].join(" ")
34+
$CXXFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include -std=c++11", $CXXFLAGS].join(" ")
35+
$CPPFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include -std=c++11", $CPPFLAGS].join(" ")
3636

3737
flags = " --include=#{fftw_incdir} --libdir=#{fftw_libdir}"
3838

3939
if have_library("fftw3")
4040
$CFLAGS += [" -lfftw3 -lm #{$CFLAGS} #{$flags}"].join(" ")
41-
dir_config('nmatrix_fftw', fftw_incdir, fftw_libdir)
42-
dir_config('nmatrix_fftw')
41+
dir_config("nmatrix_fftw", fftw_incdir, fftw_libdir)
42+
dir_config("nmatrix_fftw")
4343
end
4444

4545
create_conf_h("nmatrix_fftw_config.h")
4646
create_makefile("nmatrix_fftw")
4747

4848
# to clean up object files in subdirectories:
49-
open('Makefile', 'a') do |f|
50-
clean_objs_paths = %w{ }.map { |d| "#{d}/*.#{CONFIG["OBJEXT"]}" }
51-
f.write("CLEANOBJS := $(CLEANOBJS) #{clean_objs_paths.join(' ')}")
49+
open("Makefile", "a") do |f|
50+
clean_objs_paths = %w[].map { |d| "#{d}/*.#{CONFIG["OBJEXT"]}" }
51+
f.write("CLEANOBJS := $(CLEANOBJS) #{clean_objs_paths.join(" ")}")
5252
end

ext/nmatrix_lapacke/extconf.rb

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,47 +27,47 @@
2727

2828
require "nmatrix/mkmf"
2929

30-
#$INSTALLFILES = [['nmatrix.h', '$(archdir)'], ['nmatrix.hpp', '$(archdir)'], ['nmatrix_config.h', '$(archdir)'], ['nm_memory.h', '$(archdir)']]
31-
if /cygwin|mingw/ =~ RUBY_PLATFORM
32-
#$INSTALLFILES << ['libnmatrix.a', '$(archdir)']
30+
# $INSTALLFILES = [['nmatrix.h', '$(archdir)'], ['nmatrix.hpp', '$(archdir)'], ['nmatrix_config.h', '$(archdir)'], ['nm_memory.h', '$(archdir)']]
31+
if /cygwin|mingw/.match?(RUBY_PLATFORM)
32+
# $INSTALLFILES << ['libnmatrix.a', '$(archdir)']
3333
end
3434

3535
$DEBUG = true
36-
#not the right way to add this include directory
37-
$CFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include",$CFLAGS].join(" ")
38-
$CXXFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include",$CXXFLAGS].join(" ")
39-
$CPPFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include",$CPPFLAGS].join(" ")
36+
# not the right way to add this include directory
37+
$CFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include", $CFLAGS].join(" ")
38+
$CXXFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include", $CXXFLAGS].join(" ")
39+
$CPPFLAGS = ["-Wall -Werror=return-type -I$(srcdir)/../nmatrix -I$(srcdir)/lapacke/include", $CPPFLAGS].join(" ")
4040

4141
# When adding objects here, make sure their directories are included in CLEANOBJS down at the bottom of extconf.rb.
4242
# Why not just autogenerate this list from all .c/.cpp files in directory?
43-
basenames = %w{nmatrix_lapacke math_lapacke lapacke}
43+
basenames = %w[nmatrix_lapacke math_lapacke lapacke]
4444
$objs = basenames.map { |b| "#{b}.o" }
4545
$srcs = basenames.map { |b| "#{b}.cpp" }
4646

4747
# For some reason, if we try to look for /usr/lib64/atlas on a Mac OS X Mavericks system, and the directory does not
4848
# exist, it will give a linker error -- even if the lib dir is already correctly included with -L. So we need to check
4949
# that Dir.exists?(d) for each.
50-
ldefaults = {lapack: ["/usr/local/lib"].delete_if { |d| !Dir.exists?(d) } }
50+
ldefaults = {lapack: ["/usr/local/lib"].delete_if { |d| !Dir.exist?(d) }}
5151

52-
# It is not clear how this variable should be defined, or if it is necessary at all.
52+
# It is not clear how this variable should be defined, or if it is necessary at all.
5353
# See issue https://github.com/SciRuby/nmatrix/issues/403
54-
idefaults = {lapack: [] }
54+
idefaults = {lapack: []}
5555

5656
unless have_library("lapack")
5757
dir_config("lapack", idefaults[:lapack], ldefaults[:lapack])
5858
end
5959

6060
# Order matters here: ATLAS has to go after LAPACK: http://mail.scipy.org/pipermail/scipy-user/2007-January/010717.html
6161
$libs += " -llapack "
62-
#To use the Intel MKL, comment out the line above, and also comment out the bit above with have_library and dir_config for lapack.
63-
#Then add something like the line below (for exactly what linker flags to use see https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor ):
64-
#$libs += " -L${MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_sequential "
62+
# To use the Intel MKL, comment out the line above, and also comment out the bit above with have_library and dir_config for lapack.
63+
# Then add something like the line below (for exactly what linker flags to use see https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor ):
64+
# $libs += " -L${MKLROOT}/lib/intel64 -lmkl_intel_lp64 -lmkl_core -lmkl_sequential "
6565

6666
create_conf_h("nmatrix_lapacke_config.h")
6767
create_makefile("nmatrix_lapacke")
6868

6969
# to clean up object files in subdirectories:
70-
open('Makefile', 'a') do |f|
71-
clean_objs_paths = %w{ }.map { |d| "#{d}/*.#{CONFIG["OBJEXT"]}" }
72-
f.write("CLEANOBJS := $(CLEANOBJS) #{clean_objs_paths.join(' ')}")
70+
open("Makefile", "a") do |f|
71+
clean_objs_paths = %w[].map { |d| "#{d}/*.#{CONFIG["OBJEXT"]}" }
72+
f.write("CLEANOBJS := $(CLEANOBJS) #{clean_objs_paths.join(" ")}")
7373
end

ext/nmatrix_lapacke/make_lapacke_cpp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#We want this to be a C++ file since our complex types require C++.
1+
# We want this to be a C++ file since our complex types require C++.
22

3-
File.open("lapacke.cpp","w") do |file|
3+
File.open("lapacke.cpp", "w") do |file|
44
file.puts "//This file is auto-generated by make_lapacke_cpp.rb"
55
file.puts "//It includes all source files in the lapacke/ subdirectory"
66
Dir["lapacke/**/*.c"].each do |file2|

0 commit comments

Comments
 (0)