diff --git a/.dagger/.gitattributes b/.dagger/.gitattributes new file mode 100644 index 0000000..8274184 --- /dev/null +++ b/.dagger/.gitattributes @@ -0,0 +1 @@ +/sdk/** linguist-generated diff --git a/.dagger/.gitignore b/.dagger/.gitignore new file mode 100644 index 0000000..040187c --- /dev/null +++ b/.dagger/.gitignore @@ -0,0 +1,4 @@ +/sdk +/**/node_modules/** +/**/.pnpm-store/** +/.env diff --git a/.dagger/package-lock.json b/.dagger/package-lock.json new file mode 100644 index 0000000..e19b623 --- /dev/null +++ b/.dagger/package-lock.json @@ -0,0 +1,25 @@ +{ + "name": ".dagger", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "typescript": "5.9.3" + } + }, + "node_modules/typescript": { + "version": "5.9.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", + "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + } + } +} diff --git a/.dagger/package.json b/.dagger/package.json new file mode 100644 index 0000000..fe4de26 --- /dev/null +++ b/.dagger/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +,"dependencies":{"typescript":"5.9.3"}} \ No newline at end of file diff --git a/.dagger/src/index.ts b/.dagger/src/index.ts new file mode 100644 index 0000000..e5c4387 --- /dev/null +++ b/.dagger/src/index.ts @@ -0,0 +1,68 @@ +import { + dag, + Container, + Directory, + File, + object, + func, + argument, +} from "@dagger.io/dagger"; + +const RUST_IMAGE = "rust:1.85"; +const WORKDIR = "/workspace"; + +@object() +export class LineAndSurface { + private baseRust(source: Directory): Container { + return dag + .container() + .from(RUST_IMAGE) + .withEnvVariable("CARGO_HOME", "/root/.cargo") + .withMountedCache("/root/.cargo", dag.cacheVolume("cargo-cache")) + .withMountedCache( + `${WORKDIR}/target`, + dag.cacheVolume("cargo-target"), + ) + .withWorkdir(WORKDIR) + .withDirectory(WORKDIR, source) + .withExec(["cargo", "fetch", "--locked"]); + } + + /** + * Build the native desktop binary (release). + */ + @func() + async nativeBuild( + @argument({ + defaultPath: "/", + ignore: [".git/**", ".dagger/**", "target/**", "node_modules/**"], + }) + source: Directory, + ): Promise { + const ctr = this.baseRust(source) + .withExec(["cargo", "build", "--release"]) + .withExec(["mkdir", "-p", "/out"]) + .withExec(["cp", "-v", `${WORKDIR}/target/release/las`, "/out/las"]); + + return ctr.file("/out/las"); + } + + /** + * Build the web (wasm) bundle using Trunk. + */ + @func() + async webBuild( + @argument({ + defaultPath: "/", + ignore: [".git/**", ".dagger/**", "target/**", "node_modules/**"], + }) + source: Directory, + ): Promise { + const ctr = this.baseRust(source) + .withExec(["rustup", "target", "add", "wasm32-unknown-unknown"]) + .withExec(["cargo", "install", "trunk"]) + .withExec(["trunk", "build", "--release", "--dist", "/out"]); + + return ctr.directory("/out"); + } +} diff --git a/.dagger/tsconfig.json b/.dagger/tsconfig.json new file mode 100644 index 0000000..4ec0c2d --- /dev/null +++ b/.dagger/tsconfig.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "target": "ES2022", + "moduleResolution": "Node", + "experimentalDecorators": true, + "strict": true, + "skipLibCheck": true, + "paths": { + "@dagger.io/dagger": ["./sdk/index.ts"], + "@dagger.io/dagger/telemetry": ["./sdk/telemetry.ts"] + } + } +} diff --git a/.dagger/yarn.lock b/.dagger/yarn.lock new file mode 100644 index 0000000..aec1754 --- /dev/null +++ b/.dagger/yarn.lock @@ -0,0 +1,8 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +typescript@5.9.3: + version "5.9.3" + resolved "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz" + integrity sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw== diff --git a/dagger.json b/dagger.json new file mode 100644 index 0000000..be9c05b --- /dev/null +++ b/dagger.json @@ -0,0 +1,8 @@ +{ + "name": "line-and-surface", + "engineVersion": "v0.19.10", + "sdk": { + "source": "typescript" + }, + "source": ".dagger" +}