[Sugar-devel] [PATCH sugar-toolkit-gtk3 3/3] Support out of source directory builds
Daniel Narvaez
dwnarvaez at gmail.com
Wed Dec 5 19:32:37 EST 2012
From: Daniel Narvaez <dwnarvaez at gmail.com>
It works similarly to automake. The current working directory
is used as build directory.
---
src/sugar3/activity/bundlebuilder.py | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/sugar3/activity/bundlebuilder.py b/src/sugar3/activity/bundlebuilder.py
index aaa2887..74ae3db 100644
--- a/src/sugar3/activity/bundlebuilder.py
+++ b/src/sugar3/activity/bundlebuilder.py
@@ -64,9 +64,10 @@ def list_files(base_dir, ignore_dirs=None, ignore_files=None):
class Config(object):
- def __init__(self):
- self.source_dir = os.getcwd()
- self.dist_dir = os.path.join(self.source_dir, 'dist')
+ def __init__(self, source_dir):
+ self.source_dir = source_dir
+ self.build_dir = os.getcwd()
+ self.dist_dir = os.path.join(self.build_dir, 'dist')
self.bundle = None
self.version = None
self.activity_name = None
@@ -97,7 +98,7 @@ class Builder(object):
def __init__(self, config):
self.config = config
- self.locale_dir = os.path.join(self.config.source_dir, 'locale')
+ self.locale_dir = os.path.join(self.config.build_dir, 'locale')
def build(self):
self.build_locale()
@@ -109,7 +110,7 @@ class Builder(object):
logging.warn('Missing po/ dir, cannot build_locale')
return
- locale_dir = os.path.join(self.config.source_dir, 'locale')
+ locale_dir = os.path.join(self.config.build_dir, 'locale')
if os.path.exists(self.locale_dir):
shutil.rmtree(self.locale_dir)
@@ -121,7 +122,7 @@ class Builder(object):
file_name = os.path.join(po_dir, f)
lang = f[:-3]
- localedir = os.path.join(self.config.source_dir, 'locale', lang)
+ localedir = os.path.join(self.config.build_dir, 'locale', lang)
mo_path = os.path.join(localedir, 'LC_MESSAGES')
if not os.path.isdir(mo_path):
os.makedirs(mo_path)
@@ -220,7 +221,7 @@ class SourcePackager(Packager):
class Installer(Packager):
def __init__(self, builder):
- self.config = builder.config
+ Packager.__init__(self, builder.config)
self.builder = builder
def install(self, prefix):
@@ -325,6 +326,8 @@ def cmd_genpot(config, args):
print 'Usage: %prog genpot'
return
+ os.chdir(config.source_dir)
+
po_path = os.path.join(config.source_dir, 'po')
if not os.path.isdir(po_path):
os.mkdir(po_path)
@@ -391,7 +394,8 @@ def start():
parser.disable_interspersed_args()
(options_, args) = parser.parse_args()
- config = Config()
+ source_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
+ config = Config(source_dir)
try:
globals()['cmd_' + args[0]](config, args[1:])
--
1.7.10.4
More information about the Sugar-devel
mailing list