Merge lp:~daniel.bueltmann/openwns-sdk/sconsenvironinfo into lp:openwns-sdk

Proposed by Daniel Bültmann
Status: Merged
Merged at revision: 176
Proposed branch: lp:~daniel.bueltmann/openwns-sdk/sconsenvironinfo
Merge into: lp:openwns-sdk
Diff against target: 218 lines (+157/-8)
3 files modified
.bzrignore (+5/-1)
SConstruct (+65/-4)
bin/setupKDevelop.py (+87/-3)
To merge this branch: bzr merge lp:~daniel.bueltmann/openwns-sdk/sconsenvironinfo
Reviewer Review Type Date Requested Status
Maciej Muehleisen Approve
Karsten Klagges Approve
ComNets, RWTH Aachen, University Pending
Review via email: mp+28720@code.launchpad.net

Description of the change

Made SConstruct more aware of linux distribution specifics, especially made it work on Ubuntu lucid

To post a comment you must log in.
175. By Daniel Bültmann <dbn@drjekyll>

Renamed include dir to .include in SConstruct for better compatability with KDevelop4

176. By Daniel Bültmann <dbn@drjekyll>

setupKDevelop.py now support KDevelop4

Revision history for this message
Karsten Klagges (karsten.klagges) :
review: Approve
Revision history for this message
Maciej Muehleisen (mue-comnets) wrote :

Works under Hardy. Might require "scons -c" and deleting .scon* in root dir.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2009-07-24 13:12:35 +0000
3+++ .bzrignore 2010-06-30 08:25:44 +0000
4@@ -40,7 +40,7 @@
5 .build
6 .createManualsWorkingDir
7 config/projects.py
8-include
9+.include
10 ./Doxyfile
11 ./WNS.kdevelop
12 ./WNS.kdevelop.filelist
13@@ -50,3 +50,7 @@
14 config.log
15 .sconf_temp
16 tags
17+.kdev4
18+./Makefile
19+./.kdev_include_paths
20+*.kdev4
21
22=== modified file 'SConstruct'
23--- SConstruct 2010-05-12 14:09:47 +0000
24+++ SConstruct 2010-06-30 08:25:44 +0000
25@@ -1,6 +1,64 @@
26 import os
27 import sys
28 import wnsbase.playground.Project
29+import subprocess
30+
31+class EnvInfo:
32+ def __init__(self):
33+ self.lsb = {}
34+ self.python = {}
35+
36+ try:
37+ f = open('/etc/lsb-release')
38+ c = f.read()
39+ f.close()
40+ c = c.split("\n")
41+ for l in c:
42+ if len(l.lstrip()) == 0:
43+ continue
44+ k,v = l.split("=")
45+ self.lsb[k] = v
46+
47+ except IOError:
48+ print
49+ print "WARNING Cannot acces /etc/lsb-release. Unknown distribution. Trying fallback."
50+ print
51+ self.lsb["DISTRIB_ID"]="Unknown"
52+
53+ try:
54+ output = subprocess.Popen(["python", "-V"], stderr=subprocess.PIPE).communicate()[1]
55+ output = output.split()
56+ version = output[1].split(".")
57+ self.python["version_major"] = "%s.%s" % (version[0], version[1])
58+ self.python["version_minor"] = "%s" % (version[2])
59+ except OSError:
60+ print
61+ print "Error!!! Cannot find python command"
62+ print
63+ exit(1)
64+
65+ guess_python_config = "python-config"
66+
67+ if self.lsb["DISTRIB_ID"] == "Ubuntu" and self.lsb["DISTRIB_CODENAME"] == 'lucid':
68+ guess_python_config = "python2.6-config"
69+
70+ try:
71+ output = subprocess.Popen([guess_python_config, "--includes"], stderr=subprocess.PIPE).communicate()[1]
72+ output = subprocess.Popen([guess_python_config, "--libs"], stderr=subprocess.PIPE).communicate()[1]
73+ except OSError:
74+ print
75+ print "ERROR!!! Cannot find python-config or python2.6-config which is needed to find correct Python paths"
76+ print
77+ sys.exit(1)
78+
79+ self.pythonConfigCmd = guess_python_config
80+
81+ def dump(self):
82+ print self.lsb
83+ print self.python
84+
85+
86+envInfo = EnvInfo()
87
88 sys.path.append('config')
89 import projects
90@@ -147,7 +205,7 @@
91 CXX = ARGUMENTS.get('CXX')
92
93 allHeaders = []
94-includeDir = os.path.join(os.getcwd(),'include')
95+includeDir = os.path.join(os.getcwd(),'.include')
96 libraries = []
97 for project in projects.all:
98 if isinstance(project, (wnsbase.playground.Project.Root, wnsbase.playground.Project.SystemTest, wnsbase.playground.Project.Generic)):
99@@ -179,15 +237,18 @@
100 pyConfigDirs = []
101
102 for env in environments:
103- env.Append(CPPPATH = ['#include'])
104+ env.Append(CPPPATH = ['#.include'])
105 env.Append(LIBPATH = os.path.join(env['sandboxDir'], env.flavour, 'lib'))
106- env.ParseConfig("python-config --includes")
107+
108+ env.ParseConfig(envInfo.pythonConfigCmd + " --includes")
109+
110 env.Replace(CXX = CXX)
111 env.installDir = os.path.join(env['sandboxDir'], env.flavour)
112 env.includeDir = includeDir
113+ print env
114 env['libraries'] = libraries
115 env['externalLIBS'] = externalLIBS
116- pylibs = env.ParseFlags(env.backtick('python-config --libs'))
117+ pylibs = env.ParseFlags(env.backtick(envInfo.pythonConfigCmd + ' --libs'))
118 env['externalLIBS'] += pylibs['LIBS']
119 if env['cacheDir']:
120 env.CacheDir(env['cacheDir'])
121
122=== modified file 'bin/setupKDevelop.py'
123--- bin/setupKDevelop.py 2010-01-09 18:36:57 +0000
124+++ bin/setupKDevelop.py 2010-06-30 08:25:44 +0000
125@@ -154,7 +154,91 @@
126 projectFile = os.path.join(pathToSDK, "WNS.kdevses")
127 shutil.copy (template, projectFile)
128
129-setupFileList()
130-setupProjectFile()
131-setupDevsesFile()
132+def setupKDevelop4():
133+ projfile = """
134+[Project]
135+Manager=KDevCustomMakeManager
136+Name=openwns
137+"""
138+ makefile = """
139+dbg:
140+\tscons dbg
141+
142+opt:
143+\tscons opt
144+
145+clean:
146+\tscons clean
147+"""
148+
149+ builderconf = """
150+[Buildset]
151+BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00\x16\x00o\x00p\x00e\x00n\x00w\x00n\x00s\x00-\x00s\x00d\x00k)
152+
153+[MakeBuilder]
154+Default Target=dbg
155+Number Of Jobs=1
156+"""
157+
158+ p = searchPathToSDK("./")
159+
160+ includepaths = """
161+%s
162+""" % (str(os.path.join(p, ".include")))
163+
164+ projfilename = os.path.join(p, "openwns.kdev4")
165+ makefilefilename = os.path.join(p, "Makefile")
166+ confdir = os.path.join(p, ".kdev4")
167+ conffilename = os.path.join(confdir, "openwns.kdev4")
168+ includepathfilename = os.path.join(p, ".kdev_include_paths")
169+
170+ f = open(projfilename, "w")
171+ f.write(projfile)
172+ f.close()
173+
174+ f = open(makefilefilename, "w")
175+ f.write(makefile)
176+ f.close()
177+
178+ try:
179+ os.mkdir(confdir)
180+ except OSError, e:
181+ if not(e.errno == 17):
182+ # Not path exists
183+ raise e
184+
185+ f = open(conffilename, "w")
186+ f.write(builderconf)
187+ f.close()
188+
189+ f = open(includepathfilename, "w")
190+ f.write(includepaths)
191+ f.close()
192+
193+def getKDevelopVersion():
194+ import subprocess
195+ output = subprocess.Popen(["kdevelop", "--version"], stdout=subprocess.PIPE).communicate()[0]
196+ found = None
197+ for l in output.split("\n"):
198+ fields = l.split(":")
199+ if fields[0] == "KDevelop":
200+ found = fields[1].lstrip().rstrip().split(".")
201+
202+ return found
203+
204+if __name__ == "__main__":
205+
206+ kdevVersion = getKDevelopVersion()
207+ if kdevVersion == None:
208+ print "ERROR!! I cannot find your kdevelop installation. Stopping."
209+ sys.exit(1)
210+ elif kdevVersion[0] == "3":
211+ print "Found KDevelop3"
212+
213+ setupFileList()
214+ setupProjectFile()
215+ setupDevsesFile()
216+
217+ elif kdevVersion[0] == "4":
218+ setupKDevelop4()
219

Subscribers

People subscribed via source and target branches