Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.4 KB
Raw Blame
const { execFileSync } = require('node:child_process')
const { copyFileSync, cpSync, mkdirSync, mkdtempSync, rmSync } = require('node:fs')
const { tmpdir } = require('node:os')
const { join, resolve } = require('node:path')

const SHIPIT_SCHEDULING_ADDON = 'orca_shipit_scheduling.node'

function buildMacShipItScheduling(resourcesDir, arch) {
  if (process.platform !== 'darwin' || !['x64', 'arm64'].includes(arch)) {
    throw new Error(`Cannot build macOS installer scheduling for ${process.platform}/${arch}`)
  }
  const root = resolve(__dirname, '../..')
  const workDir = mkdtempSync(join(tmpdir(), `orca-shipit-scheduling-${arch}-`))
  try {
    cpSync(join(root, 'native/macos-shipit-scheduling'), workDir, { recursive: true })
    execFileSync(
      process.execPath,
      [require.resolve('node-gyp/bin/node-gyp.js'), 'rebuild', `--arch=${arch}`],
      { cwd: workDir, stdio: 'inherit' }
    )
    const built = join(workDir, 'build/Release', SHIPIT_SCHEDULING_ADDON)
    const expectedArch = arch === 'x64' ? 'x86_64' : 'arm64'
    execFileSync('/usr/bin/lipo', [built, '-verify_arch', expectedArch])
    mkdirSync(resourcesDir, { recursive: true })
    const target = join(resourcesDir, SHIPIT_SCHEDULING_ADDON)
    copyFileSync(built, target)
    return target
  } finally {
    rmSync(workDir, { recursive: true, force: true })
  }
}

module.exports = { buildMacShipItScheduling, SHIPIT_SCHEDULING_ADDON }