From dc5132921dca4874e0e15cd8fca13038797415e2 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Fri, 24 May 2024 12:29:17 +0200 Subject: [PATCH 1/3] :technologist: (rubocop): Add config --- .rubocop.yml | 303 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 303 insertions(+) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..3d4b732 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,303 @@ +--- +inherit_mode: + merge: + - Include + - Exclude + +AllCops: + TargetRubyVersion: 3.3 + NewCops: enable + Include: + - "**/*.rbi" + SuggestExtensions: + rubocop-minitest: false + +# `system` is a special case and aligns on second argument, so allow this for formulae. +Layout/ArgumentAlignment: + Exclude: + - Formula/**/*.rb + +# this is a bit less "floaty" +Layout/CaseIndentation: + EnforcedStyle: end + +# significantly less indentation involved; more consistent +Layout/FirstArrayElementIndentation: + EnforcedStyle: consistent +Layout/FirstHashElementIndentation: + EnforcedStyle: consistent + +# this is a bit less "floaty" +Layout/EndAlignment: + EnforcedStyleAlignWith: start_of_line + +# make our hashes consistent +Layout/HashAlignment: + EnforcedHashRocketStyle: table + EnforcedColonStyle: table + +# Need to allow #: for external commands. +Layout/LeadingCommentSpace: + Exclude: + - "Taps/*/*/cmd/*.rb" + +# GitHub diff UI wraps beyond 118 characters +Layout/LineLength: + Max: 118 + # ignore manpage comments and long single-line strings + AllowedPatterns: + [ + "#: ", + ' url "', + ' mirror "', + " plist_options ", + ' executable: "', + ' font "', + ' homepage "', + ' name "', + ' pkg "', + ' pkgutil: "', + " sha256 cellar: ", + " sha256 ", + "#{language}", + "#{version.", + ' "/Library/Application Support/', + '"/Library/Caches/', + '"/Library/PreferencePanes/', + ' "~/Library/Application Support/', + '"~/Library/Caches/', + '"~/Library/Containers', + '"~/Application Support', + " was verified as official when first introduced to the cask", + ] + +# conflicts with DSL-style path concatenation with `/` +Layout/SpaceAroundOperators: + Enabled: false + +# makes DSL usage ugly. +Layout/SpaceBeforeBrackets: + Exclude: + - "**/*_spec.rb" + +# favour parens-less DSL-style arguments +Lint/AmbiguousBlockAssociation: + Enabled: false + +Lint/DuplicateBranch: + Exclude: + - Formula/**/*.rb + +# so many of these in formulae and can't be autocorrected +Lint/ParenthesesAsGroupedExpression: + Exclude: + - Formula/**/*.rb + +# unused keyword arguments improve APIs +Lint/UnusedMethodArgument: + AllowUnusedKeywordArguments: true + +# These metrics didn't end up helping. +Metrics: + Enabled: false + +# Disabled because it breaks Sorbet: "The declaration for `with` is missing parameter(s): & (RuntimeError)" +Naming/BlockForwarding: + Enabled: false + +# Allow dashes in filenames. +Naming/FileName: + Regex: !ruby/regexp /^[\w\@\-\+\.]+(\.rb)?$/ + +# Implicitly allow EOS as we use it everywhere. +Naming/HeredocDelimiterNaming: + ForbiddenDelimiters: + - END, EOD, EOF + +Naming/InclusiveLanguage: + CheckStrings: true + FlaggedTerms: + slave: + AllowedRegex: + - "gitslave" # Used in formula `gitslave` + - "log_slave" # Used in formula `ssdb` + - "ssdb_slave" # Used in formula `ssdb` + - "var_slave" # Used in formula `ssdb` + - "patches/13_fix_scope_for_show_slave_status_data.patch" # Used in formula `mytop` + +Naming/MethodName: + AllowedPatterns: + - '\A(fetch_)?HEAD\?\Z' + +Naming/MethodParameterName: + inherit_mode: + merge: + - AllowedNames + +# Both styles are used depending on context, +# e.g. `sha256` and `something_countable_1`. +Naming/VariableNumber: + Enabled: false + +# Require &&/|| instead of and/or +Style/AndOr: + EnforcedStyle: always + +# Disabled because it breaks Sorbet: "The declaration for `with` is missing parameter(s): & (RuntimeError)" +Style/ArgumentsForwarding: + Enabled: false + +# Avoid leaking resources. +Style/AutoResourceCleanup: + Enabled: true + +# This makes these a little more obvious. +Style/BarePercentLiterals: + EnforcedStyle: percent_q + +Style/BlockDelimiters: + BracesRequiredMethods: + - "sig" + +Style/ClassAndModuleChildren: + Exclude: + - "**/*.rbi" + +# Use consistent style for better readability. +Style/CollectionMethods: + Enabled: true + +# Don't allow cops to be disabled in casks and formulae. +Style/DisableCopsWithinSourceCodeDirective: + Enabled: true + Include: + - Formula/**/*.rb + +# The files actually scanned in this cop are in `Library/Homebrew/.rubocop.yml`. +Style/Documentation: + Enabled: false + Exclude: + - Formula/**/*.rb + - "Taps/**/*" + - "/**/{Formula,Casks}/**/*.rb" + - "**/{Formula,Casks}/**/*.rb" + - "**/*.rbi" + +# This is quite a large change, so don't enforce this yet for formulae. +# We should consider doing so in the future, but be aware of the impact on third-party taps. +Style/FetchEnvVar: + Exclude: + - Formula/**/*.rb + +# Not used for casks and formulae. +Style/FrozenStringLiteralComment: + EnforcedStyle: always + Exclude: + - Formula/**/*.rb + +# potential for errors in formulae too high with this +Style/GuardClause: + Exclude: + - Formula/**/*.rb + +# Allow for license expressions +Style/HashAsLastArrayItem: + Exclude: + - Formula/**/*.rb + +Style/InverseMethods: + InverseMethods: + :blank?: :present? + +Style/InvertibleUnlessCondition: + Enabled: true + InverseMethods: + # Favor `if a != b` over `unless a == b` + :==: :!= + # Unset this (prefer `unless a.zero?` over `if a.nonzero?`) + :zero?: + :blank?: :present? + +Style/MutableConstant: + # would rather freeze too much than too little + EnforcedStyle: strict + +# Zero-prefixed octal literals are widely used and understood. +Style/NumericLiteralPrefix: + EnforcedOctalStyle: zero_only + +# Only use this for numbers >= `1_000_000`. +Style/NumericLiterals: + MinDigits: 7 + Strict: true + Exclude: + - "**/Brewfile" + +Style/OpenStructUse: + Exclude: + - Formula/**/*.rb + +# Rescuing `StandardError` is an understood default. +Style/RescueStandardError: + EnforcedStyle: implicit + +# Returning `nil` is unnecessary. +Style/ReturnNil: + Enabled: true + +# We have no use for using `warn` because we +# are calling Ruby with warnings disabled. +Style/StderrPuts: + Enabled: false + +# so many of these in formulae and can't be autocorrected +Style/StringConcatenation: + Exclude: + - Formula/**/*.rb + +# ruby style guide favorite +Style/StringLiterals: + EnforcedStyle: double_quotes + +# consistency with above +Style/StringLiteralsInInterpolation: + EnforcedStyle: double_quotes + +# Use consistent method names. +Style/StringMethods: + Enabled: true + +# Treating this the same as Style/MethodCallWithArgsParentheses +Style/SuperWithArgsParentheses: + Enabled: false + +# An array of symbols is more readable than a symbol array +# and also allows for easier grepping. +Style/SymbolArray: + EnforcedStyle: brackets + +# make things a bit easier to read +Style/TernaryParentheses: + EnforcedStyle: require_parentheses_when_complex + +Style/TopLevelMethodDefinition: + Enabled: true + Exclude: + - "Taps/**/*" + +# Trailing commas make diffs nicer. +Style/TrailingCommaInArguments: + EnforcedStyleForMultiline: comma +Style/TrailingCommaInArrayLiteral: + EnforcedStyleForMultiline: comma +Style/TrailingCommaInHashLiteral: + EnforcedStyleForMultiline: comma + +# `unless ... ||` and `unless ... &&` are hard to mentally parse +Style/UnlessLogicalOperators: + Enabled: true + EnforcedStyle: forbid_logical_operators + +# a bit confusing to non-Rubyists but useful for longer arrays +Style/WordArray: + MinSize: 4 From 24248afd6f38d4b1773b1786a34b3e83288dd82c Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Fri, 24 May 2024 12:30:37 +0200 Subject: [PATCH 2/3] :rotating_light: (rubocop): Fix all warnings --- Formula/arm-gcc-bin@10.rb | 2 ++ Formula/arm-gcc-bin@11.rb | 2 ++ Formula/arm-gcc-bin@12.rb | 2 ++ Formula/arm-gcc-bin@13.rb | 6 ++-- Formula/arm-gcc-bin@8.rb | 2 ++ Formula/arm-gcc-bin@9.rb | 2 ++ Formula/arm-none-eabi-binutils.rb | 2 ++ Formula/arm-none-eabi-gcc@8.rb | 52 ++++++++++++++++--------------- Formula/arm-none-eabi-gcc@9.rb | 52 ++++++++++++++++--------------- 9 files changed, 70 insertions(+), 52 deletions(-) diff --git a/Formula/arm-gcc-bin@10.rb b/Formula/arm-gcc-bin@10.rb index bbdaed1..da39c5c 100644 --- a/Formula/arm-gcc-bin@10.rb +++ b/Formula/arm-gcc-bin@10.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ArmGccBinAT10 < Formula desc "Pre-built GNU toolchain for Arm Cortex-M and Cortex-R processors" homepage "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm" diff --git a/Formula/arm-gcc-bin@11.rb b/Formula/arm-gcc-bin@11.rb index 4c4ef1f..458a4b2 100644 --- a/Formula/arm-gcc-bin@11.rb +++ b/Formula/arm-gcc-bin@11.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ArmGccBinAT11 < Formula desc "Pre-built GNU toolchain for Arm Cortex-M and Cortex-R processors" homepage "https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads" diff --git a/Formula/arm-gcc-bin@12.rb b/Formula/arm-gcc-bin@12.rb index 4d15128..29ebe9a 100644 --- a/Formula/arm-gcc-bin@12.rb +++ b/Formula/arm-gcc-bin@12.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ArmGccBinAT12 < Formula @tar_file = if Hardware::CPU.arm? "arm-gnu-toolchain-12.2.rel1-darwin-arm64-arm-none-eabi.tar.xz" diff --git a/Formula/arm-gcc-bin@13.rb b/Formula/arm-gcc-bin@13.rb index 2a90f52..fbf5996 100644 --- a/Formula/arm-gcc-bin@13.rb +++ b/Formula/arm-gcc-bin@13.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ArmGccBinAT13 < Formula @tar_file = if Hardware::CPU.arm? "arm-gnu-toolchain-13.2.rel1-darwin-arm64-arm-none-eabi.tar.xz" @@ -13,8 +15,8 @@ class ArmGccBinAT13 < Formula bottle do root_url "https://github.com/osx-cross/homebrew-arm/releases/download/arm-gcc-bin@13-13.2.rel1" sha256 cellar: :any_skip_relocation, arm64_sonoma: "91ec58e4f00cf911ed4d12534591b776e9b1217ceb3b5b5f582da76646f70de7" - sha256 cellar: :any, ventura: "6e8834c9c8bd67023b438451588ac679b2c520139ff9daec0692f184923078ec" - sha256 cellar: :any, monterey: "b2ea7549fb70b7a69438a814c84bd9ef637b33ee93ec135842e82b787aa1db34" + sha256 cellar: :any_skip_relocation, ventura: "6e8834c9c8bd67023b438451588ac679b2c520139ff9daec0692f184923078ec" + sha256 cellar: :any_skip_relocation, monterey: "b2ea7549fb70b7a69438a814c84bd9ef637b33ee93ec135842e82b787aa1db34" end @tar_file_sha = if Hardware::CPU.arm? diff --git a/Formula/arm-gcc-bin@8.rb b/Formula/arm-gcc-bin@8.rb index 73694e9..2c76dff 100644 --- a/Formula/arm-gcc-bin@8.rb +++ b/Formula/arm-gcc-bin@8.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ArmGccBinAT8 < Formula desc "Pre-built GNU toolchain for Arm Cortex-M and Cortex-R processors" homepage "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm" diff --git a/Formula/arm-gcc-bin@9.rb b/Formula/arm-gcc-bin@9.rb index 8e631e3..85b7420 100644 --- a/Formula/arm-gcc-bin@9.rb +++ b/Formula/arm-gcc-bin@9.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ArmGccBinAT9 < Formula desc "Pre-built GNU toolchain for Arm Cortex-M and Cortex-R processors" homepage "https://developer.arm.com/open-source/gnu-toolchain/gnu-rm" diff --git a/Formula/arm-none-eabi-binutils.rb b/Formula/arm-none-eabi-binutils.rb index a282e65..b46f811 100644 --- a/Formula/arm-none-eabi-binutils.rb +++ b/Formula/arm-none-eabi-binutils.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ArmNoneEabiBinutils < Formula desc "GNU Tools for ARM Embedded Processors - Binutils" homepage "https://www.gnu.org/software/binutils/binutils.html" diff --git a/Formula/arm-none-eabi-gcc@8.rb b/Formula/arm-none-eabi-gcc@8.rb index 76f7e34..43c4244 100644 --- a/Formula/arm-none-eabi-gcc@8.rb +++ b/Formula/arm-none-eabi-gcc@8.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ArmNoneEabiGccAT8 < Formula desc "GNU Tools for ARM Embedded Processors - GCC" homepage "https://www.gnu.org/software/gcc/gcc.html" @@ -47,7 +49,7 @@ class ArmNoneEabiGccAT8 < Formula end def install - arm_prefix = prefix/"arm-none-eabi" + arm_prefix = prefix / "arm-none-eabi" # GCC will suffer build errors if forced to use a particular linker. ENV.delete "LD" @@ -63,8 +65,8 @@ def install --prefix=/ --target=arm-none-eabi --enable-languages=c - --with-ld=#{Formula["arm-none-eabi-binutils"].opt_bin/"arm-none-eabi-ld"} - --with-as=#{Formula["arm-none-eabi-binutils"].opt_bin/"arm-none-eabi-as"} + --with-ld=#{Formula["arm-none-eabi-binutils"].opt_bin / "arm-none-eabi-ld"} + --with-as=#{Formula["arm-none-eabi-binutils"].opt_bin / "arm-none-eabi-as"} --disable-nls --disable-libssp --disable-shared @@ -87,7 +89,7 @@ def install --with-multilib-list=rmprofile --with-system-zlib --with-sysroot=#{prefix} - --with-build-sysroot=#{buildpath.parent/"gcc-install"} + --with-build-sysroot=#{buildpath.parent / "gcc-install"} ] # Avoid reference to sed shim @@ -99,21 +101,21 @@ def install # otherwise updated load commands won't fit in the Mach-O header. # This is needed because `gcc` avoids the superenv shim. system "make", "all-gcc", "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" - system "make", "DESTDIR=#{buildpath.parent/"gcc-install"}", "install-gcc" + system "make", "DESTDIR=#{buildpath.parent / "gcc-install"}", "install-gcc" end - ENV["PATH"] = "#{buildpath.parent/"gcc-install/bin"}:#{ENV["PATH"]}" + ENV["PATH"] = "#{buildpath.parent / "gcc-install/bin"}:#{ENV["PATH"]}" # `make install` complains if these dirs do not already exist, for some reason - (arm_prefix/"lib/arm/v5te/hard").mkpath - (arm_prefix/"lib/arm/v5te/softfp").mkpath - (arm_prefix/"lib/thumb/nofp").mkpath + (arm_prefix / "lib/arm/v5te/hard").mkpath + (arm_prefix / "lib/arm/v5te/softfp").mkpath + (arm_prefix / "lib/thumb/nofp").mkpath ["v6-m", "v7", "v7-m", "v7e-m", "v8-m.base", "v8-m.main"].each do |v| - (arm_prefix/"lib/thumb/#{v}/nofp").mkpath + (arm_prefix / "lib/thumb/#{v}/nofp").mkpath end ["v7+fp", "v7e-m+fp", "v7e-m+dp", "v8-m.main+fp", "v8-m.main+dp"].each do |v| - (arm_prefix/"lib/thumb/#{v}/hard").mkpath - (arm_prefix/"lib/thumb/#{v}/softfp").mkpath + (arm_prefix / "lib/thumb/#{v}/hard").mkpath + (arm_prefix / "lib/thumb/#{v}/softfp").mkpath end mkdir "build-nano" do @@ -138,11 +140,11 @@ def install system "make" system "make", "install" - (arm_prefix/"lib").glob("**/lib{c,g,rdimon}.a").each do |f| + (arm_prefix / "lib").glob("**/lib{c,g,rdimon}.a").each do |f| mv f, f.sub(".a", "_nano.a") end - (arm_prefix/"include/newlib-nano").mkpath - mv arm_prefix/"include/newlib.h", arm_prefix/"include/newlib-nano/newlib.h" + (arm_prefix / "include/newlib-nano").mkpath + mv arm_prefix / "include/newlib.h", arm_prefix / "include/newlib-nano/newlib.h" end mkdir "build" do @@ -175,8 +177,8 @@ def install --enable-languages=#{languages.join(",")} - --with-ld=#{Formula["arm-none-eabi-binutils"].opt_bin/"arm-none-eabi-ld"} - --with-as=#{Formula["arm-none-eabi-binutils"].opt_bin/"arm-none-eabi-as"} + --with-ld=#{Formula["arm-none-eabi-binutils"].opt_bin / "arm-none-eabi-ld"} + --with-as=#{Formula["arm-none-eabi-binutils"].opt_bin / "arm-none-eabi-as"} --enable-plugins --disable-decimal-float @@ -219,7 +221,7 @@ def install # otherwise updated load commands won't fit in the Mach-O header. # This is needed because `gcc` avoids the superenv shim. system "make", "INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'", - "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" + "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" system "make", "install" end @@ -230,7 +232,7 @@ def install ENV["CXXFLAGS_FOR_TARGET"] = "-g -Os -ffunction-sections -fdata-sections -fno-exceptions" system "make", "INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'", - "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" + "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" system "make", "DESTDIR=#{buildpath.parent}/nano-install", "install" end @@ -238,19 +240,19 @@ def install multilibs = `#{bin}/arm-none-eabi-gcc -print-multi-lib`.split("\n") multilibs.each do |multilib| m_dir = multilib.split(";").first.chomp - from_dir = buildpath.parent/"nano-install"/arm_prefix/"lib"/m_dir - to_dir = arm_prefix/"lib"/m_dir - cp from_dir/"libstdc++.a", to_dir/"libstdc++_nano.a" - cp from_dir/"libsupc++.a", to_dir/"libsupc++_nano.a" + from_dir = buildpath.parent / "nano-install" / arm_prefix / "lib" / m_dir + to_dir = arm_prefix / "lib" / m_dir + cp from_dir / "libstdc++.a", to_dir / "libstdc++_nano.a" + cp from_dir / "libsupc++.a", to_dir / "libsupc++_nano.a" end # strip target binaries - (arm_prefix/"lib").glob("**/*.{a,o}").each do |f| + (arm_prefix / "lib").glob("**/*.{a,o}").each do |f| system "arm-none-eabi-objcopy", "-R", ".comment", "-R", ".note", "-R", ".debug_info", "-R", ".debug_aranges", "-R", ".debug_pubnames", "-R", ".debug_pubtypes", "-R", ".debug_abbrev", "-R", ".debug_line", "-R", ".debug_str", "-R", ".debug_ranges", "-R", ".debug_loc", f.to_s end - (prefix/"lib").glob("**/*.{a,o}").each do |f| + (prefix / "lib").glob("**/*.{a,o}").each do |f| system "arm-none-eabi-objcopy", "-R", ".comment", "-R", ".note", "-R", ".debug_info", "-R", ".debug_aranges", "-R", ".debug_pubnames", "-R", ".debug_pubtypes", "-R", ".debug_abbrev", "-R", ".debug_line", "-R", ".debug_str", "-R", ".debug_ranges", "-R", ".debug_loc", f.to_s diff --git a/Formula/arm-none-eabi-gcc@9.rb b/Formula/arm-none-eabi-gcc@9.rb index a4851d0..0c728a5 100644 --- a/Formula/arm-none-eabi-gcc@9.rb +++ b/Formula/arm-none-eabi-gcc@9.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ArmNoneEabiGccAT9 < Formula desc "GNU Tools for ARM Embedded Processors - GCC" homepage "https://www.gnu.org/software/gcc/gcc.html" @@ -47,7 +49,7 @@ class ArmNoneEabiGccAT9 < Formula end def install - arm_prefix = prefix/"arm-none-eabi" + arm_prefix = prefix / "arm-none-eabi" # GCC will suffer build errors if forced to use a particular linker. ENV.delete "LD" @@ -63,8 +65,8 @@ def install --prefix=/ --target=arm-none-eabi --enable-languages=c - --with-ld=#{Formula["arm-none-eabi-binutils"].opt_bin/"arm-none-eabi-ld"} - --with-as=#{Formula["arm-none-eabi-binutils"].opt_bin/"arm-none-eabi-as"} + --with-ld=#{Formula["arm-none-eabi-binutils"].opt_bin / "arm-none-eabi-ld"} + --with-as=#{Formula["arm-none-eabi-binutils"].opt_bin / "arm-none-eabi-as"} --disable-nls --disable-libssp --disable-shared @@ -87,7 +89,7 @@ def install --with-multilib-list=rmprofile --with-system-zlib --with-sysroot=#{prefix} - --with-build-sysroot=#{buildpath.parent/"gcc-install"} + --with-build-sysroot=#{buildpath.parent / "gcc-install"} ] # Avoid reference to sed shim @@ -99,21 +101,21 @@ def install # otherwise updated load commands won't fit in the Mach-O header. # This is needed because `gcc` avoids the superenv shim. system "make", "all-gcc", "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" - system "make", "DESTDIR=#{buildpath.parent/"gcc-install"}", "install-gcc" + system "make", "DESTDIR=#{buildpath.parent / "gcc-install"}", "install-gcc" end - ENV["PATH"] = "#{buildpath.parent/"gcc-install/bin"}:#{ENV["PATH"]}" + ENV["PATH"] = "#{buildpath.parent / "gcc-install/bin"}:#{ENV["PATH"]}" # `make install` complains if these dirs do not already exist, for some reason - (arm_prefix/"lib/arm/v5te/hard").mkpath - (arm_prefix/"lib/arm/v5te/softfp").mkpath - (arm_prefix/"lib/thumb/nofp").mkpath + (arm_prefix / "lib/arm/v5te/hard").mkpath + (arm_prefix / "lib/arm/v5te/softfp").mkpath + (arm_prefix / "lib/thumb/nofp").mkpath ["v6-m", "v7", "v7-m", "v7e-m", "v8-m.base", "v8-m.main"].each do |v| - (arm_prefix/"lib/thumb/#{v}/nofp").mkpath + (arm_prefix / "lib/thumb/#{v}/nofp").mkpath end ["v7+fp", "v7e-m+fp", "v7e-m+dp", "v7-r+fp.sp", "v8-m.main+fp", "v8-m.main+dp"].each do |v| - (arm_prefix/"lib/thumb/#{v}/hard").mkpath - (arm_prefix/"lib/thumb/#{v}/softfp").mkpath + (arm_prefix / "lib/thumb/#{v}/hard").mkpath + (arm_prefix / "lib/thumb/#{v}/softfp").mkpath end mkdir "build-nano" do @@ -138,11 +140,11 @@ def install system "make" system "make", "install" - (arm_prefix/"lib").glob("**/lib{c,g,rdimon}.a").each do |f| + (arm_prefix / "lib").glob("**/lib{c,g,rdimon}.a").each do |f| mv f, f.sub(".a", "_nano.a") end - (arm_prefix/"include/newlib-nano").mkpath - mv arm_prefix/"include/newlib.h", arm_prefix/"include/newlib-nano/newlib.h" + (arm_prefix / "include/newlib-nano").mkpath + mv arm_prefix / "include/newlib.h", arm_prefix / "include/newlib-nano/newlib.h" end mkdir "build" do @@ -175,8 +177,8 @@ def install --enable-languages=#{languages.join(",")} - --with-ld=#{Formula["arm-none-eabi-binutils"].opt_bin/"arm-none-eabi-ld"} - --with-as=#{Formula["arm-none-eabi-binutils"].opt_bin/"arm-none-eabi-as"} + --with-ld=#{Formula["arm-none-eabi-binutils"].opt_bin / "arm-none-eabi-ld"} + --with-as=#{Formula["arm-none-eabi-binutils"].opt_bin / "arm-none-eabi-as"} --enable-plugins --disable-decimal-float @@ -219,7 +221,7 @@ def install # otherwise updated load commands won't fit in the Mach-O header. # This is needed because `gcc` avoids the superenv shim. system "make", "INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'", - "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" + "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" system "make", "install" end @@ -230,7 +232,7 @@ def install ENV["CXXFLAGS_FOR_TARGET"] = "-g -Os -ffunction-sections -fdata-sections -fno-exceptions" system "make", "INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'", - "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" + "BOOT_LDFLAGS=-Wl,-headerpad_max_install_names" system "make", "DESTDIR=#{buildpath.parent}/nano-install", "install" end @@ -238,19 +240,19 @@ def install multilibs = `#{bin}/arm-none-eabi-gcc -print-multi-lib`.split("\n") multilibs.each do |multilib| m_dir = multilib.split(";").first.chomp - from_dir = buildpath.parent/"nano-install"/arm_prefix/"lib"/m_dir - to_dir = arm_prefix/"lib"/m_dir - cp from_dir/"libstdc++.a", to_dir/"libstdc++_nano.a" - cp from_dir/"libsupc++.a", to_dir/"libsupc++_nano.a" + from_dir = buildpath.parent / "nano-install" / arm_prefix / "lib" / m_dir + to_dir = arm_prefix / "lib" / m_dir + cp from_dir / "libstdc++.a", to_dir / "libstdc++_nano.a" + cp from_dir / "libsupc++.a", to_dir / "libsupc++_nano.a" end # strip target binaries - (arm_prefix/"lib").glob("**/*.{a,o}").each do |f| + (arm_prefix / "lib").glob("**/*.{a,o}").each do |f| system "arm-none-eabi-objcopy", "-R", ".comment", "-R", ".note", "-R", ".debug_info", "-R", ".debug_aranges", "-R", ".debug_pubnames", "-R", ".debug_pubtypes", "-R", ".debug_abbrev", "-R", ".debug_line", "-R", ".debug_str", "-R", ".debug_ranges", "-R", ".debug_loc", f.to_s end - (prefix/"lib").glob("**/*.{a,o}").each do |f| + (prefix / "lib").glob("**/*.{a,o}").each do |f| system "arm-none-eabi-objcopy", "-R", ".comment", "-R", ".note", "-R", ".debug_info", "-R", ".debug_aranges", "-R", ".debug_pubnames", "-R", ".debug_pubtypes", "-R", ".debug_abbrev", "-R", ".debug_line", "-R", ".debug_str", "-R", ".debug_ranges", "-R", ".debug_loc", f.to_s From 1295df612f697149ff8c72ddf06e15ec589b14b9 Mon Sep 17 00:00:00 2001 From: Ladislas de Toldi Date: Fri, 24 May 2024 12:41:41 +0200 Subject: [PATCH 3/3] :bug: (formula): Fix arm-gcc-bin@13 tar_file_sha location --- Formula/arm-gcc-bin@13.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Formula/arm-gcc-bin@13.rb b/Formula/arm-gcc-bin@13.rb index fbf5996..754eeef 100644 --- a/Formula/arm-gcc-bin@13.rb +++ b/Formula/arm-gcc-bin@13.rb @@ -7,6 +7,12 @@ class ArmGccBinAT13 < Formula "arm-gnu-toolchain-13.2.rel1-darwin-x86_64-arm-none-eabi.tar.xz" end + @tar_file_sha = if Hardware::CPU.arm? + "39c44f8af42695b7b871df42e346c09fee670ea8dfc11f17083e296ea2b0d279" + else + "075faa4f3e8eb45e59144858202351a28706f54a6ec17eedd88c9fb9412372cc" + end + desc "Pre-built GNU toolchain for Arm Cortex-M and Cortex-R processors" homepage "https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads" url "https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/#{@tar_file}" @@ -19,12 +25,6 @@ class ArmGccBinAT13 < Formula sha256 cellar: :any_skip_relocation, monterey: "b2ea7549fb70b7a69438a814c84bd9ef637b33ee93ec135842e82b787aa1db34" end - @tar_file_sha = if Hardware::CPU.arm? - "39c44f8af42695b7b871df42e346c09fee670ea8dfc11f17083e296ea2b0d279" - else - "075faa4f3e8eb45e59144858202351a28706f54a6ec17eedd88c9fb9412372cc" - end - depends_on "xz" unless Hardware::CPU.arm? keg_only <<~KEG_ONLY_EOS