-
-
Notifications
You must be signed in to change notification settings - Fork 101
package.json: Make llnode installable via npm #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a131fd9
76cbbfb
848005f
2e5461d
7813eb0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| llnode.gyp.json |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| { | ||
| "variables": { | ||
| # gyp does not appear to let you test for undefined variables, so define | ||
| # lldb_build_dir as empty so we can test it later. | ||
| "lldb_build_dir%": "" | ||
| }, | ||
|
|
||
| "targets": [{ | ||
| "target_name": "llnode", | ||
| "type": "shared_library", | ||
| "product_prefix": "", | ||
|
|
||
| "include_dirs": [ | ||
| ".", | ||
| "<(lldb_dir)/include", | ||
| ], | ||
|
|
||
| "sources": [ | ||
| "src/llnode.cc", | ||
| "src/llv8.cc", | ||
| "src/llv8-constants.cc", | ||
| "src/llscan.cc", | ||
| ], | ||
|
|
||
| "conditions": [ | ||
| [ "OS == 'mac'", { | ||
| "conditions": [ | ||
| [ "lldb_build_dir == ''", { | ||
| "variables": { | ||
| "mac_shared_frameworks": "/Applications/Xcode.app/Contents/SharedFrameworks", | ||
| }, | ||
| "xcode_settings": { | ||
| "OTHER_LDFLAGS": [ | ||
| "-F<(mac_shared_frameworks)", | ||
| "-Wl,-rpath,<(mac_shared_frameworks)", | ||
| "-framework LLDB", | ||
| ], | ||
| }, | ||
| }, | ||
| # lldb_builddir != "" | ||
| { | ||
| "xcode_settings": { | ||
| "OTHER_LDFLAGS": [ | ||
| "-Wl,-rpath,<(lldb_build_dir)/lib", | ||
| "-L<(lldb_build_dir)/lib", | ||
| "-l<(lldb_lib)", | ||
| ], | ||
| }, | ||
| }], | ||
| ], | ||
| }], | ||
| ] | ||
| }], | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| var os = require('os'); | ||
This comment was marked as off-topic.
Sorry, something went wrong. |
||
| var child_process = require('child_process'); | ||
|
|
||
| var cwd = process.cwd(); | ||
| var osName = os.type(); | ||
| var libExt = "so"; | ||
This comment was marked as off-topic.
Sorry, something went wrong. |
||
|
|
||
| if (osName === 'Darwin') { | ||
| libExt = "dylib"; | ||
| } | ||
|
|
||
| var llnodeLib = "llnode." + libExt; | ||
|
|
||
| // Move the library somewhere easy to remember. | ||
| console.log('Copying ' + cwd + '/out/Release/' + llnodeLib + ' to ' + cwd + '/' + llnodeLib); | ||
This comment was marked as off-topic.
Sorry, something went wrong. |
||
| child_process.execSync('mv ' + cwd + '/out/Release/' + llnodeLib + ' ' + cwd + '/' + llnodeLib ); | ||
|
|
||
| console.log(os.EOL + 'llnode plugin installed, load in lldb with:'); | ||
| console.log('(lldb) plugin load ' + cwd + '/' + llnodeLib + os.EOL); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,166 @@ | ||
| const os = require('os'); | ||
| const fs = require('fs'); | ||
| const child_process = require('child_process'); | ||
|
|
||
| const lldbReleases = { | ||
| '3.9': 'release_39', | ||
| '3.8': 'release_38', | ||
| '3.7': 'release_37', | ||
| '3.6': 'release_36', | ||
| '3.5': 'release_35', | ||
| '3.4': 'release_34', | ||
| }; | ||
|
|
||
| const buildDir = process.cwd(); | ||
|
|
||
| console.log('Build dir is: ' + buildDir); | ||
|
|
||
| const osName = os.type(); | ||
|
|
||
| var lldbVersion; | ||
| var lldbHeadersBranch; | ||
| var lldbIncludeDir; | ||
|
|
||
| // Need to determine: | ||
| // - What level of lldb we are running. | ||
| // - If we need the headers. (Linux may have them installed) | ||
| if (osName === 'Darwin') { | ||
|
|
||
| lldbVersion = getDarwinRelease(); | ||
|
|
||
| if(lldbVersion === undefined) { | ||
This comment was marked as off-topic.
Sorry, something went wrong.
This comment was marked as off-topic.
Sorry, something went wrong. |
||
| console.log('Unable to locate lldb binary. llnode installation failed.'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| lldbHeadersBranch = lldbReleases[lldbVersion]; | ||
| lldbIncludeDir = 'lldb-' + lldbVersion; | ||
|
|
||
| } else if ( osName === 'Linux') { | ||
This comment was marked as off-topic.
Sorry, something went wrong. |
||
|
|
||
| lldbVersion = getLinuxVersion(); | ||
|
|
||
| if(lldbVersion === undefined) { | ||
| console.log('Unable to locate lldb binary. llnode installation failed.'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| // console.log('lldb_version is ' + lldb_version) | ||
| var installedHeadersDir = getLinuxHeadersDir(lldbVersion); | ||
| // console.log('installed_headers_dir is ' + installed_headers_dir); | ||
| if (installedHeadersDir === undefined) { | ||
| // Initialising lldb_headers_branch will cause us to clone them. | ||
| lldbHeadersBranch = lldbReleases[lldbVersion]; | ||
| lldbIncludeDir = 'lldb-' + lldbVersion; | ||
| } else { | ||
| lldbIncludeDir = installedHeadersDir; | ||
| } | ||
| } | ||
|
|
||
| console.log('Installing llnode for lldb version ' + lldbVersion); | ||
|
|
||
| // Check out source code of the LLDB that is compatible with OS X's default lldb | ||
| // TODO: The llvm project is probably moving to github soon at that point we | ||
| // should stop using the mirror. | ||
| if (lldbHeadersBranch != undefined) { | ||
| console.log('Cloning lldb from ' + lldbHeadersBranch); | ||
| child_process.execFileSync('git', ['clone', '--depth=1', '-b', lldbHeadersBranch, 'https://github.com/llvm-mirror/lldb.git', lldbIncludeDir], | ||
| {cwd: buildDir}); | ||
| } | ||
|
|
||
| // Link to the headers file so we can run gyp_llnode directly and don't need to | ||
| // setup | ||
| // parameters to pass it. | ||
| console.log('Linking lldb to include directory ' + lldbIncludeDir); | ||
| fs.symlinkSync(lldbIncludeDir, 'lldb'); | ||
|
|
||
| // Initialize GYP | ||
| // We can use the node-gyp that comes with npm. | ||
| // We can locate it with npm -g explore npm npm explore node-gyp pwd | ||
| // It might have been neater to make node-gyp one of our dependencies | ||
| // *but* they don't get installed until after the install step has run. | ||
| var gypDir = child_process.execFileSync('npm', ['-g', 'explore', 'npm', 'npm', 'explore', 'node-gyp', 'pwd'], {cwd: buildDir}).toString().trim(); | ||
| fs.mkdirSync('tools'); | ||
| console.log('Linking tools/gyp to ' + gypDir+'/gyp'); | ||
| fs.symlinkSync(gypDir + '/gyp', 'tools/gyp'); | ||
|
|
||
| // Exit with success. | ||
| process.exit(0); | ||
|
|
||
| // On Mac the lldb version string doesn't match the original lldb versions. | ||
| function getDarwinRelease() { | ||
| var xcodeStr; | ||
| try { | ||
| xcodeStr = child_process.execFileSync('xcodebuild', ['-version']).toString(); | ||
| } catch(err) { | ||
| return undefined; | ||
| } | ||
| var versionStr = ''; | ||
| var splitStr = xcodeStr.split(os.EOL); | ||
| for( var str of splitStr) { | ||
| if (str.indexOf('Xcode') != -1) { | ||
| versionStr = str.split(' ')[1]; | ||
| break; | ||
| } | ||
| } | ||
| // console.log('Xcode version is ' + version_str) | ||
|
|
||
| var version = parseFloat(versionStr); | ||
| if (version > 8.0) { | ||
| return '3.8'; | ||
| } else { | ||
| return '3.4'; | ||
| } | ||
| } | ||
|
|
||
| // There are multiple versions of lldb available for the various linux distos. | ||
| // Use the default unless --llnode_version= has been set on the command line. | ||
| function getLinuxVersion() { | ||
|
|
||
| // TODO - Allow the user to specify the version of lldb to use, e.g: | ||
| // lldb-3.9 instead of lldb as Linux has packages for multiple versions | ||
| // of lldb. | ||
| var lldbStr; | ||
| try { | ||
| lldbStr = child_process.execFileSync('lldb', ['-v']).toString(); | ||
| } catch(err) { | ||
| return undefined; | ||
| } | ||
| // Ignore minor revisions like 3.8.1 | ||
| if (lldbStr.indexOf('version 3.9') > 0) { | ||
| return '3.9'; | ||
| } else if (lldbStr.indexOf('version 3.8') > 0) { | ||
| return '3.8'; | ||
| } else if (lldbStr.indexOf('version 3.7') > 0) { | ||
| return '3.7'; | ||
| } if (lldbStr.indexOf('version 3.6') > 0) { | ||
| return '3.6'; | ||
| } if (lldbStr.indexOf('version 3.5') > 0) { | ||
| return '3.5'; | ||
| } | ||
| return undefined; | ||
| } | ||
|
|
||
| function getLinuxHeadersDir(version) { | ||
| // Get the directory which should contain the headers and | ||
| // check if they are present. | ||
| // (Using the installed headers will ensure we have the correct ones.) | ||
| console.log('Checking for headers, version is ' + version); | ||
| try { | ||
| var includeDir = child_process.execFileSync('llvm-config-' + version, ['--prefix']).toString().trim(); | ||
| // console.log('Checking for directory ' + include_dir); | ||
| // Include directory doesn't need include/lldb on the end but the llvm | ||
| // headers can be installed without the lldb headers so check for them. | ||
| if (fs.existsSync(includeDir + '/include/lldb')) { | ||
| // console.log('Found ' + include_dir); | ||
| return includeDir; | ||
| } | ||
| } catch(err) { | ||
| // Return undefined, we will download the headers. | ||
| } | ||
| // On Redhat the headers are just installed in /usr/include | ||
| if (fs.existsSync('/usr/include/lldb')) { | ||
| return '/usr'; | ||
| } | ||
| return undefined; | ||
| } | ||
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as off-topic.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.