Skip to content

Commit 639ea50

Browse files
Cong LiuLin Sun
authored andcommitted
Fix for MAS submission requirements
* Fix for "Anatomy of Framework Bundles" compatible (nw part) * Fixed package script for MAS flavor - keep symbolic links when copying and zipping files - use `-mas` for package name * Fix loading path for libnode.dylib
1 parent dcbd48d commit 639ea50

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

BUILD.gn

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,11 @@ action("commit_id") {
254254
if (is_mac) {
255255
copy("copy_ffmpeg") {
256256
sources = [ "$root_out_dir/libffmpeg.dylib" ]
257+
if (nwjs_mas) {
258+
outputs = [ "$root_out_dir/$chrome_product_full_name.app/Contents/Versions/$chrome_version_full/Versions/A/libffmpeg.dylib" ]
259+
} else {
257260
outputs = [ "$root_out_dir/$chrome_product_full_name.app/Contents/Versions/$chrome_version_full/libffmpeg.dylib" ]
261+
}
258262
deps = [
259263
"//chrome",
260264
"//third_party/ffmpeg:ffmpeg"
@@ -274,7 +278,11 @@ copy("copy_node") {
274278
}
275279
if (is_mac) {
276280
sources = [ "$node_dir" + "../libnode.dylib" ]
281+
if (nwjs_mas) {
282+
outputs = [ "$root_out_dir/nwjs.app/Contents/Versions/$chrome_version_full/nwjs Framework.framework/Versions/A/libnode.dylib" ]
283+
} else {
277284
outputs = [ "$root_out_dir/nwjs.app/Contents/Versions/$chrome_version_full/nwjs Framework.framework/libnode.dylib" ]
285+
}
278286
}
279287
if (is_win) {
280288
suffix=""
@@ -396,7 +404,9 @@ executable("payload") {
396404
if (!is_component_build) {
397405
action("dist") {
398406
script = "tools/package_binaries.py"
399-
if (nwjs_sdk) {
407+
if (is_mac && nwjs_mas) {
408+
package_mode = "mas"
409+
} else if (nwjs_sdk) {
400410
package_mode = "sdk"
401411
} else {
402412
package_mode = "nosdk"

nw.gypi

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,17 @@
421421
'<(DEPTH)/components/nacl.gyp:nacl',
422422
]
423423
}],
424-
[ 'OS=="mac"', {
424+
[ 'OS=="mac" and nwjs_mas==1', {
425+
'copies': [
426+
{
427+
'destination': '<(PRODUCT_DIR)/<(mac_product_name).app/Contents/Versions/<(version_full)/<(mac_product_name) Framework.framework/Versions/Current/',
428+
'files': [
429+
'<(PRODUCT_DIR)/libnode.dylib',
430+
],
431+
},
432+
],
433+
}],
434+
[ 'OS=="mac" and nwjs_mas!=1', {
425435
'copies': [
426436
{
427437
'destination': '<(PRODUCT_DIR)/<(mac_product_name).app/Contents/Versions/<(version_full)/<(mac_product_name) Framework.framework/',
@@ -448,6 +458,9 @@
448458
['disable_nacl==0 and nwjs_sdk==0', {
449459
'package_mode': 'nacl',
450460
}],
461+
['nwjs_mas==1 and OS=="mac"', {
462+
'package_mode': 'mas',
463+
}],
451464
], # conditions
452465
}, # variables
453466
'actions': [

src/renderer/nw_content_renderer_hooks.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ namespace nw {
3939
void LoadNodeSymbols() {
4040
base::NativeLibraryLoadError error;
4141
#if defined(OS_MACOSX)
42+
#if defined(NWJS_MAS)
43+
base::FilePath node_dll_path = base::mac::FrameworkBundlePath().Append("Versions").Append("Current").Append(base::FilePath::FromUTF8Unsafe(base::GetNativeLibraryName("node")));
44+
#else
4245
base::FilePath node_dll_path = base::mac::FrameworkBundlePath().Append(base::FilePath::FromUTF8Unsafe(base::GetNativeLibraryName("node")));
46+
#endif
4347
#else
4448
base::FilePath node_dll_path = base::FilePath::FromUTF8Unsafe(base::GetNativeLibraryName("node"));
4549
#endif

tools/package_binaries.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import os
77
import platform
88
import shutil
9+
import stat
910
import sys
1011
import tarfile
1112
import zipfile
@@ -39,7 +40,7 @@
3940
is_headers_ok = False # record whether nw-headers generated
4041
package_name = 'nwjs'
4142

42-
if flavor in ['sdk', 'nacl']:
43+
if flavor in ['sdk', 'nacl', 'mas']:
4344
package_name = 'nwjs-' + args.mode
4445

4546
step = args.step
@@ -379,6 +380,20 @@ def _ArchiveDirectory(parentDirectory):
379380
zipOut.close()
380381

381382
def compress(from_dir, to_dir, fname, compress):
383+
384+
def zipOneFile(z, filename, root):
385+
_path = os.path.join(root, filename)
386+
_arcname = _path.replace(from_dir+os.sep, '')
387+
_mode = os.lstat(_path).st_mode
388+
if stat.S_ISLNK(_mode): # deal with symbolic links
389+
_zipInfo = zipfile.ZipInfo(_arcname)
390+
_zipInfo.create_system = 3 # 0 - Windows, 3 - Unix
391+
_zipInfo.compress_type = zipfile.ZIP_STORED
392+
_zipInfo.external_attr = _mode << 16L
393+
z.writestr(_zipInfo, os.readlink(_path))
394+
elif stat.S_ISREG(_mode): # regular file
395+
z.write(_path, _arcname)
396+
382397
from_dir = os.path.normpath(from_dir)
383398
to_dir = os.path.normpath(to_dir)
384399
_from = os.path.join(from_dir, fname)

0 commit comments

Comments
 (0)