Skip to content

Commit 0fb0191

Browse files
cfcf
cf
authored and
cf
committed
add all
1 parent 609178d commit 0fb0191

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+13920
-0
lines changed

COPYING

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright 2012, Tencent Inc.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are
6+
met:
7+
8+
* Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
* Redistributions in binary form must reproduce the above
11+
copyright notice, this list of conditions and the following disclaimer
12+
in the documentation and/or other materials provided with the
13+
distribution.
14+
* Neither the name of Tencent Inc. nor the names of its
15+
contributors may be used to endorse or promote products derived from
16+
this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ChangeLog

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Tue Aug 21 21:09:14 2012 Tencent Inc. <[email protected]>
2+
3+
* blade: version 1.0
4+
* initialize opensource release
5+

OWNERS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
michaelpeng
2+
phongchen

README

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
Blade Unified Construction Collection
2+
=======================================
3+
4+
http://code.tencent.com/projects/blade
5+
6+
Overview
7+
-----------------------------
8+
9+
Blade is designed to be a distributed unified building
10+
system. It is powerful and easy to use. It supports
11+
building mulitiple languages, such as c/c++, Java, protobuf
12+
and swig etc. It analyzes the target dependency automatically
13+
and integrates compiling and linking, testing(incremental
14+
testing and parallel testing), static code inspection functions
15+
together. It aims to improve the clarity and simplicity of the
16+
building rules for a project.
17+
18+
Requirements for End Users
19+
-----------------------------
20+
21+
Blade is designed to have fairly minimal requirements
22+
to build your projects, but there are some. Currently we
23+
only support Linux. We will also make our best effort to
24+
support other platforms (e.g. Solaris, Windows).
25+
However, since core members of the Blade project have no
26+
access to these platforms, it may have outstanding issues
27+
there. If you notice any problems on your platform, please
28+
29+
Patches for fixing them are even more welcome!
30+
31+
### Linux requirements ###
32+
These are the basic requirements to use Blade as a source
33+
package.
34+
35+
* GNU Complier Collection (required)
36+
* Scons v2.0 or newer (required)
37+
* Python v2.6 or newer (required)
38+
* Ccache v3.1 or newer (optional)
39+
40+
If you want to make Blade to have the capability to build
41+
every target it supports, these are the prerequisites.
42+
43+
* swig v2.0 or newer (required for swig_library)
44+
* flex v2.5 or newer (required for lex_yacc)
45+
* bison v2.1 or newer (required for lex_yacc)
46+
47+
Requirements for Contributor
48+
-----------------------------
49+
50+
We welcome patches. If you plan to contribute a patch,
51+
you need to develop and test your patch from (SVN) checkout.
52+
You need to have this requirement to develop. Blade is
53+
written in python.
54+
55+
* Python version 2.6 or newer (python 3.0 or newer excluded)
56+
57+
Getting the source
58+
-----------------------------
59+
60+
You can directly check out the source from our Subversion (SVN)
61+
repository. The SVN checkout requires a few extra steps and some
62+
extra software packages on your system, but lets you track the
63+
latest development and make patches much more easily, so we
64+
highly encourage it.
65+
66+
### Source Package ###
67+
68+
Blade is released in versioned source packages which is
69+
located at this site [1].
70+
71+
[1] http://code.tencent.com/projects/blade
72+
73+
Setting up the collection
74+
-----------------------------
75+
76+
End users or developers need to execute the install script to
77+
intall Blade into current user environment. Please make sure
78+
that ~/bin is in your PATH environment variable. We establish
79+
several symbolic links that enable you to execute blade command.
80+
81+
Reference
82+
-----------------------------
83+
[1] http://code.tencent.com/projects/blade
84+
[2] user manual is inside the package
85+
[3] developer manual is inside the package
86+
87+
Happy testing!

blade

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
#
3+
# SCRIPT: blade
4+
# AUTHOR: Michaelpeng <[email protected]>
5+
# Phongchen <[email protected]>
6+
# DATE: Dec 17 2011
7+
# REV: 1.0.P (Valid are A, B, D, T and P)
8+
# (For Alpha, Beta, Dev, Test and Production)
9+
#
10+
# PLATFORM: Linux
11+
# PURPOSE : A bash wrapper for blade, always run blade of
12+
# corresponding version in for given source dir
13+
# tree.
14+
# REV LIST:
15+
# DATE: Dec 17 2011
16+
# BY : Michaelpeng
17+
# MODIFICATION: Created
18+
19+
function _info()
20+
{
21+
if [ -t 1 ]; then
22+
echo -e "\e[1;36mBlade(info): $@\e[m"
23+
else
24+
echo -e "Blade(info): $@"
25+
fi
26+
}
27+
28+
function _warning()
29+
{
30+
if [ -t 2 ]; then
31+
echo -e "\e[1;33mBlade(warning): $@\e[m" >&2
32+
else
33+
echo -e "Blade(warning): $@" >&2
34+
fi
35+
}
36+
37+
function _error_exit()
38+
{
39+
if [ -t 2 ]; then
40+
echo -e "\e[1;31mBlade(error): $@\nBlade (error): Blade will exit...\e[m" >&2
41+
else
42+
echo -e "Blade(error): $@\nBlade (error): Blade will exit..." >&2
43+
fi
44+
exit 1
45+
}
46+
47+
blade_path=''
48+
49+
if [ -L "$0" ]; then
50+
blade_path=`readlink -f $0`
51+
else
52+
blade_path=$0
53+
fi
54+
55+
blade_dir=$(cd $(dirname $blade_path) && pwd)
56+
57+
blade_file="$blade_dir/blade.zip"
58+
59+
# Check the python version at first, exit blade when python
60+
# version is under 2.6
61+
no_python=$(which python 2>&1 | grep 'which: no')
62+
if [[ -n "$no_python" ]]; then
63+
_error_exit "Please install python 2.6 or above in your system"
64+
fi
65+
66+
python_ver=$(python -V 2>&1 | sed 's/Python //g')
67+
68+
if [[ "$python_ver" < "2.6" ]]; then
69+
_info "Python version in your machine: $python_ver"
70+
_error_exit "Please upgrade your python version to 2.6 or above"
71+
fi
72+
73+
# Check scons environment
74+
no_scons=$(which scons 2>&1 | grep 'which: no scons in')
75+
if [[ -n "$no_scons" ]]; then
76+
_error_exit "Please install scons v2.0 or above on your machine"
77+
fi
78+
79+
# blade now
80+
if [[ ! -f "$blade_file" ]]; then
81+
_error_exit "Cannot find the core file $blade_file"
82+
fi
83+
84+
python $blade_file "$@"

blade.conf

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
cc_test_config(
2+
dynamic_link=False,
3+
heap_check='',
4+
gperftools_libs=['#tcmalloc'],
5+
gperftools_debug_libs=['#tcmalloc_debug'],
6+
gtest_libs=['#gtest', '#pthread'],
7+
gtest_main_libs=['#gtest_main']
8+
)
9+
10+
distcc_config(
11+
enabled=False
12+
)
13+
14+
link_config(
15+
link_on_tmp=False,
16+
enable_dccc=False
17+
)
18+
19+
proto_library_config(
20+
protoc='protoc',
21+
protobuf_libs=['#protobuf', '#glog', '#gflags', '#pthread'],
22+
protobuf_path='thirdparty',
23+
protobuf_include_path = 'thirdparty',
24+
protobuf_php_path='thirdparty/Protobuf-PHP/library',
25+
protoc_php_plugin='thirdparty/Protobuf-PHP/protoc-gen-php.php'
26+
)
27+
28+
cc_config(
29+
extra_incs='thirdparty'
30+
)
31+
32+
"""
33+
java_config(
34+
source_version='1.6',
35+
target_version='1.6'
36+
)
37+
"""

blade.zip

78.2 KB
Binary file not shown.

bladefunctions

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/bin/bash
2+
# some useful blade shell functions
3+
# usage:
4+
# source this file in your ~/.bashrc, for example:
5+
# test -s ~/bin/bladefunctions && . ~/bin/bladefunctions || true
6+
7+
_find_project_root ()
8+
{
9+
local dir
10+
dir=$PWD;
11+
while [ "$dir" != "/" ]; do
12+
if [ -f "$dir/BLADE_ROOT" ]; then
13+
echo "$dir"
14+
return 0
15+
fi;
16+
dir=`dirname "$dir"`
17+
done
18+
return 1
19+
}
20+
21+
_BUILD_DIR_PATTERN="blade-bin|(build(32|64)_(debug|release))"
22+
23+
# cd to build directory
24+
function cddst()
25+
{
26+
local root
27+
local relpath
28+
if root=`_find_project_root`; then
29+
if ! [[ "$PWD" =~ $_BUILD_DIR_PATTERN ]]; then
30+
if relpath=$(pwd | sed "s|^$root||"); then
31+
echo $relpath
32+
cd `readlink $root/blade-bin`/$relpath
33+
return $?
34+
fi
35+
fi
36+
fi
37+
return 1
38+
}
39+
40+
# cd to source directory
41+
function cdsrc()
42+
{
43+
local root
44+
local relpath
45+
if root=`_find_project_root`; then
46+
if [[ "$PWD" =~ $_BUILD_DIR_PATTERN ]]; then
47+
if relpath=$(pwd | sed -r -e "s%^$root/($_BUILD_DIR_PATTERN)%%"); then
48+
cd $root/$relpath
49+
return $?
50+
fi
51+
fi
52+
fi
53+
return 1
54+
}
55+
56+
function alt()
57+
{
58+
if ! cdsrc; then cddst; fi
59+
}
60+
61+
alias a=alt
62+
63+
64+
# @() pattern match require this
65+
shopt -s extglob progcomp
66+
67+
_blade()
68+
{
69+
local cur cmds cmdOpts optsParam opt
70+
local optBase i
71+
72+
COMPREPLY=()
73+
cur=${COMP_WORDS[COMP_CWORD]}
74+
75+
# Possible expansions, without unambiguous abbreviations such as "up".
76+
cmds='build test clean run query'
77+
78+
if [[ $COMP_CWORD -eq 1 ]] ; then
79+
COMPREPLY=( $( compgen -W "$cmds" -- $cur ) )
80+
return 0
81+
fi
82+
83+
commonOpts="--color --profile --generate-dynamic --no-test --help -pdebug -prelease -m32 -m64"
84+
85+
# possible options for the command
86+
cmdOpts=
87+
case ${COMP_WORDS[1]} in
88+
build)
89+
cmdOpts="$commonOpts"
90+
;;
91+
test)
92+
cmdOpts="$commonOpts --full-test --test-jobs -t"
93+
;;
94+
clean)
95+
cmdOpts="$commonOpts"
96+
;;
97+
query)
98+
cmdOpts="$commonOpts"
99+
;;
100+
*)
101+
;;
102+
esac
103+
104+
# take out options already given
105+
for ((i=2; i<=$COMP_CWORD-1; ++i)) ; do
106+
opt=${COMP_WORDS[$i]}
107+
108+
case $opt in
109+
--*) optBase=${opt/=*/} ;;
110+
-*) optBase=${opt:0:2} ;;
111+
esac
112+
113+
cmdOpts=" $cmdOpts "
114+
cmdOpts=${cmdOpts/ ${optBase} / }
115+
116+
# skip next option if this one requires a parameter
117+
if [[ $opt == @($optsParam) ]] ; then
118+
((++i))
119+
fi
120+
done
121+
122+
COMPREPLY=($(compgen -d -W "$cmdOpts" -- $cur | grep -v '.svn'))
123+
124+
return 0
125+
}
126+
127+
complete -F _blade -o default blade
128+

0 commit comments

Comments
 (0)