1#!/usr/bin/env node 2 3const child_process = require('child_process'); 4const stdio = { stdio: 'inherit' }; 5const fs = require('fs'); 6 7function set_env(name, val) { 8 fs.appendFileSync(process.env['GITHUB_ENV'], `${name}=${val}\n`) 9} 10 11// On OSX all we need to do is configure our deployment target as old as 12// possible. For now 10.9 is the limit. 13if (process.platform == 'darwin') { 14 set_env("MACOSX_DEPLOYMENT_TARGET", "10.9"); 15 return; 16} 17 18// On Windows we build against the static CRT to reduce dll dependencies 19if (process.platform == 'win32') { 20 set_env("RUSTFLAGS", "-Ctarget-feature=+crt-static"); 21 return; 22} 23 24// Android doesn't use a container as it's controlled by the installation of the 25// SDK/NDK. 26if (process.env.INPUT_NAME && process.env.INPUT_NAME.indexOf("android") >= 0) { 27 return; 28} 29 30// ... and on Linux we do fancy things with containers. We'll spawn an old 31// CentOS container in the background with a super old glibc, and then we'll run 32// commands in there with the `$CENTOS` env var. 33 34if (process.env.CENTOS !== undefined) { 35 const args = ['exec', '-w', process.cwd(), '-i', 'build-container']; 36 for (const arg of process.argv.slice(2)) { 37 args.push(arg); 38 } 39 child_process.execFileSync('docker', args, stdio); 40 return; 41} 42 43const name = process.env.INPUT_NAME.replace(/-min$/, ''); 44 45child_process.execFileSync('docker', [ 46 'build', 47 '--tag', 'build-image', 48 `${process.cwd()}/ci/docker/${name}` 49], stdio); 50 51child_process.execFileSync('docker', [ 52 'run', 53 '--detach', 54 '--interactive', 55 '--name', 'build-container', 56 '-v', `${process.cwd()}:${process.cwd()}`, 57 '-v', `${child_process.execSync('rustc --print sysroot').toString().trim()}:/rust:ro`, 58 'build-image', 59], stdio); 60 61// Use ourselves to run future commands 62set_env("CENTOS", __filename); 63