Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Cargo binding lib #475

Closed
wants to merge 2 commits into from
Closed

Conversation

afinch7
Copy link

@afinch7 afinch7 commented May 31, 2019

First pass at a cargo binding based on the WIP native binding api in denoland/deno#2385
This is intended as a bootstrapping tool for other native bindings.
Example usage:

import { build } from "https://deno.land/std/cargo/mod.ts";
import { join, dirname } from "https://deno.land/std/fs/path/mod.ts";

const { dlopen, dlname } = Deno;

const manifest_path = join(dirname(import.meta.url), "Cargo.toml");
const buildResult = build({
    manifest_path,
});
// We could also search through the artifacts list here to find something more specific if we wanted. 
const dlib = dlopen(join(buildResult.output_root, dlname(buildResult.artifacts[0].output_name)));
const someOp = dlib.loadFn("some_op");

This should work on any machine that has at least a version of rustc installed.

@CLAassistant
Copy link

CLAassistant commented May 31, 2019

CLA assistant check
All committers have signed the CLA.

@afinch7 afinch7 force-pushed the cargo_binding_plugin branch 2 times, most recently from 11a9206 to dae0c0a Compare May 31, 2019 18:31
cargo/mod.ts Outdated
// TODO(afinch7) make DL_PATH_CARGO_LOAD optional once we can load libs via url
// and add default url to use here.
const dlib = dlopen(env().DL_PATH_CARGO_LOAD);
const cargoBuildOp = dlib.loadFn("cargo_build");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@afinch7
Copy link
Author

afinch7 commented May 31, 2019

This is working with tests and all instructions if you want to test:

  1. Build deno cli from my native bindings branch. Last tested with this commit afinch7/deno@34bc878 you will need to update sub modules recursively (still waiting on the new version of dlopen-derive to get published).
  2. You need to make sure that the dependency config for deno in the Cargo.toml files points to //core in the clone of my branch used to build deno.
  3. cargo build --release -p deno_cargo_plugin
  4. DL_PATH_CARGO_BINDING=$PWD/target/release/libdeno_cargo_plugin.so <PATH_TO_DENO_BINARY> run --allow-all --config=tsconfig.test.json cargo/run_test.ts

If everything is setup correctly it should automatically build the test binding and then run tests on it.

@afinch7 afinch7 force-pushed the cargo_binding_plugin branch 3 times, most recently from a262f70 to c627df0 Compare June 3, 2019 19:50
@afinch7 afinch7 force-pushed the cargo_binding_plugin branch from 466297c to 908a885 Compare June 29, 2019 22:08
inverted-capital pushed a commit to dreamcatcher-tech/napps that referenced this pull request Oct 24, 2024
Please pay attention to the migration script, as it's responsible for
migrating all items and votes. I've also changed all instances of
`monotonicUlid()` to `ulid()` at there appears to be a bug that prevents
`monotonicUlid()` from respecting the `seedTime` parameter.

The migration can be simulated as follows:
1. Switch to **main** branch.
2. Run `deno run db:reset`.
3. Run `deno run db:seed`.
4. Run `deno task start` and navigate to `http://localhost:8000`.
6. Vote some items.
7. Note the voted items and the order of the items feed.
8. Switch to **ulid-items** branch.
9. Run `deno run db:migrate`.
10. Run `deno task start` and navigate to `http://localhost:8000`.
11. Check that the voted items and the order of the items feed are
identical to those previously noted.

Closes denoland#475
Closes denoland#476
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants