-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial code from refactored AutobahnJS SConstruct
- Loading branch information
Tobias Oberstein
committed
Oct 26, 2013
1 parent
8104d56
commit 3e3cdf7
Showing
8 changed files
with
386 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
recursive-include crossbardashboard/web * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
all: | ||
@echo "Targets:" | ||
@echo "" | ||
@echo " install Local install" | ||
@echo " clean Cleanup" | ||
@echo " build Clean build" | ||
@echo " publish Clean build and publish to PyPI" | ||
@echo "" | ||
|
||
install: | ||
python setup.py install | ||
|
||
clean: | ||
rm -rf ./taschenmesser.egg-info | ||
rm -rf ./build | ||
rm -rf ./dist | ||
find . -name "*.pyc" -exec rm -f {} \; | ||
|
||
build: clean | ||
python setup.py bdist_egg | ||
|
||
publish: clean | ||
python setup.py register | ||
python setup.py sdist upload | ||
python setup.py bdist_egg upload | ||
python setup.py bdist_wininst upload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
############################################################################### | ||
## | ||
## Copyright 2013 (C) Tavendo GmbH | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
############################################################################### | ||
|
||
from setuptools import setup, find_packages | ||
|
||
LONGSDESC = """ | ||
""" | ||
|
||
setup ( | ||
name = 'taschenmesser', | ||
version = '0.0.1', | ||
description = 'Taschenmesser', | ||
long_description = LONGSDESC, | ||
license = 'Apache License 2.0', | ||
author = 'Tavendo GmbH', | ||
author_email = 'contact@tavendo.de', | ||
url = 'http://www.tavendo.de', | ||
platforms = ('Any'), | ||
install_requires = ['setuptools'], | ||
packages = find_packages(), | ||
include_package_data = True, | ||
zip_safe = False, | ||
entry_points = {}, | ||
## http://pypi.python.org/pypi?%3Aaction=list_classifiers | ||
## | ||
classifiers = ["License :: OSI Approved :: Apache Software License", | ||
"Development Status :: 3 - Alpha", | ||
"Environment :: Console", | ||
"Framework :: Twisted", | ||
"Intended Audience :: Developers", | ||
"Intended Audience :: System Administrators", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Topic :: Database", | ||
"Topic :: Internet", | ||
"Topic :: Software Development", | ||
"Topic :: Software Development :: Build Tools", | ||
"Topic :: Software Development :: Testing", | ||
"Topic :: System :: Systems Administration", | ||
"Topic :: Utilities"], | ||
keywords = '' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"folders": | ||
[ | ||
{ | ||
"follow_symlinks": false, | ||
"name": "Taschenmesser", | ||
"path": ".", | ||
"folder_exclude_patterns": ["build", "dist", "*.egg-info"], | ||
"file_exclude_patterns": ["*.pyc", ".sconsign.dblite"] | ||
} | ||
], | ||
"settings": | ||
{ | ||
"tab_size": 3, | ||
"translate_tabs_to_spaces": true, | ||
"use_tab_stops": true, | ||
"detect_indentation": false, | ||
"trim_trailing_white_space_on_save": true, | ||
"ensure_newline_at_eof_on_save": true, | ||
"default_encoding": "UTF-8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
############################################################################### | ||
## | ||
## Copyright 2013 (C) Tavendo GmbH | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
############################################################################### | ||
|
||
import gclosure | ||
import aws | ||
import fileutil | ||
|
||
|
||
def generate(env): | ||
if aws.exists(env): | ||
aws.generate(env) | ||
|
||
if gclosure.exists(env): | ||
gclosure.generate(env) | ||
|
||
if fileutil.exists(env): | ||
fileutil.generate(env) | ||
|
||
|
||
def exists(env): | ||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
############################################################################### | ||
## | ||
## Copyright 2013 (C) Tavendo GmbH | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
############################################################################### | ||
|
||
__all__ = ['exists', 'generate'] | ||
|
||
|
||
def exists(env): | ||
try: | ||
import boto | ||
return True | ||
except: | ||
print "Taschenmesser: Boto library missing. Upload to Amazon S3 won't be available." | ||
return False | ||
|
||
|
||
|
||
def generate(env): | ||
from SCons.Builder import Builder | ||
|
||
import os, sys, hashlib, gzip | ||
import subprocess | ||
|
||
from boto.s3.connection import S3Connection | ||
from boto.s3.key import Key | ||
|
||
def s3_uploader(target, source, env): | ||
""" | ||
SCons builder for Amazon S3 upload. | ||
""" | ||
## S3 connection and bucket to upload to | ||
## | ||
s3 = S3Connection() | ||
bucket = s3.get_bucket("autobahn") | ||
|
||
## compute MD5s of artifacts to upload | ||
## | ||
checksums = {} | ||
for s in source: | ||
key = Key(s.name) | ||
md5 = key.compute_md5(open(s.path, "rb"))[0] | ||
checksums[s.name] = md5 | ||
|
||
## determine stuff we need to upload | ||
## | ||
uploads = [] | ||
for s in source: | ||
key = bucket.lookup("js/%s" % s.name) | ||
if not key or key.etag.replace('"', '') != checksums[s.name]: | ||
uploads.append(s) | ||
else: | ||
print "%s unchanged versus S3" % s.name | ||
|
||
## actually upload new or changed stuff | ||
## | ||
for u in uploads: | ||
print "Uploading %s to S3 .." % u.name | ||
key = Key(bucket, "js/%s" % u.name) | ||
## | ||
## Do special stuff for "*.jgz". Note that "set_metadata" | ||
## must be set before uploading! | ||
## | ||
if os.path.splitext(u.name)[1].lower() == ".jgz": | ||
## override default chosen by S3 .. | ||
key.set_metadata('Content-Type', 'application/x-javascript') | ||
key.set_metadata('Content-Encoding', 'gzip') | ||
key.set_contents_from_filename(u.path) | ||
key.set_acl('public-read') | ||
|
||
## revisit uploaded stuff and get MD5s | ||
## | ||
checksumsS3 = {} | ||
for s in source: | ||
key = bucket.lookup("js/%s" % s.name) | ||
md5 = key.etag.replace('"', '') | ||
checksumsS3[s.name] = md5 | ||
checksumsS3String = ''.join(["MD5 (%s) = %s\n" % c for c in checksumsS3.items()]) | ||
|
||
## target produced is checksums as they exist on S3 | ||
## | ||
f = open(target[0].path, "wb") | ||
f.write(checksumsS3String) | ||
f.close() | ||
|
||
|
||
def checksumsMD5(target, source, env): | ||
""" | ||
SCons builder for computing a fingerprint file for artifacts. | ||
""" | ||
checksums = {} | ||
for s in source: | ||
key = Key(s.name) | ||
md5 = key.compute_md5(open(s.path, "rb"))[0] | ||
checksums[s.name] = md5 | ||
|
||
## MD5 (autobahn.js) = d1ff7ad2c5c4cf0d652566cbc78476ea | ||
## | ||
checksumsString = ''.join(["MD5 (%s) = %s\n" % c for c in checksums.items()]) | ||
|
||
f = open(target[0].path, 'wb') | ||
f.write(checksumsString) | ||
f.close() | ||
|
||
|
||
env.Append(BUILDERS = {'S3': Builder(action = s3_uploader), | ||
'MD5': Builder(action = checksumsMD5)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
############################################################################### | ||
## | ||
## Copyright 2013 (C) Tavendo GmbH | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
############################################################################### | ||
|
||
__all__ = ['exists', 'generate'] | ||
|
||
|
||
def exists(env): | ||
try: | ||
import hashlib, gzip | ||
return True | ||
except: | ||
print "Taschenmesser: Hashlibs missing" | ||
return False | ||
|
||
|
||
|
||
def generate(env): | ||
from SCons.Builder import Builder | ||
import hashlib, gzip | ||
|
||
def gzipper(target, source, env): | ||
if len(source) > 1: | ||
raise Exception("cannot GZip multiple files") | ||
f_in = open(source[0].path, 'rb') | ||
f_out = gzip.open(target[0].path, 'wb') | ||
f_out.writelines(f_in) | ||
f_out.close() | ||
f_in.close() | ||
|
||
|
||
env.Append(BUILDERS = {'GZip': Builder(action = gzipper)}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
############################################################################### | ||
## | ||
## Copyright 2013 (C) Tavendo GmbH | ||
## | ||
## Licensed under the Apache License, Version 2.0 (the "License"); | ||
## you may not use this file except in compliance with the License. | ||
## You may obtain a copy of the License at | ||
## | ||
## http://www.apache.org/licenses/LICENSE-2.0 | ||
## | ||
## Unless required by applicable law or agreed to in writing, software | ||
## distributed under the License is distributed on an "AS IS" BASIS, | ||
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
## See the License for the specific language governing permissions and | ||
## limitations under the License. | ||
## | ||
############################################################################### | ||
|
||
__all__ = ['exists', 'generate'] | ||
|
||
|
||
def exists(env): | ||
import os | ||
|
||
if os.environ.has_key('JAVA_HOME'): | ||
env['JAVA_HOME'] = os.environ['JAVA_HOME'] | ||
else: | ||
print "Need to have a Java Run-time - please set JAVA_HOME ennvironment variable." | ||
return False | ||
|
||
if os.environ.has_key('JS_COMPILER'): | ||
env['JS_COMPILER'] = os.environ['JS_COMPILER'] | ||
else: | ||
print "Need path to Google Closure Compiler JAR (compiler.jar) in JS_COMPILER environment variable." | ||
return False | ||
|
||
return True | ||
|
||
|
||
|
||
def generate(env): | ||
from SCons.Builder import Builder | ||
import os, subprocess | ||
|
||
def js_builder(target, source, env): | ||
""" | ||
SCons builder for Google Closure. | ||
""" | ||
if env['JS_COMPILATION_LEVEL'] == 'NONE': | ||
outfile = str(target[0]) | ||
of = open(outfile, 'w') | ||
for file in source: | ||
of.write(open(str(file)).read()) | ||
of.write("\n") | ||
of.close() | ||
|
||
else: | ||
cmd = [] | ||
cmd.append(os.path.join(env['JAVA_HOME'], 'bin', 'java')) | ||
|
||
cmd.extend(['-jar', env['JS_COMPILER']]) | ||
|
||
for define in env['JS_DEFINES']: | ||
cmd.append('--define="%s=%s"' % (define, env['JS_DEFINES'][define])) | ||
|
||
for file in source: | ||
cmd.extend(["--js", str(file)]) | ||
|
||
cmd.extend(["--js_output_file", str(target[0])]) | ||
|
||
#cmd.append("--warning_level=VERBOSE") | ||
#cmd.append("--jscomp_warning=missingProperties") | ||
#cmd.append("--jscomp_warning=checkTypes") | ||
|
||
print ' '.join(cmd) | ||
subprocess.call(cmd) | ||
|
||
env.Append(BUILDERS = {'JavaScript': Builder(action = js_builder)}) |