32 Commits

Author SHA1 Message Date
Mike McQuaid
d135e744b1
Add more Sorbet types
`typed: strict` a few more places and fix other files necessarily to
make that happen.
2025-08-15 19:21:28 +01:00
Douglas Eichelberger
eed660e784 Move remaining OS extensions to prepend 2024-10-05 12:18:29 -07:00
Douglas Eichelberger
61985bc7f3 Use top-level OS instead 2024-09-19 10:58:53 -07:00
Douglas Eichelberger
bb80f063dc Fix namespacing 2024-09-19 10:58:53 -07:00
Douglas Eichelberger
27e951c408 Replace undef with prepended modules 2024-09-19 10:58:53 -07:00
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
Issy Long
0e81efcccb
sorbet: Comment more files that can't be strict because of undef
- Found with
  `grep -rL "# typed: strict" Library/Homebrew | xargs grep -l "undef "`.
- This stops people from trying to bump them and
  getting an error that they can't fix because
  [it's a Sorbet limitation](https://sorbet.org/docs/error-reference#3008),
  wasting contributor time.
2024-08-09 18:23:00 +01:00
apainintheneck
c073cf901a search: show results by platform
This means that formulas that are only available on one
OS should only show up in the search results for the platform.
2023-03-27 20:04:57 -07:00
Mike McQuaid
59f4b5226a
tests: test on Ubuntu 18.04. 2022-11-09 14:45:43 +00:00
Bo Anderson
66fa1f7e6a
Use GCC 12 for runtime libraries 2022-09-19 00:51:17 +01:00
Mike McQuaid
1f709d360d
extend/os/linux: improve glibc, gcc dependency handling.
- Add more early return checks
- Move to a recursive approach for more readability and avoiding a
  counter that we need to bump
- Perform more caching
- Keep class variable usage isolated into specific methods
2022-08-30 12:54:34 +00:00
Michka Popoff
d271614872
install glibc/gcc automatically if too old.
Right now this is done through the gcc@5 formula.
See 9692318ca6/Formula/gcc%405.rb (L33)

This is fragile because when we will migrate to gcc@11
we have to think about migrating the installation from one gcc formula to another..
Also, not having the right glibc version results in a non-functional brew
installation on an older Linux: the glibc installation needs
to be done by brew, and not by a workaround in a specific formula

Co-Authored-By: Mike McQuaid <mike@mikemcquaid.com>
Co-Authored-By: Bo Anderson <mail@boanderson.me>
Co-Authored-By: Shaun Jackman <sjackman@gmail.com>
2022-08-25 11:04:37 +01:00
Carlo Cabrera
c7030eaba0
formula: add optional source and target args to #rpath
There are about 10 formulae which need a bit more flexibility from
`#rpath`. Most of them use `Pathname#relative_path_from`, so we can
replace those instances with a call to `#rpath` instead once `#rpath`
knows how to handle this.
2022-08-19 17:32:43 +08:00
Rylan Polster
34a1bc6618
Use SimulateSystem for ignore_missing_libraries 2022-07-23 03:09:29 +02:00
Carlo Cabrera
5e0b786da2
formula: add deuniversalize_machos method
This method takes an optional array of `Pathnames`s or `Strings`s and
extracts the native slice from the specified universal binary. If no
parameter is supplied, this is done on all compatible universal binaries
in a formula's keg.

`deuniversalize_machos` is a no-op on Linux.

I still need to look into a) error handling, and b) whether using this
method requires codesigning on ARM.

I've also added signatures to the methods in `extend/os/linux/formula`.
2021-07-22 01:24:56 +08:00
Carlo Cabrera
309504a32c
formula: add rpath helper method
About 40 formulae set `CMAKE_INSTALL_RPATH` to `lib` or `opt_lib`, but
this breaks bottle relocatability.

The correct solution is to use `@loader_path/../lib`, but this is macOS
specific, so it requires some OS-specific logic. Rather than replicating
this logic over many formulae, we may as well define a helper method for
it.

See https://github.com/Homebrew/homebrew-core/issues/75458.
2021-04-19 09:23:33 +01:00
Seeker
0aa4259654 formula: include versioned *.so.* libs for shared_library("*") 2020-12-24 08:51:01 -08:00
Seeker
a2af19360b extend: add on_os (for on_macos/on_linux) 2020-12-07 10:36:51 -08:00
Markus Reiter
0184e271d8 Fix RuboCop offenses. 2020-11-17 11:09:55 +01:00
Michka Popoff
8b85ef2e88 formula: add on_linux and on_macos blocks
for install and others
2020-11-03 22:54:07 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Maxim Belkin
152dd1ca24 Move allowed_missing_libraries: extend/os/linux/formula.rb ~> formula.rb 2020-07-24 11:06:38 +00:00
Maxim Belkin
85cca2e852 formula.rb [Linux]: undefine allowed_missing_libraries first 2020-07-24 10:54:44 +00:00
Maxim Belkin
1b8c32c716 Move allowed_missing_libs? to linkage_checker.rb.
Optimize 'unexpected_broken_dylibs'
2020-07-22 14:30:52 +00:00
Maxim Belkin
73495c4959 formula.rb [extend/Linux]: add missing comma 2020-07-21 15:48:55 +00:00
Maxim Belkin
2ffb9fd0fc
extend/os/linux/formula.rb: ignore_missing_libraries: change unless to if
Change
```rb
      unless libraries.all? { |x| x.is_a?(String) || x.is_a?(Regexp) }
```
to
```rb
if libraries.any? { |x| !x.is_a?(String) && !x.is_a?(Regexp) }
```

Co-authored-by: Mike McQuaid <mike@mikemcquaid.com>
2020-07-21 10:43:28 -05:00
Maxim Belkin
68ebf8866a extend/os/linux/formula.rb: allowed_missing_lib: check input class 2020-07-21 15:40:27 +00:00
Maxim Belkin
7080ad5ebc formula.rb: update missing libs feature
1. Raise an exception on macOS.
2. Verify that the missing libraries are specified either as Strings or
   Regular Expressions.

Signed-off-by: Maxim Belkin <maxim.belkin@gmail.com>
2020-07-21 13:16:56 +00:00
Maxim Belkin
f2ddcda85b Fix style (Convert if-elsif to case-when) 2020-07-16 13:53:32 +00:00
Maxim Belkin
c61aba4ec3 Formula: ignore_missing_libraries DSL 2020-07-16 13:51:16 +00:00
Michka Popoff
955bca6574 formule: add generic shared-lib methods
We have strings containing hardcoded ".dylib" extensions in homebrew-core.
To be able to bring linuxbrew-core and homebrew-core closer together,
I am introducing a new generic attribute that can be used in formulae.
2020-06-20 23:14:18 +02:00
Michka Popoff
c7927f5af5 formula: add linux and macos only function blocks 2020-04-12 23:51:41 +02:00