diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2019-04-04 06:29:02 +0800 |
---|---|---|
committer | Refael Ackermann <refack@gmail.com> | 2019-04-16 18:23:32 -0400 |
commit | 4fd71935795fa7c284f5ed621551b65a28b8271c (patch) | |
tree | 63a90841b3ac80aab7c28c64d0b6dc46e2f19c82 /test/code-cache | |
parent | 1c2616971417bee811ea00da436c87a489f9b1ed (diff) | |
download | android-node-v8-4fd71935795fa7c284f5ed621551b65a28b8271c.tar.gz android-node-v8-4fd71935795fa7c284f5ed621551b65a28b8271c.tar.bz2 android-node-v8-4fd71935795fa7c284f5ed621551b65a28b8271c.zip |
tools: implement mkcodecache as an executable
This patch implement a mkcodecache executable on top of the
`NativeModuleLoader` singleton.
This makes it possible to build a Node.js binary with embedded
code cache without building itself using the code cache stub -
the cache is now initialized by `NativeModuleEnv` instead which
can be refactored out of the mkcodecache dependencies.
PR-URL: https://github.com/nodejs/node/pull/27161
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'test/code-cache')
-rw-r--r-- | test/code-cache/test-code-cache-generator.js | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/test/code-cache/test-code-cache-generator.js b/test/code-cache/test-code-cache-generator.js index a117a2e6a6..2fed3294bf 100644 --- a/test/code-cache/test-code-cache-generator.js +++ b/test/code-cache/test-code-cache-generator.js @@ -1,10 +1,10 @@ 'use strict'; -// This test verifies that the binary is compiled with code cache and the -// cache is used when built in modules are compiled. +// This test verifies the code cache generator can generate a C++ +// file that contains the code cache. This can be removed once we +// actually build that C++ file into our binary. const common = require('../common'); - const tmpdir = require('../common/tmpdir'); const { spawnSync } = require('child_process'); const assert = require('assert'); @@ -12,17 +12,29 @@ const path = require('path'); const fs = require('fs'); const readline = require('readline'); -const generator = path.join( - __dirname, '..', '..', 'tools', 'generate_code_cache.js' -); +console.log('Looking for mkcodecache executable'); +let buildDir; +const stat = fs.statSync(process.execPath); +if (stat.isSymbolicLink()) { + console.log('Binary is a symbolic link'); + buildDir = path.dirname(fs.readlinkSync(process.execPath)); +} else { + buildDir = path.dirname(process.execPath); +} + +const ext = common.isWindows ? '.exe' : ''; +const generator = path.join(buildDir, `mkcodecache${ext}`); +if (!fs.existsSync(generator)) { + common.skip('Could not find mkcodecache'); +} + +console.log(`mkcodecache is ${generator}`); + tmpdir.refresh(); const dest = path.join(tmpdir.path, 'cache.cc'); -// Run tools/generate_code_cache.js -const child = spawnSync( - process.execPath, - ['--expose-internals', generator, dest] -); +// Run mkcodecache +const child = spawnSync(generator, [dest]); assert.ifError(child.error); if (child.status !== 0) { console.log(child.stderr.toString()); |