-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
45 lines (34 loc) · 1.26 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# PowerShell Script to build the compiler
# Change directory to the script's directory (optional, depends on your setup)
# $PSScriptRoot is the directory the script is running from
cd $PSScriptRoot
# Run JJTree
jjtree src\main\mygrammar.jjt
if ($LASTEXITCODE -ne 0) {
Write-Error "JJTree failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
# Run JavaCC
javacc -OUTPUT_DIRECTORY:src\main\jjtree src\main\jjtree\mygrammar.jj
if ($LASTEXITCODE -ne 0) {
Write-Error "JavaCC failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
# Get list of all Java files
$files = Get-ChildItem -Recurse -Filter *.java | Where-Object { -not $_.PSIsContainer } | Select-Object -ExpandProperty FullName
# Join file paths into a single string
$filesAsString = $files -join ' '
# Compile the Java files
Invoke-Expression "javac $filesAsString -d ./bin"
if ($LASTEXITCODE -ne 0) {
Write-Error "Java compilation failed with exit code $LASTEXITCODE"
exit $LASTEXITCODE
}
# Build one JAR file
jar cfm bin\yalc.jar Manifest.txt -C bin\ .
cp bin\yalc.jar .
# Copy it into ./examples for demo purposes
# cp bin\yalc.jar examples\yalc.jar
# cp bin\yalc.jar examples_error\yalc.jar
# cp bin\yalc.jar test_cases_errors\yalc.jar
# dot -Tpng $graph1FilePath -o $graph2FilePath