40 Commits

Author SHA1 Message Date
Gibson Fahnestock
69e9f60da8
build_environment: pass http_proxy env vars through to build env
This allows you to build bottles in an environment that doesn't have
access to the source URLs, or things downloaded during the bottling
phase, without a proxy.

These are the set of environment variables that are already documented
in `man brew`.
2025-01-13 19:35:31 +00:00
Patrick Linnane
c2e2b23c50
brew style --fix
Signed-off-by: Patrick Linnane <patrick@linnane.io>
2024-10-02 10:03:12 -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
Markus Reiter
480e264d9a
Lint Ruby docs. 2024-05-01 11:35:21 +02:00
Markus Reiter
0f0055ede4
Make documentation @api private by default. 2024-04-26 19:04:20 +02:00
Douglas Eichelberger
24cf6076e8 brew style --fix 2023-04-24 20:42:39 -07:00
Issy Long
0c86425d6a
rubocop: Drop "o" from Naming/MethodParameterName allowlist
- I couldn't figure out what this would stand for, so I asked on Slack
  if anyone had better ideas otherwise I'd go with "ostrich" or
  "octopus". Rylan suggested "option", which is very sensible.
2023-03-11 00:17:29 +00:00
Issy Long
e9d994622e
rubocop: Drop "f" from Naming/MethodParameterName allowlist
- This either stands for "file" but more often than not "formula".
2023-03-11 00:17:27 +00:00
Bo Anderson
abfbb46678
Freeze formula definition once first instance is created 2022-08-31 20:40:42 +01:00
Sean Molenaar
2de6958a36
build_environment: add proper types to dump() and fix inreplace error 2022-08-15 19:03:55 +02:00
fn ⌃ ⌥
f7cc71b195 build_environment: delete BuildEnvironment#userpaths? 2021-09-30 14:06:00 -07:00
Markus Reiter
70dd41cfd8 Add type signatures to BuildEnvironment. 2020-11-19 16:07:50 +01:00
Markus Reiter
24ae318a3d Move type annotations into files. 2020-10-10 14:59:39 +02:00
Markus Reiter
b5363025a6 Refactor and document BuildEnvironment. 2020-08-14 18:41:44 +02:00
Mike McQuaid
cd777088d0
build_environment: tweak frozen string handling. 2019-05-01 09:03:39 +01:00
Kevin Menard
2f21de596f Fix bad mutable call on a frozen string. 2019-04-30 13:12:27 -04:00
Mike McQuaid
36dbad3922
Add frozen_string_literal to all files. 2019-04-20 13:27:36 +09:00
Mike McQuaid
eed1444d61
Update deprecations and cleanup
- Move `odeprecated` to `odisabled`
- Remove `odisabled`
- Enable automatic cleanup on install/reinstall/upgrade.
2019-01-23 21:57:40 +00:00
Andrew Janke
e0a8a79921 Style fixes for Rubocop 0.57.1 2018-06-30 19:40:14 -04:00
Mike McQuaid
9fca172d03 Fix HOMEBREW_RUBY_WARNINGS="-w"
Fix various circular requirements, method redefinitions, etc.
2018-04-07 20:28:56 +01:00
Maxim Belkin
70005859b1
build_environment: Linux env vars 2017-10-19 15:24:30 -05:00
Markus Reiter
3cdf8f938a Use scoped RSpec matchers. 2017-05-15 17:23:40 +02:00
Markus Reiter
0ab750bf24 Use module_function for commands. 2016-10-02 00:24:47 +02:00
Mike McQuaid
6693915399 rubocop --auto-correct all remaining files.
But remove some manual `.freeze`s on constants that shouldn't be
constants.
2016-09-17 16:14:13 +01:00
Baptiste Fontaine
24a1eeceb3 Common build environment methods moved in build_environment.rb
Closes Homebrew/homebrew#45966.

Signed-off-by: Baptiste Fontaine <batifon@yahoo.fr>
2015-11-17 00:17:22 +01:00
BrewTestBot
13d544e11e Core files style updates.
Closes Homebrew/homebrew#42354.

Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
2015-08-03 13:22:35 +01:00
Jack Nagel
7ee49db51e Remove proc handling from BuildEnvironment 2014-07-07 22:02:32 -05:00
Jack Nagel
6664ec23dc Merge should return self 2014-07-07 20:03:41 -05:00
Jack Nagel
23b4da18c2 Only call proc if it is set
Fixes Homebrew/homebrew#30723.
Fixes Homebrew/homebrew#30724.
Fixes Homebrew/homebrew#30727.
2014-07-07 19:47:11 -05:00
Jack Nagel
5ba06ff614 Define 1.8 marshal hooks in terms of 1.9+ marshal hooks 2014-07-07 18:12:24 -05:00
Jack Nagel
cbdb46887a Remove knowledge of serialization details by marshaling twice 2014-07-07 18:12:24 -05:00
Jack Nagel
8c4569b7c2 Fix BuildEnvironment initializer 2014-07-07 18:12:24 -05:00
Jack Nagel
879ec96743 Only store one proc per BuildEnvironment instance 2014-07-07 17:36:20 -05:00
Jack Nagel
9e7f5dc261 Merge instead of calling << in a loop 2014-07-07 09:15:56 -05:00
Jack Nagel
1b0f0824fe Requirement: env DSL is evaluated in context of self, not ENV
This was meant to support:

  env do |req|
    append_path 'PATH', req.some_method
    ...
  end

i.e., the block was evaluated in the context of ENV. But it turned out
to be not so useful after all, so I'm ripping it out before something
actually depends on it.
2013-04-01 16:17:35 -05:00
Jack Nagel
aca48deda0 BuildEnvironment: use separate sets for procs and symbols 2013-02-25 14:01:02 -06:00
Jack Nagel
2503cedf2c Object#instance_exec for Ruby 1.8.6
Not thread safe! But I don't think we care.

We want to evaluate the env DSL block in the context of ENV for asthetic
reasons, but we also want access to methods on the requirement instance.
We can use #instance_exec to pass the requirement itself into the block:

  class Foo < Requirement
    env do |req|
      append 'PATH', req.some_path
    end

    def some_path
      which 'something'
    end
  end

Also add a simplified version of Object#instance_exec for Ruby 1.8.6.
2013-01-21 17:24:11 -06:00
Jack Nagel
c53af42117 Allow env DSL to take a block
In addition to

  env :userpaths
  env :std

requirements can now do

  env do
    append 'PATH', '/some/path/to/bin'
    # and more
  end
2013-01-21 17:24:10 -06:00
Jack Nagel
a358bee8e2 Clean up BuildEnvironment interface a bit 2012-12-26 14:37:02 -06:00
Adam Vandenberg
88ad4c061d Support env :std, :userpaths
Closes Homebrew/homebrew#14654.
2012-09-14 09:14:48 -07:00