summaryrefslogtreecommitdiffstats
path: root/meta/classes/npm.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/npm.bbclass')
-rw-r--r--meta/classes/npm.bbclass39
1 files changed, 25 insertions, 14 deletions
diff --git a/meta/classes/npm.bbclass b/meta/classes/npm.bbclass
index 068032a1e5..55a6985fb0 100644
--- a/meta/classes/npm.bbclass
+++ b/meta/classes/npm.bbclass
@@ -17,8 +17,10 @@
17# NPM_INSTALL_DEV: 17# NPM_INSTALL_DEV:
18# Set to 1 to also install devDependencies. 18# Set to 1 to also install devDependencies.
19 19
20inherit python3native
21
20DEPENDS_prepend = "nodejs-native " 22DEPENDS_prepend = "nodejs-native "
21RDEPENDS_${PN}_prepend = "nodejs " 23RDEPENDS_${PN}_append_class-target = " nodejs"
22 24
23NPM_INSTALL_DEV ?= "0" 25NPM_INSTALL_DEV ?= "0"
24 26
@@ -130,11 +132,17 @@ python npm_do_configure() {
130 cached_manifest.pop("dependencies", None) 132 cached_manifest.pop("dependencies", None)
131 cached_manifest.pop("devDependencies", None) 133 cached_manifest.pop("devDependencies", None)
132 134
133 with open(orig_shrinkwrap_file, "r") as f: 135 has_shrinkwrap_file = True
134 orig_shrinkwrap = json.load(f) 136
137 try:
138 with open(orig_shrinkwrap_file, "r") as f:
139 orig_shrinkwrap = json.load(f)
140 except IOError:
141 has_shrinkwrap_file = False
135 142
136 cached_shrinkwrap = copy.deepcopy(orig_shrinkwrap) 143 if has_shrinkwrap_file:
137 cached_shrinkwrap.pop("dependencies", None) 144 cached_shrinkwrap = copy.deepcopy(orig_shrinkwrap)
145 cached_shrinkwrap.pop("dependencies", None)
138 146
139 # Manage the dependencies 147 # Manage the dependencies
140 progress = OutOfProgressHandler(d, r"^(\d+)/(\d+)$") 148 progress = OutOfProgressHandler(d, r"^(\d+)/(\d+)$")
@@ -165,8 +173,10 @@ python npm_do_configure() {
165 progress.write("%d/%d" % (progress_done, progress_total)) 173 progress.write("%d/%d" % (progress_done, progress_total))
166 174
167 dev = bb.utils.to_boolean(d.getVar("NPM_INSTALL_DEV"), False) 175 dev = bb.utils.to_boolean(d.getVar("NPM_INSTALL_DEV"), False)
168 foreach_dependencies(orig_shrinkwrap, _count_dependency, dev) 176
169 foreach_dependencies(orig_shrinkwrap, _cache_dependency, dev) 177 if has_shrinkwrap_file:
178 foreach_dependencies(orig_shrinkwrap, _count_dependency, dev)
179 foreach_dependencies(orig_shrinkwrap, _cache_dependency, dev)
170 180
171 # Configure the main package 181 # Configure the main package
172 with tempfile.TemporaryDirectory() as tmpdir: 182 with tempfile.TemporaryDirectory() as tmpdir:
@@ -181,16 +191,19 @@ python npm_do_configure() {
181 cached_manifest[depkey] = {} 191 cached_manifest[depkey] = {}
182 cached_manifest[depkey][name] = version 192 cached_manifest[depkey][name] = version
183 193
184 _update_manifest("dependencies") 194 if has_shrinkwrap_file:
195 _update_manifest("dependencies")
185 196
186 if dev: 197 if dev:
187 _update_manifest("devDependencies") 198 if has_shrinkwrap_file:
199 _update_manifest("devDependencies")
188 200
189 with open(cached_manifest_file, "w") as f: 201 with open(cached_manifest_file, "w") as f:
190 json.dump(cached_manifest, f, indent=2) 202 json.dump(cached_manifest, f, indent=2)
191 203
192 with open(cached_shrinkwrap_file, "w") as f: 204 if has_shrinkwrap_file:
193 json.dump(cached_shrinkwrap, f, indent=2) 205 with open(cached_shrinkwrap_file, "w") as f:
206 json.dump(cached_shrinkwrap, f, indent=2)
194} 207}
195 208
196python npm_do_compile() { 209python npm_do_compile() {
@@ -237,9 +250,7 @@ python npm_do_compile() {
237 sysroot = d.getVar("RECIPE_SYSROOT_NATIVE") 250 sysroot = d.getVar("RECIPE_SYSROOT_NATIVE")
238 nodedir = os.path.join(sysroot, d.getVar("prefix_native").strip("/")) 251 nodedir = os.path.join(sysroot, d.getVar("prefix_native").strip("/"))
239 configs.append(("nodedir", nodedir)) 252 configs.append(("nodedir", nodedir))
240 bindir = os.path.join(sysroot, d.getVar("bindir_native").strip("/")) 253 configs.append(("python", d.getVar("PYTHON")))
241 pythondir = os.path.join(bindir, "python-native", "python")
242 configs.append(("python", pythondir))
243 254
244 # Add node-pre-gyp configuration 255 # Add node-pre-gyp configuration
245 args.append(("target_arch", d.getVar("NPM_ARCH"))) 256 args.append(("target_arch", d.getVar("NPM_ARCH")))