-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: update clang-fetcher with libcxx headers and object paths
- Loading branch information
1 parent
c35888a
commit ea37945
Showing
2 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import * as debug from 'debug'; | ||
import * as fs from 'fs-extra'; | ||
import * as path from 'path'; | ||
import * as tar from 'tar'; | ||
import * as zlib from 'zlib'; | ||
import { ELECTRON_GYP_DIR } from './constants'; | ||
import { fetch } from './fetcher'; | ||
|
||
const d = debug('electron-rebuild'); | ||
|
||
// Determine base where we download these headers | ||
// `-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++', 'trunk', 'include')}"`, | ||
// `-isystem"${path.resolve(BASE, 'buildtools', 'third_party', 'libc++abi', 'trunk', 'include')}"`, | ||
export async function downloadLibcxxHeaders(electronVersion: string, libs: string[]): Promise<string> { | ||
const headersDirPath = path.resolve(ELECTRON_GYP_DIR, `${electronVersion}-libcxx_headers`); | ||
|
||
for (const lib_name in libs) { | ||
if (await fs.pathExists(path.resolve(headersDirPath, `${lib_name}`))) return headersDirPath; | ||
if (!await fs.pathExists(ELECTRON_GYP_DIR)) await fs.mkdirp(ELECTRON_GYP_DIR); | ||
|
||
// download libcxxabi_headers.zip | ||
const contents = await fetch(`https://raw.githubusercontent.com/electron/electron/v${electronVersion}/${lib_name}_headers.zip`, 'buffer') | ||
d(`deflating ${lib_name}_headers`); | ||
zlib.deflateSync(contents); | ||
const tarPath = path.resolve(ELECTRON_GYP_DIR, `${electronVersion}-${lib_name}_headers.tar`); | ||
if (await fs.pathExists(tarPath)) await fs.remove(tarPath) | ||
await fs.writeFile(tarPath, Buffer.from(contents)); | ||
await fs.mkdirp(headersDirPath); | ||
|
||
d(`tar running on ${lib_name}_headers`); | ||
await tar.x({ | ||
file: tarPath, | ||
cwd: headersDirPath, | ||
}); | ||
|
||
await fs.remove(tarPath); | ||
d(`cleaning up ${lib_name}_headers tar file`); | ||
} | ||
return headersDirPath; | ||
} | ||
|
||
// Determine base where we download these headers | ||
// `-L"${path.resolve(BASE, 'out', `${utils.getOutDir({ shouldLog: true })}`, 'obj', 'buildtools', 'third_party', 'libc++abi')}"`, | ||
// `-L"${path.resolve(BASE, 'out', `${utils.getOutDir({ shouldLog: true })}`, 'obj', 'buildtools', 'third_party', 'libc++')}"`, | ||
export async function downloadLibcxxObjects(electronVersion: string, targetArch: string): Promise<string> { | ||
const platform = process.platform; | ||
const libcxxObjectsDirPath = path.resolve(ELECTRON_GYP_DIR, 'libcxx-objects'); | ||
|
||
if (await fs.pathExists(path.resolve(libcxxObjectsDirPath, 'libcxx-objects'))) return libcxxObjectsDirPath; | ||
if (!await fs.pathExists(ELECTRON_GYP_DIR)) await fs.mkdirp(ELECTRON_GYP_DIR); | ||
|
||
// download objects (e.g. libcxx-objects-v13.0.0-linux-x64.zip) | ||
const contents = await fetch(`https://raw.githubusercontent.com/electron/electron/v${electronVersion}/libcxx-objects-v${electronVersion}-${platform}-${targetArch}.zip`, 'buffer') | ||
d(`deflating libcxx-objects-${platform}-${targetArch}`); | ||
zlib.deflateSync(contents); | ||
const tarPath = path.resolve(ELECTRON_GYP_DIR, `libcxx-objects-v${electronVersion}-${platform}-${targetArch}.tar`); | ||
if (await fs.pathExists(tarPath)) await fs.remove(tarPath) | ||
await fs.writeFile(tarPath, Buffer.from(contents)); | ||
await fs.mkdirp(libcxxObjectsDirPath); | ||
|
||
d(`tar running on libcxx-objects-${platform}-${targetArch}`); | ||
await tar.x({ | ||
file: tarPath, | ||
cwd: libcxxObjectsDirPath, | ||
}); | ||
|
||
await fs.remove(tarPath); | ||
d(`cleaning up libcxx-objects-${platform}-${targetArch} tar file`); | ||
return libcxxObjectsDirPath; | ||
} | ||
|