From 29b9761d1da1906f5b952d4f6ac168c74a446fa9 Mon Sep 17 00:00:00 2001 From: Oliver Reiche Date: Wed, 12 Apr 2023 14:08:15 +0200 Subject: test: Use pkgconfig for prebuilt bootstrap --- test/bootstrap/TARGETS | 45 +++++++++---------- test/bootstrap/test-bootstrap-pkgconfig.sh | 72 ++++++++++++++++++++++++++++++ test/bootstrap/test-bootstrap-prebuilt.sh | 69 ---------------------------- test/bootstrap/test-mixed-bootstrap.sh | 7 ++- test/bootstrap/test-symlink-bootstrap.sh | 8 ++-- 5 files changed, 102 insertions(+), 99 deletions(-) create mode 100755 test/bootstrap/test-bootstrap-pkgconfig.sh delete mode 100644 test/bootstrap/test-bootstrap-prebuilt.sh diff --git a/test/bootstrap/TARGETS b/test/bootstrap/TARGETS index a3c34307..9018ccbf 100644 --- a/test/bootstrap/TARGETS +++ b/test/bootstrap/TARGETS @@ -43,42 +43,39 @@ , "body": {"type": "env", "vars": ["TEST_ENV", "SUFFIX"]} } } -, "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"] + { "type": "install" + , "dirs": [["just_cc_deps", "LOCALBASE"], ["just_other_deps", "LOCALBASE"]] + , "tainted": ["test"] + } +, "just_cc_deps": + { "type": ["@", "rules", "CC", "install-with-deps"] + , "targets": + [ ["@", "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"] + , ["@", "cli11", "", "cli11"] + , ["@", "ssl", "", "crypto"] , ["", "libgit2"] + , ["@", "protoc", "", "protoc"] + , ["@", "protoc", "", "libprotobuf"] + , ["@", "grpc", "", "grpc++"] + , ["@", "grpc", "", "grpc_cpp_plugin"] ] - , "bins": - [ ["@", "protoc", "", "protoc"] - , ["@", "grpc", "src/compiler", "grpc_cpp_plugin"] - ] + } +, "just_other_deps": + { "type": ["test/bootstrap", "stage-deps"] , "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": +, "pkgconfig-test": { "type": ["@", "rules", "shell/test", "script"] - , "name": ["bootstrap-test-prebuilt"] - , "test": ["test-bootstrap-prebuilt.sh"] + , "name": ["bootstrap-test-pkgconfig"] + , "test": ["test-bootstrap-pkgconfig.sh"] , "deps": ["distro-bootstrap-deps", "staged-sources"] } , "mixed-test": @@ -104,7 +101,7 @@ [ "bundled-test" , "bundled-test-debug" , "bundled-test-gnu" - , "prebuilt-test" + , "pkgconfig-test" , "mixed-test" , "symlink-test" ] diff --git a/test/bootstrap/test-bootstrap-pkgconfig.sh b/test/bootstrap/test-bootstrap-pkgconfig.sh new file mode 100755 index 00000000..3087d380 --- /dev/null +++ b/test/bootstrap/test-bootstrap-pkgconfig.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +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 \ + JUST_BUILD_CONF='{"COMPILER_FAMILY":"clang", "PKG_CONFIG_ARGS":["--define-prefix"]}' \ + python3 ${WRKSRC}/bin/bootstrap.py ${WRKSRC} ${WRKDIR} 2>&1 + +# 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 diff --git a/test/bootstrap/test-bootstrap-prebuilt.sh b/test/bootstrap/test-bootstrap-prebuilt.sh deleted file mode 100644 index 4b78ede8..00000000 --- a/test/bootstrap/test-bootstrap-prebuilt.sh +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -# Copyright 2022 Huawei Cloud Computing Technology Co., Ltd. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -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 diff --git a/test/bootstrap/test-mixed-bootstrap.sh b/test/bootstrap/test-mixed-bootstrap.sh index 86d47896..61b1f5ea 100755 --- a/test/bootstrap/test-mixed-bootstrap.sh +++ b/test/bootstrap/test-mixed-bootstrap.sh @@ -48,8 +48,11 @@ cp distdir/fmt-9.1.0.zip "${DISTDIR}" # bootstrap command -env LOCALBASE=${LOCALBASE} PACKAGE=YES NON_LOCAL_DEPS='["gsl-lite", "fmt"]' \ - python3 ${WRKSRC}/bin/bootstrap.py ${WRKSRC} ${WRKDIR} ${DISTDIR} +env LOCALBASE=${LOCALBASE} \ + PACKAGE=YES \ + NON_LOCAL_DEPS='["gsl-lite", "fmt"]' \ + JUST_BUILD_CONF='{"COMPILER_FAMILY":"clang", "PKG_CONFIG_ARGS":["--define-prefix"]}' \ + python3 ${WRKSRC}/bin/bootstrap.py ${WRKSRC} ${WRKDIR} ${DISTDIR} 2>&1 # Do some sanity checks with the binary diff --git a/test/bootstrap/test-symlink-bootstrap.sh b/test/bootstrap/test-symlink-bootstrap.sh index df10c528..dc541fe4 100755 --- a/test/bootstrap/test-symlink-bootstrap.sh +++ b/test/bootstrap/test-symlink-bootstrap.sh @@ -32,8 +32,6 @@ readonly TEST_BUILD_ROOT=${TMPDIR}/.just mkdir -p ${TEST_BUILD_ROOT} readonly TEST_OUT_DIR=${TMPDIR}/work-test-out mkdir -p ${TEST_OUT_DIR} -readonly DISTDIR=${TMPDIR}/distdir -mkdir -p "${DISTDIR}" # Set up local base, adding some symbolic links @@ -50,8 +48,10 @@ ln -s ${UNRELATED_FILE} ${LOCALBASE}/lib/libfoo.so # bootstrap command -env LOCALBASE=${LOCALBASE} PACKAGE=YES \ - python3 ${WRKSRC}/bin/bootstrap.py ${WRKSRC} ${WRKDIR} ${DISTDIR} +env LOCALBASE=${LOCALBASE} \ + PACKAGE=YES \ + JUST_BUILD_CONF='{"COMPILER_FAMILY":"clang", "PKG_CONFIG_ARGS":["--define-prefix"]}' \ + python3 ${WRKSRC}/bin/bootstrap.py ${WRKSRC} ${WRKDIR} 2>&1 # Do some sanity checks with the binary -- cgit v1.2.3