diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2021-10-20 13:43:58 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2021-10-20 13:43:58 +0200 |
commit | 1bbd01a9837c5a4297e53701055a309593945fa1 (patch) | |
tree | ee2724ba79fafbfd2b64928c267e90d8097964ce /intro2-tour | |
parent | b19d997a16b93f49d5bde0938f7e53949a0ee5f1 (diff) |
Update intro scripts
Diffstat (limited to 'intro2-tour')
-rwxr-xr-x | intro2-tour | 133 |
1 files changed, 120 insertions, 13 deletions
diff --git a/intro2-tour b/intro2-tour index 6f8c2a9..660ffc8 100755 --- a/intro2-tour +++ b/intro2-tour @@ -23,22 +23,35 @@ msvc=cl-15 repo=https://stage.build2.org/1/ trust="EC:50:13:E2:3D:F7:92:B4:50:0B:BF:2A:1F:7D:31:04:C6:57:6F:BC:BE:04:2E:E0:58:14:FA:66:66:21:1F:14" +# Keep in sync with *-tldr. +# function show () # <cmd> ... { if [ $show = "y" ]; then echo echo "+ $*" - "${@}" - else - "${@}" fi + + local p=("$1") + + if [ "$1" = b -o "$1" = bpkg -o "$1" = bdep ]; then + p+=(--no-progress) + fi + + if [ "$1" = tree ]; then + p+=(-n) # No color. + fi + + shift + + "${p[@]}" "${@}" } cd "$tmp" function clean () { - rm -rf hello hello-gcc hello-clang hello-vc-* hello-mingw + rm -rf hello hello-host hello-build2 hello-base hello-gcc hello-gcc-1 hello-clang hello-vc-* hello-mingw } ## if false; then @@ -74,19 +87,19 @@ show b ../hello-clang/hello/ show b test: ../hello-clang/hello/ show ../hello-clang/hello/hello/hello World -b clean: ../hello-clang/hello/ +b --no-progress clean: ../hello-clang/hello/ show bdep test @clang show bdep test @gcc @clang show bdep init -C ../hello-mingw @mingw cc config.cxx=x86_64-w64-mingw32-g++ show bdep update @mingw show bdep test @mingw -show ../hello-mingw/hello/hello/hello.exe Windows +show ../hello-mingw/hello/hello/hello.exe Windows | cat # Strip term junk. show git add . show git commit -m "Initial implementation" show git remote add origin git@github.com:boris-kolpackov/hello.git -show git push origin master -u --force +show git push --no-progress origin master -u --force show bdep ci --simulate success show bdep deinit @gcc @clang @@ -221,6 +234,102 @@ show bdep sync ?sys:libsqlite3 cd .. +# Build-time Dependencies. +# +clean +show bdep new -t exe -l c++ hello +cd hello +show bdep init -C @gcc cc config.cxx=$gcc +show bdep init -C @clang cc config.cxx=$clang + +cat <<EOF >>repositories.manifest +: +role: prerequisite +location: https://pkg.cppget.org/1/alpha +trust: 70:64:FE:E4:E0:F3:60:F1:B4:51:E1:FA:12:5C:E0:B3:DB:DF:96:33:39:B9:2E:E5:C2:68:63:4C:A6:47:39:43 +EOF +echo 'depends: * xxd >= 8.2.0' >>manifest +cat <<EOF >hello/buildfile +import! [metadata] xxd = xxd%exe{xxd} + +exe{hello}: {hxx ixx txx cxx}{** -names} cxx{names} $libs testscript + +cxx{names}: file{names.txt} \$xxd +{{ + i = \$path(\$<[0]) + env --cwd \$directory(\$i) -- \$xxd -i \$leaf(\$i) >\$path(\$>) +}} +EOF +cat <<EOF >hello/hello.cxx +#include <iostream> +#include <string> + +extern unsigned char names_txt[]; +extern unsigned int names_txt_len; + +int main (int argc, char* argv[]) +{ + using namespace std; + + if (argc < 2) + { + cerr << "error: missing name" << endl; + return 1; + } + + cout << string (reinterpret_cast<const char*> (names_txt), names_txt_len) << ", " << argv[1] << '!' << endl; +} +EOF +echo -n "Hello" >hello/names.txt + +show bdep config list +#show bdep sync --create-host-config # Needed if not terminal. +show b +b --no-progress test +show bdep config list +show bdep update @clang + +echo 'depends: * libbuild2-hello' >>manifest +echo 'using hello' >>hello/buildfile + +#show bdep sync --create-build2-config # Needed if not terminal. +show b +show bdep config list +show bdep update @clang + +cd .. + + +# Linked Configurations. +# +clean +show bdep new -t exe -l c++ hello +cd hello + +cat <<EOF >>repositories.manifest +: +role: prerequisite +location: $repo +trust: $trust +EOF +sed -i -re 's/^#depends: libhello/depends: libhello/' manifest # ^1.0.0 +sed -i -re 's/^#import/import/' hello/buildfile + +show bdep config create ../hello-base @base --no-default cc config.cxx=$gcc +show bdep config create ../hello-gcc @gcc --default cc config.cxx=$gcc +show bdep config create ../hello-clang @clang cc config.cxx=$clang + +show bdep config link @gcc @base +show bdep config link @clang @base + +show bdep init @gcc { @base }+ ?libhello +show bdep init @clang + +show bdep update @gcc +show bdep update @clang + +cd .. + # Versioning and Release Management. # clean @@ -228,13 +337,13 @@ show bdep new -C hello-gcc @gcc -t exe -l c++ hello cc config.cxx=$gcc cd hello git remote add origin git@github.com:boris-kolpackov/hello.git -git push origin :build2-control || true -git push -d origin v0.1.0-a.1 || true -git push -d origin v0.1.0 || true +git push --no-progress origin :build2-control || true +git push --no-progress -d origin v0.1.0-a.1 || true +git push --no-progress -d origin v0.1.0 || true git add . git commit -m "Initial implementation" -git push -f -u +git push --no-progress -f -u show bdep status show b info @@ -331,5 +440,3 @@ show /opt/tools/bin/hello World show tree /opt/tools show bpkg uninstall hello show bpkg drop hello - -echo "finished" |