Skip to content

Commit

Permalink
Update to work with object capabilities changes in Pony 0.49.0 (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanTAllen authored Feb 24, 2022
1 parent 35cd2e4 commit 176841c
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 26 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/nightlies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Build and upload x86-64-unknown-linux-nightly to Cloudsmith
runs-on: ubuntu-latest
container:
image: ponylang/shared-docker-ci-x86-64-unknown-linux-builder:release
image: ponylang/shared-docker-ci-x86-64-unknown-linux-builder:latest
steps:
- uses: actions/checkout@v2
- name: Build and upload
Expand All @@ -34,7 +34,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: install ponyc
run: bash .ci-scripts/macOS-install-pony-tools.bash release
run: bash .ci-scripts/macOS-install-pony-tools.bash nightly
- name: brew install dependencies
run: brew install coreutils
- name: pip install dependencies
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Build and upload
run: |
python.exe -m pip install --upgrade cloudsmith-cli
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/ponyc-x86-64-pc-windows-msvc.zip -OutFile C:\ponyc.zip;
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/nightlies/raw/versions/latest/ponyc-x86-64-pc-windows-msvc.zip -OutFile C:\ponyc.zip;
Expand-Archive -Path C:\ponyc.zip -DestinationPath C:\ponyc;
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
.\make.ps1 -Command build;
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
name: Verify PR builds most recent ponyc release on Linux
runs-on: ubuntu-latest
container:
image: ponylang/shared-docker-ci-x86-64-unknown-linux-builder:release
image: ponylang/shared-docker-ci-x86-64-unknown-linux-builder:latest
steps:
- uses: actions/checkout@v2
- name: Test with most recent ponyc release
Expand All @@ -52,7 +52,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: install ponyc
run: bash .ci-scripts/macOS-install-pony-tools.bash release
run: bash .ci-scripts/macOS-install-pony-tools.bash nightly
- name: brew install dependencies
run: brew install coreutils
- name: Test with most recent ponyc release
Expand All @@ -67,7 +67,7 @@ jobs:
- uses: actions/checkout@v2
- name: Test with most recent ponyc release
run: |
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/releases/raw/versions/latest/ponyc-x86-64-pc-windows-msvc.zip -OutFile C:\ponyc.zip;
Invoke-WebRequest https://dl.cloudsmith.io/public/ponylang/nightlies/raw/versions/latest/ponyc-x86-64-pc-windows-msvc.zip -OutFile C:\ponyc.zip;
Expand-Archive -Path C:\ponyc.zip -DestinationPath C:\ponyc;
$env:PATH = 'C:\ponyc\bin;' + $env:PATH;
.\make.ps1 -Command test 2>&1
3 changes: 3 additions & 0 deletions .release-notes/obj-cap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Update to work with change Pony 0.49.0

The object capabilities system in the Pony standard library was [reworked](https://github.com/ponylang/ponyc/pull/4031) and we've updated to match it.
8 changes: 4 additions & 4 deletions corral/bundle/project.pony
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ primitive BundleDir
Locates project bundle directories either by direct resolving of bundle
files, or searching up the directory tree until the files are found.
"""
fun find(auth: AmbientAuth, dir: String, log: Logger[String]): (FilePath | None) =>
fun find(auth: FileAuth, dir: String, log: Logger[String]): (FilePath | None) =>
var dir' = dir
while dir'.size() > 0 do
log(Info) and log.log("Looking for " + Files.bundle_filename() + " in: '" + dir' + "'")
Expand All @@ -29,7 +29,7 @@ primitive BundleDir
log(Info) and log.log(Files.bundle_filename() + " not found, looked last in: '" + dir' + "'")
None

fun resolve(auth: AmbientAuth, dir: String, log: Logger[String]): (FilePath | None) =>
fun resolve(auth: FileAuth, dir: String, log: Logger[String]): (FilePath | None) =>
log(Info) and log.log("Checking for " + Files.bundle_filename() + " in: '" + dir + "'")
try
let dir_path = FilePath(auth, dir)
Expand All @@ -46,11 +46,11 @@ class val Project
Project assists with the performing operations on bundles and deps of a
project.
"""
let auth: AmbientAuth
let auth: FileAuth
let log: Logger[String]
let dir: FilePath

new val create(auth': AmbientAuth, log': Logger[String], dir': FilePath) =>
new val create(auth': FileAuth, log': Logger[String], dir': FilePath) =>
auth = auth'
log = log'
dir = dir'
Expand Down
6 changes: 3 additions & 3 deletions corral/cmd/_test_cmd_update.pony
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ primitive _OpsRecorderTestRunner
"""
Runs an _OpsRecorder test.
"""
let auth = h.env.root
let auth = FileAuth(h.env.root)
let log = StringLogger(Error, h.env.err, SimpleLogFormatter)
let fp: FilePath = _TestData.file_path_from(h, dep_path)?
let repo_cache = _TestRepoCache(auth)
Expand Down Expand Up @@ -203,8 +203,8 @@ class val _RecordedCheckout is RepoOperation

primitive _TestData
fun file_path_from(h: TestHelper, subdir: String = ""): FilePath ? =>
FilePath(h.env.root, "corral/test/testdata").join(subdir)?
FilePath(FileAuth(h.env.root), "corral/test/testdata").join(subdir)?

primitive _TestRepoCache
fun apply(auth: AmbientAuth): FilePath =>
fun apply(auth: FileAuth): FilePath =>
FilePath(auth,"_test_cmd_update_repo_cache")
2 changes: 1 addition & 1 deletion corral/cmd/executor.pony
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ primitive Executor
bundle_dir_arg: String)
// TODO: add when we have the cli flag: repo_cache_str: String
=>
let auth = env.root
let auth = FileAuth(env.root)

// Resolve the bundle dir arg into a clean path string
let bundle_dir_str =
Expand Down
2 changes: 1 addition & 1 deletion corral/cmd/repo.pony
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use "../vcs"
primitive RepoForDep
fun apply(ctx: Context, project: Project box, dep: Dep box): Repo ? =>

let auth = ctx.env.root
let auth = FileAuth(ctx.env.root)

ctx.log(Info) and ctx.log.log("dep is_vcs:" + dep.locator.is_vcs().string() +
" is_local:" + dep.locator.is_local().string() +
Expand Down
7 changes: 4 additions & 3 deletions corral/test/util.pony
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ primitive \nodoc\ Execute

primitive \nodoc\ Data
fun apply(h: TestHelper, subdir: String = ""): FilePath ? =>
FilePath(h.env.root, "corral/test/testdata").join(subdir)?
FilePath(FileAuth(h.env.root), "corral/test/testdata").join(subdir)?


class \nodoc\ val DataClone
let _root: FilePath
let _dir: FilePath

new val create(h: TestHelper, subdirs: (Array[String] val | String | None) = None) ? =>
let auth = h.env.root
let auth = FileAuth(h.env.root)
let src_root = FilePath(auth, "corral/test/testdata")

_root = FilePath.mkdtemp(auth, "test_scratch.")?
Expand Down Expand Up @@ -90,7 +90,8 @@ primitive RelativePathToPonyc
env("PATH")?
end
for bindir in Path.split_list(path).values() do
let ponyc_path = FilePath(h.env.root, Path.join(bindir, "ponyc"))
let ponyc_path = FilePath(
FileAuth(h.env.root), Path.join(bindir, "ponyc"))
if ponyc_path.exists() then
let prefix: String val = CommonPrefix([cwd; ponyc_path.path])
while cwd.size() > prefix.size() do
Expand Down
21 changes: 13 additions & 8 deletions corral/util/action.pony
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use "backpressure"
use "cli" // EnvVars
use "files"
use "process"
Expand All @@ -6,21 +7,25 @@ class val Program
"""
A Program encapsulates an executable program and authority to execute it.
"""
let auth: AmbientAuth
let process_auth: StartProcessAuth
let backpressure_auth: ApplyReleaseBackpressureAuth
let path: FilePath

new val create(
env: Env,
name: String) ?
=>
auth = env.root
let file_auth = FileAuth(env.root)
process_auth = StartProcessAuth(env.root)
backpressure_auth = ApplyReleaseBackpressureAuth(env.root)

path = if Path.is_abs(name) then
FilePath(auth, name)
FilePath(file_auth, name)
else
let cwd = Path.cwd()
// first try to resolve the binary with the current directory as base
try
first_existing(auth, cwd, name)?
first_existing(file_auth, cwd, name)?
else
// then try with $PATH entries
(let evars, let pathkey) =
Expand All @@ -30,11 +35,11 @@ class val Program
else
(EnvVars(env.vars), "PATH")
end
first_existing(auth, evars.get_or_else(pathkey, ""), name)?
first_existing(file_auth, evars.get_or_else(pathkey, ""), name)?
end
end

fun tag first_existing(auth': AmbientAuth, binpath: String, name: String)
fun tag first_existing(auth': FileAuth, binpath: String, name: String)
: FilePath ?
=>
for bindir in Path.split_list(binpath).values() do
Expand Down Expand Up @@ -162,8 +167,8 @@ primitive Runner
argv.push(appname)
argv.append(action.args)
let pm = ProcessMonitor(
action.prog.auth,
action.prog.auth,
action.prog.process_auth,
action.prog.backpressure_auth,
consume c,
action.prog.path,
consume argv,
Expand Down

0 comments on commit 176841c

Please sign in to comment.