From 13449f72291c9a65787edd99d9d38adb97e6ef93 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Mon, 31 Aug 2020 09:26:45 -0700 Subject: [PATCH 1/4] Add check for cmake to extconf --- .github/workflows/ci.yml | 1 - aws-crt/ext/extconf.rb | 2 ++ aws-crt/native/aws-common-runtime/aws-c-auth | 2 +- aws-crt/native/aws-common-runtime/aws-c-cal | 2 +- aws-crt/native/aws-common-runtime/aws-c-common | 2 +- aws-crt/native/aws-common-runtime/aws-c-http | 2 +- aws-crt/native/aws-common-runtime/aws-c-io | 2 +- 7 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e113387..fd62345 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,6 @@ env: RUN: ${{ github.run_id }}-${{ github.run_number }} jobs: - osx: runs-on: macos-latest steps: diff --git a/aws-crt/ext/extconf.rb b/aws-crt/ext/extconf.rb index 186ebc8..554dabd 100644 --- a/aws-crt/ext/extconf.rb +++ b/aws-crt/ext/extconf.rb @@ -1,5 +1,7 @@ require 'mkmf' +abort 'Missing cmake' unless find_executable 'cmake' + # create a dummy makefile create_makefile '' diff --git a/aws-crt/native/aws-common-runtime/aws-c-auth b/aws-crt/native/aws-common-runtime/aws-c-auth index bb28736..3d23c1c 160000 --- a/aws-crt/native/aws-common-runtime/aws-c-auth +++ b/aws-crt/native/aws-common-runtime/aws-c-auth @@ -1 +1 @@ -Subproject commit bb28736d03f527a3050d31fc6d60713b040708d9 +Subproject commit 3d23c1c44077dded5ee069bcf5d7c5c9e6ee280e diff --git a/aws-crt/native/aws-common-runtime/aws-c-cal b/aws-crt/native/aws-common-runtime/aws-c-cal index 2b9c589..3215b8f 160000 --- a/aws-crt/native/aws-common-runtime/aws-c-cal +++ b/aws-crt/native/aws-common-runtime/aws-c-cal @@ -1 +1 @@ -Subproject commit 2b9c589b296bad0c411e5014222739c0edef5f03 +Subproject commit 3215b8f640056487205bea4306ee5e6794748c01 diff --git a/aws-crt/native/aws-common-runtime/aws-c-common b/aws-crt/native/aws-common-runtime/aws-c-common index 48fae4e..78dbfab 160000 --- a/aws-crt/native/aws-common-runtime/aws-c-common +++ b/aws-crt/native/aws-common-runtime/aws-c-common @@ -1 +1 @@ -Subproject commit 48fae4e7deddc54a91fc65c292357617315f27da +Subproject commit 78dbfab579dea968a116a4e97f4af04b94e0d2b5 diff --git a/aws-crt/native/aws-common-runtime/aws-c-http b/aws-crt/native/aws-common-runtime/aws-c-http index 98b3e49..b53100e 160000 --- a/aws-crt/native/aws-common-runtime/aws-c-http +++ b/aws-crt/native/aws-common-runtime/aws-c-http @@ -1 +1 @@ -Subproject commit 98b3e4979fc41f54c13a68475919fa56b5377aef +Subproject commit b53100ee427a3618c1692e7ca8aaa1f2cbeb4109 diff --git a/aws-crt/native/aws-common-runtime/aws-c-io b/aws-crt/native/aws-common-runtime/aws-c-io index 919c27a..cf9dbd7 160000 --- a/aws-crt/native/aws-common-runtime/aws-c-io +++ b/aws-crt/native/aws-common-runtime/aws-c-io @@ -1 +1 @@ -Subproject commit 919c27a6c0369c71770cb37f855cea67e81a8d4a +Subproject commit cf9dbd744f56eccc00bd3f9c4e7ba283949e1a28 From fd4a1da9aa59d7820cf5c9ccd095e4af0947673d Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Mon, 31 Aug 2020 11:56:15 -0700 Subject: [PATCH 2/4] Add rubocop + run auto-correct --- .rubocop.yml | 5 +++++ Gemfile | 4 ++++ aws-crt/Rakefile | 11 ++++------- aws-crt/aws-crt.gemspec | 4 ++-- aws-crt/ext/extconf.rb | 4 +--- aws-crt/lib/aws-crt.rb | 9 ++++----- aws-crt/lib/aws-crt/platforms.rb | 20 ++++++++++---------- aws-crt/spec/crt_spec.rb | 2 +- 8 files changed, 31 insertions(+), 28 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..e69d016 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,5 @@ +AllCops: + TargetRubyVersion: 1.9 + +Metrics/LineLength: + Max: 80 \ No newline at end of file diff --git a/Gemfile b/Gemfile index 870e55d..5935c58 100644 --- a/Gemfile +++ b/Gemfile @@ -9,3 +9,7 @@ group :test do gem 'rspec' end +group :development do + gem 'rubocop', '0.50.0' # latest version to support Ruby 1.9 +end + diff --git a/aws-crt/Rakefile b/aws-crt/Rakefile index 9e17d59..58501d2 100644 --- a/aws-crt/Rakefile +++ b/aws-crt/Rakefile @@ -12,15 +12,13 @@ task :compile do build_dir = File.expand_path('build', native_dir) FileUtils.mkdir_p(build_dir) Dir.chdir(build_dir) do - if !File.exist?('CMakeCache.txt') - sh "cmake #{native_dir}" - end + sh "cmake #{native_dir}" unless File.exist?('CMakeCache.txt') sh "cmake --build #{build_dir}" end end desc 'Move the compiled lib into bin' -task :bin => :compile do +task bin: :compile do require_relative 'lib/aws-crt/platforms' platform = local_platform binary_name = PLATFORM_BINARIES[platform] @@ -90,7 +88,7 @@ task 'gem:jruby' => 'bin:all' do require 'fileutils' platform = 'universal-java' - + root = File.dirname(__FILE__) pkgs = File.join(root, 'pkg') bins = File.join(root, 'bin') @@ -116,5 +114,4 @@ task 'gem:jruby' => 'bin:all' do end RSpec::Core::RakeTask.new(:spec) -task :spec => :bin - +task spec: :bin diff --git a/aws-crt/aws-crt.gemspec b/aws-crt/aws-crt.gemspec index f598fd3..c533c2f 100644 --- a/aws-crt/aws-crt.gemspec +++ b/aws-crt/aws-crt.gemspec @@ -11,5 +11,5 @@ Gem::Specification.new do |spec| spec.files += Dir['lib/**/*.rb'] spec.platform = Gem::Platform::RUBY spec.add_dependency 'ffi' - spec.add_development_dependency "rspec" -end \ No newline at end of file + spec.add_development_dependency 'rspec' +end diff --git a/aws-crt/ext/extconf.rb b/aws-crt/ext/extconf.rb index 554dabd..cf2aa21 100644 --- a/aws-crt/ext/extconf.rb +++ b/aws-crt/ext/extconf.rb @@ -11,9 +11,7 @@ Dir.chdir('../') do native_dir = File.expand_path('./native') build_dir = File.expand_path('build', native_dir) - if !Dir.exist?(build_dir) - Dir.mkdir(build_dir) - end + Dir.mkdir(build_dir) unless Dir.exist?(build_dir) Dir.chdir(build_dir) do system "cmake #{native_dir}" system "cmake --build #{build_dir}" diff --git a/aws-crt/lib/aws-crt.rb b/aws-crt/lib/aws-crt.rb index 7a7086c..5e6295a 100644 --- a/aws-crt/lib/aws-crt.rb +++ b/aws-crt/lib/aws-crt.rb @@ -37,13 +37,12 @@ class Error < StandardError end module Errors - @const_set_mutex = Mutex.new def self.raise_last_error - error_code = Aws::Crt::aws_last_error - error_name = Aws::Crt::aws_error_name(error_code) - raise error_class(error_name), Aws::Crt::aws_error_debug_str(error_code) + error_code = Aws::Crt.aws_last_error + error_name = Aws::Crt.aws_error_name(error_code) + raise error_class(error_name), Aws::Crt.aws_error_debug_str(error_code) end # Get the error class for a given error_name @@ -65,7 +64,7 @@ def self.error_class(error_name) # This requires filtering non-safe characters from the constant # name and ensuring it begins with an uppercase letter. def self.error_class_constant(error_name) - constant = error_name.to_s.gsub(/AWS_ERROR_/, '').split('_').map{|e| e.capitalize}.join + constant = error_name.to_s.gsub(/AWS_ERROR_/, '').split('_').map(&:capitalize).join end def self.set_error_constant(constant) diff --git a/aws-crt/lib/aws-crt/platforms.rb b/aws-crt/lib/aws-crt/platforms.rb index ccd8973..df11982 100644 --- a/aws-crt/lib/aws-crt/platforms.rb +++ b/aws-crt/lib/aws-crt/platforms.rb @@ -23,26 +23,26 @@ def host_string # @return [String] host cpu, even on jruby def host_cpu - case RbConfig::CONFIG["host_cpu"] + case RbConfig::CONFIG['host_cpu'] when /86_64/ - "x86_64" + 'x86_64' when /86/ - "x86" + 'x86' else - RbConfig::CONFIG["host_cpu"] + RbConfig::CONFIG['host_cpu'] end end # @return [String] host os, even on jruby def host_os - case RbConfig::CONFIG["host_os"] + case RbConfig::CONFIG['host_os'] when /darwin/ - "darwin" + 'darwin' when /linux/ - "linux" + 'linux' when /mingw|mswin/ - "mingw32" + 'mingw32' else - RbConfig::CONFIG["host_os"] + RbConfig::CONFIG['host_os'] end -end \ No newline at end of file +end diff --git a/aws-crt/spec/crt_spec.rb b/aws-crt/spec/crt_spec.rb index 4e3ca10..5d6107a 100644 --- a/aws-crt/spec/crt_spec.rb +++ b/aws-crt/spec/crt_spec.rb @@ -14,4 +14,4 @@ end.to raise_error(Aws::Crt::Error) end end -end \ No newline at end of file +end From 586e4d2e765bd80bea0b542bc161a2c191c30b0d Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Mon, 31 Aug 2020 12:21:32 -0700 Subject: [PATCH 3/4] Add rubocop --- .rubocop.yml | 2 ++ Gemfile | 2 +- aws-crt/Rakefile | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index e69d016..ea16f2e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,7 @@ AllCops: TargetRubyVersion: 1.9 + Exclude: + - 'aws-crt/native/aws-common-runtime/**/*.rb' Metrics/LineLength: Max: 80 \ No newline at end of file diff --git a/Gemfile b/Gemfile index 5935c58..0b5790a 100644 --- a/Gemfile +++ b/Gemfile @@ -10,6 +10,6 @@ group :test do end group :development do - gem 'rubocop', '0.50.0' # latest version to support Ruby 1.9 + gem 'rubocop', '0.50.0', require: false # latest version to support Ruby 1.9 end diff --git a/aws-crt/Rakefile b/aws-crt/Rakefile index 58501d2..f0dd3fe 100644 --- a/aws-crt/Rakefile +++ b/aws-crt/Rakefile @@ -1,5 +1,6 @@ require 'rake/clean' require 'rspec/core/rake_task' +require 'rubocop/rake_task' CLEAN.include 'tmp' CLEAN.include 'pkg' @@ -115,3 +116,8 @@ end RSpec::Core::RakeTask.new(:spec) task spec: :bin + +RuboCop::RakeTask.new(:rubocop) do |t| + config_file = File.join(File.dirname(__FILE__), '..', '.rubocop.yml') + t.options = ['-E', '-S', '-c', config_file] +end From 587f0e25638c363630b004c45356bbe46429a594 Mon Sep 17 00:00:00 2001 From: Alex Woods Date: Mon, 31 Aug 2020 13:47:31 -0700 Subject: [PATCH 4/4] Ignore hash rocket in Rakefile --- .github/workflows/ci.yml | 1 + .rubocop.yml | 4 ++++ aws-crt/Rakefile | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fd62345..e113387 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,6 +15,7 @@ env: RUN: ${{ github.run_id }}-${{ github.run_number }} jobs: + osx: runs-on: macos-latest steps: diff --git a/.rubocop.yml b/.rubocop.yml index ea16f2e..835dd48 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,5 +3,9 @@ AllCops: Exclude: - 'aws-crt/native/aws-common-runtime/**/*.rb' +Style/HashSyntax: + Exclude: + - 'aws-crt/Rakefile' + Metrics/LineLength: Max: 80 \ No newline at end of file diff --git a/aws-crt/Rakefile b/aws-crt/Rakefile index f0dd3fe..f6c7f37 100644 --- a/aws-crt/Rakefile +++ b/aws-crt/Rakefile @@ -19,7 +19,7 @@ task :compile do end desc 'Move the compiled lib into bin' -task bin: :compile do +task :bin => :compile do require_relative 'lib/aws-crt/platforms' platform = local_platform binary_name = PLATFORM_BINARIES[platform] @@ -115,7 +115,7 @@ task 'gem:jruby' => 'bin:all' do end RSpec::Core::RakeTask.new(:spec) -task spec: :bin +task :spec => :bin RuboCop::RakeTask.new(:rubocop) do |t| config_file = File.join(File.dirname(__FILE__), '..', '.rubocop.yml')