Skip to content

Commit 5382a35

Browse files
authored
Merge branch 'real-logic:master' into rust-lang
2 parents 561ef2c + 1d8a465 commit 5382a35

34 files changed

+706
-68
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ env:
1414

1515
jobs:
1616
java-build:
17-
name: Java ${{ matrix.java }}
18-
runs-on: ubuntu-20.04
17+
name: Java ${{ matrix.java }} (${{ matrix.os }})
18+
runs-on: ${{ matrix.os }}
1919
strategy:
2020
fail-fast: false
2121
matrix:
2222
java: [ '8', '11', '16', '17-ea' ]
23+
os: [ 'ubuntu-20.04', 'windows-latest' ]
2324
steps:
2425
- name: Checkout code
2526
uses: actions/checkout@v2
@@ -170,9 +171,11 @@ jobs:
170171

171172
cpp-clang-macos-build:
172173
name: C++ Xcode ${{ matrix.version }} (macOS)
173-
runs-on: macos-latest
174+
runs-on: ${{ matrix.os }}
174175
strategy:
175176
fail-fast: false
177+
matrix:
178+
os: [ 'macos-latest' ]
176179
env:
177180
CC: clang
178181
CXX: clang++
@@ -189,9 +192,11 @@ jobs:
189192

190193
cpp-msvc-build:
191194
name: C++ MSVC (Windows)
192-
runs-on: windows-latest
195+
runs-on: ${{ matrix.os }}
193196
strategy:
194197
fail-fast: false
198+
matrix:
199+
os: [ 'windows-latest' ]
195200
env:
196201
CC: cl
197202
CXX: cl

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ file(GLOB_RECURSE SBE_SOURCES
153153
)
154154

155155
add_custom_command(OUTPUT ${SBE_JAR}
156-
COMMAND ./gradlew assemble -x javadoc
156+
COMMAND ./gradlew assemble -x javadoc --console=plain
157157
DEPENDS ${SBE_SOURCES}
158158
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
159159
COMMENT "Generating SBE jar"

build.gradle

Lines changed: 87 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
* limitations under the License.
1515
*/
1616

17+
import java.nio.file.Files
18+
import java.nio.file.StandardOpenOption
19+
import java.security.MessageDigest
20+
1721
plugins {
1822
id 'java-library'
1923
id 'com.github.johnrengelman.shadow' version '7.0.0' apply false
@@ -41,11 +45,10 @@ def toolchainLauncher = javaToolchains.launcherFor {
4145
def checkstyleVersion = '8.39'
4246
def hamcrestVersion = '2.2'
4347
def mockitoVersion = '3.11.2'
44-
def byteBuddyVersion = '1.11.3'
4548
def junitVersion = '5.7.2'
46-
def jmhVersion = '1.32'
47-
def agronaVersion = '1.11.0'
48-
def agronaVersionRange = '[1.11,1.12[' // allow any patch release of 1.11.x
49+
def jmhVersion = '1.33'
50+
def agronaVersion = '1.12.0'
51+
def agronaVersionRange = '[1.12,1.13[' // allow any patch release of 1.12.x
4952

5053
def sbeGroup = 'uk.co.real-logic'
5154
def sbeVersion = file('version.txt').text.trim()
@@ -138,8 +141,6 @@ allprojects {
138141
configurations.all {
139142
resolutionStrategy {
140143
failOnVersionConflict()
141-
142-
force "net.bytebuddy:byte-buddy:${byteBuddyVersion}", "net.bytebuddy:byte-buddy-agent:${byteBuddyVersion}"
143144
}
144145
}
145146

@@ -723,7 +724,7 @@ task generateCSharpCodecs {
723724
'generateCSharpCodecsWithXIncludes'
724725
}
725726

726-
task generateJavaIrCodecs(type: JavaExec) {
727+
task generateJavaIrCodecs(type: JavaExec, dependsOn: 'computeOriginalIrHash') {
727728
mainClass = 'uk.co.real_logic.sbe.SbeTool'
728729
classpath = project(':sbe-all').sourceSets.main.runtimeClasspath
729730
systemProperties(
@@ -771,20 +772,98 @@ task testReport(type: TestReport) {
771772
reportOn subprojects*.test
772773
}
773774

775+
final codecsDir = project.file('sbe-tool/src/main/java/uk/co/real_logic/sbe/ir/generated')
776+
final outputDir = project.file('sbe-tool/build')
777+
final oldHashFile = new File(outputDir, 'old.sha256')
778+
final newHashFile = new File(outputDir, 'new.sha256')
779+
780+
task computeOriginalIrHash(type: ChecksumTask) {
781+
inputDirectory = codecsDir
782+
outputFile = oldHashFile
783+
}
784+
785+
task computeUpdatedIrHash(type: ChecksumTask, dependsOn: 'generateJavaIrCodecs') {
786+
inputDirectory = codecsDir
787+
outputFile = newHashFile
788+
}
789+
790+
task verifyJavaIrCodecsInSync(dependsOn: 'computeUpdatedIrHash') {
791+
doLast {
792+
final byte[] oldHash = Files.readAllBytes(oldHashFile.toPath())
793+
final byte[] newHash = Files.readAllBytes(newHashFile.toPath())
794+
if (!Arrays.equals(oldHash, newHash))
795+
{
796+
throw new GradleException("Java Ir codecs are out of sync! Please execute the `generateJavaIrCodecs` task and commit the changes.")
797+
}
798+
}
799+
}
800+
774801
def isNonStable = { String version ->
775802
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
776803
def regex = /^[0-9,.v-]+(-r)?$/
777804
return !stableKeyword && !(version ==~ regex)
778805
}
779806

780-
tasks.named("dependencyUpdates").configure {
807+
tasks.named('dependencyUpdates').configure {
781808
// Reject all non stable versions
782809
rejectVersionIf {
783810
isNonStable(it.candidate.version)
784811
}
785812
}
786813

814+
tasks.findByName('build').dependsOn verifyJavaIrCodecsInSync
815+
787816
wrapper {
788817
gradleVersion = '7.1.1'
789818
distributionType = 'ALL'
790819
}
820+
821+
class ChecksumTask extends DefaultTask
822+
{
823+
private static final MessageDigest SHA_256 = MessageDigest.getInstance("SHA-256");
824+
private static final byte CR = (byte) ('\r' as char)
825+
private static final byte LF = (byte) ('\n' as char)
826+
827+
@InputDirectory
828+
File inputDirectory
829+
830+
@OutputFile
831+
File outputFile
832+
833+
@TaskAction
834+
def checksum() {
835+
SHA_256.reset()
836+
837+
final File[] files = inputDirectory.listFiles();
838+
for (final File f : files)
839+
{
840+
final byte[] raw = Files.readAllBytes(f.toPath())
841+
final byte[] normalized = normalizeEOL(raw);
842+
SHA_256.update(normalized)
843+
}
844+
845+
final byte[] hash = SHA_256.digest()
846+
847+
Files.write(
848+
outputFile.toPath(),
849+
hash,
850+
StandardOpenOption.CREATE,
851+
StandardOpenOption.WRITE,
852+
StandardOpenOption.TRUNCATE_EXISTING)
853+
}
854+
855+
private byte[] normalizeEOL(final byte[] raw)
856+
{
857+
final byte[] result = new byte[raw.length]
858+
int i = 0
859+
for (int j = 0, size = raw.length; j < size; j++)
860+
{
861+
if (CR == raw[j] && (j == size - 1 || LF == raw[j + 1]))
862+
{
863+
continue;
864+
}
865+
result[i++] = raw[j]
866+
}
867+
return raw.length == i ? result : Arrays.copyOf(result, i);
868+
}
869+
}

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
org.gradle.java.installations.auto-download=false
22
org.gradle.java.installations.fromEnv=BUILD_JAVA_HOME
33

4+
org.gradle.logging.level=warn
5+
org.gradle.warning.mode=all
6+
47
# HTTP timeouts for Gradle
58
systemProp.org.gradle.internal.http.connectionTimeout=300000
69
systemProp.org.gradle.internal.http.socketTimeout=300000

sbe-benchmarks/src/main/java/uk/co/real_logic/sbe/CarBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ private static void decode(
210210
}
211211

212212
/*
213-
* Benchmarks to allow execution outside of JMH.
213+
* Benchmarks to allow execution outside JMH.
214214
*/
215215

216216
public static void main(final String[] args)

sbe-samples/src/main/java/uk/co/real_logic/sbe/examples/OtfExample.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static void main(final String[] args) throws Exception
6363
final ByteBuffer encodedMsgBuffer = ByteBuffer.allocate(MSG_BUFFER_CAPACITY);
6464
encodeTestMessage(encodedMsgBuffer);
6565

66-
// Now lets decode the schema IR so we have IR objects.
66+
// Now let's decode the schema IR, so we have IR objects.
6767
encodedSchemaBuffer.flip();
6868
final Ir ir = decodeIr(encodedSchemaBuffer);
6969

@@ -81,7 +81,7 @@ public static void main(final String[] args) throws Exception
8181

8282
bufferOffset += headerDecoder.encodedLength();
8383

84-
// Given the header information we can select the appropriate message template to do the decode.
84+
// Given the header information we can select the appropriate message template to do the decode operation.
8585
// The OTF Java classes are thread safe so the same instances can be reused across multiple threads.
8686

8787
final List<Token> msgTokens = ir.getMessage(templateId);

sbe-tool/src/main/java/uk/co/real_logic/sbe/ValidationUtil.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public static boolean isCKeyword(final String token)
8080
* Is the value a possible C language keyword?
8181
*
8282
* @param value to be checked.
83-
* @return true if the value a possible C language keyword.
83+
* @return true if the value is a possible C language keyword.
8484
*/
8585
private static boolean possibleCKeyword(final String value)
8686
{
@@ -178,7 +178,7 @@ public static boolean isCppKeyword(final String token)
178178
* Is the value a possible C++ language keyword?
179179
*
180180
* @param value to be checked.
181-
* @return true if the value a possible C++ language keyword.
181+
* @return true if the value is a possible C++ language keyword.
182182
*/
183183
private static boolean possibleCppKeyword(final String value)
184184
{
@@ -319,7 +319,7 @@ private static boolean isJavaIdentifier(final String token)
319319
* identifier = letter { letter | unicode_digit }
320320
* letter = unicode_letter | "_" .
321321
* <p>
322-
* unicode_letter and unicode_digit are defined in section 4.5 of the the unicode
322+
* unicode_letter and unicode_digit are defined in section 4.5 of the unicode
323323
* standard at http://www.unicode.org/versions/Unicode8.0.0/ and
324324
* the Java Character and Digit functions are unicode friendly
325325
*
@@ -358,7 +358,7 @@ public static boolean isGolangKeyword(final String token)
358358
* Is the value a possible Go language keyword?
359359
*
360360
* @param value to be checked.
361-
* @return true if the value a possible Go language keyword.
361+
* @return true if the value is a possible Go language keyword.
362362
*/
363363
private static boolean possibleGolangKeyword(final String value)
364364
{
@@ -418,11 +418,11 @@ private static boolean isSbeGolangIdentifierPart(final char c)
418418
/**
419419
* "Check" value for validity of usage as a csharp identifier.
420420
* https://msdn.microsoft.com/en-us/library/aa664670(v=vs.71).aspx
421-
* ( Which basically boils down to
421+
* Which basically boils down to
422422
* <p>
423423
* first subsequent*
424424
* first is { @ | letter | underscore }
425-
* subsequent is { first | digit | connecing | combining | formatting }*
425+
* subsequent is { first | digit | connecting | combining | formatting }*
426426
* <p>
427427
* letter is Lu, Ll, Lt, Lm, Lo, or Nl (possibly escaped)
428428
* digit is Nd (possibly escaped)
@@ -468,7 +468,7 @@ public static boolean isCSharpKeyword(final String token)
468468
* Is the value a possible C# language keyword?
469469
*
470470
* @param value to be checked.
471-
* @return true if the value a possible C# language keyword.
471+
* @return true if the value is a possible C# language keyword.
472472
*/
473473
public static boolean possibleCSharpKeyword(final String value)
474474
{

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/Generators.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static void forEachField(final List<Token> tokens, final BiConsumer<Token
5454
/**
5555
* Uppercase the first character of a given String.
5656
*
57-
* @param s to have the first character upper cased.
57+
* @param s to have the first character upper-cased.
5858
* @return a new String with the first character in uppercase.
5959
*/
6060
public static String toUpperFirstChar(final String s)
@@ -70,7 +70,7 @@ public static String toUpperFirstChar(final String s)
7070
/**
7171
* Lowercase the first character of a given String.
7272
*
73-
* @param s to have the first character upper cased.
73+
* @param s to have the first character upper-cased.
7474
* @return a new String with the first character in uppercase.
7575
*/
7676
public static String toLowerFirstChar(final String s)

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/TargetCodeGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public interface TargetCodeGenerator
2525
/**
2626
* Get a new {@link CodeGenerator} for the given target language.
2727
*
28-
* @param ir describing the message schemas from which code should generated.
28+
* @param ir describing the message schemas from which code should be generated.
2929
* @param outputDir to which the generated code with be written.
3030
* @return a new instance of a {@link CodeGenerator} for the given target language.
3131
*/

sbe-tool/src/main/java/uk/co/real_logic/sbe/generation/TargetCodeGeneratorLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import static uk.co.real_logic.sbe.SbeTool.*;
3131

3232
/**
33-
* Loader for {@link CodeGenerator}s which target a language. This provide convenient short names rather than the
33+
* Loader for {@link CodeGenerator}s which target a language. This provides convenient short names rather than the
3434
* fully qualified class name of the generator.
3535
*/
3636
public enum TargetCodeGeneratorLoader implements TargetCodeGenerator
@@ -118,7 +118,7 @@ public CodeGenerator newInstance(final Ir ir, final String outputDir)
118118
};
119119

120120
/**
121-
* Do a case insensitive lookup of a target language for code generation.
121+
* Do a case-insensitive lookup of a target language for code generation.
122122
*
123123
* @param name of the target language to lookup.
124124
* @return the {@link TargetCodeGenerator} for the given language name.

0 commit comments

Comments
 (0)