linux: Ship system dynamic libraries, closes #278.

This commit is contained in:
Cheng Zhao 2014-05-09 19:29:18 +08:00
parent 42c2f87217
commit d9e1861aff
2 changed files with 27 additions and 1 deletions

View file

@ -2,6 +2,7 @@
import argparse
import os
import re
import shutil
import subprocess
import sys
@ -64,6 +65,11 @@ TARGET_DIRECTORIES = {
],
}
SYSTEM_LIBRARIES = [
'libudev.so',
'libgcrypt.so',
]
HEADERS_SUFFIX = [
'.h',
'.gypi',
@ -94,6 +100,10 @@ def main():
copy_binaries()
copy_headers()
copy_license()
if TARGET_PLATFORM == 'linux':
copy_system_libraries()
create_version()
create_dist_zip()
create_symbols_zip()
@ -157,6 +167,20 @@ def copy_license():
shutil.copy2(os.path.join(SOURCE_ROOT, 'LICENSE'), DIST_DIR)
def copy_system_libraries():
ldd = execute(['ldd', os.path.join(OUT_DIR, 'atom')])
lib_re = re.compile('\t(.*) => (.+) \(.*\)$')
for line in ldd.splitlines():
m = lib_re.match(line)
if not m:
continue
for i, library in enumerate(SYSTEM_LIBRARIES):
real_library = m.group(1)
if real_library.startswith(library):
shutil.copy2(m.group(2), os.path.join(DIST_DIR, real_library))
SYSTEM_LIBRARIES[i] = real_library
def create_version():
version_path = os.path.join(SOURCE_ROOT, 'dist', 'version')
with open(version_path, 'w') as version_file:
@ -194,6 +218,8 @@ def create_dist_zip():
with scoped_cwd(DIST_DIR):
files = TARGET_BINARIES[TARGET_PLATFORM] + ['LICENSE', 'version']
if TARGET_PLATFORM == 'linux':
files += SYSTEM_LIBRARIES
dirs = TARGET_DIRECTORIES[TARGET_PLATFORM]
make_zip(zip_file, files, dirs)

View file

@ -112,7 +112,7 @@ def safe_mkdir(path):
def execute(argv):
try:
subprocess.check_output(argv, stderr=subprocess.STDOUT)
return subprocess.check_output(argv, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print e.output
raise e