summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--etc/repos.json1
-rw-r--r--test/bootstrap/RULES208
-rw-r--r--test/bootstrap/TARGETS44
-rw-r--r--test/bootstrap/test-bootstrap-prebuilt.sh55
4 files changed, 307 insertions, 1 deletions
diff --git a/etc/repos.json b/etc/repos.json
index 28c84200..8623d43d 100644
--- a/etc/repos.json
+++ b/etc/repos.json
@@ -14,6 +14,7 @@
, "bazel_remote_apis": "bazel_remote_apis"
, "libgit2": "com_github_libgit2_libgit2"
, "catch2": "catch2"
+ , "protoc": "protobuf"
}
, "bootstrap": {"link": ["-lpthread"]}
, "bootstrap_local": {"link": ["-lpthread"]}
diff --git a/test/bootstrap/RULES b/test/bootstrap/RULES
new file mode 100644
index 00000000..fb9fca0f
--- /dev/null
+++ b/test/bootstrap/RULES
@@ -0,0 +1,208 @@
+{ "stage-deps":
+ { "doc":
+ [ "Set up depending libraries in a way they could occur in a distribution"
+ , ""
+ , "Runfiles and \"compile-deps\" of \"libs\" are staged to \"include\","
+ , "artifacts and \"link-deps\" to \"lib\", in a flat way."
+ , "Articats of \"bins\" are staged to \"bin\"."
+ , "The source files underlying \"protos\" are staged to \"proto\"."
+ , "The artifacts of \"deps\" are directly added to the stage."
+ , "This is only for testing bootstrapping against preinstalled dependencies."
+ ]
+ , "tainted": ["test"]
+ , "target_fields": ["libs", "bins", "protos", "deps"]
+ , "string_fields": ["prefix"]
+ , "anonymous":
+ { "proto-srcs":
+ { "target": "protos"
+ , "provider": "proto"
+ , "rule_map":
+ {"library": "stage-proto", "service library": "stage-proto"}
+ }
+ }
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "prefix"
+ , { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "FIELD", "name": "prefix"}
+ }
+ ]
+ , [ "runfiles"
+ , { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "foreach"
+ , "var": "dep"
+ , "range": {"type": "FIELD", "name": "libs"}
+ , "body":
+ { "type": "DEP_RUNFILES"
+ , "dep": {"type": "var", "name": "dep"}
+ }
+ }
+ , { "type": "foreach"
+ , "var": "dep"
+ , "range": {"type": "FIELD", "name": "libs"}
+ , "body":
+ { "type": "DEP_PROVIDES"
+ , "dep": {"type": "var", "name": "dep"}
+ , "provider": "compile-deps"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ ]
+ }
+ }
+ ]
+ , [ "artifacts"
+ , { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "++"
+ , "$1":
+ [ { "type": "foreach"
+ , "var": "dep"
+ , "range": {"type": "FIELD", "name": "libs"}
+ , "body":
+ { "type": "DEP_ARTIFACTS"
+ , "dep": {"type": "var", "name": "dep"}
+ }
+ }
+ , { "type": "foreach"
+ , "var": "dep"
+ , "range": {"type": "FIELD", "name": "libs"}
+ , "body":
+ { "type": "DEP_PROVIDES"
+ , "dep": {"type": "var", "name": "dep"}
+ , "provider": "link-deps"
+ , "default": {"type": "empty_map"}
+ }
+ }
+ ]
+ }
+ }
+ ]
+ , [ "bins"
+ , { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "dep"
+ , "range": {"type": "FIELD", "name": "bins"}
+ , "body":
+ {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "dep"}}
+ }
+ }
+ ]
+ , [ "protos"
+ , { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "dep"
+ , "range": {"type": "FIELD", "name": "proto-srcs"}
+ , "body":
+ {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "dep"}}
+ }
+ }
+ ]
+ , [ "deps"
+ , { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "dep"
+ , "range": {"type": "FIELD", "name": "deps"}
+ , "body":
+ {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "dep"}}
+ }
+ }
+ ]
+ , [ "stage"
+ , { "type": "map_union"
+ , "$1":
+ [ { "type": "to_subdir"
+ , "subdir": "include"
+ , "$1": {"type": "var", "name": "runfiles"}
+ }
+ , { "type": "to_subdir"
+ , "subdir": "lib"
+ , "flat": true
+ , "$1": {"type": "var", "name": "artifacts"}
+ }
+ , { "type": "to_subdir"
+ , "subdir": "bin"
+ , "$1": {"type": "var", "name": "bins"}
+ }
+ , { "type": "to_subdir"
+ , "subdir": "proto"
+ , "$1": {"type": "var", "name": "protos"}
+ }
+ , {"type": "var", "name": "deps"}
+ ]
+ }
+ ]
+ , [ "stage"
+ , { "type": "to_subdir"
+ , "subdir": {"type": "var", "name": "prefix"}
+ , "$1": {"type": "var", "name": "stage"}
+ }
+ ]
+ ]
+ , "body":
+ { "type": "RESULT"
+ , "runfiles": {"type": "var", "name": "stage"}
+ , "artifacts": {"type": "var", "name": "stage"}
+ }
+ }
+ }
+, "stage-proto":
+ { "string_fields": ["name", "stage"]
+ , "target_fields": ["srcs", "deps"]
+ , "expression":
+ { "type": "let*"
+ , "bindings":
+ [ [ "srcs"
+ , { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "src"
+ , "range": {"type": "FIELD", "name": "srcs"}
+ , "body":
+ {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "src"}}
+ }
+ }
+ ]
+ , [ "srcs"
+ , { "type": "to_subdir"
+ , "subdir":
+ { "type": "join"
+ , "separator": "/"
+ , "$1": {"type": "FIELD", "name": "stage"}
+ }
+ , "$1": {"type": "var", "name": "srcs"}
+ }
+ ]
+ , [ "transitive srcs"
+ , { "type": "disjoint_map_union"
+ , "$1":
+ { "type": "foreach"
+ , "var": "src"
+ , "range": {"type": "FIELD", "name": "deps"}
+ , "body":
+ {"type": "DEP_ARTIFACTS", "dep": {"type": "var", "name": "src"}}
+ }
+ }
+ ]
+ , [ "all srcs"
+ , { "type": "disjoint_map_union"
+ , "$1":
+ [ {"type": "var", "name": "srcs"}
+ , {"type": "var", "name": "transitive srcs"}
+ ]
+ }
+ ]
+ ]
+ , "body":
+ {"type": "RESULT", "artifacts": {"type": "var", "name": "all srcs"}}
+ }
+ }
+}
diff --git a/test/bootstrap/TARGETS b/test/bootstrap/TARGETS
index 3873cbce..258b006c 100644
--- a/test/bootstrap/TARGETS
+++ b/test/bootstrap/TARGETS
@@ -4,5 +4,47 @@
, "test": ["test-bootstrap.sh"]
, "deps": [["", "bootstrap-src"], ["@", "just-distfiles", "", "distdir"]]
}
-, "TESTS": {"type": "install", "tainted": ["test"], "deps": ["bundled-test"]}
+, "well_known_protos":
+ { "type": ["@", "rules", "data", "staged"]
+ , "srcs": [["@", "protoc", "", "well_known_protos"]]
+ , "stage": ["proto"]
+ }
+, "distro-bootstrap-deps":
+ { "type": "stage-deps"
+ , "prefix": ["LOCALBASE"]
+ , "libs":
+ [ ["@", "cli11", "", "cli11"]
+ , ["@", "json", "", "json"]
+ , ["@", "fmt", "", "fmt"]
+ , ["@", "ssl", "", "ssl"]
+ , ["@", "grpc", "", "grpc++"]
+ , ["@", "grpc", "", "grpc++_codegen_proto"]
+ , ["@", "bazel_remote_apis", "", "remote_execution_proto"]
+ , ["@", "gsl-lite", "", "gsl-lite"]
+ , ["@", "protoc", "", "C++ runtime"]
+ , ["", "libgit2"]
+ ]
+ , "bins":
+ [ ["@", "protoc", "", "protoc"]
+ , ["@", "grpc", "src/compiler", "grpc_cpp_plugin"]
+ ]
+ , "protos":
+ [ ["@", "bazel_remote_apis", "", "remote_execution_proto"]
+ , ["@", "googleapis", "", "google_bytestream_proto"]
+ ]
+ , "deps": ["well_known_protos"]
+ }
+, "staged-sources":
+ {"type": "install", "dirs": [[["", "bootstrap-src"], "srcs/just"]]}
+, "prebuilt-test":
+ { "type": ["@", "rules", "shell/test", "script"]
+ , "name": ["bootstrap-test-prebuilt"]
+ , "test": ["test-bootstrap-prebuilt.sh"]
+ , "deps": ["distro-bootstrap-deps", "staged-sources"]
+ }
+, "TESTS":
+ { "type": "install"
+ , "tainted": ["test"]
+ , "deps": ["bundled-test", "prebuilt-test"]
+ }
}
diff --git a/test/bootstrap/test-bootstrap-prebuilt.sh b/test/bootstrap/test-bootstrap-prebuilt.sh
new file mode 100644
index 00000000..6585f5d7
--- /dev/null
+++ b/test/bootstrap/test-bootstrap-prebuilt.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+set -eu
+
+# Set paths
+
+export PATH=/bin:/usr/bin:$PATH
+
+readonly LOCALBASE=`pwd`/LOCALBASE
+readonly WRKSRC=`pwd`/srcs/just
+readonly WRKDIR=${TMPDIR}/work-just-bootstrap
+mkdir -p ${WRKDIR}
+readonly TESTDIR=${TMPDIR}/work-test
+mkdir -p ${TESTDIR}
+readonly TEST_BUILD_ROOT=${TMPDIR}/.just
+mkdir -p ${TEST_BUILD_ROOT}
+readonly TEST_OUT_DIR=${TMPDIR}/work-test-out
+mkdir -p ${TEST_OUT_DIR}
+
+# bootstrap command
+
+env LOCALBASE=${LOCALBASE} PACKAGE=YES python3 ${WRKSRC}/bin/bootstrap.py ${WRKSRC} ${WRKDIR}
+
+# Do some sanity checks with the binary
+
+JUST=${WRKDIR}/out/bin/just
+echo Bootstrap finished. Obtained ${JUST}
+
+echo
+${JUST} -h
+echo
+${JUST} version
+echo
+touch ${TESTDIR}/ROOT
+cat > ${TESTDIR}/TARGETS <<'EOF'
+{ "hello world":
+ { "type": "generic"
+ , "cmds": ["echo Hello World > out.txt"]
+ , "outs": ["out.txt"]
+ }
+, "":
+ { "type": "generic"
+ , "cmds": ["cat out.txt | tr a-z A-Z > final.txt"]
+ , "outs": ["final.txt"]
+ , "deps": ["hello world"]
+ }
+}
+EOF
+
+echo ${JUST} install -o ${TEST_OUT_DIR} --workspace-root ${TESTDIR} --local-build-root ${TEST_BUILD_ROOT} '' ''
+${JUST} install -o ${TEST_OUT_DIR} --workspace-root ${TESTDIR} --local-build-root ${TEST_BUILD_ROOT} '' ''
+
+grep HELLO ${TEST_OUT_DIR}/final.txt
+
+echo OK