distributable:
  url: https://nodejs.org/dist/v{{ version }}/node-v{{ version }}.tar.xz
  strip-components: 1

versions:
  github: nodejs/node/releases/tags

companions:
  npmjs.com: '*'

dependencies:
  # prior builds of nodejs used our icu4c
  unicode.org: ^71
  openssl.org: 1.1
  zlib.net: 1

provides:
  - bin/node

interprets:
  extensions: js
  args: node

build:
  dependencies:
    # otherwise, we hit https://reviews.llvm.org/D131307
    linux:
      llvm.org: '<16'
      gnu.org/make: '*'
    python.org: ~3.9
    freedesktop.org/pkg-config: ^0.29
  script:
    - run: python configure.py $ARGS
      if: <14
    - run: ./configure $ARGS
      if: '>=14'
    - make --jobs {{ hw.concurrency }} install
  env:
    ARGS:
      - --without-npm
      - --prefix={{ prefix }}
      - --shared-openssl
      - --shared-zlib
    linux:
      CC: clang
      CXX: clang++
      AS: llvm-as
    linux/x86-64:
      CFLAGS: -fPIC
      CXXFLAGS: -fPIC
      LDFLAGS: -pie

test:
  script: |
    out=$(node $FIXTURE)
    test "$out" = "Hello, world!"
  fixture: console.log("Hello, world!");
