summaryrefslogtreecommitdiff
path: root/efl
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2015-01-02 19:46:06 +0100
committerDave Andreoli <dave@gurumeditation.it>2015-01-02 19:46:06 +0100
commite4a3616613e18e63992ff3b74125cf58aca26a01 (patch)
tree56365338ce7f15a1b0dad40e09138309391a4d2e /efl
parentbb8deff060b6b73e03a99da4a63b8696a3b44fbe (diff)
Provide a new distutil command: build_edc
Diffstat (limited to 'efl')
-rw-r--r--efl/utils/setup.py71
1 files changed, 65 insertions, 6 deletions
diff --git a/efl/utils/setup.py b/efl/utils/setup.py
index 673fb16..4564d53 100644
--- a/efl/utils/setup.py
+++ b/efl/utils/setup.py
@@ -26,9 +26,62 @@ class build_extra(distutils.command.build.build):
26 def run(self): 26 def run(self):
27 if 'build_i18n' in self.distribution.cmdclass: 27 if 'build_i18n' in self.distribution.cmdclass:
28 self.run_command('build_i18n') 28 self.run_command('build_i18n')
29 if 'build_edc' in self.distribution.cmdclass:
30 self.run_command('build_edc')
29 distutils.command.build.build.run(self) 31 distutils.command.build.build.run(self)
30 32
31 33
34class build_edc(distutils.cmd.Command):
35 description = 'Compile all the edje themes using edje_cc'
36 user_options = [('themes-dir=', 'd', 'directory that holds the themes '
37 '(default: data/themes)'),
38 ('main-name=', 'n', 'main edc file name of the themes '
39 '(default: main.edc)')]
40
41 def initialize_options(self):
42 self.themes_dir = None
43 self.main_name = None
44
45 def finalize_options(self):
46 if self.themes_dir is None:
47 self.themes_dir = 'data/themes'
48 if self.main_name is None:
49 self.main_name = 'main.edc'
50
51 def run(self):
52 distutils.dir_util.mkpath('build/themes', verbose=False)
53 for name in os.listdir(self.themes_dir):
54 edc_file = os.path.join(self.themes_dir, name, self.main_name)
55 if os.path.isfile(edc_file):
56 self.compile_theme(name, edc_file)
57
58 def compile_theme(self, name, edc_file):
59 """
60 Compile edc file to using edje_cc, and put the generated theme file
61 in the data_files list so it got installed.
62 """
63 theme_dir = os.path.dirname(edc_file)
64 sources = []
65 for root, dirs, files in os.walk(theme_dir):
66 sources.extend( os.path.join(root, name) for name in files )
67
68 edj_file = os.path.join('build', 'themes', '%s.edj' % name)
69 if distutils.dep_util.newer_group(sources, edj_file):
70 info('compiling theme "%s" from edc file: "%s"' % (name, edc_file))
71 cmd = ['edje_cc', '-v',
72 '-id', theme_dir, '-id', os.path.join(theme_dir, 'images'),
73 '-fd', theme_dir, '-fd', os.path.join(theme_dir, 'fonts'),
74 '-sd', theme_dir, '-sd', os.path.join(theme_dir, 'sounds'),
75 edc_file, edj_file]
76 self.spawn(cmd)
77
78 info("changing mode of %s to 644", edj_file)
79 os.chmod(edj_file, 0o0644) # stupid edje_cc create files as 0600 :/
80
81 target = os.path.join('share', self.distribution.get_name(), 'themes')
82 _data_files_append(self.distribution, target, edj_file)
83
84
32class build_i18n(distutils.cmd.Command): 85class build_i18n(distutils.cmd.Command):
33 description = 'integrate the gettext framework' 86 description = 'integrate the gettext framework'
34 user_options = [('domain=', 'd', 'gettext domain ' 87 user_options = [('domain=', 'd', 'gettext domain '
@@ -113,10 +166,16 @@ class build_i18n(distutils.cmd.Command):
113 else: 166 else:
114 info('compiling po file: %s updated yet' % (po_file)) 167 info('compiling po file: %s updated yet' % (po_file))
115 168
116 if self.distribution.data_files is None: 169 target = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
117 data_files = self.distribution.data_files = [] 170 _data_files_append(self.distribution, target, mo_file)
118 else: 171
119 data_files = self.distribution.data_files
120 targetpath = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
121 data_files.append((targetpath, (mo_file,)))
122 172
173def _data_files_append(distribution, target, files):
174 """ Tiny util to append to data_files, ensuring data_file is defined """
175 if not isinstance(files, (list, tuple)):
176 files = (files,)
177 if distribution.data_files is None:
178 data_files = distribution.data_files = []
179 else:
180 data_files = distribution.data_files
181 data_files.append((target, files))