Skip to content

Commit 341dc6e

Browse files
luke-hillbarancev
authored andcommitted
Small tidy to Rakefile and moving requires around to avoid duplication
1 parent fcb9d6f commit 341dc6e

File tree

6 files changed

+40
-64
lines changed

6 files changed

+40
-64
lines changed

Rakefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ require 'rake_tasks/selenium_rake/java_formatter'
3232
require 'rake_tasks/selenium_rake/cpp_formatter'
3333
require 'rake_tasks/selenium_rake/type_definitions_generator'
3434

35+
# Our modifications to the Rake library
36+
require 'rake_tasks/rake/task'
37+
require 'rake_tasks/rake/dsl'
38+
3539
# Require the migrated rake files, which need to be tidied up further
3640
# These are the final items mixed into the global NS
3741
require 'rake_tasks/bazel'
3842
require 'rake_tasks/copyright'
3943
require 'rake_tasks/python'
4044

41-
# Our modifications to the Rake library
42-
require 'rake_tasks/rake/task'
43-
4445
$DEBUG = orig_verbose != Rake::FileUtilsExt::DEFAULT ? true : false
4546
$DEBUG = true if ENV['debug'] == 'true'
4647

rake_tasks/bazel.rb

Lines changed: 36 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,58 +3,54 @@
33
require 'rake/task'
44
require 'rake_tasks/selenium_rake/checks'
55
require 'rake_tasks/bazel/task'
6-
require 'rake_tasks/rake/dsl'
76

87
module Bazel
9-
class << self
10-
def execute(kind, args, target, &block)
11-
verbose = Rake::FileUtilsExt.verbose_flag
8+
def self.execute(kind, args, target, &block)
9+
verbose = Rake::FileUtilsExt.verbose_flag
1210

13-
if target.end_with?(":run")
14-
kind = "run"
15-
target = target[0, target.length - 4]
16-
end
11+
if target.end_with?(':run')
12+
kind = 'run'
13+
target = target[0, target.length - 4]
14+
end
1715

18-
cmd = %w[bazel] + [kind, target] + (args || [])
19-
puts cmd.join(" ")
20-
21-
if SeleniumRake::Checks::windows?
22-
cmd = cmd + ["2>&1"]
23-
cmd_line = cmd.join(" ")
24-
cmd_out = `#{cmd_line}`
25-
cmd_exit_code = $?.success?
26-
else
27-
Open3.popen2e(*cmd) do |stdin, stdouts, wait|
28-
is_running = true
29-
stdin.close
30-
cmd_out = ''
31-
while is_running
32-
begin
33-
pipes = IO.select([stdouts])
34-
if pipes.empty?
35-
is_running = false
36-
else
37-
line = stdouts.readpartial(512)
38-
cmd_out << line
39-
STDOUT.print line if verbose
40-
end
41-
rescue EOFError
16+
cmd = %w[bazel] + [kind, target] + (args || [])
17+
18+
if SeleniumRake::Checks.windows?
19+
cmd = cmd + ["2>&1"]
20+
cmd_line = cmd.join(' ')
21+
cmd_out = `#{cmd_line}`
22+
cmd_exit_code = $?.success?
23+
else
24+
Open3.popen2e(*cmd) do |stdin, stdouts, wait|
25+
is_running = true
26+
stdin.close
27+
cmd_out = ''
28+
while is_running
29+
begin
30+
pipes = IO.select([stdouts])
31+
if pipes.empty?
4232
is_running = false
33+
else
34+
line = stdouts.readpartial(512)
35+
cmd_out << line
36+
STDOUT.print line if verbose
4337
end
38+
rescue EOFError
39+
is_running = false
4440
end
45-
cmd_exit_code = wait.value.exitstatus
4641
end
42+
cmd_exit_code = wait.value.exitstatus
4743
end
44+
end
4845

49-
puts cmd_out if verbose
46+
puts cmd_out if verbose
5047

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

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

56-
puts "#{target} -> #{out_artifact}" if out_artifact
57-
out_artifact
58-
end
53+
puts "#{target} -> #{out_artifact}" if out_artifact
54+
out_artifact
5955
end
6056
end

rake_tasks/crazy_fun/mappings/python.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
require 'rake_tasks/selenium_rake/checks'
22

3-
require_relative 'python/add_normal_dependencies'
4-
require_relative 'python/py_task'
5-
63
module Python
74
def self.lib_dir
85
Dir.glob('build/lib*')[0] || 'build/lib'

rake_tasks/crazy_fun/mappings/python/add_normal_dependencies.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.

rake_tasks/crazy_fun/mappings/python/py_task.rb

Lines changed: 0 additions & 9 deletions
This file was deleted.

rake_tasks/crazy_fun/mappings/rename.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)