Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 43 additions & 22 deletions scripts/lldb.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,18 @@ function getLibPath(libDir) {
return path.join(libDir, lib);
}

/**
* Check if the installed version of git supports sparse checkout. Notably,
* Ubuntu 18.04 (which is not EOL at time of writing) has git 2.17, which does
* not support sparse-checkout.
*/
function doesGitSupportSparseCheckout() {
const returnCode = child_process.spawnSync('git', ['sparse-checkout', '--help']).status;
return returnCode === 0;
}

/**
* Check out source code of the lldb for headers
* TODO: The llvm project is probably moving to github soon at that point we
* should stop using the mirror.
* @param {string} lldbVersion Version of lldb, either like 3.9 or 39
* @param {string} buildDir Path to the llnode module directory
* @returns {string} The include directory in the downloaded lldb source code
Expand All @@ -60,26 +68,39 @@ function cloneHeaders(lldbVersion, buildDir) {

if (!fs.existsSync(lldbInstallDir)) {
console.log(`\nCloning lldb ${lldbHeadersBranch} into ${lldbInstallDir}`);
// use `git clone --filter` in git v2.19 to only download `lldb` dir of `llvm-project` monorepo
// see: https://stackoverflow.com/a/52269934/3117331
// see: https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/
child_process.execFileSync(
'git', ['clone',
'--depth', '1',
'--filter=blob:none',
'--sparse',
'--branch', lldbHeadersBranch,
'https://github.com/llvm/llvm-project.git',
lldbInstallDir
],
{ stdio: 'inherit' }); // show progress
child_process.execFileSync(
'git', [
'-C', lldbInstallDir,
'sparse-checkout',
'set', 'lldb'
],
{ stdio: 'inherit' }); // show progress
if (doesGitSupportSparseCheckout()) {
// use `git clone --filter` in git v2.19 to only download `lldb` dir of `llvm-project` monorepo
// see: https://stackoverflow.com/a/52269934/3117331
// see: https://github.blog/2020-01-17-bring-your-monorepo-down-to-size-with-sparse-checkout/
child_process.execFileSync(
'git', ['clone',
'--depth', '1',
'--filter=blob:none',
'--sparse',
'--branch', lldbHeadersBranch,
'https://github.com/llvm/llvm-project.git',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe could we put that one into a variable ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @tony-go I'm looking to merge this.
Can you be a bit more specific with the point about the variable?
I'm not 100% on what your ask is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the ask is to put the Github URL into a variable. I don't feel particularly strongly about it; feel free to do it before merging if you'd like.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK this has been around for a while with no updates.
@tony-go I'm also not strongly pushed about changing the implementation.
I'll merge this and please feel free to PR your suggested change if you want.

lldbInstallDir
],
{ stdio: 'inherit' }); // show progress
child_process.execFileSync(
'git', [
'-C', lldbInstallDir,
'sparse-checkout',
'set', 'lldb'
],
{ stdio: 'inherit' }); // show progress
} else {
// There's no sparse checkout support, so we need to clone the entire
// repo.
child_process.execFileSync(
'git', ['clone',
'--depth', '1',
'--branch', lldbHeadersBranch,
'https://github.com/llvm/llvm-project.git',
lldbInstallDir
],
{ stdio: 'inherit' }); // show progress
}
} else {
console.log(`\nSkip cloning lldb headers because ${lldbInstallDir} exists`);
}
Expand Down