diff options
author | Elvis Pranskevichus <elvis@magic.io> | 2016-05-08 12:35:08 -0400 |
---|---|---|
committer | Patrice Clement <monsieurp@gentoo.org> | 2016-05-10 11:12:16 +0000 |
commit | 35a0f25a84b32b2f15b5d115aa607db4020cc55b (patch) | |
tree | 4dc7c3d75cc482f23d02d4b58ae196a2bc9e8a56 /app-editors/atom/files | |
parent | x11-misc/openbox-menu: Add maintainer name. (diff) | |
download | gentoo-35a0f25a84b32b2f15b5d115aa607db4020cc55b.tar.gz gentoo-35a0f25a84b32b2f15b5d115aa607db4020cc55b.tar.bz2 gentoo-35a0f25a84b32b2f15b5d115aa607db4020cc55b.zip |
app-editors/atom: Switch to using dev-util/electron, recompile binaries and unbundle libraries.
Proper build of dev-util/electron is now in the tree (#579116),
which makes it possible to rebuild Atom properly, i.e. without
the use of precompiled blobs and with proper library unbundling.
The strategy used in this build is to take the upstream release
build and recompile the native module portions against the system
Electron and system libraries.
Gentoo-Bug: https://bugs.gentoo.org/582462
Package-Manager: portage-2.2.28
Closes: https://github.com/gentoo/gentoo/pull/1430
Signed-off-by: Patrice Clement <monsieurp@gentoo.org>
Diffstat (limited to 'app-editors/atom/files')
-rw-r--r-- | app-editors/atom/files/atom-unbundle-electron.patch | 45 | ||||
-rw-r--r-- | app-editors/atom/files/gyp-unbundle.py | 123 |
2 files changed, 168 insertions, 0 deletions
diff --git a/app-editors/atom/files/atom-unbundle-electron.patch b/app-editors/atom/files/atom-unbundle-electron.patch new file mode 100644 index 000000000000..ba5833083dad --- /dev/null +++ b/app-editors/atom/files/atom-unbundle-electron.patch @@ -0,0 +1,45 @@ +From d8e2b7e0fabdb4604063071f7f3a4a24e49daca7 Mon Sep 17 00:00:00 2001 +From: Elvis Pranskevichus <elvis@magic.io> +Date: Thu, 5 May 2016 17:23:35 -0400 +Subject: [PATCH] Unbundle electron + +--- + atom.sh | 12 +++++------- + 1 file changed, 5 insertions(+), 7 deletions(-) + +diff --git a/atom.sh b/atom.sh +index b68716b..d89587f 100755 +--- a/atom.sh ++++ b/atom.sh +@@ -87,11 +87,9 @@ elif [ $OS == 'Linux' ]; then + SCRIPT=$(readlink -f "$0") + USR_DIRECTORY=$(readlink -f $(dirname $SCRIPT)/..) + +- if [ -n "$BETA_VERSION" ]; then +- ATOM_PATH="$USR_DIRECTORY/share/atom-beta/atom" +- else +- ATOM_PATH="$USR_DIRECTORY/share/atom/atom" +- fi ++ export NPM_CONFIG_NODEDIR="/usr/include/electron/node/" ++ export ATOM_RESOURCE_PATH="{{ATOM_RESOURCE_PATH}}" ++ ATOM_PATH="{{ATOM_PATH}}" + + ATOM_HOME="${ATOM_HOME:-$HOME/.atom}" + mkdir -p "$ATOM_HOME" +@@ -101,11 +99,11 @@ elif [ $OS == 'Linux' ]; then + [ -x "$ATOM_PATH" ] || ATOM_PATH="$TMPDIR/atom-build/Atom/atom" + + if [ $EXPECT_OUTPUT ]; then +- "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" ++ "$ATOM_PATH" --app="$ATOM_RESOURCE_PATH" --executed-from="$(pwd)" --pid=$$ "$@" + exit $? + else + ( +- nohup "$ATOM_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > "$ATOM_HOME/nohup.out" 2>&1 ++ nohup "$ATOM_PATH" --app="$ATOM_RESOURCE_PATH" --executed-from="$(pwd)" --pid=$$ "$@" > "$ATOM_HOME/nohup.out" 2>&1 + if [ $? -ne 0 ]; then + cat "$ATOM_HOME/nohup.out" + exit $? +-- +2.7.3 + diff --git a/app-editors/atom/files/gyp-unbundle.py b/app-editors/atom/files/gyp-unbundle.py new file mode 100644 index 000000000000..381de792edc9 --- /dev/null +++ b/app-editors/atom/files/gyp-unbundle.py @@ -0,0 +1,123 @@ +#!/usr/bin/env python + +from __future__ import print_function + + +import argparse +import sys + + +def die(msg): + print(msg, file=sys.stderr) + sys.exit(1) + + +def do_unbundle(gypdata, targets): + gyptargets = {t['target_name']: t for t in gypdata['targets']} + dropped_deps = set() + + def _unbundle_in_block(gypblock): + gypdeps = gypblock.get('dependencies') or {} + + for dep, libs in unbundlings.items(): + if dep not in gypdeps: + continue + + gypdeps.remove(dep) + + try: + ls = gyptarget['link_settings'] + except KeyError: + ls = gyptarget['link_settings'] = {} + + try: + gyplibs = ls['libraries'] + except KeyError: + gyplibs = ls['libraries'] = [] + + gyplibs.extend('-l{}'.format(lib) for lib in libs) + + dropped_deps.add(dep) + + gypconds = gypblock.get('conditions') or [] + for cond in gypconds: + condblocks = cond[1:] + for condblock in condblocks: + _unbundle_in_block(condblock) + + for target, unbundlings in targets.items(): + if target not in gyptargets: + die('There is no {} target in gyp file'.format(target)) + + gyptarget = gyptargets[target] + + _unbundle_in_block(gyptarget) + + for gyptarget in gypdata['targets']: + if gyptarget['target_name'] in dropped_deps: + if gyptarget.get('dependencies'): + dropped_deps.update(gyptarget.get('dependencies')) + + new_targets = [] + for gyptarget in gypdata['targets']: + if gyptarget['target_name'] not in dropped_deps: + new_targets.append(gyptarget) + + gypdata['targets'] = new_targets + + gypconds = gypdata.get('conditions') + if gypconds: + for cond in gypconds: + condblocks = cond[1:] + for condblock in condblocks: + new_targets = [] + blocktargets = condblock.get('targets') + if blocktargets: + for blocktarget in blocktargets: + if blocktarget['target_name'] not in dropped_deps: + new_targets.append(blocktarget) + condblock['targets'] = new_targets + + +def main(): + parser = argparse.ArgumentParser(description='Unbundle libs in gyp files') + parser.add_argument('gypfile', type=str, help='input gyp file') + parser.add_argument( + '--unbundle', type=str, action='append', + help='unbundle rule in the format <target>;<dep>;<lib>[;lib]') + parser.add_argument( + '-i', '--inplace', action='store_true', + help='modify gyp file in-place') + + args = parser.parse_args() + + targets = {} + + for unbundle in args.unbundle: + rule = unbundle.split(';') + if len(rule) < 3: + die('Invalid unbundle rule: {!r}'.format(unbundle)) + target, dep = rule[:2] + libs = rule[2:] + + try: + target_unbundlings = targets[target] + except KeyError: + target_unbundlings = targets[target] = {} + + target_unbundlings[dep] = libs + + with open(args.gypfile, 'rt') as f: + gypdata = eval(f.read()) + + do_unbundle(gypdata, targets) + + if args.inplace: + with open(args.gypfile, 'wt') as f: + f.write(repr(gypdata) + "\n") + else: + print(repr(gypdata)) + + +if __name__ == '__main__': + main() |