Skip to content

Commit

Permalink
Merge pull request #52 from dlifshitz-maca/TIMOB-8926_01
Browse files Browse the repository at this point in the history
TIMOB-8926: Blackberry: Implement proper packaging of blackberry mobile sdk

[Issues Fixed]
TIMOB-8926: Blackberry: Implement proper packaging of blackberry mobile sdk

[Added]
blackberry/tibb/.gitignore

    ignore *.a

[Changes]
SConstruct

    import BlackberryNDK
    fix build_type butchering for clean builds
    build tibb

package.py

    function zip_blackberry
        only zip the following:
        .h and .a files for libv8 and tibb
        tibbapp

blackberryndk.py

    added function buildTibb

[Tests]
Test 1: Build and use mobile sdk
1) Run scons
2) Verify the mobilesdk/win32/2.0.0/blackberry folder in the zip only contains what is needed
3) Run scons clean
4) Verify the build files are gone

Test 2: Use the mobile sdk
1) Run scons
2) Extract the sdk so Titanium Studio can use it
3) Open Titanium Studio and create a new project
4) Verify the templates were created properly
5) Run for simulator
6) Verify the app is built, deployed, and run
  • Loading branch information
dlifshitz-maca committed May 23, 2012
2 parents 953263d + 558be17 commit 2ea4208
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.pyc
dist
.sconsign.dblite
scons_*.log
.DS_Store
*~
project.xcworkspace
Expand Down
36 changes: 25 additions & 11 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
#
# Top level scons script
#
# Usage:
#
# TODO: fill in the rest
# blackberry 1 to build only blackberry, 0 to skip
# blackberry_ndk path to the BlackBerry NDK
#
import os, shutil, platform, os.path as path, sys
import package
import SCons.Variables
Expand All @@ -14,8 +20,12 @@ from SCons.Script import *
cwd = os.path.abspath(os.path.dirname(sys._getframe(0).f_code.co_filename))
sys.path.append(path.join(cwd,"build"))
sys.path.append(path.join(cwd,"support","android"))
sys.path.append(path.join(cwd,"support","blackberry"))
sys.path.append(path.join(cwd,"support","common"))
import titanium_version, ant
from tilogger import TiLogger
from androidsdk import AndroidSDK
from blackberryndk import BlackberryNDK
version = titanium_version.version
module_apiversion = titanium_version.module_apiversion

Expand Down Expand Up @@ -109,8 +119,8 @@ if build_type in ['full', 'iphone', 'ipad'] and not only_package \
os.chdir('iphone')
try:
#output = 0
if clean: build_type = "clean"
output = os.system("scons PRODUCT_VERSION=%s COMPILER_FLAGS='%s' BUILD_TYPE='%s'" % (version,flags,build_type))
iphone_build_type = "clean" if clean else build_type
output = os.system("scons PRODUCT_VERSION=%s COMPILER_FLAGS='%s' BUILD_TYPE='%s'" % (version,flags,iphone_build_type))
if output!=0:
sys.stderr.write("BUILD FAILED!!!!\n")
# beep, please
Expand All @@ -127,7 +137,7 @@ if build_type in ['full', 'mobileweb'] and not only_package:
d = os.getcwd()
os.chdir('mobileweb')
try:
if clean: build_type = "clean"
mobileweb_build_type = "clean" if clean else build_type
# nothing to do... yet
finally:
os.chdir(d)
Expand All @@ -136,14 +146,18 @@ if build_type in ['full', 'blackberry'] and not only_package:
d = os.getcwd()
try:
os.chdir('blackberry')
if clean: build_type = "clean"
# nothing to do... yet
print 'Building for BlackBerry'
# Add blackberry build steps here
except OSError as (errno, strerror):
# Temporary except clause while the blackberry folder doesn't
# yet exist in the github repo, so the script won't just exit
print "OS error ({0}): {1} [{2}]".format(errno, strerror, 'blackberry')
log = TiLogger(os.path.join(cwd, 'scons_blackberry.log'), level = TiLogger.INFO)
bbndk = BlackberryNDK(ARGUMENTS.get("blackberry_ndk", None), log = log)
if clean:
blackberryBuildType = "clean"
print 'Cleaning for BlackBerry'
else:
blackberryBuildType = "all"
print 'Building for BlackBerry'
retCode = bbndk.buildTibb(os.path.join(os.getcwd(), 'tibb'), blackberryBuildType)
if retCode != 0:
sys.stderr.write("BUILD FAILED!!!!\n")
sys.exit(retCode)
finally:
os.chdir(d)

Expand Down
40 changes: 17 additions & 23 deletions site_scons/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,31 +309,25 @@ def zip_mobileweb(zf,basepath,version):
zf.write(from_, to_)

def zip_blackberry(zf,basepath,version):
# TODO Mac: adjust zipping logic for the mobile_sdk as we add to it, using zip_mobileweb as starting point
subs = {
"__VERSION__":version,
"__TIMESTAMP__":ts,
"__GITHASH__": githash
}
dir = os.path.join(top_dir, 'blackberry')

for root, dirs, files in os.walk(dir):
for name in ignoreDirs:
if name in dirs:
dirs.remove(name)
for file in files:
e = os.path.splitext(file)
if len(e)==2 and e[1] in ignoreExtensions: continue
from_ = os.path.join(root, file)
to_ = from_.replace(dir, os.path.join(basepath,'blackberry'), 1)
if file == 'package.json':
c = open(from_).read()
for key in subs:
c = c.replace(key, subs[key])
zf.writestr(to_, c)
else:
blackberryDir = os.path.join(top_dir, 'blackberry')
toPath = os.path.join(basepath, 'blackberry')

def zipBlackberryDir(dir):
for root, dirs, files in os.walk(dir):
for file in files:
if not file.endswith('.a'):
continue
from_ = os.path.join(root, file)
to_ = from_.replace(blackberryDir, toPath, 1)
zf.write(from_, to_)

# add folders
zipBlackberryDir(os.path.join(blackberryDir, 'libv8'))
zipBlackberryDir(os.path.join(blackberryDir, 'tibb'))
zip_dir(zf, os.path.join(blackberryDir, 'tibbapp'), os.path.join(toPath, 'tibbapp'))

# add files
zf.write(os.path.join(blackberryDir, 'tibb', 'include', 'tibb.h'), os.path.join(toPath, 'tibb', 'include', 'tibb.h'))

def create_platform_zip(platform,dist_dir,osname,version,version_tag):
if not os.path.exists(dist_dir):
Expand Down
9 changes: 9 additions & 0 deletions support/blackberry/blackberryndk.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ def deploy(self, deviceIP, package):
command = [deploy, '-installApp', '-launchApp', '-device', deviceIP, '-package', package]
return self._run(command)

def buildTibb(self, tibbPath, buildType):
assert os.path.exists(tibbPath)
oldPath = os.getcwd()
os.chdir(tibbPath)
command = ['make', buildType]
retCode = self._run(command)
os.chdir(oldPath)
return retCode

def __runUnitTests():
# on windows the double dirname need to be done on 2 lines
baseDir = os.path.abspath(os.path.dirname(sys.argv[0]))
Expand Down

0 comments on commit 2ea4208

Please sign in to comment.