Merge lp:~sergiusens/snapcraft/scons_options into lp:~snappy-dev/snapcraft/core

Proposed by Sergio Schvezov on 2015-09-29
Status: Merged
Approved by: Leo Arias on 2015-09-29
Approved revision: 219
Merged at revision: 219
Proposed branch: lp:~sergiusens/snapcraft/scons_options
Merge into: lp:~snappy-dev/snapcraft/core
Diff against target: 97 lines (+31/-6)
5 files modified
integration-tests/data/simple-scons/SConstruct (+12/-4)
integration-tests/data/simple-scons/snapcraft.yaml (+2/-0)
integration-tests/units/jobs.pxu (+8/-0)
plugins/scons-project.yaml (+1/-0)
snapcraft/plugins/scons_project.py (+8/-2)
To merge this branch: bzr merge lp:~sergiusens/snapcraft/scons_options
Reviewer Review Type Date Requested Status
Leo Arias 2015-09-29 Approve on 2015-09-29
Review via email: mp+272817@code.launchpad.net

Commit Message

Allow parameters/options for scons

To post a comment you must log in.
218. By Sergio Schvezov on 2015-09-29

Allow parameters/options for scons

Leo Arias (elopio) wrote :

Could you add options to the scons project in the integration suite, so this is tested?

Leo Arias (elopio) :
review: Needs Fixing
219. By Sergio Schvezov on 2015-09-29

Adding a test

Leo Arias (elopio) wrote :

/me approves

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'integration-tests/data/simple-scons/SConstruct'
2--- integration-tests/data/simple-scons/SConstruct 2015-09-29 10:42:52 +0000
3+++ integration-tests/data/simple-scons/SConstruct 2015-09-29 19:41:31 +0000
4@@ -1,14 +1,22 @@
5 import os.path
6
7+AddOption('--prefix',
8+ dest='prefix',
9+ type='string',
10+ nargs=1,
11+ default='/usr/local',
12+ action='store',
13+ metavar='DIR',
14+ help='installation prefix')
15+
16 env = Environment()
17 hello = env.Program('main.c')
18 DESTDIR = os.environ.get('DESTDIR', '')
19-install_dir = os.path.join('usr', 'bin')
20
21 if DESTDIR:
22- install_dir = os.path.join(DESTDIR, install_dir)
23+ install_dir = os.path.join(DESTDIR + os.path.sep + GetOption('prefix'), 'bin')
24 else:
25- install_dir = os.path.join(os.path.sep, install_dir)
26+ install_dir = os.path.join(GetOption('prefix'), 'bin')
27
28-env.Install(install_dir, hello)
29+env.Install(install_dir, hello)
30 env.Alias('install', install_dir)
31
32=== modified file 'integration-tests/data/simple-scons/snapcraft.yaml'
33--- integration-tests/data/simple-scons/snapcraft.yaml 2015-09-29 13:36:43 +0000
34+++ integration-tests/data/simple-scons/snapcraft.yaml 2015-09-29 19:41:31 +0000
35@@ -7,5 +7,7 @@
36
37 parts:
38 scons-project:
39+ scons-options:
40+ - --prefix=/opt
41 plugin: scons-project
42 source: .
43
44=== modified file 'integration-tests/units/jobs.pxu'
45--- integration-tests/units/jobs.pxu 2015-09-29 11:44:18 +0000
46+++ integration-tests/units/jobs.pxu 2015-09-29 19:41:31 +0000
47@@ -107,6 +107,14 @@
48 test "$(./stage/bin/test)" = "Hello world"
49 flags: simple has-leftovers
50
51+id: snapcraft/normal/simple-scons
52+command:
53+ set -ex
54+ cp -rT $PLAINBOX_PROVIDER_DATA/simple-scons .
55+ ${SNAPCRAFT} stage
56+ test "$(./stage/opt/bin/main)" = "Hello world"
57+flags: simple has-leftovers
58+
59 id: snapcraft/normal/simple-make-filesets
60 command:
61 set -ex
62
63=== modified file 'plugins/scons-project.yaml'
64--- plugins/scons-project.yaml 2015-09-29 09:07:45 +0000
65+++ plugins/scons-project.yaml 2015-09-29 19:41:31 +0000
66@@ -3,6 +3,7 @@
67 options:
68 source:
69 required: true
70+ scons-options:
71 source-type:
72 source-tag:
73 source-branch:
74
75=== modified file 'snapcraft/plugins/scons_project.py'
76--- snapcraft/plugins/scons_project.py 2015-09-29 09:07:45 +0000
77+++ snapcraft/plugins/scons_project.py 2015-09-29 19:41:31 +0000
78@@ -21,11 +21,17 @@
79
80 class SconsPlugin(snapcraft.BasePlugin):
81
82+ def __init__(self, name, options):
83+ super().__init__(name, options)
84+ self.scons_options = []
85+ if options.scons_options:
86+ self.scons_options = options.scons_options
87+
88 def pull(self):
89 return self.handle_source_options()
90
91 def build(self):
92 env = os.environ.copy()
93 env['DESTDIR'] = self.installdir
94- return self.run(['scons', 'prefix=/usr']) and \
95- self.run(['scons', 'install'], env=env)
96+ return (self.run(['scons', ] + self.scons_options) and
97+ self.run(['scons', 'install'] + self.scons_options, env=env))

Subscribers

People subscribed via source and target branches