package init

This commit is contained in:
root 2020-08-28 17:24:51 +08:00
parent 63fdc8e21a
commit 6e35a5010e
7 changed files with 276 additions and 0 deletions

105
addon-rpm.gypi Normal file
View File

@ -0,0 +1,105 @@
{
'target_defaults': {
'type': 'loadable_module',
'win_delay_load_hook': 'true',
'product_prefix': '',
'include_dirs': [
'/usr/include/node',
'/usr/include'
],
'defines': [
'NODE_GYP_MODULE_NAME=>(_target_name)'
],
'target_conditions': [
['_type=="loadable_module"', {
'product_extension': 'node',
'defines': [
'BUILDING_NODE_EXTENSION'
],
'xcode_settings': {
'OTHER_LDFLAGS': [
'-undefined dynamic_lookup'
],
},
}],
['_type=="static_library"', {
# set to `1` to *disable* the -T thin archive 'ld' flag.
# older linkers don't support this flag.
'standalone_static_library': '<(standalone_static_library)'
}],
['_win_delay_load_hook=="true"', {
# If the addon specifies `'win_delay_load_hook': 'true'` in its
# binding.gyp, link a delay-load hook into the DLL. This hook ensures
# that the addon will work regardless of whether the node/iojs binary
# is named node.exe, iojs.exe, or something else.
'conditions': [
[ 'OS=="win"', {
'sources': [
'<(node_gyp_dir)/src/win_delay_load_hook.c',
],
'msvs_settings': {
'VCLinkerTool': {
'DelayLoadDLLs': [ 'iojs.exe', 'node.exe' ],
# Don't print a linker warning when no imports from either .exe
# are used.
'AdditionalOptions': [ '/ignore:4199' ],
},
},
}],
],
}],
],
'conditions': [
[ 'OS=="mac"', {
'defines': [
'_DARWIN_USE_64_BIT_INODE=1'
],
'xcode_settings': {
'DYLIB_INSTALL_NAME_BASE': '@rpath'
},
}],
[ 'OS=="aix"', {
'ldflags': [
'-Wl,-bimport:<(node_exp_file)'
],
}],
[ 'OS=="win"', {
'libraries': [
'-lkernel32.lib',
'-luser32.lib',
'-lgdi32.lib',
'-lwinspool.lib',
'-lcomdlg32.lib',
'-ladvapi32.lib',
'-lshell32.lib',
'-lole32.lib',
'-loleaut32.lib',
'-luuid.lib',
'-lodbc32.lib',
'-lDelayImp.lib',
'-l"<(node_root_dir)/$(ConfigurationName)/<(node_lib_file)"'
],
'msvs_disabled_warnings': [
# warning C4251: 'node::ObjectWrap::handle_' : class 'v8::Persistent<T>'
# needs to have dll-interface to be used by
# clients of class 'node::ObjectWrap'
4251
],
}, {
# OS!="win"
'defines': [
'_LARGEFILE_SOURCE',
'_FILE_OFFSET_BITS=64'
],
}],
[ 'OS=="freebsd" or OS=="openbsd" or OS=="solaris" or (OS=="linux" and target_arch!="ia32")', {
'cflags': [ '-fPIC' ],
}]
]
}
}

BIN
node-gyp-3.6.0.tar.gz Normal file

Binary file not shown.

62
node-gyp-addon-gypi.patch Normal file
View File

@ -0,0 +1,62 @@
commit 4daac6e35e1ea8e886a823785e7b06e80c933ac2
Author: Tom Hughes <tom@compton.nu>
Date: Mon Jan 18 17:06:18 2016 +0000
Use custom addon.gypi by default instead of downloading node source
diff --git a/lib/configure.js b/lib/configure.js
index 4e06529..046c12f 100644
--- a/lib/configure.js
+++ b/lib/configure.js
@@ -59,24 +59,26 @@ function configure (gyp, argv, callback) {
if ('v' + release.version !== process.version) {
// if --target was given, then determine a target version to compile for
log.verbose('get node dir', 'compiling against --target node version: %s', release.version)
- } else {
- // if no --target was specified then use the current host node version
- log.verbose('get node dir', 'no --target version specified, falling back to host node version: %s', release.version)
- }
- if (!release.semver) {
- // could not parse the version string with semver
- return callback(new Error('Invalid version number: ' + release.version))
- }
+ if (!release.semver) {
+ // could not parse the version string with semver
+ return callback(new Error('Invalid version number: ' + release.version))
+ }
- // ensure that the target node version's dev files are installed
- gyp.opts.ensure = true
- gyp.commands.install([ release.version ], function (err, version) {
- if (err) return callback(err)
- log.verbose('get node dir', 'target node version installed:', release.versionDir)
- nodeDir = path.resolve(gyp.devDir, release.versionDir)
+ // ensure that the target node version's dev files are installed
+ gyp.opts.ensure = true
+ gyp.commands.install([ release.version ], function (err, version) {
+ if (err) return callback(err)
+ log.verbose('get node dir', 'target node version installed:', release.versionDir)
+ nodeDir = path.resolve(gyp.devDir, release.versionDir)
+ createBuildDir()
+ })
+ } else {
+ // if no --target was specified then use RPM installed headers
+ log.verbose('get node dir', 'no --target version specified, falling back to RPM installed headers')
+ nodeDir = '/usr/share/node'
createBuildDir()
- })
+ }
}
}
@@ -248,7 +250,8 @@ function configure (gyp, argv, callback) {
// this logic ported from the old `gyp_addon` python file
var gyp_script = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py')
- var addon_gypi = path.resolve(__dirname, '..', 'addon.gypi')
+ var addon_gypi_file = gyp.opts.target || gyp.opts.nodeDir ? 'addon.gypi' : 'addon-rpm.gypi'
+ var addon_gypi = path.resolve(__dirname, '..', addon_gypi_file)
var common_gypi = path.resolve(nodeDir, 'include/node/common.gypi')
fs.stat(common_gypi, function (err, stat) {
if (err)

32
node-gyp-python.patch Normal file
View File

@ -0,0 +1,32 @@
commit 6d43ce52005c977ce8df57440a82bb346d3fc4cc
Author: Tom Hughes <tom@compton.nu>
Date: Sat Jul 14 19:32:14 2018 +0100
Don't test that python exists
diff --git a/test/test-find-python.js b/test/test-find-python.js
index 30ba6df..2581a8e 100644
--- a/test/test-find-python.js
+++ b/test/test-find-python.js
@@ -5,21 +5,6 @@ var configure = require('../lib/configure')
var execFile = require('child_process').execFile
var PythonFinder = configure.test.PythonFinder
-test('find python', function (t) {
- t.plan(4)
-
- configure.test.findPython('python', function (err, found) {
- t.strictEqual(err, null)
- var proc = execFile(found, ['-V'], function (err, stdout, stderr) {
- t.strictEqual(err, null)
- t.strictEqual(stdout, '')
- t.ok(/Python 2/.test(stderr))
- })
- proc.stdout.setEncoding('utf-8')
- proc.stderr.setEncoding('utf-8')
- })
-})
-
function poison(object, property) {
function fail() {
throw new Error('Property ' + property + ' should not have been accessed.')

19
node-gyp-system-gyp.patch Normal file
View File

@ -0,0 +1,19 @@
commit 31b5c191833a9c122de1c52ad53220da4ccd4589
Author: Tom Hughes <tom@compton.nu>
Date: Mon Jan 18 17:07:41 2016 +0000
Use the system gyp
diff --git a/lib/configure.js b/lib/configure.js
index 046c12f..65e78b4 100644
--- a/lib/configure.js
+++ b/lib/configure.js
@@ -249,7 +249,7 @@ function configure (gyp, argv, callback) {
}
// this logic ported from the old `gyp_addon` python file
- var gyp_script = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py')
+ var gyp_script = '/usr/bin/gyp'
var addon_gypi_file = gyp.opts.target || gyp.opts.nodeDir ? 'addon.gypi' : 'addon-rpm.gypi'
var addon_gypi = path.resolve(__dirname, '..', addon_gypi_file)
var common_gypi = path.resolve(nodeDir, 'include/node/common.gypi')

54
node-gyp.spec Normal file
View File

@ -0,0 +1,54 @@
%{?nodejs_find_provides_and_requires}
Name: node-gyp
Version: 3.6.0
Release: 1
Summary: Node.js native addon build tool
License: MIT
URL: https://github.com/nodejs/node-gyp
Source0: https://github.com/nodejs/node-gyp/archive/v%{version}/node-gyp-%{version}.tar.gz
Source1: addon-rpm.gypi
Patch1: node-gyp-addon-gypi.patch
Patch2: node-gyp-system-gyp.patch
Patch3: node-gyp-python.patch
BuildArch: noarch
ExclusiveArch: %{nodejs_arches} noarch
Requires: gyp nodejs-devel libuv-devel http-parser-devel gcc-c++
BuildRequires: gyp nodejs-devel libuv-devel http-parser-devel gcc-c++
BuildRequires: npm(tape) npm(bindings) npm(fstream) npm(glob) npm(graceful-fs) npm(minimatch)
BuildRequires: npm(mkdirp) npm(nan) npm(nopt) npm(npmlog) npm(osenv) npm(path-array)
BuildRequires: npm(request) npm(require-inject) npm(rimraf) npm(semver) npm(tar) npm(which)
%description
node-gyp is a cross-platform command-line tool written in Node.js for compiling
native addon modules for Node.js, which takes away the pain of dealing with the
various differences in build platforms. It is the replacement to the node-waf
program which is removed for node v0.8.
%prep
%autosetup -p1
cp -p %{SOURCE1} addon-rpm.gypi
%nodejs_fixdep glob "^6.0.4"
%nodejs_fixdep minimatch "^3.0.0"
rm -rf gyp
%build
%install
mkdir -p %{buildroot}%{nodejs_sitelib}/node-gyp
cp -pr addon*.gypi bin lib package.json %{buildroot}%{nodejs_sitelib}/node-gyp
mkdir -p %{buildroot}%{_bindir}
ln -sf ../lib/node_modules/node-gyp/bin/node-gyp.js %{buildroot}%{_bindir}/node-gyp
%nodejs_symlink_deps
%check
%{nodejs_symlink_deps} --check
%{nodejs_sitelib}/tape/bin/tape test/test-*.js
%files
%doc README.md CHANGELOG.md
%license LICENSE
%{nodejs_sitelib}/node-gyp
%{_bindir}/node-gyp
%changelog
* Mon Aug 17 2020 Shaoqiang Kang <kangshaoqiang1@huawei.com> - 3.6.0-1
- Package init

4
node-gyp.yaml Normal file
View File

@ -0,0 +1,4 @@
version_control: github
src_repo: nodejs/node-gyp
tag_prefix: "v"
seperator: "."