Skip to content

Commit

Permalink
tests passing locally after installing socat
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeagle committed Sep 4, 2022
1 parent a80ec0f commit c700247
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/directory/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ source "${RUNFILES_DIR:-/dev/null}/$f" 2>/dev/null || \

set -o errexit
readonly in_folder=$(rlocation $TEST_WORKSPACE/$(dirname $TEST_BINARY)/minify)

if ! [[ -e $in_folder/directory/split_app/file1.js ]]; then
echo >&2 "Missing expected output file in directory"
readonly expected="$in_folder/bazel-out/k8-fastbuild/bin/examples/directory/split_app/file1.js"
if ! [[ -e "$expected" ]]; then
echo >&2 -e "Missing expected output file\n$expected in directory:"
ls -R $in_folder
exit 1
fi
7 changes: 7 additions & 0 deletions external/socat.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
cc_library(
name = "lib",
srcs = glob([
"**/*.c",
"**/*.h",
]),
)
8 changes: 8 additions & 0 deletions swc/dependencies.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def http_archive(name, **kwargs):
# ours took precedence. Such breakages are challenging for users, so any
# changes in this function should be marked as BREAKING in the commit message
# and released only in semver majors.
# buildifier: disable=function-docstring
def rules_swc_dependencies():
http_archive(
name = "bazel_skylib",
Expand Down Expand Up @@ -44,3 +45,10 @@ def rules_swc_dependencies():
sha256 = "5aef09ed3279aa01d5c928e3beb248f9ad32dde6aafe6373a8c994c3ce643064",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.5.3/rules_nodejs-core-5.5.3.tar.gz"],
)

http_archive(
name = "socat",
build_file = "socat.BUILD",
sha256 = "d697245144731423ddbbceacabbd29447089ea223e9a439b28f9ff90d0dd216e",
urls = ["http://www.dest-unreach.org/socat/download/socat-1.7.4.3.tar.gz"],
)
20 changes: 18 additions & 2 deletions swc/private/swc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ def _impl(ctx):
output_sources = [output_dir]

args.add_all([
ctx.files.srcs[0].short_path,
"--out-dir",
output_dir.path,
# There is no longer such an option - the rust CLI doesn't go looking for it though
Expand All @@ -123,7 +124,22 @@ def _impl(ctx):
inputs = ctx.files.srcs + ctx.toolchains["@aspect_rules_swc//swc:toolchain_type"].swcinfo.tool_files,
arguments = [args],
outputs = output_sources,
command = binary + " $@ < " + ctx.files.srcs[0].path,

# command = "pwd > {}/help".format(output_dir.path), # /shared/cache/bazel/user_base/09a27d1eeea3b44d1580773090924b4d/sandbox/linux-sandbox/90/execroot/aspect_rules_swc
# command = "socat - SYSTEM:\"pwd > {}/help\",pty".format(output_dir.path),

#command = "socat - SYSTEM:\"pwd; ls --color\",pty,setsid,ctty > {}/help".format(output_dir.path),
# command = "(pwd; ls) > {}/help".format(output_dir.path),
command = "socat - SYSTEM:\"{} compile {} --out-dir {}\",pty".format(binary, ctx.files.srcs[0].path, output_dir.path),
#command = "python -c 'import os\n_, slave = os.openpty()\nsubprocess.run(\"{} compile {} --out-dir {}\", check=True, shell=True, stdin=slave, stdout=subprocess.PIPE)'".format(binary, ctx.files.srcs[0].path, output_dir.path),
#command = "python -c 'import os\n_, slave = os.openpty()'".format(binary, ctx.files.srcs[0].path, output_dir.path),

# /bin/bash -c 'socat - EXEC:"external/default_swc_linux-x64-gnu/package/swc --help",pty,setsid,ctty 2>&1 >bazel-out/k8-fastbuild/bin/examples/directory/minify/help' '' compile examples/directory/split_app --out-dir bazel-out/k8-fastbuild/bin/examples/directory/minify
# command = "socat - EXEC:\"{0} --help\",pty,setsid,ctty 2>&1 >{2}/help".format(binary, ctx.files.srcs[0].short_path, output_dir.path),

#command = binary + " $@",
#use_default_shell_env = True,
mnemonic = "SWCTranspile",
progress_message = "Transpiling with swc %s" % ctx.label,
)
else:
Expand Down Expand Up @@ -164,7 +180,7 @@ def _impl(ctx):

src_args.add_all([
# src.path,
"--out-file",
" --out-file",
js_out.path,
])

Expand Down

0 comments on commit c700247

Please sign in to comment.