Skip to content

Commit

Permalink
Merge pull request #524 from lf-lang/lfc-rebuild
Browse files Browse the repository at this point in the history
fix lfc rebuild
  • Loading branch information
lhstrh authored Sep 21, 2021
2 parents 9e635d8 + 603713d commit cd5c1a4
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/scripts/package_lfc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ cd $GITHUB_WORKSPACE

outname="lfc_nightly_$(date '+%Y%m%d-%H%M%S')"

# build lfc compiler
./gradlew generateStandaloneCompiler
# build lf compiler
./gradlew buildLfc

# assemble the files in a separate directory
mkdir -p $outname/bin
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ jobs:
run: pip3 install -r benchmark/runner/requirements.txt
- name: Build lfc;
run: |
./gradlew generateStandaloneCompiler
./gradlew buildLfc
- name: "Set LF_PATH environmental variable"
run: |
echo "LF_PATH=$GITHUB_WORKSPACE" >> $GITHUB_ENV
Expand Down
2 changes: 1 addition & 1 deletion bin/build-lfc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fi

if [ ! -f "${jarpath}" ] || ! "${FIND}" "${lfbase}src" -path "${lfbase}src/test" -prune -o -type f -newer "${jarpath}" -exec false {} +; then # Check if jar is missing or out-of-date relative to source files
1>&2 echo "Jar file is missing or out-of-date; running Gradle..."
"${base}gradlew" ${flags} -p "${base}" generateStandaloneCompiler
"${base}gradlew" ${flags} -p "${base}" buildLfc
touch -c -- "${jarpath}" # Ensure the file timestamp is up-to-date even if the file didn't need to be updated
else
echo "Already up-to-date."
Expand Down
2 changes: 1 addition & 1 deletion bin/lfc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ popd () {
# Build first if no jar exists.
if [[ ! -f "$jarpath" ]]; then
pushd "$base"
./gradlew generateStandaloneCompiler
./gradlew buildLfc
popd
fi

Expand Down
4 changes: 2 additions & 2 deletions bin/lfc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $jarpath="$lfbase\build\libs\org.lflang.lfc-0.1.0-SNAPSHOT-all.jar"
if (-not (Test-Path $jarpath -PathType leaf)) {
$old_pwd = $pwd
cd $base
./gradlew generateStandaloneCompiler
./gradlew buildLfc
cd $old_pwd
}

Expand All @@ -34,4 +34,4 @@ if ([version]$java_version -lt [version]"11.0") {
}

# invoke lfc
& $java_cmd -jar $jarpath $args
& $java_cmd -jar $jarpath $args
6 changes: 3 additions & 3 deletions org.lflang.lfc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dependencies {
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'

task generateStandaloneCompiler() {
task buildLfc() {
apply plugin: 'application'
apply plugin: 'com.github.johnrengelman.shadow'
mainClassName = 'org.lflang.lfc.Main'
Expand All @@ -25,7 +25,7 @@ task generateStandaloneCompiler() {
}
}

generateStandaloneCompiler.finalizedBy shadowJar
buildLfc.finalizedBy shadowJar

task runLfc(type: JavaExec) {
// Note: when you use --args, you need to escape cli flags which start with --
Expand All @@ -35,4 +35,4 @@ task runLfc(type: JavaExec) {
group = "application"
classpath = sourceSets.main.runtimeClasspath
mainClass = 'org.lflang.lfc.Main'
}
}
10 changes: 5 additions & 5 deletions org.lflang.lfc/src/org/lflang/lfc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class Main {
* The location of the class file of this class inside of the jar.
*/
private static String MAIN_PATH_IN_JAR = String.join("/",
new String[] {"!", "org", "lflang", "generator", "Main.class"});
new String[] {"!", "org", "lflang", "lfc", "Main.class"});


/**
Expand Down Expand Up @@ -240,8 +240,8 @@ public static void main(final String[] args) {
String jarUrl = mainClassUrl.replace("jar:", "").replace(MAIN_PATH_IN_JAR, "");

main.jarPath = Paths.get(new URL(jarUrl).toURI());
main.srcPath = main.jarPath.getParent().resolve(Paths.get("..", "..", "src")).normalize();
main.rootPath = main.jarPath.getParent().resolve(Paths.get("..", "..", "..")).normalize();
main.srcPath = main.jarPath.getParent().getParent().getParent().resolve("src").normalize();
main.rootPath = main.jarPath.getParent().getParent().getParent().getParent().normalize();
} catch (MalformedURLException | URISyntaxException e) {
reporter.printFatalErrorAndExit("An unexpected error occurred:", e);
}
Expand Down Expand Up @@ -347,7 +347,7 @@ private void rebuildOrExit() {
} else {
cmdList.add("./gradlew");
}
cmdList.add("generateStandaloneCompiler");
cmdList.add("buildLfc");
if (!this.mustUpdate()) {
cmdList.add("--offline");
}
Expand Down Expand Up @@ -377,7 +377,7 @@ private void rebuildOrExit() {
* @return
*/
private boolean rebuildAndFork() {
// jar:file:<root>org.lflang.linguafranca/build/libs/org.lflang.linguafranca-0.1.0-SNAPSHOT-all.jar!/org/icyphy/generator/Main.class
// jar:file:<root>org.lflang.lfc/build/libs/org.lflang.lfc-<semver>-SNAPSHOT-all.jar!/org/lflang/lfc/Main.class
if (needsUpdate()) {
// Only rebuild if the jar is out-of-date.
reporter.printInfo("Jar file is missing or out-of-date; running Gradle.");
Expand Down

0 comments on commit cd5c1a4

Please sign in to comment.