[elbe-devel] [PATCH 11/13] elbeproject: add a test to generate the SDK scripts

Manuel Traut manut at linutronix.de
Mon Jan 29 14:02:41 CET 2018


during developing the SDK scripts the actual generation of the scripts
by ./elbe build_sdk needs a couple of minutes. To ease development
they can now be generated by

nosetests ./elbepack/elbeproject.py

Signed-off-by: Manuel Traut <manut at linutronix.de>
---
 elbepack/elbeproject.py | 48 +++++++++++++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 17 deletions(-)

diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index 421665b6..cd4a50bf 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -65,6 +65,35 @@ class AptCacheCommitError(Exception):
         Exception.__init__(self, "Error Committing rpcaptcache %s" % msg)
 
 
+def test_gen_sdk_scripts():
+    os.system("mkdir -p /tmp/test/sdk")
+    __gen_sdk_scripts('armhf-linux-gnueabihf',
+                      'testproject',
+                      '08.15',
+                      '/tmp/test',
+                      '/tmp/test/sdk')
+
+
+def __gen_sdk_scripts(triplet, prj_name, prj_version, builddir, sdkpath):
+
+    # generate the setup script
+    sdkvalues = { 'sdk_arch': 'x86_64',
+                  'sdk_gcc_ver': '',
+                  'sdk_path': '/opt/elbe-sdk',
+                  'sdk_ext_path': '~/elbe-sdk',
+                  'real_multimach_target_sys': triplet,
+                  'sdk_title': 'ELBE %s' % prj_name,
+                  'sdk_version': prj_version,
+                }
+    t = os.path.join(mako_template_dir, 'toolchain-shar-extract.sh.mako')
+    with open(os.path.join(builddir, 'setup-sdk.sh'), 'w') as f:
+        f.write(template(t, sdkvalues))
+
+    t = os.path.join(mako_template_dir, 'environment-setup-elbe.mako')
+    with open(os.path.join(sdkpath,
+                           'environment-setup-elbe'), 'w') as f:
+        f.write(template(t, sdkvalues))
+
 class ElbeProject (object):
     def __init__(
             self,
@@ -253,23 +282,8 @@ class ElbeProject (object):
                     'amd64',
                     True)
 
-        # generate the setup script
-        sdkvalues = { 'sdk_arch': 'x86_64',
-                      'sdk_gcc_ver': '',
-                      'sdk_path': '/opt/elbe-sdk',
-                      'sdk_ext_path': '~/elbe-sdk',
-                      'real_multimach_target_sys': triplet,
-                      'sdk_title': 'ELBE %s' % self.xml.text("project/name"),
-                      'sdk_version': self.xml.text("project/version"),
-                    }
-        t = os.path.join(mako_template_dir, 'toolchain-shar-extract.sh.mako')
-        with open(os.path.join(self.builddir, 'setup-sdk.sh'), 'w') as f:
-            f.write(template(t, sdkvalues))
-
-        t = os.path.join(mako_template_dir, 'environment-setup-elbe.mako')
-        with open(os.path.join(self.sdkpath,
-                               'environment-setup-elbe'), 'w') as f:
-            f.write(template(t, sdkvalues))
+        __gen_sdk_scripts(triplet, prj_name, prj_version,
+                          self.builddir, self.sdkpath)
 
         # create sdk tar and append it to setup script
         self.log.do("cd %s; tar cJf ../sdk.txz ." % self.sdkpath)
-- 
2.15.1




More information about the elbe-devel mailing list