Skip to content

Commit

Permalink
Merge pull request #5 from KjellSchubert/master
Browse files Browse the repository at this point in the history
latest from Kjell
  • Loading branch information
um68 committed Jun 17, 2015
2 parents 22797ef + 2c91031 commit b8cde4c
Show file tree
Hide file tree
Showing 29 changed files with 516 additions and 131 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ __pycache__
autoupdate.last
bru_modules
*.swp
*.pyc
4 changes: 2 additions & 2 deletions bru.bat
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
rem This is the equivalent of bru.sh on Windows.
rem Add the parent dir of bru.bat to your PATH.
SET script_dir=%~dp0
call python3 %script_dir%/autoupdate.py --hours 24
call python3 %script_dir%/bru.py %*
call python %script_dir%/autoupdate.py --hours 24
call python %script_dir%/bru.py %*
7 changes: 6 additions & 1 deletion bru.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/usr/bin/env python3
#!/usr/bin/env python

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os
import argparse
Expand Down
13 changes: 11 additions & 2 deletions brulib/clone.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
""" code responsible for creating svn and git clones for modules which don't
offer tar.gz or zip downloads of their releases """

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os
import urllib.parse
import sys
if sys.version_info >= (3, 0):
from urllib.parse import urlparse
if sys.version_info < (3, 0):
from urlparse import urlparse
import subprocess

def remove_url_prefix(url, prefix):
Expand All @@ -17,7 +26,7 @@ def svn_checkout(repo_url, clone_root_dir):
def split_off_changeset(repo_url):
""" splits http://foo.com/bar@xyz into tuple (http://foo.com/bar, xyz),
with the 2nd tuple elem being None if there's no '@' in the URL """
parse = urllib.parse.urlparse(repo_url)
parse = urlparse(repo_url)
at_index = parse.path.rfind('@')
if at_index != -1:
changeset_len = len(parse.path) - at_index # includes '@'
Expand Down
5 changes: 5 additions & 0 deletions brulib/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
'bru install package.json' or 'bru install protobug googlemock@1.7.0'.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os
import re
import glob
Expand Down
8 changes: 7 additions & 1 deletion brulib/jsonc.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@
commas that are illegal in JSON.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import json
import collections
import os
import brulib.util

def drop_hash_comment(line):
""" Getting a line with '#' comment it drops the comment.
Expand Down Expand Up @@ -62,7 +68,7 @@ def savefile(filename, jso):
json_text = json.dumps(jso, indent = 4)
dirname = os.path.dirname(filename)
if len(dirname) > 0:
os.makedirs(dirname, exist_ok=True)
brulib.util.mkdir_p(dirname)
with open(filename, 'w') as json_file:
json_file.write(json_text)
#print("saved " + filename)
6 changes: 6 additions & 0 deletions brulib/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
about how to download tar.gzs for (or hwo to clone) each module, as well
as for how to build the module's libs and some of its tests/examples.
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os
import re
import functools
Expand Down
18 changes: 15 additions & 3 deletions brulib/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
modules via gyp and local compiler toolchain
"""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os
import re
import sys
import glob
import pdb
import platform
import brulib.install

Expand Down Expand Up @@ -47,7 +53,7 @@ def cmd_make(config, verbose, targetPlatform="Native"):
elif system == 'Linux':
if targetPlatform == 'Native':
cmd_make_linux(gyp_file, config, verbose)
else:
else:
raise Exception('targetPlatform {} not supported on platform {}'\
.format(targetPlatform, system))
elif system == 'Darwin':
Expand Down Expand Up @@ -83,7 +89,7 @@ def get_latest_installed_msvs_version():
# Let's do (b) for now.
# See also https://code.google.com/p/gyp/source/browse/trunk/pylib/gyp/MSVSVersion.py
msvs_versions = []
regex = re.compile('^VS([0-10]+)COMNTOOLS$')
regex = re.compile('^VS([0-9]+)COMNTOOLS$')
for key in os.environ:
match = regex.match(key)
if match != None:
Expand All @@ -109,6 +115,7 @@ def get_latest_installed_msvs_year():
90: 2008,
100: 2010,
110: 2012,
140: 2015,
}
if not latest in msvs_version2year:
print('not sure how to map VC{} to a VS year, defaulting to VS 2012'
Expand Down Expand Up @@ -146,11 +153,16 @@ def cmd_make_win(gyp_filename, config):
# or alternatively to msbuild. Lets do msbuild here:
# TODO locate msbuild via glob
msbuild_exe = get_latest_msbuild_exe()
msbuild_exe = "\"c:\\Program Files (x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe\"" #xxx see http://stackoverflow.com/questions/20661943/build-on-tfs-2013-failed-but-okay-locally
if msbuild_exe == None:
raise Exception('did not detect any installs of msbuild, these should'
' be part of .NET installations, please install msbuild or .NET')
# TODO? add /toolsversion:<version> ?
msbuild_cmdline = '{} {} /p:Configuration={} /verbosity:minimal'.format(
msbuild_cmdline = ('{} {} '
+ '/verbosity:minimal ' # or diag
+ '/p:Configuration={} '
+ '/p:VisualStudioVersion=14.0 ' # TODO: why doesn't 14.0 work for VS 2015?
+ '/p:Platform=Win32').format(
msbuild_exe, sln_filename, config)
print("running msvs via msbuild: '{}'".format(msbuild_cmdline))
sys.stdout.flush() # otherwise msbuild log lines show up first
Expand Down
24 changes: 17 additions & 7 deletions brulib/module_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,22 @@
tar.gz files or clones the corresponding repo.
"""

import urllib.parse
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import sys
if sys.version_info >= (3, 0):
from urllib.parse import urlparse
if sys.version_info < (3, 0):
from urlparse import urlparse
import os
import json
import brulib.library
import brulib.clone
import brulib.untar
import brulib.util

def get_user_home_dir():
""" work both on Linux & Windows, this dir will be the parent dir of
Expand All @@ -18,14 +28,14 @@ def unpack_dependency(library, module_name, module_version, zip_url, bru_modules
""" downloads tar.gz or zip file as given by zip_url, then unpacks it
under bru_modules_root """
module_dir = os.path.join(bru_modules_root, module_name, module_version)
os.makedirs(module_dir, exist_ok=True)
brulib.util.mkdir_p(module_dir)

parse = urllib.parse.urlparse(zip_url)
if parse.scheme in ['svn+http', 'svn+https','git+http', 'git+https']:
parse = urlparse(zip_url)
if parse.scheme in [u'svn+http', u'svn+https', u'git+http', u'git+https']:
brulib.clone.atomic_clone_repo(zip_url, module_dir)
return

if parse.scheme == 'file':
if parse.scheme == u'file':
# this is typically used to apply a patch in the form of a targ.gz
# on top of a larger downloaded file. E.g. for ogg & speex this
# patch does approximately what ./configure would have done.
Expand All @@ -46,7 +56,7 @@ def unpack_dependency(library, module_name, module_version, zip_url, bru_modules
# MOdules for which we must clone an svn or git repo are not sharable that
# easily btw, they actually are cloned multiple times atm (could clone them
# once into ~/.bru and copy, but I'm not doing this atm).
if parse.scheme in ['http', 'https', 'ftp']:
if parse.scheme in [u'http', u'https', u'ftp']:
tar_dir = os.path.join(get_user_home_dir(), ".bru", "downloads",
module_name, module_version)
brulib.untar.wget_and_untar_once(zip_url, tar_dir, module_dir)
Expand All @@ -68,7 +78,7 @@ def get_urls(library, formula, bru_modules_root):
zip_urls = formula['url']

# 'url' can be a single string or a list
if isinstance(zip_urls, str):
if not isinstance(zip_urls, list):
zip_urls = [zip_urls]

for zip_url in zip_urls:
Expand Down
5 changes: 5 additions & 0 deletions brulib/runtests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
""" this module impls the logic for 'bru test' """

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os
import glob
import time
Expand Down
24 changes: 18 additions & 6 deletions brulib/untar.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
""" code for downloading and caching and unpacking tar files """

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import os
import urllib.request
import urllib.parse # python 2 urlparse
import sys
if sys.version_info >= (3, 0):
from urllib.parse import urlparse
from urllib.request import urlretrieve
if sys.version_info < (3, 0):
from urlparse import urlparse
from urllib import urlretrieve
import tarfile
import zipfile
import shutil
import pdb
import brulib.util

def split_all(path):
(head, tail) = os.path.split(path)
Expand All @@ -17,7 +29,7 @@ def split_all(path):
def url2filename(url):
""" e.g. maps http://zlib.net/zlib-1.2.8.tar.gz to zlib-1.2.8.tar.gz,
and http://boost.../foo/1.57.0.tgz to foo_1.57.0.tgz"""
parse = urllib.parse.urlparse(url)
parse = urlparse(url)
if parse.scheme == 'file':
path = parse.netloc
assert len(path) > 0
Expand All @@ -42,7 +54,7 @@ def wget(url, filename):
""" typically to download tar.gz or zip """
# from http://stackoverflow.com/questions/7243750/download-file-from-web-in-python-3
print("wget {} -> {}".format(url, filename))
urllib.request.urlretrieve(url, filename)
urlretrieve(url, filename)

def copy_symlink_members(to_directory, lnk_members):
""" instead of creating links copy these archive members """
Expand All @@ -52,7 +64,7 @@ def copy_symlink_members(to_directory, lnk_members):
raise Exception("untar cannot deal with linked dirs yet (TODO?)")
dst = member.name
dstdir = os.path.dirname(dst)
os.makedirs(dstdir, exist_ok=True)
brulib.util.mkdir_p(dstdir)
src = os.path.join(dstdir, member.linkname)
shutil.copyfile(os.path.join(to_directory, src).replace('\\', '/'), os.path.join(to_directory, dst).replace('\\', '/'))

Expand Down Expand Up @@ -123,7 +135,7 @@ def wget_and_untar_once(zip_url, tar_dir, module_dir):
"""
zip_file = os.path.join(tar_dir, url2filename(zip_url))
if not os.path.exists(zip_file):
os.makedirs(tar_dir, exist_ok=True)
brulib.util.mkdir_p(tar_dir)
zip_file_temp = zip_file + ".tmp"
wget(zip_url, zip_file_temp)
os.rename(zip_file_temp, zip_file)
Expand Down
16 changes: 16 additions & 0 deletions brulib/util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import sys
import os
import errno

def mkdir_p(path):
if sys.version_info < (3, 0):

try:
os.makedirs(path)
except OSError as exc: # Python >2.5
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else: raise

else:
os.makedirs(path, exist_ok=True)
5 changes: 4 additions & 1 deletion library/boost-variant/1.57.0.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
{
"type": "none"
}
]
],
["OS=='win'", {
"defines": [ "BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES" ]
}]
]
}
]
Expand Down
5 changes: 3 additions & 2 deletions library/double-conversion/1.1.5.bru
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"url": "https://github.com/floitsch/double-conversion/archive/v1.1.5.tar.gz",
"module": "double-conversion",
"version": "1.1.5",
# folly includes double_conversion/double_conversion.h, even though
# folly includes double_conversion/double_conversion.h, even though
# double-conversion's own tests include "double_conversion.h". Also
# the rpm uses the parent dir. So let's copy the #includes to create
# the same dir structure.
"make_command": {
"Linux": "cd double-conversion-1.1.5 && mkdir -p include/double-conversion && cp src/*.h include/double-conversion/"
"Linux": "cd double-conversion-1.1.5 && mkdir -p include/double-conversion && cp src/*.h include/double-conversion/",
"Windows": "cd double-conversion-1.1.5 && mkdir include\\double-conversion && copy src\\*.h include\\double-conversion\\"
}
}
8 changes: 7 additions & 1 deletion library/double-conversion/1.1.5.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@
],
"dependencies" : [
"double-conversion"
]
],
"msvs_settings": {
"VCCLCompilerTool": {
# needed for msvs 2015 RC
"AdditionalOptions": [ "/bigobj" ]
}
}
}
]
}
15 changes: 9 additions & 6 deletions library/folly/master.bru
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
# Apparently these python script generate cpp src for some utils, but also
# some library cpp files.
"make_command": {
"Linux": "cd clone/folly && python build/generate_escape_tables.py && python build/generate_format_tables.py && python build/generate_varint_tables.py"
"Linux": "cd clone/folly && python build/generate_escape_tables.py && python build/generate_format_tables.py && python build/generate_varint_tables.py",
"Windows": "cd clone\\folly && python build/generate_escape_tables.py && python build/generate_format_tables.py && python build/generate_varint_tables.py"
},
"dependencies": {
"boost-algorithm": "1.57.0",
"boost-bind": "1.57.0",
"boost-container": "1.57.0",
"boost-context": "1.57.0",
"boost-conversion": "1.57.0",
"boost-core": "1.57.0",
"boost-crc": "1.57.0",
Expand All @@ -35,10 +37,11 @@
"boost-variant": "1.57.0",
"googlemock": "1.7.0",
"googletest": "1.7.0",
"glog": "0.3.3",
"gflags": "2.1.1",
"double-conversion": "1.1.5"
# TODO:
# libevent (for Windows builds at least, otherwise apt-get install libevent-dev)
"glog": "0.3.4",
"gflags": "2.1.2",
"openssl": "1.0.1j",
"pthread": "master", # pthread-win32, windows-only
"double-conversion": "1.1.5",
"libevent": "1.4.15" # not libevent 2
}
}
Loading

0 comments on commit b8cde4c

Please sign in to comment.