27 Commits

Author SHA1 Message Date
Issy Long
45978435e7
rubocop: Use Sorbet/StrictSigil as it's better than comments
- Previously I thought that comments were fine to discourage people from
  wasting their time trying to bump things that used `undef` that Sorbet
  didn't support. But RuboCop is better at this since it'll complain if
  the comments are unnecessary.

- Suggested in https://github.com/Homebrew/brew/pull/18018#issuecomment-2283369501.

- I've gone for a mixture of `rubocop:disable` for the files that can't
  be `typed: strict` (use of undef, required before everything else, etc)
  and `rubocop:todo` for everything else that should be tried to make
  strictly typed. There's no functional difference between the two as
  `rubocop:todo` is `rubocop:disable` with a different name.

- And I entirely disabled the cop for the docs/ directory since
  `typed: strict` isn't going to gain us anything for some Markdown
  linting config files.

- This means that now it's easier to track what needs to be done rather
  than relying on checklists of files in our big Sorbet issue:

```shell
$ git grep 'typed: true # rubocop:todo Sorbet/StrictSigil' | wc -l
    268
```

- And this is confirmed working for new files:

```shell
$ git status
On branch use-rubocop-for-sorbet-strict-sigils
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        Library/Homebrew/bad.rb
        Library/Homebrew/good.rb

nothing added to commit but untracked files present (use "git add" to track)

$ brew style
Offenses:

bad.rb:1:1: C: Sorbet/StrictSigil: Sorbet sigil should be at least strict got true.
^^^^^^^^^^^^^

1340 files inspected, 1 offense detected
```
2024-08-12 15:24:27 +01:00
Mike McQuaid
9d44d278e4
os/mac/keg: fix change_rpath type signature.
Fixes #15990
2023-09-11 14:57:22 +01:00
Steve Peters
94ef9a4b7a codesign in keg_relocate instead of keg methods
Currently the codesign_patched_binary method may be called many
times for the same file when installing a keg.

This removes the calls to codesign_patched_binary from os/mac/keg
and adds a single call to the relocate_dynamic_linkage and
fix_dynamic_linkage methods in extend/os/mac/keg_relocate
to speed up keg installation.
2023-09-09 18:14:28 -07:00
danielnachun
d173b44245
os/mac/keg.rb: move codesign_patched_binary from here 2022-04-08 18:09:32 -07:00
danielnachun
57e3e62edb
os/mac/keg.rb: rename to codesign_patched_binary 2022-03-03 17:35:16 -08:00
Carlo Cabrera
dee3638653
os/mac/{keg,mach}: fix cache invalidation
We were rewriting dylib IDs and install names using `MachO::Tools`,
which doesn't update the state of the file in memory. This leads to
those changes being undone when we call `delete_rpath`.

We fix this by making sure the state of the file in memory always
matches the state of file on disk.

Closes #12832.
2022-02-11 23:19:15 +08:00
Carlo Cabrera
568bc94f3e
os/mac/keg: use MachOFile#delete_rpath instead of MachO::Tools
This will allow us to avoid keeping track of the number of `RPATH`s
while trying to delete duplicates.

See discussion at #12745.
2022-01-19 00:34:39 +08:00
Carlo Cabrera
28c0caae4d
extend/os/mac/keg_relocate: remove RPATHs rooted in build directory
Keeping dangling `RPATH`s is a security risk, and is bad for build
reproducibility.
2021-05-14 01:07:14 +01:00
Carlo Cabrera
4d5971518d
os/mac/keg: add change_rpath method 2021-05-05 21:37:02 +01:00
Bo Anderson
323ff660fa rubocop: use consistent array/hash indentation 2021-02-11 13:27:42 +00:00
Bo Anderson
5202f712c0 os/mac/keg: print stderr on codesign failure 2021-02-11 12:38:40 +00:00
Francois-Xavier Coudert
4665bb8e66 keg: add codesigning 2020-11-12 09:27:07 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
490e503b1b Replace Homebrew.args with Context. 2020-08-06 16:13:14 +02:00
Mike McQuaid
bc27e38f18
Remove ARGV.debug?
Replace with `Homebrew.args.debug?`.

Part of #5730.
2020-05-23 14:38:58 +01:00
EricFromCanada
9bfd597991 Format debug messages with odebug 2019-12-02 11:33:19 -05:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Markus Reiter
e9b9ea49a1 Update to RuboCop 0.59.1. 2018-09-17 03:45:59 +02:00
Markus Reiter
9bee9ca575 Use “squiggly” heredocs. 2017-10-18 14:39:09 +02:00
ilovezfs
e8da9613fb Revert "mach: Avoid reopening the file for relocation" 2017-09-27 02:08:23 -07:00
William Woodruff
d618e574fb
mach: Avoid reopening the file for relocation
This commit allows the relocation code to perform install name
and dylib ID changes without reopening the file separately.
2017-09-25 17:46:23 -04:00
William Woodruff
0dda8a13f1
keg: Skip relocation when dylib ID/install name doesn't change. 2017-03-12 12:29:35 -04:00
Markus Reiter
94dceeab1d Move require_relocation? from os/mac/keg to keg. 2017-02-11 13:43:00 +01:00
William Woodruff
846a5b79b6
Remove old cctools references now that only ruby-macho is used. 2016-09-22 14:36:24 -04:00
William Woodruff
d16e4a782e
os/mac: Delete old cctools-based relocation code.
Disable check for $HOMEBREW_NO_RUBY_MACHO now that no alternative exists.
2016-09-20 17:48:21 -04:00
William Woodruff
f0efaac5aa
Enable ruby-macho by default.
Flips HOMEBREW_RUBY_MACHO to HOMEBREW_NO_RUBY_MACHO.
2016-08-20 10:31:34 -04:00
William Woodruff
afe0fde49c os/mac: optionally use ruby_macho.
- and branch for dylib_id_and_dylibs
- add branches for dylib id changing and change_install_name
- rename MachO module to HomebrewMachO to prevent namespace clashes
  with MachO in ruby-macho. this will eventually be replaced entirely
  with direct calls to ruby-macho methods
- break ruby-macho implementation out into separate RubyMachO module,
  and include either RubyMachO or CctoolsMachO (the original
  implementation) based on the HOMEBREW_RUBY_MACHO env var
- move ArchitectureListExtension and RubyMachO into separate files
- create {ruby_,cctools_,,}relocate.rb for isolation of different
  methods of mach-o relocation (ruby-macho vs. cctools)
- fill in require_install_name_tool? for ruby_relocate.rb
- rename {ruby_,cctools_,,}relocate.rb to keg, isolate requires in
  os/mac

Closes Homebrew/homebrew#45001.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2016-02-03 21:25:40 +00:00