Skip to content

Commit

Permalink
Initialize project with a shell script, outside of the build script.
Browse files Browse the repository at this point in the history
(#33)
  • Loading branch information
netdpb authored Sep 16, 2022
1 parent f910bb0 commit ea7d56b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 54 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- run: |
./gradlew spotlessCheck build
- run: |
./gradlew jspecifySamplesTest -x ensureCheckerFrameworkBuilt
- run: ./initialize-project
- run: ./gradlew spotlessCheck build
- run: ./gradlew jspecifySamplesTest -x ensureCheckerFrameworkBuilt
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ looking to try it out, here are some instructions, *which might fail*
and need to be worked around as described later in this section:

```
# Build the checker:
# Download the checker, its fork of Checker Framework, and the unreleased JSpecify code and samples:
$ git clone https://github.com/jspecify/nullness-checker-for-checker-framework
$ cd nullness-checker-for-checker-framework
$ ./initialize-project
$ ./gradlew assemble
# Build it:
$ ./gradlew assemble
# Use it:
Expand Down
55 changes: 8 additions & 47 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ ext {
parentDir = file("${rootDir}/../").absolutePath
cfHome = "${parentDir}/checker-framework"
jspecifyHome = "${parentDir}/jspecify"
plumeScripts = "${rootDir}/.plume-scripts"
}

sourceCompatibility = 1.9
Expand Down Expand Up @@ -101,64 +100,26 @@ spotless {
}

task ensureCheckerFrameworkBuilt() {
description 'Clone or update the Checker Framework and then build it and all dependencies'
description 'Build the Checker Framework and all dependencies'
doLast {
if (!file(plumeScripts).exists()) {
/* Introduce an autoUpdateCF variable if we want to support that usage.
if (autoUpdateCF) {
exec {
workingDir "${rootDir}"
workingDir cfHome
executable 'git'
args = ['clone', '-q', '--depth', '1', 'https://github.com/plume-lib/plume-scripts.git', plumeScripts]
args = ['pull', '-q']
ignoreExitValue = true
}
}
def jspecifyExisted = file(jspecifyHome).exists()

if (file(cfHome).exists()) {
/* Introduce an autoUpdateCF variable if we want to support that usage.
if (autoUpdateCF) {
exec {
workingDir cfHome
executable 'git'
args = ['pull', '-q']
ignoreExitValue = true
}
} else {
println "Found existing ${cfHome}. Use -PautoUpdateCF=true if you want to git pull automatically."
}
*/
} else {
exec {
workingDir rootDir
executable "${plumeScripts}/git-clone-related"
args = ['jspecify', 'checker-framework', '-q']
}
println "Found existing ${cfHome}. Use -PautoUpdateCF=true if you want to git pull automatically."
}
*/
exec {
workingDir cfHome
executable './gradlew'
// Skip Javadoc to save time. Perform a release build so that we repackage javaparser (not that that seems to matter here, but it's consistent with how the Checker Framework would be deployed).
args = ['cloneAndBuildDependencies', '-x', 'javadoc', '-x', 'allJavadoc', '-Prelease=true']
}

// We test using some modified samples in a different branch of the jspecify repo, so we want to change to that branch.
// However, if there was a JSpecify client to begin with, don't mess with it, as the developer may be running tests in a different branch.
if (!jspecifyExisted) {
// The CF build process uses --single-branch when it clones the jspecify repo, so the resulting clone doesn't have the branch we want.
exec {
workingDir jspecifyHome
executable 'git'
args = ['config', 'remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*']
}
exec {
workingDir jspecifyHome
executable 'git'
args = ['fetch']
}
exec {
workingDir jspecifyHome
executable 'git'
args = ['checkout', '-q', 'samples-google-prototype']
}
}
}
}

Expand Down
22 changes: 22 additions & 0 deletions initialize-project
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -eu

readonly PLUME_SCRIPTS=.plume-scripts
readonly CHECKER_FRAMEWORK=../checker-framework
readonly JSPECIFY=../jspecify

if [[ ! -d "${PLUME_SCRIPTS}" ]]; then
git clone -q --depth 1 https://github.com/plume-lib/plume-scripts.git \
"${PLUME_SCRIPTS}"
fi

if [[ ! -d "${CHECKER_FRAMEWORK}" ]]; then
"${PLUME_SCRIPTS}"/git-clone-related jspecify checker-framework -q
fi

if [[ ! -d "${JSPECIFY}" ]]; then
# We test using some modified samples in a different branch of the jspecify
# repo, so we check out that branch.
"${PLUME_SCRIPTS}"/git-clone-related --upstream-branch samples-google-prototype jspecify jspecify -q
fi

0 comments on commit ea7d56b

Please sign in to comment.