Don't require getopt to be installed by brew on macOS for Nix users

Other changes:

* Add/Update copyright banners
* Add post-review comment for https://github.com/status-im/nimbus-eth2/pull/5719
This commit is contained in:
Zahary Karadjov 2024-01-13 12:29:35 +02:00
parent b98f46c04d
commit 05fb7ffff0
No known key found for this signature in database
GPG Key ID: C1F42EAFF38D570F
3 changed files with 19 additions and 2 deletions

View File

@ -1964,6 +1964,14 @@ proc p2pProtocolBackendImpl*(p: P2PProtocol): Backend =
codecNameLit))
result.implementProtocolInit = proc (p: P2PProtocol): NimNode =
# TODO
# This current approach is not building on good foundations.
# Incrementing a global variable at compile-time fundamentally at odds with
# incremental compilation (because a recompile that doesn't revisit the whole
# program will mess up the counting and create duplicate indices).
# A better approach would build upon the `macrocache` module from the standard
# library, which is compatible with incremental compilation:
# https://nim-lang.org/docs/macrocache.html
var id {.global.}: int
let tmp = id
id += 1

View File

@ -1,3 +1,10 @@
# beacon_chain
# Copyright (c) 2023-2024 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
{ pkgs ? import <nixpkgs> {}}:
let
mkdocs-packages = ps: with ps; [
@ -16,6 +23,7 @@ mkShell {
git
git-lfs
gnumake
getopt
# For the local simulation
openssl # for generating the JWT file
@ -34,6 +42,7 @@ mkShell {
# will erase `-march=native` because this introduces impurity in the build.
# For the purposes of compiling Nimbus, this behavior is not desired:
export NIX_ENFORCE_NO_NATIVE=0
export USE_SYSTEM_GETOPT=1
figlet "Welcome to Nimbus-eth2"
'';

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Copyright (c) 2020-2023 Status Research & Development GmbH. Licensed under
# Copyright (c) 2020-2024 Status Research & Development GmbH. Licensed under
# either of:
# - Apache License, version 2.0
# - MIT license
@ -34,7 +34,7 @@ PIDS_TO_WAIT=""
####################
GETOPT_BINARY="getopt"
if [[ "${OS}" == "macos" ]]; then
if [[ "${OS}" == "macos" && "$USE_SYSTEM_GETOPT" != "1" ]]; then
# Without the head -n1 constraint, it gets confused by multiple matches
GETOPT_BINARY=$(find /opt/homebrew/opt/gnu-getopt/bin/getopt /usr/local/opt/gnu-getopt/bin/getopt 2> /dev/null | head -n1 || true)
[[ -f "$GETOPT_BINARY" ]] || { echo "GNU getopt not installed. Please run 'brew install gnu-getopt'. Aborting."; exit 1; }