Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/hosted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ jobs:
if: matrix.target == 'swift'
uses: swift-actions/setup-swift@v1
with:
swift-version: '5.2'
swift-version: '5.6'

- name: Use ccache
if: (startswith(matrix.os, 'macos') || startswith(matrix.os, 'ubuntu')) && (matrix.target == 'cpp')
Expand Down Expand Up @@ -323,7 +323,6 @@ jobs:
case ${{ matrix.target }} in
python2) mvn -X '-Dantlr-python2-exec=${{ env.pythonLocation }}/bin/python' '-Dtest=python2.**' test ;;
python3) mvn -X '-Dantlr-python3-exec=${{ env.pythonLocation }}/bin/python' '-Dtest=python3.**' test ;;
swift) mvn -X -e '-Dtest=python3.**' test ;;
*) mvn -X '-Dtest=${{ matrix.target }}.**' test ;;
esac

Expand Down
30 changes: 23 additions & 7 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,28 @@ let package = Package(
dependencies: ["Antlr4"],
path: "./runtime/Swift/Tests/Antlr4Tests",
exclude: [
"./runtime/Swift/Tests/VisitorBasic.g4",
"./runtime/Swift/Tests/VisitorCalc.g4",
"./runtime/Swift/Tests/LexerA.g4",
"./runtime/Swift/Tests/LexerB.g4",
"./runtime/Swift/Tests/Threading.g4"
"gen/LexerB.tokens",
"gen/VisitorCalcLexer.tokens",
"gen/VisitorBasicLexer.tokens",
"gen/VisitorBasic.tokens",
"gen/Threading.interp",
"gen/VisitorCalcLexer.interp",
"gen/ThreadingLexer.interp",
"gen/VisitorBasicLexer.interp",
"gen/LexerB.interp",
"gen/Threading.tokens",
"gen/VisitorCalc.interp",
"gen/LexerA.interp",
"gen/ThreadingLexer.tokens",
"gen/LexerA.tokens",
"gen/VisitorCalc.tokens",
"gen/VisitorBasic.interp",
"VisitorBasic.g4",
"VisitorCalc.g4",
"LexerA.g4",
"LexerB.g4",
"Threading.g4"
]
)
),
]
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@ import PackageDescription

let package = Package(
name: "Test",
products: [
.executable(name: "Test", targets: ["Test"]),
],
dependencies: [
.package(name: "Antlr4", path: "<libraryPath>"),
],
targets: [
.executableTarget(name: "Test", path: ".",
exclude:[ <excludedFiles: {f | "<f>"}; separator = ", ", wrap> ]),
.executableTarget(
name: "Test",
dependencies: [
.product(name: "Antlr4", package: "Antlr4"),
],
path: ".",
exclude: [
<excludedFiles: {f | "<f>"}; separator = ", ", wrap>
]
),
]
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Processor {
* RUNNING ln -s /Users/parrt/antlr/code/antlr4/runtime/Cpp/dist/libantlr4-runtime.dylib in /var/folders/w1/_nr4stn13lq0rvjdkwh7q8cc0000gn/T/CppRunner-ForkJoinPool-1-worker-23-1668284191961
* RUNNING clang++ -std=c++17 -I /Users/parrt/antlr/code/antlr4/runtime/Cpp/runtime/src -L. -lantlr4-runtime -pthread -o Test.out Test.cpp TLexer.cpp TParser.cpp TListener.cpp TBaseListener.cpp TVisitor.cpp TBaseVisitor.cpp in /var/folders/w1/_nr4stn13lq0rvjdkwh7q8cc0000gn/T/CppRunner-ForkJoinPool-1-worker-23-1668284191961
*/
public static final boolean WATCH_COMMANDS_EXEC = false;
public static final boolean WATCH_COMMANDS_EXEC = true;
public final String[] arguments;
public final String workingDirectory;
public final Map<String, String> environmentVariables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

package org.antlr.v4.test.runtime.swift;

import org.antlr.v4.test.runtime.*;
import org.antlr.v4.test.runtime.RunOptions;
import org.antlr.v4.test.runtime.RuntimeRunner;
import org.antlr.v4.test.runtime.states.CompiledState;
import org.antlr.v4.test.runtime.states.GeneratedState;
import org.stringtemplate.v4.ST;
Expand All @@ -20,7 +21,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import static org.antlr.v4.test.runtime.FileUtils.*;
import static org.antlr.v4.test.runtime.FileUtils.writeFile;
import static org.antlr.v4.test.runtime.RuntimeTestUtils.getTextFromResource;
import static org.antlr.v4.test.runtime.RuntimeTestUtils.isWindows;

Expand All @@ -39,21 +40,21 @@ public String getTestFileName() {
private static final String buildSuffix;
private static final Map<String, String> environment;

private static final String includePath;
// private static final String includePath;
private static final String libraryPath;

static {
swiftRuntimePath = getRuntimePath("Swift");
buildSuffix = isWindows() ? "x86_64-unknown-windows-msvc" : "";
includePath = Paths.get(swiftRuntimePath, ".build", buildSuffix, "release").toString();
String buildDir = Paths.get(swiftRuntimePath, "..", "..", ".build", buildSuffix, "release").normalize().toString();
environment = new HashMap<>();
if (isWindows()) {
libraryPath = Paths.get(includePath, "Antlr4.lib").toString();
libraryPath = Paths.get(buildDir, "Antlr4.lib").toString();
String path = System.getenv("PATH");
environment.put("PATH", path == null ? includePath : path + ";" + includePath);
environment.put("PATH", path == null ? buildDir : path + ";" + buildDir);
}
else {
libraryPath = includePath;
libraryPath = buildDir;
}
}

Expand All @@ -73,6 +74,7 @@ protected CompiledState compile(RunOptions runOptions, GeneratedState generatedS
try {
String tempDirPath = getTempDirPath();
File tempDirFile = new File(tempDirPath);
String projectPath = Paths.get(swiftRuntimePath, "../..").normalize().toString();

File[] ignoredFiles = tempDirFile.listFiles(NoSwiftFileFilter.Instance);
assert ignoredFiles != null;
Expand All @@ -81,26 +83,22 @@ protected CompiledState compile(RunOptions runOptions, GeneratedState generatedS
String text = getTextFromResource("org/antlr/v4/test/runtime/helpers/Package.swift.stg");
ST outputFileST = new ST(text);
outputFileST.add("excludedFiles", excludedFiles);
outputFileST.add("libraryPath", projectPath);
writeFile(tempDirPath, "Package.swift", outputFileST.render());

String[] buildProjectArgs = new String[]{
getCompilerPath(),
"build",
"-c",
"release",
"-Xswiftc",
"-I" + includePath,
"-Xlinker",
"-L" + includePath,
"-L"+libraryPath,
"-Xlinker",
"-lAntlr4",
"-Xlinker",
"-rpath",
"-Xlinker",
libraryPath
"-lAntlr4Static"
};
runCommand(buildProjectArgs, tempDirPath);
} catch (Exception e) {
}
catch (Exception e) {
exception = e;
}

Expand Down