Skip to content

Commit d15a24b

Browse files
committed
Modernize
1 parent 98e6279 commit d15a24b

27 files changed

+1845
-531
lines changed

.clang-format

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: LLVM
4+
AccessModifierOffset: -2
5+
AlignAfterOpenBracket: BlockIndent
6+
AlignArrayOfStructures: Left
7+
AlignConsecutiveMacros: None
8+
AlignConsecutiveAssignments: None
9+
AlignConsecutiveBitFields: None
10+
AlignConsecutiveDeclarations: None
11+
AlignEscapedNewlines: Right
12+
AlignOperands: Align
13+
AlignTrailingComments: true
14+
AllowAllArgumentsOnNextLine: true
15+
AllowAllParametersOfDeclarationOnNextLine: true
16+
AllowShortEnumsOnASingleLine: false
17+
AllowShortBlocksOnASingleLine: Never
18+
AllowShortCaseLabelsOnASingleLine: false
19+
AllowShortFunctionsOnASingleLine: None
20+
AllowShortLambdasOnASingleLine: None
21+
AllowShortIfStatementsOnASingleLine: Never
22+
AllowShortLoopsOnASingleLine: false
23+
AlwaysBreakAfterDefinitionReturnType: None
24+
AlwaysBreakAfterReturnType: None
25+
AlwaysBreakBeforeMultilineStrings: false
26+
AlwaysBreakTemplateDeclarations: MultiLine
27+
AttributeMacros:
28+
- __capability
29+
- zend_never_inline
30+
- zend_always_inline
31+
- ZEND_COLD
32+
- ZEND_HOT
33+
- PERFIDIOUS_PUBLIC
34+
- PERFIDIOUS_LOCAL
35+
- PERFIDIOUS_ATTR_NONNULL
36+
- PERFIDIOUS_ATTR_NONNULL_ALL
37+
- PERFIDIOUS_ATTR_WARN_UNUSED_RESULT
38+
- PERFIDIOUS_ATTR_RETURNS_NONNULL
39+
BinPackArguments: false
40+
BinPackParameters: false
41+
BraceWrapping:
42+
AfterCaseLabel: false
43+
AfterClass: false
44+
AfterControlStatement: Never
45+
AfterEnum: false
46+
AfterFunction: false
47+
AfterNamespace: false
48+
AfterObjCDeclaration: false
49+
AfterStruct: false
50+
AfterUnion: false
51+
AfterExternBlock: false
52+
BeforeCatch: false
53+
BeforeElse: false
54+
BeforeLambdaBody: false
55+
BeforeWhile: false
56+
IndentBraces: false
57+
SplitEmptyFunction: true
58+
SplitEmptyRecord: true
59+
SplitEmptyNamespace: true
60+
BreakBeforeBinaryOperators: None
61+
BreakBeforeConceptDeclarations: true
62+
BreakBeforeBraces: Mozilla
63+
BreakBeforeInheritanceComma: false
64+
BreakInheritanceList: BeforeColon
65+
BreakBeforeTernaryOperators: true
66+
BreakConstructorInitializersBeforeComma: false
67+
BreakConstructorInitializers: BeforeColon
68+
BreakAfterJavaFieldAnnotations: false
69+
BreakStringLiterals: true
70+
ColumnLimit: 120
71+
CommentPragmas: '^ IWYU pragma:'
72+
QualifierAlignment: Leave
73+
CompactNamespaces: false
74+
ConstructorInitializerIndentWidth: 4
75+
ContinuationIndentWidth: 4
76+
DeriveLineEnding: true
77+
DerivePointerAlignment: false
78+
DisableFormat: false
79+
EmptyLineAfterAccessModifier: Never
80+
EmptyLineBeforeAccessModifier: LogicalBlock
81+
ExperimentalAutoDetectBinPacking: false
82+
PackConstructorInitializers: Never
83+
BasedOnStyle: ''
84+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
85+
AllowAllConstructorInitializersOnNextLine: true
86+
FixNamespaceComments: true
87+
ForEachMacros:
88+
- foreach
89+
- Q_FOREACH
90+
- BOOST_FOREACH
91+
IfMacros:
92+
- KJ_IF_MAYBE
93+
IncludeBlocks: Preserve
94+
IncludeCategories:
95+
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
96+
Priority: 2
97+
SortPriority: 0
98+
CaseSensitive: false
99+
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
100+
Priority: 3
101+
SortPriority: 0
102+
CaseSensitive: false
103+
- Regex: '.*'
104+
Priority: 1
105+
SortPriority: 0
106+
CaseSensitive: false
107+
IncludeIsMainRegex: '(Test)?$'
108+
IncludeIsMainSourceRegex: ''
109+
IndentAccessModifiers: false
110+
IndentCaseLabels: true
111+
IndentCaseBlocks: false
112+
IndentGotoLabels: true
113+
IndentPPDirectives: None
114+
IndentExternBlock: AfterExternBlock
115+
IndentRequires: false
116+
IndentWidth: 4
117+
IndentWrappedFunctionNames: false
118+
InsertTrailingCommas: Wrapped
119+
KeepEmptyLinesAtTheStartOfBlocks: true
120+
LambdaBodyIndentation: Signature
121+
MacroBlockBegin: "^ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO|ZEND_PARSE_PARAMETERS_START|ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX|ZEND_BEGIN_MODULE_GLOBALS|PHP_INI_BEGIN|ZEND_INI_BEGIN$"
122+
MacroBlockEnd: '^ZEND_END_ARG_INFO|ZEND_PARSE_PARAMETERS_END|ZEND_END_MODULE_GLOBALS|PHP_INI_END|ZEND_INI_END$'
123+
MaxEmptyLinesToKeep: 1
124+
NamespaceIndentation: None
125+
PenaltyBreakAssignment: 2
126+
PenaltyBreakBeforeFirstCallParameter: 19
127+
PenaltyBreakComment: 300
128+
PenaltyBreakFirstLessLess: 120
129+
PenaltyBreakOpenParenthesis: 0
130+
PenaltyBreakString: 1000
131+
PenaltyBreakTemplateDeclaration: 10
132+
PenaltyExcessCharacter: 1000000
133+
PenaltyReturnTypeOnItsOwnLine: 60
134+
PenaltyIndentedWhitespace: 0
135+
PointerAlignment: Right
136+
PPIndentWidth: -1
137+
ReferenceAlignment: Pointer
138+
ReflowComments: true
139+
RemoveBracesLLVM: false
140+
SeparateDefinitionBlocks: Leave
141+
ShortNamespaceLines: 1
142+
SortIncludes: false
143+
SortJavaStaticImport: Before
144+
SortUsingDeclarations: true
145+
SpaceAfterCStyleCast: true
146+
SpaceAfterLogicalNot: false
147+
SpaceAfterTemplateKeyword: true
148+
SpaceBeforeAssignmentOperators: true
149+
SpaceBeforeCaseColon: false
150+
SpaceBeforeCpp11BracedList: false
151+
SpaceBeforeCtorInitializerColon: true
152+
SpaceBeforeInheritanceColon: true
153+
SpaceBeforeParens: ControlStatements
154+
SpaceBeforeParensOptions:
155+
AfterControlStatements: true
156+
AfterForeachMacros: true
157+
AfterFunctionDefinitionName: false
158+
AfterFunctionDeclarationName: false
159+
AfterIfMacros: true
160+
AfterOverloadedOperator: false
161+
BeforeNonEmptyParentheses: false
162+
SpaceAroundPointerQualifiers: Default
163+
SpaceBeforeRangeBasedForLoopColon: true
164+
SpaceInEmptyBlock: false
165+
SpaceInEmptyParentheses: false
166+
SpacesBeforeTrailingComments: 1
167+
SpacesInAngles: Never
168+
SpacesInConditionalStatement: false
169+
SpacesInContainerLiterals: true
170+
SpacesInCStyleCastParentheses: false
171+
SpacesInLineCommentPrefix:
172+
Minimum: 1
173+
Maximum: -1
174+
SpacesInParentheses: false
175+
SpacesInSquareBrackets: false
176+
SpaceBeforeSquareBrackets: false
177+
BitFieldColonSpacing: Both
178+
Standard: Latest
179+
StatementAttributeLikeMacros:
180+
- Q_EMIT
181+
StatementMacros:
182+
- Q_UNUSED
183+
- QT_REQUIRE_VERSION
184+
- PHP_INI_BEGIN
185+
- PHP_INI_END
186+
- ZEND_TSRMLS_CACHE_DEFINE
187+
- ZEND_MOD_END
188+
TabWidth: 4
189+
UseCRLF: false
190+
UseTab: Never
191+
WhitespaceSensitiveMacros:
192+
- STRINGIZE
193+
- PP_STRINGIZE
194+
- BOOST_PP_STRINGIZE
195+
- NS_SWIFT_NAME
196+
- CF_SWIFT_NAME
197+
...
198+

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.github/attrs.nix

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
system ? builtins.currentSystem,
3+
lib ? import <nixpkgs/lib>,
4+
prefix,
5+
}: attrs:
6+
lib.pipe attrs.${system} [
7+
builtins.attrNames
8+
(builtins.map (x: "${prefix}.${system}.${x}"))
9+
(builtins.concatStringsSep "\n")
10+
]

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"

.github/php-debian.Dockerfile

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,23 @@
11

2-
ARG PHP_VERSION=7.4
3-
ARG BASE_IMAGE=php:$PHP_VERSION
2+
ARG PHP_VERSION=8.1
3+
ARG PHP_TYPE=bookworm
4+
ARG BASE_IMAGE=php:$PHP_VERSION-cli-$PHP_TYPE
45

56
# image0
67
FROM ${BASE_IMAGE}
7-
RUN apt-get update && apt-get install -y \
8-
autoconf \
9-
automake \
10-
gcc \
11-
libtool \
12-
m4 \
13-
make \
14-
pkg-config
15-
WORKDIR /build/php-shoco
8+
ENV DEV_PACKAGES="libcap-dev libpfm4-dev"
9+
WORKDIR /build
10+
RUN apt-get update && apt-get install -y ${DEV_PACKAGES}
1611
ADD . .
1712
RUN phpize
18-
RUN ./configure CFLAGS="-O3"
13+
RUN ./configure
1914
RUN make
2015
RUN make install
2116

2217
# image1
2318
FROM ${BASE_IMAGE}
19+
ENV BIN_PACKAGES="libcap2 libpfm4"
20+
RUN apt-get update && apt-get install -y ${BIN_PACKAGES}
2421
COPY --from=0 /usr/local/lib/php/extensions /usr/local/lib/php/extensions
2522
RUN docker-php-ext-enable shoco
2623
ENTRYPOINT ["docker-php-entrypoint"]

.github/php-fedora.Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,32 @@ ARG BASE_IMAGE=fedora:latest
33

44
# image0
55
FROM ${BASE_IMAGE}
6+
WORKDIR /build
7+
68
RUN dnf groupinstall 'Development Tools' -y
79
RUN dnf install \
10+
git-all \
811
gcc \
912
automake \
1013
autoconf \
1114
libtool \
1215
php-devel \
16+
libcap-devel \
17+
libpfm-devel \
1318
-y
14-
WORKDIR /build/php-shoco
19+
20+
WORKDIR /build
1521
ADD . .
1622
RUN phpize
17-
RUN ./configure CFLAGS="-O3"
23+
RUN ./configure
1824
RUN make
1925
RUN make install
2026

2127
# image1
2228
FROM ${BASE_IMAGE}
23-
RUN dnf install php-cli -y
29+
RUN dnf install php-cli libcap libpfm -y
2430
# this probably won't work on other arches
25-
COPY --from=0 /usr/lib64/php/modules/shoco.so /usr/lib64/php/modules/shoco.so
31+
COPY --from=0 /usr/lib64/php/modules/shoco.so /usr/lib64/php/modules/perfidious.so
2632
# please forgive me
2733
COPY --from=0 /usr/lib64/php/build/run-tests.php /usr/local/lib/php/build/run-tests.php
2834
RUN echo extension=shoco.so | sudo tee /etc/php.d/90-shoco.ini

.github/scripts/docker.sh

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,30 @@
11
#!/usr/bin/env bash
22

3-
set -e -o pipefail
4-
source .github/scripts/fold.sh
3+
set -ex -o pipefail
54

65
# config
7-
export DOCKER_NAME=${DOCKER_NAME:-"alpine"}
8-
export PHP_VERSION=${PHP_VERSION:-"7.4"}
9-
export TEST_PHP_EXECUTABLE=${TEST_PHP_EXECUTABLE:-"/usr/local/bin/php"}
10-
export RUN_TESTS_PHP=${RUN_TESTS_PHP:-"/usr/local/lib/php/build/run-tests.php"}
6+
export PHP_VERSION="${PHP_VERSION:-"8.1"}"
7+
export TEST_PHP_EXECUTABLE="${TEST_PHP_EXECUTABLE:-"/usr/local/bin/php"}"
8+
export RUN_TESTS_PHP="${RUN_TESTS_PHP:-"/usr/local/lib/php/build/run-tests.php"}"
9+
export IMAGE_TAG="${IMAGE_TAG:-"php-shoco-${DOCKER_NAME}"}"
1110

12-
function docker_build() (
13-
docker build \
14-
-f .github/php-${DOCKER_NAME}.Dockerfile \
15-
-t php-shoco \
16-
--build-arg PHP_VERSION=${PHP_VERSION} \
17-
.
18-
)
11+
docker build \
12+
-f ".github/php-${DOCKER_NAME}.Dockerfile" \
13+
-t "${IMAGE_TAG}" \
14+
--build-arg "PHP_VERSION=${PHP_VERSION}" \
15+
.
1916

20-
function docker_run() (
21-
set -x
22-
docker run \
23-
--env NO_INTERACTION=1 \
24-
--env REPORT_EXIT_STATUS=1 \
25-
--env TEST_PHP_EXECUTABLE=${TEST_PHP_EXECUTABLE} \
26-
-v "$PWD/tests:/mnt" \
27-
php-shoco \
28-
php ${RUN_TESTS_PHP} /mnt
29-
)
17+
trap 'catch' ERR
3018

31-
cifold "docker build" docker_build
32-
cifold "docker run" docker_run
19+
catch() {
20+
find tests -print0 -name '*.log' | xargs -0 -n1 cat
21+
}
22+
23+
docker run \
24+
--env NO_INTERACTION=1 \
25+
--env REPORT_EXIT_STATUS=1 \
26+
--env "TEST_PHP_EXECUTABLE=${TEST_PHP_EXECUTABLE}" \
27+
--cap-add CAP_PERFMON \
28+
-v "${PWD}/tests:/mnt" \
29+
"${IMAGE_TAG}" \
30+
php "${RUN_TESTS_PHP}" /mnt

0 commit comments

Comments
 (0)