Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
Zemnmez committed May 24, 2022
1 parent 343bfce commit c6f07a1
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
13 changes: 8 additions & 5 deletions cc/inkscape/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ alias(

# Required to bypass FUSE restrictions on bazel.
sh_binary(
name = "bin",
srcs = [ "run.sh" ],
data = [ ":app_image" ],
env = { "APP_IMAGE": "$(location :app_image)" },
deps = ["@bazel_tools//tools/bash/runfiles"],
name = "bin",
srcs = ["run.sh"],
data = [":app_image"],
env = {"APP_IMAGE": "$(location :app_image)"},
visibility = [
"//ts/cmd/svgshot:__subpackages__",
],
deps = ["@bazel_tools//tools/bash/runfiles"],
)
4 changes: 3 additions & 1 deletion cc/inkscape/run.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# --- begin runfiles.bash initialization v2 ---
# Copy-pasted from the Bazel Bash runfiles library v2.
set -uo pipefail; f=bazel_tools/tools/bash/runfiles/runfiles.bash
Expand All @@ -10,4 +12,4 @@ source "$(grep -sm1 "^$f " "$0.exe.runfiles_manifest" | cut -f2- -d' ')" 2>/dev/
# --- end runfiles.bash initialization v2 ---

# bypasses FUSE issues on bazel https://github.com/AppImage/AppImageKit/pull/842
$(rlocation $APP_IMAGE) --appimage-extract-and-run $@
$(rlocation inkscape_linux/file/bin) --appimage-extract-and-run $@
19 changes: 8 additions & 11 deletions ts/cmd/svgshot/BUILD
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
load("//:rules.bzl", "nodejs_binary", "ts_project", "jest_test")
load("//:rules.bzl", "jest_test", "nodejs_binary", "ts_project")

ts_project(
name = "project",
srcs = [
"index.ts",
"lib.ts",
"svgshot_test.ts"
"svgshot_test.ts",
],
deps = [
"@npm//@bazel/runfiles",
"@npm//@types/jest",
"@npm//@types/node",
"@npm//@types/svgo",
"@npm//@types/tmp",
"@npm//@types/jest",
"@npm//commander",
"@npm//puppeteer",
"@npm//svgo",
"@npm//tmp",
"@npm//@bazel/runfiles"
],
)

Expand All @@ -27,20 +27,17 @@ nodejs_binary(
"$(location //cc/inkscape:bin)",
],
data = [
"//cc/inkscape:bin",
":project_ts",
"//cc/inkscape:bin",
],
entry_point = "index.ts",
)

jest_test(
name = "tests",
srcs = [ "svgshot_test.js" ],
project_deps = [ ":project" ],
srcs = ["svgshot_test.js"],
data = [
"//cc/inkscape:bin",
],
env = {
"INKSCAPE_BIN": "$(rootpath //cc/inkscape:bin)",
},
)
project_deps = [":project"],
)
4 changes: 3 additions & 1 deletion ts/cmd/svgshot/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ const main = async (argv: string[] = process.argv) => {
});

if (out !== undefined && args.length > 1) {
throw new Error(`Out file specified and more than one URL (${args}) to load.`);
throw new Error(
`Out file specified and more than one URL (${args}) to load.`
);
}

const captures = map(args, async (url, i) => {
Expand Down
23 changes: 12 additions & 11 deletions ts/cmd/svgshot/svgshot_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import main from './lib';
import tmp from 'tmp';
import fs from 'fs/promises';
import { runfiles } from '@bazel/runfiles';
import s from 'child_process';

describe('svgshot', () => {
it('should render a test URL', async () => {
Expand All @@ -13,18 +12,20 @@ describe('svgshot', () => {
})
);

const inkscape = runfiles.resolveWorkspaceRelative(process.env["INKSCAPE_BIN"]!);
const inkscape =
runfiles.resolveWorkspaceRelative('cc/inkscape/run.sh');

// something weird happens here :(
// something weird happens here :(
await main([
"fake123",
"fake1234",
"--inkscapeBin", inkscape,
'data:text/plain,Hello, world!', '--out', target
]);
'fake123',
'fake1234',
'--inkscapeBin',
inkscape,
'data:text/plain,Hello, world!',
'--out',
target,
]);



expect(await fs.readFile(target).toString()).toEqual('');
expect((await fs.readFile(target)).toString()).toEqual(' this should fail ');
});
});

0 comments on commit c6f07a1

Please sign in to comment.