| 1 | #!/bin/shscip-shell filesystem . . `/bin/sh`. |
| 2 | set -e |
| 3 | |
| 4 | script_path="$( |
| 5 | cd "$(dirnamescip-shell system . . dirname. "$0")" |
| 6 | pwdscip-shell system . . pwd. -P |
| 7 | )" |
| 8 | |
| 9 | os=ubuntu-focal |
| 10 | dart_version=v6.13 |
| 11 | build_dir_prefix=.build/ |
| 12 | project_dir=/opt/dart/scip-shell filesystem . . `/opt/dart/`. |
| 13 | cleanup_command="" |
| 14 | use_dev_image=false |
| 15 | build_mode="Release" |
| 16 | build_test=true |
| 17 | build_example=true |
| 18 | build_tutorial=true |
| 19 | build_dartpy=true |
| 20 | codecov_option="" |
| 21 | num_cores=1 |
| 22 | |
| 23 | helpscip-shell shell dart 6.13.2+ds-3 help().() { |
| 24 | catscip-shell system . . cat. <<EOF |
| 25 | Usage: ${0##*/} <routine> [<options>...] |
| 26 | |
| 27 | Example: ${0##*/} build # Build with the default settings |
| 28 | |
| 29 | Routines: |
| 30 | build Build DART and run its tests |
| 31 | clean Remove build directory for a specific build configuration |
| 32 | clean_all Remove all the build directories |
| 33 | launch Launch Docker image for DART build |
| 34 | |
| 35 | Options: |
| 36 | -o <name> OS version. Available <name>: {ubuntu-bionic, ubuntu-focal (default), ubuntu-impish} |
| 37 | -v <version> DART version. Available <version>: {v6.10, v7.0 (default)} |
| 38 | -c Clean build. Empty the build directory before building. |
| 39 | -j <num_cores> Number of cores to use for build. Use -j 1 to disable parallel build. Single core will be used if this option is not specified. |
| 40 | --dev Use Docker image for development rather than release image. |
| 41 | --no-test Skip building and running tests |
| 42 | --no-example Skip building examples |
| 43 | --no-tutorial Skip building tutorials |
| 44 | --no-dartpy Skip building dartpy |
| 45 | --codecov Enable code coverage (experimental) |
| 46 | --mode <mode> Build mode. Available <mode>: {Release (default), Debug} |
| 47 | EOF |
| 48 | } |
| 49 | |
| 50 | if [scip-shell system . . `[`. "$#" -lt 1 ]; then |
| 51 | helpscip-shell shell dart 6.13.2+ds-3 help(). |
| 52 | exit |
| 53 | else |
| 54 | routine=$1 |
| 55 | shift |
| 56 | fi |
| 57 | |
| 58 | while [scip-shell system . . `[`. $# -gt 0 ]; do |
| 59 | case "$1" in |
| 60 | -o) |
| 61 | os=$2 |
| 62 | shift |
| 63 | ;; |
| 64 | -v) |
| 65 | dart_version=$2 |
| 66 | shift |
| 67 | ;; |
| 68 | -c) |
| 69 | cleanup_command="&& rm -rf *" |
| 70 | ;; |
| 71 | --dev) |
| 72 | use_dev_image=true |
| 73 | ;; |
| 74 | --no-test) |
| 75 | build_test=false |
| 76 | ;; |
| 77 | --no-example) |
| 78 | build_example=false |
| 79 | ;; |
| 80 | --no-tutorial) |
| 81 | build_tutorial=false |
| 82 | ;; |
| 83 | --no-dartpy) |
| 84 | build_dartpy=false |
| 85 | ;; |
| 86 | --mode) |
| 87 | build_mode=$2 |
| 88 | shift |
| 89 | ;; |
| 90 | -j) |
| 91 | num_cores=$2 |
| 92 | shift |
| 93 | ;; |
| 94 | --codecov) |
| 95 | codecov_option="-DDART_CODECOV=ON" |
| 96 | ;; |
| 97 | *) |
| 98 | bash_command=$@ |
| 99 | break |
| 100 | ;; |
| 101 | esac |
| 102 | shift |
| 103 | done |
| 104 | |
| 105 | full_image_name_deploy=jslee02/dart:$os-$dart_version |
| 106 | full_image_name_dev=jslee02/dart-dev:$os-$dart_version |
| 107 | |
| 108 | if [scip-shell system . . `[`. "$build_test" = true ]; then |
| 109 | test_command="&& make -j$num_cores tests && ctest --output-on-failure" |
| 110 | else |
| 111 | test_command="" |
| 112 | fi |
| 113 | |
| 114 | if [scip-shell system . . `[`. "$build_example" = true ]; then |
| 115 | example_command="&& make -j$num_cores examples" |
| 116 | else |
| 117 | example_command="" |
| 118 | fi |
| 119 | |
| 120 | if [scip-shell system . . `[`. "$build_tutorial" = true ]; then |
| 121 | tutorial_command="&& make -j$num_cores tutorials" |
| 122 | else |
| 123 | tutorial_command="" |
| 124 | fi |
| 125 | |
| 126 | if [scip-shell system . . `[`. "$build_dartpy" = true ]; then |
| 127 | dartpy_command="&& make -j30 dartpy && make pytest" |
| 128 | else |
| 129 | dartpy_command="" |
| 130 | fi |
| 131 | |
| 132 | full_build_dir=$project_dir$build_dir_prefix$os-$dart_version-$build_mode/ |
| 133 | |
| 134 | launchscip-shell shell dart 6.13.2+ds-3 launch().() { |
| 135 | if [scip-shell system . . `[`. "$use_dev_image" = true ]; then |
| 136 | full_image_name=$full_image_name_dev |
| 137 | else |
| 138 | full_image_name=$full_image_name_deploy |
| 139 | fi |
| 140 | |
| 141 | docker pull $full_image_name |
| 142 | |
| 143 | docker run \ |
| 144 | -it \ |
| 145 | --privileged \ |
| 146 | --volume $(pwdscip-shell system . . pwd.):$project_dir \ |
| 147 | -w $project_dir \ |
| 148 | -t $scip-shell filesystem . . `/bin/bash`.fulscip-shell filesystem . . `/bin/bash`.l_image_name \ |
| 149 | /bin/bash |
| 150 | } |
| 151 | |
| 152 | cleanscip-shell shell dart 6.13.2+ds-3 clean().() { |
| 153 | full_image_name=$full_image_name_dev |
| 154 | |
| 155 | docker pull $full_image_name |
| 156 | |
| 157 | docker run \ |
| 158 | -it \ |
| 159 | --volume $(pwdscip-shell system . . pwd.):$project_dir \ |
| 160 | -w $project_dir/ \ |
| 161 | $full_image_name /binscip-shell filesystem . . `/bin/bash`./bashscip-shell filesystem . . `/bin/bash`. -c \ |
| 162 | "rm -rf $full_build_dir" |
| 163 | } |
| 164 | |
| 165 | clean_allscip-shell shell dart 6.13.2+ds-3 clean_all().() { |
| 166 | full_image_name=$full_image_name_dev |
| 167 | |
| 168 | docker pull $full_image_name |
| 169 | |
| 170 | docker run \ |
| 171 | -it \ |
| 172 | --volume $(pwdscip-shell system . . pwd.):$project_dir \ |
| 173 | -w $project_dir/ \ |
| 174 | $full_image_name /scip-shell filesystem . . `/bin/bash`.bscip-shell filesystem . . `/bin/bash`.in/bashscip-shell filesystem . . `/bin/bash`. -c \ |
| 175 | "rm -rf $project_dir$build_dir_prefix" |
| 176 | } |
| 177 | |
| 178 | buildscip-shell shell dart 6.13.2+ds-3 build().() { |
| 179 | full_image_name=$full_image_name_dev |
| 180 | |
| 181 | echoscip-shell system . . echo. "=======================================================================" |
| 182 | echoscip-shell system . . echo. " [Build] " |
| 183 | echoscip-shell system . . echo. " Docker : $full_image_name" |
| 184 | echoscip-shell system . . echo. " Num cores: $num_cores / $(nprocscip-shell system . . nproc.)" |
| 185 | echoscip-shell system . . echo. "=======================================================================" |
| 186 | |
| 187 | docker pull $full_image_name |
| 188 | |
| 189 | docker run \ |
| 190 | -it \ |
| 191 | --volume $(pwdscip-shell system . . pwd.):$project_dir \ |
| 192 | -w $project_dir/ \ |
| 193 | $full_image_name /bin/bscip-shell filesystem . . `/bin/bash`.ashscip-shell filesystem . . `/bin/bash`. -c \ |
| 194 | "mkdir -p $full_build_dir \ |
| 195 | && cd $full_build_dir \ |
| 196 | $cleanup_command \ |
| 197 | && cmake $project_dir \ |
| 198 | -DCMAKE_BUILD_TYPE=$build_mode \ |
| 199 | $codecov_option \ |
| 200 | && make -j$num_cores \ |
| 201 | $test_command \ |
| 202 | $example_command \ |
| 203 | $tutorial_command \ |
| 204 | $dartpy_command" |
| 205 | } |
| 206 | |
| 207 | # Run the selected routine |
| 208 | "$routine" |