Top Level Namespace
Defined Under Namespace
Modules: Nokolexbor Classes: CMakeTimeout
Constant Summary collapse
- MAKE =
if windows? # On Windows, Ruby-DevKit only has 'make'. find_executable('make') else find_executable('gmake') || find_executable('make') end
- CWD =
File.(File.dirname(__FILE__))
- LEXBOR_DIR =
File.join(CWD, '..', '..', 'vendor', 'lexbor')
- EXT_DIR =
File.join(CWD, '..', '..', 'ext', 'nokolexbor')
- INSTALL_DIR =
File.join(LEXBOR_DIR, 'dist')
Class Method Summary collapse
Instance Method Summary collapse
- #apply_patch(patch_file, chdir) ⇒ Object
-
#Nokolexbor(string_or_io = nil, &block) ⇒ Object
Parse an HTML document, or build one with the DSL when a block is given.
-
#which(cmd) ⇒ Object
From: https://stackoverflow.com/questions/2108727 Cross-platform way of finding an executable in the $PATH.
- #windows? ⇒ Boolean
Class Method Details
.run_cmake(timeout, args) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'ext/nokolexbor/extconf.rb', line 84 def self.run_cmake(timeout, args) # Set to process group so we can kill it and its children pgroup = (windows? && !ENV['NOKOLEXBOR_CROSS_COMPILE']) ? :new_pgroup : :pgroup pid = Process.spawn("cmake #{args}", pgroup => true) Timeout.timeout(timeout) do Process.waitpid(pid) end rescue Timeout::Error # Kill it, #detach is essentially a background wait, since we don't actually # care about waiting for it now Process.kill(-9, pid) Process.detach(pid) raise CMakeTimeout.new("cmake has exceeded its timeout of #{timeout}s") end |
Instance Method Details
#apply_patch(patch_file, chdir) ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'ext/nokolexbor/extconf.rb', line 102 def apply_patch(patch_file, chdir) case when which('git') # By --work-tree=. git-apply uses the current directory as # the project root and will not search upwards for .git. Process.waitpid(Process.spawn("git --git-dir=. --work-tree=. apply #{patch_file}", chdir: chdir)) when which('patch') Process.waitpid(Process.spawn("patch -p1 -i #{patch_file}", chdir: chdir)) else raise "Failed to complete patch task; patch(1) or git(1) is required." end end |
#Nokolexbor(string_or_io = nil, &block) ⇒ Object
Parse an HTML document, or build one with the DSL when a block is given.
44 45 46 47 48 49 50 |
# File 'lib/nokolexbor.rb', line 44 def Nokolexbor(string_or_io = nil, &block) if block Nokolexbor::Builder.new(&block).parent else Nokolexbor.parse(string_or_io) end end |
#which(cmd) ⇒ Object
From: https://stackoverflow.com/questions/2108727 Cross-platform way of finding an executable in the $PATH.
which('ruby') #=> /usr/bin/ruby
16 17 18 19 20 21 22 23 24 25 |
# File 'ext/nokolexbor/extconf.rb', line 16 def which(cmd) exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : [''] ENV['PATH'].split(File::PATH_SEPARATOR).each do |path| exts.each { |ext| exe = File.join(path, "#{cmd}#{ext}") return exe if File.executable? exe } end return nil end |
#windows? ⇒ Boolean
8 9 10 |
# File 'ext/nokolexbor/extconf.rb', line 8 def windows? RbConfig::CONFIG["target_os"].match?(/mingw|mswin/) end |