diff --git a/.github/workflows/example_tests.yml b/.github/workflows/example_tests.yml index b722d3e..843268e 100644 --- a/.github/workflows/example_tests.yml +++ b/.github/workflows/example_tests.yml @@ -40,4 +40,4 @@ jobs: if: matrix.sumo_version == 'head' run: brew install --with-examples --HEAD sumo - - run: python $(brew --prefix sumo)/share/sumo/docs/examples/runAll.py + - run: python "$(brew --prefix sumo)/share/sumo/docs/examples/runAll.py" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 93540f5..eb8ae83 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -18,7 +18,7 @@ jobs: env: HOMEBREW_GITHUB_API_TOKEN: ${{ github.token }} PULL_REQUEST: ${{ github.event.pull_request.number }} - run: brew pr-pull --debug --tap=$GITHUB_REPOSITORY $PULL_REQUEST + run: brew pr-pull --debug --tap="$GITHUB_REPOSITORY" "$PULL_REQUEST" - name: Push commits uses: Homebrew/actions/git-try-push@master @@ -30,4 +30,4 @@ jobs: if: github.event.pull_request.head.repo.fork == false env: BRANCH: ${{ github.event.pull_request.head.ref }} - run: git push --delete origin $BRANCH + run: git push --delete origin "$BRANCH" diff --git a/Aliases/sumo@1.20 b/Aliases/sumo@1.21 similarity index 100% rename from Aliases/sumo@1.20 rename to Aliases/sumo@1.21 diff --git a/Formula/sumo.rb b/Formula/sumo.rb index d2669b8..be28333 100644 --- a/Formula/sumo.rb +++ b/Formula/sumo.rb @@ -1,18 +1,15 @@ class Sumo < Formula desc "Simulation of Urban MObility" homepage "https://www.eclipse.dev/sumo" - url "https://sumo.dlr.de/releases/1.20.0/sumo-src-1.20.0.tar.gz" - sha256 "34320ba1695db74c769d6b4931cb6bc6ec5b26c37e556451ab29d3963d6af8ec" + url "https://sumo.dlr.de/releases/1.21.0/sumo-src-1.21.0.tar.gz" + sha256 "1a246c30159abd4b5a878c0ce4eba3779bc6fce95f9c815c5f45567ceaa4ea53" license "EPL-2.0" head "https://github.com/eclipse-sumo/sumo.git", branch: "main" - bottle do - root_url "https://github.com/DLR-TS/homebrew-sumo/releases/download/sumo-1.20.0" - sha256 cellar: :any, arm64_sonoma: "de437553bbfff2c123b1e2c90f2bc0e35693cb34a1f371887891cd837577a279" - sha256 cellar: :any, arm64_ventura: "0416595756b2ce18e84c6c760257982210ffb3df07c9c43f60ade8a26d34578d" - sha256 cellar: :any, ventura: "711ff64f1d59c52b669a340cc3924097cdc1bbbc0000042b28e13156051d5f21" - sha256 cellar: :any, monterey: "dd3c1d156ed3a48fbe61227a314b213ae4c6c903cf03edb4f5e344b3689a09c3" - end + # stable do + # url "https://sumo.dlr.de/releases/1.21.0/sumo-src-1.21.0.tar.gz" + # sha256 "1a246c30159abd4b5a878c0ce4eba3779bc6fce95f9c815c5f45567ceaa4ea53" + # end option "with-examples", "Install docs/examples and docs/tutorial folder" diff --git a/Formula/sumo@1.20.0.rb b/Formula/sumo@1.20.0.rb new file mode 100644 index 0000000..40f7f14 --- /dev/null +++ b/Formula/sumo@1.20.0.rb @@ -0,0 +1,136 @@ +class SumoAT1200 < Formula + desc "Simulation of Urban MObility" + homepage "https://www.eclipse.dev/sumo" + url "https://sumo.dlr.de/releases/1.20.0/sumo-src-1.20.0.tar.gz" + sha256 "34320ba1695db74c769d6b4931cb6bc6ec5b26c37e556451ab29d3963d6af8ec" + license "EPL-2.0" + head "https://github.com/eclipse-sumo/sumo.git", branch: "main" + + bottle do + root_url "https://github.com/DLR-TS/homebrew-sumo/releases/download/sumo-1.20.0" + sha256 cellar: :any, arm64_sonoma: "de437553bbfff2c123b1e2c90f2bc0e35693cb34a1f371887891cd837577a279" + sha256 cellar: :any, arm64_ventura: "0416595756b2ce18e84c6c760257982210ffb3df07c9c43f60ade8a26d34578d" + sha256 cellar: :any, ventura: "711ff64f1d59c52b669a340cc3924097cdc1bbbc0000042b28e13156051d5f21" + sha256 cellar: :any, monterey: "dd3c1d156ed3a48fbe61227a314b213ae4c6c903cf03edb4f5e344b3689a09c3" + end + + option "with-examples", "Install docs/examples and docs/tutorial folder" + + depends_on "cmake" => :build + depends_on "fontconfig" + depends_on "fox" + # indirect dependencies due to fox + depends_on "freetype" + depends_on "gettext" + depends_on "jpeg-turbo" + depends_on "libice" + depends_on "libpng" + depends_on "libtiff" + depends_on "libx11" + depends_on "libxcursor" + depends_on "libxext" + depends_on "libxfixes" + depends_on "libxft" + depends_on "libxi" + depends_on "libxrandr" + depends_on "libxrender" + depends_on "mesa" + depends_on "mesa-glu" + + depends_on "proj" + depends_on "python" if build.head? && build.with?("examples") + depends_on "xerces-c" + + depends_on "ffmpeg" => :optional + depends_on "gdal" => :optional + depends_on "gl2ps" => :optional + depends_on "open-scene-graph" => :optional + depends_on "swig" => :optional + + # workaround due to dependency gdal -> numpy -> openblas -> gcc (originally gfortran) + # (use 'brew deps --tree sumo' to see dependencies of higher levels) + # also see: https://github.com/davidchall/homebrew-hep/issues/28 + cxxstdlib_check :skip + + def install + # cf. https://rubydoc.brew.sh/Formula.html#std_cmake_args-instance_method + cmake_args = *std_cmake_args(find_framework: "LAST") + + # bottling uses default formula options and we want minimal requirement bottles, + # therefore, by default, do not check for optional libs + if build.with?("ffmpeg") || + build.with?("gdal") || + build.with?("gl2ps") || + build.with?("open-scene-graph") + ohai "Enabling check for optional libraries..." + cmake_args << "-DCHECK_OPTIONAL_LIBS=ON" + else + cmake_args << "-DCHECK_OPTIONAL_LIBS=OFF" + end + + # If found, SWIG is enabled by default by sumo cmake config step + # but Java/Python library paths found by cmake might still be broken, + # so we disable SWIG by default here. + cmake_args << "-DSWIG_EXECUTABLE=\"\"" if build.without?("swig") + # XXX: pointers for getting '--with-swig' to work: + # cmake_args << "-DJAVA_HOME=#{Formula["openjdk"].opt_prefix}/libexec/openjdk.jdk/Contents/Home" + # cmake_args << "-DPython_ROOT_DIR=#{Formula["python"].opt_prefix}" + + mkdir "build/cmake-build" do # creates and changes to dir in block + system "cmake", "../..", *cmake_args + system "make" + system "make", "install" + system "make", "examples" if build.head? && build.with?("examples") + end + + if build.with?("examples") + (pkgshare/"docs").install "docs/examples" + (pkgshare/"docs").install "docs/tutorial" + end + end + + def caveats + <<~EOS + In order to let X11 start automatically whenever a GUI-based SUMO application + (e.g., "sumo-gui") is called, you need to log out and in again. + Alternatively, start X11 manually by pressing cmd-space and entering "XQuartz". + + Don't forget to set your SUMO_HOME environment variable: + export SUMO_HOME="#{prefix}/share/sumo" + + Please report any problems with this formula directly to the eclipse-sumo/sumo issue tracker: + https://github.com/eclipse-sumo/sumo/issues + + EOS + end + + test do # will create, run in and delete a temporary directory + # This small test verifies the functionality of SUMO. + # Run with 'brew test sumo'. + # Options passed to 'brew install' such as '--HEAD' also need to be provided to 'brew test'. + + (testpath/"nodes.xml").write <<~EOS + + + + + EOS + + (testpath/"edges.xml").write <<~EOS + + + + EOS + + system "#{bin}/netconvert", "-n", "#{testpath}/nodes.xml", "-e", "#{testpath}/edges.xml", "-o", + "#{testpath}/net.xml" + + (testpath/"flows.xml").write <<~EOS + + + + EOS + + system "#{bin}/sumo", "-n", "#{testpath}/net.xml", "-r", "#{testpath}/flows.xml" + end +end diff --git a/README.md b/README.md index 187bc29..aa1a66d 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,12 @@ If you want to use `sumo-gui` and/or `netedit`, you need to install XQuartz as a ## Usage -By default, the above command lines install a bottled SUMO stable version (currently ```1.20.0```) with minimal requirements (```fox```, ```proj```, ```xerces-c```). +By default, the above command lines install a bottled SUMO stable version (currently ```1.21.0```) with minimal requirements (```fox```, ```proj```, ```xerces-c```). Alternatively, ```brew``` can compile SUMO from source with the following command line options: brew install [OPTIONS] sumo - + ==> Options --with-examples Install docs/examples and docs/tutorial folder diff --git a/update_formula.sh b/update_formula.sh old mode 100755 new mode 100644 index 7ed0429..8df4cba --- a/update_formula.sh +++ b/update_formula.sh @@ -8,19 +8,19 @@ FORMULA_NAME=dlr-ts/sumo/sumo README_FILE=README.md # check for cmd line parameters -if [ $# -ne 2 ]; then - echo "" - echo "Usage: $0 " - echo "Examples:" - echo " NEW_VERSION: 1.3.1" - echo " SUMO_SRC_URL: https://github.com/eclipse-sumo/sumo/archive/v1_3_1.tar.gz" - echo "" - exit 1 +if [[ $# -ne 2 ]] +then + echo "" + echo "Usage: $0 " + echo "Examples:" + echo " NEW_VERSION: 1.3.1" + echo " SUMO_SRC_URL: https://github.com/eclipse-sumo/sumo/archive/v1_3_1.tar.gz" + echo "" + exit 1 fi -NEW_VERSION=$1 -SUMO_SRC_URL=$2 -DATE_STRING=$(date +"%Y-%m-%d") +NEW_VERSION="$1" +SUMO_SRC_URL="$2" NEW_MAJOR=$(echo "${NEW_VERSION}" | awk -F . '{ print $1 }') NEW_MINOR=$(echo "${NEW_VERSION}" | awk -F . '{ print $2 }') NEW_PATCH=$(echo "${NEW_VERSION}" | awk -F . '{ print $3 }') @@ -31,50 +31,50 @@ brew uninstall sumo brew install sumo # figure out version number -OLD_VERSION_WITH_REVISION=$(brew ls sumo --versions | awk '{print $2}') +OLD_VERSION_WITH_REVISION=$(brew ls sumo --versions | awk '{print $2}' || true) OLD_VERSION=$(echo "${OLD_VERSION_WITH_REVISION}" | awk -F _ '{print $1}') OLD_MAJOR=$(echo "${OLD_VERSION}" | awk -F . '{ print $1 }') OLD_MINOR=$(echo "${OLD_VERSION}" | awk -F . '{ print $2 }') OLD_PATCH=$(echo "${OLD_VERSION}" | awk -F . '{ print $3 }') -echo "old sumo version: '$OLD_VERSION'" +echo "old sumo version: '${OLD_VERSION}'" # generate full string (including version number) for formula class name -FORMULA_CLASS_NAME="SumoAT$(echo $OLD_VERSION | sed 's/\.//g')" -echo "formula class name: '$FORMULA_CLASS_NAME'" +FORMULA_CLASS_NAME="SumoAT${OLD_VERSION//./}" +echo "formula class name: '${FORMULA_CLASS_NAME}'" ARCHIVED_FORMULA_FILENAME="sumo@${OLD_VERSION}.rb" - + # archive old formula echo "copying formula to Formula/${ARCHIVED_FORMULA_FILENAME} and updating class name of archived formula..." -sed "s/class Sumo/class ${FORMULA_CLASS_NAME}/" Formula/sumo.rb >> Formula/${ARCHIVED_FORMULA_FILENAME} +sed "s/class Sumo/class ${FORMULA_CLASS_NAME}/" Formula/sumo.rb >>Formula/"${ARCHIVED_FORMULA_FILENAME}" echo "done archiving old formula!" echo "creating git branch" git checkout -b sumo echo "adding archived formula to git" -git add Formula/${ARCHIVED_FORMULA_FILENAME} +git add Formula/"${ARCHIVED_FORMULA_FILENAME}" git commit -m "sumo: archive formula for version ${OLD_VERSION}" ### BUMP formula version (https://docs.brew.sh/Manpage#bump-formula-pr-options-formula) echo "bumping formula version..." -brew bump-formula-pr -v --write-only --no-audit --url=${SUMO_SRC_URL} ${FORMULA_NAME} +brew bump-formula-pr -v --write-only --no-audit --url="${SUMO_SRC_URL}" "${FORMULA_NAME}" # remove bottle block # NOTE: dirty hack assumes lines 12-17 (including extra blank line) -sed '12,17d' /usr/local/Homebrew/Library/Taps/dlr-ts/homebrew-sumo/Formula/sumo.rb > Formula/sumo.rb +sed '12,17d' /usr/local/Homebrew/Library/Taps/dlr-ts/homebrew-sumo/Formula/sumo.rb >Formula/sumo.rb git add Formula/sumo.rb git commit -m "sumo: update formula to v${NEW_VERSION}" ### UPDATE alias link echo "updating Alias symlink..." -git mv Aliases/sumo\@${OLD_MAJOR}.${OLD_MINOR}.${OLD_PATCH} Aliases/sumo\@${NEW_MAJOR}.${NEW_MINOR}.${NEW_PATCH} +git mv Aliases/sumo@"${OLD_MAJOR}.${OLD_MINOR}.${OLD_PATCH}" Aliases/sumo@"${NEW_MAJOR}.${NEW_MINOR}.${NEW_PATCH}" git commit -m "sumo: update alias" ### UPDATE version number in README.md echo "updating version number in README.md" -sed "s/${OLD_VERSION}/${NEW_VERSION}/" ${README_FILE} >> ${README_FILE}.NEW -mv ${README_FILE}.NEW ${README_FILE} -git add ${README_FILE} +sed "s/${OLD_VERSION}/${NEW_VERSION}/" "${README_FILE}" >>"${README_FILE}.NEW" +mv "${README_FILE}.NEW" "${README_FILE}" +git add "${README_FILE}" git commit -m "update version number in README" echo "You now need to create a pull request from the new branch to trigger the workflows ..."