Skip to content

Commit dc7faf9

Browse files
author
taylorcyang
committed
Migrate ScriptX to Github for open source, ignoring previous history.
0 parents  commit dc7faf9

File tree

240 files changed

+31003
-0
lines changed

Some content is hidden

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

240 files changed

+31003
-0
lines changed

.clang-format

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# this is the tencent cpp format style
2+
Language: Cpp
3+
BasedOnStyle: Google
4+
ColumnLimit: 100
5+
6+
# Only sort headers in each include block
7+
SortIncludes: true
8+
IncludeBlocks: Preserve
9+
10+
---
11+
Language: ObjC
12+
BasedOnStyle: Google
13+
ColumnLimit: 100
14+
15+
---
16+
Language: JavaScript
17+
BasedOnStyle: Google
18+
ColumnLimit: 100

.clang-tidy

Lines changed: 225 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,225 @@
1+
---
2+
Checks: 'clang-diagnostic-*,
3+
clang-analyzer-*,
4+
-*,
5+
modernize-*,
6+
-modernize-use-trailing-return-type,
7+
-modernize-use-nodiscard,
8+
bugprone-*,
9+
-bugprone-macro-parentheses,
10+
google-*,
11+
performance-*,
12+
-performance-trivially-destructible,
13+
misc-*,
14+
clang-*,
15+
android-*,
16+
cppcoreguidelines-*,
17+
-cppcoreguidelines-pro-type-reinterpret-cast,
18+
-cppcoreguidelines-owning-memory,
19+
-cppcoreguidelines-pro-bounds-array-to-pointer-decay,
20+
-cppcoreguidelines-macro-usage,
21+
-cppcoreguidelines-pro-type-const-cast,
22+
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
23+
-cppcoreguidelines-avoid-non-const-global-variables'
24+
WarningsAsErrors: ''
25+
HeaderFilterRegex: ''
26+
AnalyzeTemporaryDtors: false
27+
FormatStyle: none
28+
User: young
29+
CheckOptions:
30+
- key: bugprone-argument-comment.StrictMode
31+
value: '0'
32+
- key: bugprone-assert-side-effect.AssertMacros
33+
value: assert
34+
- key: bugprone-assert-side-effect.CheckFunctionCalls
35+
value: '0'
36+
- key: bugprone-dangling-handle.HandleClasses
37+
value: 'std::basic_string_view;std::experimental::basic_string_view'
38+
- key: bugprone-exception-escape.FunctionsThatShouldNotThrow
39+
value: ''
40+
- key: bugprone-exception-escape.IgnoredExceptions
41+
value: ''
42+
- key: bugprone-misplaced-widening-cast.CheckImplicitCasts
43+
value: '0'
44+
- key: bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant
45+
value: '1'
46+
- key: bugprone-sizeof-expression.WarnOnSizeOfConstant
47+
value: '1'
48+
- key: bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression
49+
value: '0'
50+
- key: bugprone-sizeof-expression.WarnOnSizeOfThis
51+
value: '1'
52+
- key: bugprone-string-constructor.LargeLengthThreshold
53+
value: '8388608'
54+
- key: bugprone-string-constructor.WarnOnLargeLength
55+
value: '1'
56+
- key: bugprone-suspicious-enum-usage.StrictMode
57+
value: '0'
58+
- key: bugprone-suspicious-missing-comma.MaxConcatenatedTokens
59+
value: '5'
60+
- key: bugprone-suspicious-missing-comma.RatioThreshold
61+
value: '0.200000'
62+
- key: bugprone-suspicious-missing-comma.SizeThreshold
63+
value: '5'
64+
- key: bugprone-suspicious-string-compare.StringCompareLikeFunctions
65+
value: ''
66+
- key: bugprone-suspicious-string-compare.WarnOnImplicitComparison
67+
value: '1'
68+
- key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison
69+
value: '0'
70+
- key: bugprone-unused-return-value.CheckedFunctions
71+
value: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty'
72+
- key: cert-dcl16-c.NewSuffixes
73+
value: 'L;LL;LU;LLU'
74+
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues
75+
value: '1.0;100.0;'
76+
- key: cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues
77+
value: '1;2;3;4;'
78+
- key: cppcoreguidelines-no-malloc.Allocations
79+
value: '::malloc;::calloc'
80+
- key: cppcoreguidelines-no-malloc.Deallocations
81+
value: '::free'
82+
- key: cppcoreguidelines-no-malloc.Reallocations
83+
value: '::realloc'
84+
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
85+
value: '1'
86+
- key: cppcoreguidelines-owning-memory.LegacyResourceConsumers
87+
value: '::free;::realloc;::freopen;::fclose'
88+
- key: cppcoreguidelines-owning-memory.LegacyResourceProducers
89+
value: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile'
90+
- key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader
91+
value: ''
92+
- key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle
93+
value: '0'
94+
- key: cppcoreguidelines-pro-type-member-init.IgnoreArrays
95+
value: '0'
96+
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions
97+
value: '0'
98+
- key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor
99+
value: '0'
100+
- key: google-build-namespaces.HeaderFileExtensions
101+
value: ',h,hh,hpp,hxx'
102+
- key: google-global-names-in-headers.HeaderFileExtensions
103+
value: ',h,hh,hpp,hxx'
104+
- key: google-readability-braces-around-statements.ShortStatementLines
105+
value: '1'
106+
- key: google-readability-function-size.BranchThreshold
107+
value: '4294967295'
108+
- key: google-readability-function-size.LineThreshold
109+
value: '4294967295'
110+
- key: google-readability-function-size.NestingThreshold
111+
value: '4294967295'
112+
- key: google-readability-function-size.ParameterThreshold
113+
value: '4294967295'
114+
- key: google-readability-function-size.StatementThreshold
115+
value: '800'
116+
- key: google-readability-function-size.VariableThreshold
117+
value: '4294967295'
118+
- key: google-readability-namespace-comments.ShortNamespaceLines
119+
value: '10'
120+
- key: google-readability-namespace-comments.SpacesBeforeComments
121+
value: '2'
122+
- key: google-runtime-int.SignedTypePrefix
123+
value: int
124+
- key: google-runtime-int.TypeSuffix
125+
value: ''
126+
- key: google-runtime-int.UnsignedTypePrefix
127+
value: uint
128+
- key: google-runtime-references.WhiteListTypes
129+
value: ''
130+
- key: misc-definitions-in-headers.HeaderFileExtensions
131+
value: ',h,hh,hpp,hxx'
132+
- key: misc-definitions-in-headers.UseHeaderFileExtension
133+
value: '1'
134+
- key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries
135+
value: '1'
136+
- key: misc-unused-parameters.StrictMode
137+
value: '0'
138+
- key: modernize-loop-convert.MaxCopySize
139+
value: '16'
140+
- key: modernize-loop-convert.MinConfidence
141+
value: reasonable
142+
- key: modernize-loop-convert.NamingStyle
143+
value: CamelCase
144+
- key: modernize-make-shared.IgnoreMacros
145+
value: '1'
146+
- key: modernize-make-shared.IncludeStyle
147+
value: '0'
148+
- key: modernize-make-shared.MakeSmartPtrFunction
149+
value: 'std::make_shared'
150+
- key: modernize-make-shared.MakeSmartPtrFunctionHeader
151+
value: memory
152+
- key: modernize-make-unique.IgnoreMacros
153+
value: '1'
154+
- key: modernize-make-unique.IncludeStyle
155+
value: '0'
156+
- key: modernize-make-unique.MakeSmartPtrFunction
157+
value: 'std::make_unique'
158+
- key: modernize-make-unique.MakeSmartPtrFunctionHeader
159+
value: memory
160+
- key: modernize-pass-by-value.IncludeStyle
161+
value: llvm
162+
- key: modernize-pass-by-value.ValuesOnly
163+
value: '0'
164+
- key: modernize-raw-string-literal.ReplaceShorterLiterals
165+
value: '0'
166+
- key: modernize-replace-auto-ptr.IncludeStyle
167+
value: llvm
168+
- key: modernize-replace-random-shuffle.IncludeStyle
169+
value: llvm
170+
- key: modernize-use-auto.MinTypeNameLength
171+
value: '5'
172+
- key: modernize-use-auto.RemoveStars
173+
value: '0'
174+
- key: modernize-use-default-member-init.IgnoreMacros
175+
value: '1'
176+
- key: modernize-use-default-member-init.UseAssignment
177+
value: '0'
178+
- key: modernize-use-emplace.ContainersWithPushBack
179+
value: '::std::vector;::std::list;::std::deque'
180+
- key: modernize-use-emplace.SmartPointers
181+
value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr'
182+
- key: modernize-use-emplace.TupleMakeFunctions
183+
value: '::std::make_pair;::std::make_tuple'
184+
- key: modernize-use-emplace.TupleTypes
185+
value: '::std::pair;::std::tuple'
186+
- key: modernize-use-equals-default.IgnoreMacros
187+
value: '1'
188+
- key: modernize-use-equals-delete.IgnoreMacros
189+
value: '1'
190+
- key: modernize-use-nodiscard.ReplacementString
191+
value: '[[nodiscard]]'
192+
- key: modernize-use-noexcept.ReplacementString
193+
value: ''
194+
- key: modernize-use-noexcept.UseNoexceptFalse
195+
value: '1'
196+
- key: modernize-use-nullptr.NullMacros
197+
value: 'NULL'
198+
- key: modernize-use-transparent-functors.SafeMode
199+
value: '0'
200+
- key: modernize-use-using.IgnoreMacros
201+
value: '1'
202+
- key: performance-faster-string-find.StringLikeClasses
203+
value: 'std::basic_string'
204+
- key: performance-for-range-copy.AllowedTypes
205+
value: ''
206+
- key: performance-for-range-copy.WarnOnAllAutoCopies
207+
value: '0'
208+
- key: performance-inefficient-string-concatenation.StrictMode
209+
value: '0'
210+
- key: performance-inefficient-vector-operation.VectorLikeClasses
211+
value: '::std::vector'
212+
- key: performance-move-const-arg.CheckTriviallyCopyableMove
213+
value: '1'
214+
- key: performance-move-constructor-init.IncludeStyle
215+
value: llvm
216+
- key: performance-type-promotion-in-math-fn.IncludeStyle
217+
value: llvm
218+
- key: performance-unnecessary-copy-initialization.AllowedTypes
219+
value: ''
220+
- key: performance-unnecessary-value-param.AllowedTypes
221+
value: ''
222+
- key: performance-unnecessary-value-param.IncludeStyle
223+
value: llvm
224+
...
225+

.devtools/LicenseHeader.template

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Tencent is pleased to support the open source community by making ScriptX available.
3+
* Copyright (C) ${YEAR} THL A29 Limited, a Tencent company. All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+

.devtools/appendLicenseHeader.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
# bash case insensitive match
4+
shopt -s nocasematch
5+
6+
DEVTOOLS=$(dirname $0)
7+
8+
file=$1
9+
10+
TEMPLATE_FILE=${DEVTOOLS}/LicenseHeader.template
11+
THIRDPARTY_PATTERN='thirdparty|third_party'
12+
YEAR=$(date +"%Y")
13+
14+
if [[ $file =~ ${THIRDPARTY_PATTERN} ]]; then
15+
exit 0
16+
fi
17+
18+
if ! grep -q 'THL A29 Limited, a Tencent company.' $file; then
19+
echo "append license header to $file"
20+
temp_file=$(mktemp)
21+
sed -e "s/\${YEAR\}/${YEAR}/" ${TEMPLATE_FILE} > $temp_file
22+
cat $file >> $temp_file
23+
# copy file content instead of moving file to keep file attributes
24+
cat $temp_file > $file
25+
rm -f $temp_file
26+
fi

.devtools/hooks/pre-commit

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
DEVTOOLS=.devtools
4+
# C C++ OC files
5+
SOURCE_SUFFIX='\.(h|c|cpp|cc|hpp|cxx|hxx|m|mm|js)$'
6+
7+
# bash case insensitive match
8+
shopt -s nocasematch
9+
10+
# clang-format
11+
if ! command -v clang-format >/dev/null 2>&1; then
12+
cat >&2 <<EOF
13+
clang-format not fond, abort git commit.
14+
please install clang-format first, then commit again.
15+
16+
mac -> brew install clang-format
17+
windows -> http://llvm.org/builds/
18+
ubuntu -> sudo apt install clang-format
19+
20+
EOF
21+
exit 1
22+
fi
23+
24+
function regenerateVersionHeader() {
25+
VERSION_STRING=$(cat VERSION)
26+
IFS='.' read -a VERSION_ARRAY <<<"${VERSION_STRING}"
27+
28+
cat > src/version.h <<EOF
29+
// ScriptX version config files
30+
// auto generated from the file VERSION
31+
#define SCRIPTX_VERSION_STRING "${VERSION_STRING}"
32+
#define SCRIPTX_VERSION_MAJOR ${VERSION_ARRAY[0]}
33+
#define SCRIPTX_VERSION_MINOR ${VERSION_ARRAY[1]}
34+
#define SCRIPTX_VERSION_PATCH ${VERSION_ARRAY[2]}
35+
36+
constexpr const char* kVersionString = SCRIPTX_VERSION_STRING;
37+
constexpr int kVersionMajor = SCRIPTX_VERSION_MAJOR;
38+
constexpr int kVersionMinor = SCRIPTX_VERSION_MINOR;
39+
constexpr int kVersionPatch = SCRIPTX_VERSION_PATCH;
40+
41+
EOF
42+
43+
git add src/version.h
44+
}
45+
46+
function formatFile() {
47+
file=$1
48+
if [[ -f $file ]]; then
49+
# append license headers
50+
${DEVTOOLS}/appendLicenseHeader.sh $file
51+
echo "clang-format $file"
52+
clang-format -i $file
53+
# stage changed
54+
git add $file
55+
fi
56+
}
57+
58+
for file in $(git diff-index --cached --diff-filter=d --name-only HEAD); do
59+
# version file
60+
if [[ $file == "VERSION" ]]; then
61+
echo regenerate src/version.h from VERSION
62+
regenerateVersionHeader
63+
formatFile src/version.h
64+
fi
65+
66+
# clang-format & license header
67+
if [[ $file =~ ${SOURCE_SUFFIX} ]]; then
68+
formatFile "$file"
69+
fi
70+
71+
done

.devtools/install.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
cd "$(git rev-parse --show-toplevel)"
6+
DEVTOOLS=.devtools
7+
8+
chmod a+x ${DEVTOOLS}/*.sh
9+
10+
cp ${DEVTOOLS}/hooks/pre-commit .git/hooks/
11+
chmod a+x .git/hooks/pre-commit
12+
13+
if ! command -v clang-format >/dev/null 2>&1; then
14+
cat >&2 <<EOF
15+
clang-format not fond, git commit would fail.
16+
please install clang-format.
17+
18+
mac -> brew install clang-format
19+
windows -> http://llvm.org/builds/
20+
ubuntu -> sudo apt install clang-format
21+
22+
EOF
23+
fi

0 commit comments

Comments
 (0)