Add .astylerc, waf and related scripts
This commit is contained in:
parent
4e8f6c8745
commit
0cd83dc1f3
26
.astylerc
Normal file
26
.astylerc
Normal file
@ -0,0 +1,26 @@
|
||||
# No backup files
|
||||
--suffix=none
|
||||
|
||||
--exclude="build"
|
||||
--exclude="bundle_dependencies"
|
||||
--ignore-exclude-errors-x
|
||||
|
||||
--style=allman
|
||||
--indent-namespaces
|
||||
--pad-header
|
||||
--unpad-paren
|
||||
--convert-tabs
|
||||
--indent=spaces=4
|
||||
--indent-preproc-block
|
||||
--align-pointer=type
|
||||
--align-reference=type
|
||||
--attach-extern-c
|
||||
|
||||
--keep-one-line-blocks
|
||||
--keep-one-line-statements
|
||||
--min-conditional-indent=0
|
||||
--max-instatement-indent=50
|
||||
|
||||
--max-code-length=80
|
||||
--break-after-logical
|
||||
--lineend=linux
|
107
buildbot.py
Normal file
107
buildbot.py
Normal file
@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import subprocess
|
||||
|
||||
project_name = 'astyle'
|
||||
|
||||
|
||||
def run_command(args):
|
||||
print("Running: {}".format(args))
|
||||
sys.stdout.flush()
|
||||
subprocess.check_call(args)
|
||||
|
||||
|
||||
def get_tool_options(properties):
|
||||
options = []
|
||||
if 'tool_options' in properties:
|
||||
# Make sure that the values are correctly comma separated
|
||||
for key, value in properties['tool_options'].items():
|
||||
if value is None:
|
||||
options += ['--{0}'.format(key)]
|
||||
else:
|
||||
options += ['--{0}={1}'.format(key, value)]
|
||||
|
||||
return options
|
||||
|
||||
|
||||
def configure(properties):
|
||||
command = [sys.executable, 'waf']
|
||||
|
||||
if properties.get('build_distclean'):
|
||||
command += ['distclean']
|
||||
|
||||
command += ['configure', '--git-protocol=git@']
|
||||
|
||||
if 'waf_bundle_path' in properties:
|
||||
command += ['--bundle-path=' + properties['waf_bundle_path']]
|
||||
|
||||
if 'dependency_project' in properties:
|
||||
command += ['--{0}-use-checkout={1}'.format(
|
||||
properties['dependency_project'],
|
||||
properties['dependency_checkout'])]
|
||||
|
||||
command += ["--cxx_mkspec={}".format(properties['cxx_mkspec'])]
|
||||
command += get_tool_options(properties)
|
||||
|
||||
run_command(command)
|
||||
|
||||
|
||||
def build(properties):
|
||||
command = [sys.executable, 'waf', 'build', '-v']
|
||||
run_command(command)
|
||||
|
||||
|
||||
def run_tests(properties):
|
||||
command = [sys.executable, 'waf', '-v', '--run_tests']
|
||||
run_cmd = None
|
||||
|
||||
if properties.get('valgrind_run'):
|
||||
run_cmd = 'valgrind --error-exitcode=1 %s'
|
||||
|
||||
if run_cmd:
|
||||
command += ["--run_cmd={}".format(run_cmd)]
|
||||
|
||||
command += get_tool_options(properties)
|
||||
|
||||
run_command(command)
|
||||
|
||||
|
||||
def install(properties):
|
||||
command = [sys.executable, 'waf', '-v', 'install']
|
||||
|
||||
if 'install_path' in properties:
|
||||
command += ['--install_path={0}'.format(properties['install_path'])]
|
||||
if properties.get('install_relative'):
|
||||
command += ['--install_relative']
|
||||
|
||||
run_command(command)
|
||||
|
||||
|
||||
def main():
|
||||
argv = sys.argv
|
||||
|
||||
if len(argv) != 3:
|
||||
print("Usage: {} <command> <properties>".format(argv[0]))
|
||||
sys.exit(0)
|
||||
|
||||
cmd = argv[1]
|
||||
properties = json.loads(argv[2])
|
||||
|
||||
if cmd == 'configure':
|
||||
configure(properties)
|
||||
elif cmd == 'build':
|
||||
build(properties)
|
||||
elif cmd == 'run_tests':
|
||||
run_tests(properties)
|
||||
elif cmd == 'install':
|
||||
install(properties)
|
||||
else:
|
||||
print("Unknown command: {}".format(cmd))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
73
config.py
Normal file
73
config.py
Normal file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
import urllib2
|
||||
import traceback
|
||||
import sys
|
||||
|
||||
project_name = 'astyle'
|
||||
project_dependencies = \
|
||||
[
|
||||
'waf-tools',
|
||||
]
|
||||
|
||||
# Importing a dynamically generated module
|
||||
# Python recipe from http://code.activestate.com/recipes/82234
|
||||
|
||||
|
||||
def importCode(code, name, add_to_sys_modules=0):
|
||||
"""
|
||||
Import dynamically generated code as a module. code is the
|
||||
object containing the code (a string, a file handle or an
|
||||
actual compiled code object, same types as accepted by an
|
||||
exec statement). The name is the name to give to the module,
|
||||
and the final argument says whether to add it to sys.modules
|
||||
or not. If it is added, a subsequent import statement using
|
||||
name will return this module. If it is not added to sys.modules
|
||||
import will try to load it in the normal fashion.
|
||||
|
||||
import foo
|
||||
|
||||
is equivalent to
|
||||
|
||||
foofile = open("/path/to/foo.py")
|
||||
foo = importCode(foofile,"foo",1)
|
||||
|
||||
Returns a newly generated module.
|
||||
"""
|
||||
import imp
|
||||
|
||||
module = imp.new_module(name)
|
||||
|
||||
exec code in module.__dict__
|
||||
if add_to_sys_modules:
|
||||
sys.modules[name] = module
|
||||
|
||||
return module
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
print('Updating Smart Project Config Tool...')
|
||||
|
||||
url = "https://raw.github.com/steinwurf/steinwurf-labs/" \
|
||||
"master/config_helper/config-impl.py"
|
||||
|
||||
try:
|
||||
# Fetch the code file from the given url
|
||||
req = urllib2.Request(url)
|
||||
response = urllib2.urlopen(req)
|
||||
code = response.read()
|
||||
print("Update complete. Code size: {}\n".format(len(code)))
|
||||
try:
|
||||
# Import the code string as a module
|
||||
mod = importCode(code, "config_helper")
|
||||
# Run the actual config tool from the dynamic module
|
||||
mod.config_tool(project_dependencies)
|
||||
except:
|
||||
print("Unexpected error:")
|
||||
print traceback.format_exc()
|
||||
except Exception as e:
|
||||
print("Could not fetch code file from:\n\t{}".format(url))
|
||||
print(e)
|
||||
|
||||
raw_input('Press ENTER to exit...')
|
169
waf
vendored
Executable file
169
waf
vendored
Executable file
File diff suppressed because one or more lines are too long
51
wscript
Normal file
51
wscript
Normal file
@ -0,0 +1,51 @@
|
||||
#! /usr/bin/env python
|
||||
# encoding: utf-8
|
||||
|
||||
APPNAME = 'astyle'
|
||||
VERSION = '0.1.0'
|
||||
|
||||
import waflib.extras.wurf_options
|
||||
|
||||
|
||||
def options(opt):
|
||||
|
||||
opt.load('wurf_common_tools')
|
||||
|
||||
|
||||
def resolve(ctx):
|
||||
|
||||
import waflib.extras.wurf_dependency_resolve as resolve
|
||||
|
||||
ctx.load('wurf_common_tools')
|
||||
|
||||
ctx.add_dependency(resolve.ResolveVersion(
|
||||
name='waf-tools',
|
||||
git_repository='github.com/steinwurf/waf-tools.git',
|
||||
major=3))
|
||||
|
||||
|
||||
def configure(conf):
|
||||
|
||||
conf.load("wurf_common_tools")
|
||||
|
||||
|
||||
def build(bld):
|
||||
|
||||
bld.load("wurf_common_tools")
|
||||
|
||||
bld.env.append_unique(
|
||||
'DEFINES_STEINWURF_VERSION',
|
||||
'STEINWURF_ASTYLE_VERSION="{}"'.format(VERSION))
|
||||
|
||||
if bld.is_toplevel():
|
||||
|
||||
static_libs = []
|
||||
if bld.is_mkspec_platform('windows'):
|
||||
static_libs = ['Shell32']
|
||||
|
||||
bld.program(
|
||||
features='cxx',
|
||||
source=bld.path.ant_glob('src/*.cpp'),
|
||||
lib=static_libs,
|
||||
target='astyle')
|
||||
|
Loading…
x
Reference in New Issue
Block a user