Skip to content

Commit

Permalink
Merge branch 'main' into python-build-temp
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewlacy committed Jun 17, 2024
2 parents 22746e6 + 126cfe7 commit b0f9d07
Show file tree
Hide file tree
Showing 96 changed files with 558 additions and 679 deletions.
2 changes: 1 addition & 1 deletion examples/nodejs_frontend/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function staticSite(): std.Recipe<std.Directory> {
// Setting `$LD_LIBRARY_PATH` allows Node.js to find this library.
LD_LIBRARY_PATH: std.tpl`${std.toolchain()}/lib`,
})
.cast("directory");
.toDirectory();
}

// Build the static site and serve it
Expand Down
2 changes: 1 addition & 1 deletion examples/rust_backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ See [`project.bri`](./project.bri) for the Brioche build definition.
- Start the server by running `brioche run -p ./examples/rust_backend`. listens on `http://localhost:8000`
- Make a request to the server using Curl: `curl -v 'http://localhost:8000'`
- Build a container: `brioche build -p ./examples/rust_backend -e container -o container.tar`
- Run the container with Podman:
- Run the container with Podman / Docker (example with Podman shown below):
1. Load the container with `podman load -i container.tar`. Podman will print the digest of the image, like `sha256:xxxxx`
2. Run the container with `podman run --rm -p 8000:8000 'sha256:xxxx'` (using the same digest from (1))
8 changes: 4 additions & 4 deletions packages/curl/project.bri
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as std from "std";
import openssl from "openssl";

export const project = {
name: "curl",
Expand All @@ -13,8 +14,7 @@ const source = std
),
})
.unarchive("tar", "gzip")
.peel()
.cast("directory");
.peel();

export default (): std.Recipe<std.Directory> => {
const curl = std.runBash`
Expand All @@ -28,8 +28,8 @@ export default (): std.Recipe<std.Directory> => {
make install DESTDIR="$BRIOCHE_OUTPUT"
`
.workDir(source)
.dependencies(std.toolchain())
.cast("directory");
.dependencies(std.toolchain(), openssl())
.toDirectory();

return std.withRunnableLink(curl, "bin/curl");
};
7 changes: 3 additions & 4 deletions packages/go/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ export function go(): std.Recipe<std.Directory> {
),
})
.unarchive("tar", "gzip")
.peel()
.cast("directory");
.peel();

let go = std.directory({
go: goRoot,
Expand Down Expand Up @@ -89,7 +88,7 @@ export async function goInstall(
GOMODCACHE: modules,
GOBIN: std.tpl`${std.outputPath}/bin`,
})
.cast("directory");
.toDirectory();

if (options.runnable != null) {
buildResult = std.withRunnableLink(buildResult, options.runnable);
Expand Down Expand Up @@ -125,5 +124,5 @@ async function goModDownload(
.dependencies(go(), caCertificates())
.env({ GOMODCACHE: std.outputPath })
.unsafe({ networking: true })
.cast("directory");
.toDirectory();
}
5 changes: 2 additions & 3 deletions packages/jq/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ const source = std
),
})
.unarchive("tar", "gzip")
.peel(1)
.cast("directory");
.peel();

export default function (): std.Recipe<std.Directory> {
const jq = std.runBash`
Expand All @@ -27,7 +26,7 @@ export default function (): std.Recipe<std.Directory> {
.workDir(source)
.dependencies(std.toolchain())
.env(autotoolsEnv())
.cast("directory");
.toDirectory();
return std.withRunnableLink(jq, "bin/jq");
}

Expand Down
3 changes: 1 addition & 2 deletions packages/miniserve/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ const crate = std
),
})
.unarchive("tar", "gzip")
.peel()
.cast("directory");
.peel();

export default () => {
return cargoBuild({
Expand Down
5 changes: 2 additions & 3 deletions packages/nodejs/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ function nodejs(): std.Recipe<std.Directory> {
),
})
.unarchive("tar", "xz")
.peel()
.cast("directory");
.peel();

node = std.autowrap(node, {
executables: ["bin/node"],
Expand Down Expand Up @@ -72,5 +71,5 @@ export function npmInstall(
.dependencies(nodejs())
.outputScaffold(options.npmPackage)
.unsafe({ networking: true })
.cast("directory");
.toDirectory();
}
3 changes: 3 additions & 0 deletions packages/openssl/brioche.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions packages/openssl/project.bri
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import * as std from "std";

export const project = {
name: "openssl",
version: "3.3.1",
};

const source = std
.download({
url: `https://github.com/openssl/openssl/releases/download/openssl-${project.version}/openssl-${project.version}.tar.gz`,
hash: std.sha256Hash(
"777cd596284c883375a2a7a11bf5d2786fc5413255efab20c50d6ffe6d020b7e",
),
})
.unarchive("tar", "gzip")
.peel();

export default function (): std.Recipe<std.Directory> {
let openssl = std.runBash`
./config \\
--prefix=/ \\
--openssldir=/etc/ssl \\
--libdir=lib
make
make install DESTDIR="$BRIOCHE_OUTPUT"
`
.dependencies(std.toolchain())
.workDir(source)
.toDirectory();

openssl = std.withRunnableLink(openssl, "bin/openssl");
openssl = std.setEnv(openssl, {
LIBRARY_PATH: { path: "lib" },
CPATH: { path: "include" },
});

return std.withRunnableLink(openssl, "bin/openssl");
}

export function test() {
return std.runBash`
openssl version | tee "$BRIOCHE_OUTPUT"
`;
}
7 changes: 3 additions & 4 deletions packages/python/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const source = std
),
})
.unarchive("tar", "xz")
.peel()
.cast("directory");
.peel();

export default function (): std.Recipe<std.Directory> {
const toolchain = std.toolchain().insert(
Expand All @@ -35,7 +34,7 @@ export default function (): std.Recipe<std.Directory> {
./configure \\
--prefix=/ \\
--enable-optimizations \\
--enable-ipv6
--enable-ipv6
make
make install DESTDIR="$BRIOCHE_OUTPUT"
`
Expand All @@ -46,7 +45,7 @@ export default function (): std.Recipe<std.Directory> {
CPATH: std.tpl`${toolchain}/include/uuid`,
LD_LIBRARY_PATH: std.tpl`${toolchain}/lib`,
})
.cast("directory");
.toDirectory();

python = python.insert("bin/python", std.symlink({ target: "python3" }));
python = python.insert("bin/pip", std.symlink({ target: "pip3" }));
Expand Down
12 changes: 6 additions & 6 deletions packages/rust/project.bri
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function rust(): Promise<std.Recipe<std.Directory>> {
--disable-ldconfig
`
.env({ pkgTargetArchive })
.cast("directory");
.toDirectory();

result = std.merge(result, installedPkg);
}
Expand All @@ -89,7 +89,7 @@ async function rust(): Promise<std.Recipe<std.Directory>> {
find lib -type f -name '*.so' -print0 > "$BRIOCHE_OUTPUT"
`
.workDir(result)
.cast("file")
.toFile()
.read()
.then((libs) => libs.split("\0").filter((lib) => lib !== ""));
const localLibNames = localLibs
Expand Down Expand Up @@ -158,7 +158,7 @@ export function cargoBuild(options: CargoBuildOptions) {
.dependencies(rust(), caCertificates())
.outputScaffold(skeletonCrate)
.unsafe({ networking: true })
.cast("directory");
.toDirectory();

// Combine the original crate with the vendored dependencies
let crate = std.merge(vendoredSkeletonCrate, options.crate);
Expand All @@ -179,7 +179,7 @@ export function cargoBuild(options: CargoBuildOptions) {
PATH: std.tpl`${std.outputPath}/bin`,
})
.workDir(crate)
.cast("directory");
.toDirectory();

// Add a runnable link if set in the options
if (options.runnable != null) {
Expand All @@ -203,15 +203,15 @@ export function createSkeletonCrate(
`
.dependencies(rust(), cargoChef())
.workDir(crate)
.cast("file");
.toFile();
return std.runBash`
cd "$BRIOCHE_OUTPUT"
cargo chef cook --recipe-path "$recipe" --no-build
`
.dependencies(rust(), cargoChef())
.env({ recipe })
.outputScaffold(std.directory())
.cast("directory");
.toDirectory();
}

function cargoChef(): std.Recipe<std.Directory> {
Expand Down
19 changes: 9 additions & 10 deletions packages/std/core/console.bri
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
const ops = (globalThis as any).Deno.core.ops;

declare global {
const console: Console;
}

interface Console {
log: (...args: unknown[]) => void;
debug: (...args: unknown[]) => void;
info: (...args: unknown[]) => void;
warn: (...args: unknown[]) => void;
error: (...args: unknown[]) => void;
// eslint-disable-next-line
namespace console {
function log(...args: unknown[]): void;
function debug(...args: unknown[]): void;
function info(...args: unknown[]): void;
function warn(...args: unknown[]): void;
function error(...args: unknown[]): void;
}
}

const console = {
Expand All @@ -28,7 +27,7 @@ const console = {
error(...args: unknown[]) {
logLevel("error", ...args);
},
} satisfies Console;
} satisfies typeof globalThis.console;

function logLevel(level: string, ...args: unknown[]) {
ops.op_brioche_console(level, displayAll(...args).join(" "));
Expand Down
Loading

0 comments on commit b0f9d07

Please sign in to comment.