Skip to content

Commit

Permalink
Small tidy to Rakefile and moving requires around to avoid duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-hill authored and barancev committed Oct 30, 2019
1 parent fcb9d6f commit 341dc6e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 64 deletions.
7 changes: 4 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ require 'rake_tasks/selenium_rake/java_formatter'
require 'rake_tasks/selenium_rake/cpp_formatter'
require 'rake_tasks/selenium_rake/type_definitions_generator'

# Our modifications to the Rake library
require 'rake_tasks/rake/task'
require 'rake_tasks/rake/dsl'

# Require the migrated rake files, which need to be tidied up further
# These are the final items mixed into the global NS
require 'rake_tasks/bazel'
require 'rake_tasks/copyright'
require 'rake_tasks/python'

# Our modifications to the Rake library
require 'rake_tasks/rake/task'

$DEBUG = orig_verbose != Rake::FileUtilsExt::DEFAULT ? true : false
$DEBUG = true if ENV['debug'] == 'true'

Expand Down
76 changes: 36 additions & 40 deletions rake_tasks/bazel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,58 +3,54 @@
require 'rake/task'
require 'rake_tasks/selenium_rake/checks'
require 'rake_tasks/bazel/task'
require 'rake_tasks/rake/dsl'

module Bazel
class << self
def execute(kind, args, target, &block)
verbose = Rake::FileUtilsExt.verbose_flag
def self.execute(kind, args, target, &block)
verbose = Rake::FileUtilsExt.verbose_flag

if target.end_with?(":run")
kind = "run"
target = target[0, target.length - 4]
end
if target.end_with?(':run')
kind = 'run'
target = target[0, target.length - 4]
end

cmd = %w[bazel] + [kind, target] + (args || [])
puts cmd.join(" ")

if SeleniumRake::Checks::windows?
cmd = cmd + ["2>&1"]
cmd_line = cmd.join(" ")
cmd_out = `#{cmd_line}`
cmd_exit_code = $?.success?
else
Open3.popen2e(*cmd) do |stdin, stdouts, wait|
is_running = true
stdin.close
cmd_out = ''
while is_running
begin
pipes = IO.select([stdouts])
if pipes.empty?
is_running = false
else
line = stdouts.readpartial(512)
cmd_out << line
STDOUT.print line if verbose
end
rescue EOFError
cmd = %w[bazel] + [kind, target] + (args || [])

if SeleniumRake::Checks.windows?
cmd = cmd + ["2>&1"]
cmd_line = cmd.join(' ')
cmd_out = `#{cmd_line}`
cmd_exit_code = $?.success?
else
Open3.popen2e(*cmd) do |stdin, stdouts, wait|
is_running = true
stdin.close
cmd_out = ''
while is_running
begin
pipes = IO.select([stdouts])
if pipes.empty?
is_running = false
else
line = stdouts.readpartial(512)
cmd_out << line
STDOUT.print line if verbose
end
rescue EOFError
is_running = false
end
cmd_exit_code = wait.value.exitstatus
end
cmd_exit_code = wait.value.exitstatus
end
end

puts cmd_out if verbose
puts cmd_out if verbose

raise "#{cmd.join(' ')} failed with exit code: #{cmd_exit_code}" if not cmd_exit_code
raise "#{cmd.join(' ')} failed with exit code: #{cmd_exit_code}" unless cmd_exit_code

block&.call(cmd_out)
out_artifact = Regexp.last_match(1) if cmd_out =~ %r{\s+(bazel-bin/\S+)}
block&.call(cmd_out)
out_artifact = Regexp.last_match(1) if cmd_out =~ %r{\s+(bazel-bin/\S+)}

puts "#{target} -> #{out_artifact}" if out_artifact
out_artifact
end
puts "#{target} -> #{out_artifact}" if out_artifact
out_artifact
end
end
3 changes: 0 additions & 3 deletions rake_tasks/crazy_fun/mappings/python.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
require 'rake_tasks/selenium_rake/checks'

require_relative 'python/add_normal_dependencies'
require_relative 'python/py_task'

module Python
def self.lib_dir
Dir.glob('build/lib*')[0] || 'build/lib'
Expand Down

This file was deleted.

9 changes: 0 additions & 9 deletions rake_tasks/crazy_fun/mappings/python/py_task.rb

This file was deleted.

1 change: 0 additions & 1 deletion rake_tasks/crazy_fun/mappings/rename.rb

This file was deleted.

0 comments on commit 341dc6e

Please sign in to comment.