<commit_before>require "formula"
require File.expand_path("../../Requirements/qgis_requirements",
                         Pathname.new(__FILE__).realpath)

class UnlinkedQGIS26 < UnlinkedQGIS
  fatal true
  def qgis_formula_name
    "qgis-26"
  end
  satisfy(:build_env => false) { no_linked_qgis[0] }
end

class Qgis26 < Formula
  homepage "http://www.qgis.org"
  url "https://github.com/qgis/QGIS/archive/final-2_6_1.tar.gz"
  sha1 "44f11f227658034c96b1bb8de52e84765422308c"

  bottle do
    root_url "http://qgis.dakotacarto.com/osgeo4mac/bottles"
    sha1 "c149eacf36355a18d026b054771140c08b03585d" => :mavericks
  end

  def pour_bottle?
    brewed_python?
  end

  def bottle_caveat
    (MacOS.version == :mavericks) ? "Bottle supports only Homebrew Python\n\n" : ""
  end

  head "https://github.com/qgis/QGIS.git", :branch => "master"

  option "enable-isolation", "Isolate .app's environment to HOMEBREW_PREFIX, to coexist with other QGIS installs"
  option "with-debug", "Enable debug build, which outputs info to system.log or console"
  option "without-server", "Build without QGIS Server (qgis_mapserv.fcgi)"
  option "without-postgresql", "Build without current PostgreSQL client"
  option "without-globe", "Build without Globe plugin, based upon osgEarth"
  option "without-postgis", "Build without extra PostGIS geospatial database extender"
  option "without-grass", "Build without GRASS 6 integration plugin and Processing plugin support"
  option "with-grass7", "Build with GRASS 7 for Processing plugin"
  option "with-oracle", "Build extra Oracle geospatial database and raster support"
  option "with-orfeo", "Build extra Orfeo Toolbox for Processing plugin"
  option "with-r", "Build extra R for Processing plugin"
  option "with-saga-gis", "Build extra Saga GIS for Processing plugin"
  option "with-qt-mysql", "Build extra Qt MySQL plugin for eVis plugin"
  option "with-api-docs", "Build the API documentation with Doxygen and Graphviz"

  depends_on UnlinkedQGIS26

  # core qgis
  depends_on "cmake" => :build
  depends_on "bison" => :build
  if build.with? "api-docs"
    depends_on "graphviz" => [:build, "with-freetype"]
    depends_on "doxygen" => [:build, "with-dot"] # with graphviz support
  end
  depends_on (build.include? "enable-isolation" || MacOS.version < :lion ) ? "python" : :python
  depends_on "qt"
  depends_on "pyqt"
  depends_on SipBinary
  depends_on PyQtConfig
  depends_on "qscintilla2" # will probably be a C++ lib deps in near future
  depends_on "qwt"
  depends_on "qwtpolar"
  depends_on "gsl"
  depends_on "sqlite" # keg_only
  depends_on "expat" # keg_only
  depends_on "proj"
  depends_on "spatialindex"
  depends_on "fcgi" if build.with? "server"
  # use newer postgresql client than Apple's, also needed by `psycopg2`
  depends_on "postgresql" => :recommended

  # core providers
  depends_on "gdal"
  depends_on "postgis" => :recommended
  depends_on "oracle-client-sdk" if build.with? "oracle"
  # TODO: add MSSQL third-party support formula?, :optional

  # core plugins (c++ and python)
  if build.with? "grass"
    depends_on "grass-64"
    depends_on "gdal-grass64"
    depends_on "gettext"
  end

  if build.with? "globe"
    depends_on "open-scene-graph" => ["with-qt"]
    depends_on "homebrew/science/osgearth"
  end
  depends_on "gpsbabel" => [:recommended, "with-libusb"]
  # TODO: remove "pyspatialite" when PyPi package supports spatialite 4.x
  #       or DB Manager supports libspatialite >= 4.2.0 (with mod_spatialite)
  depends_on "pyspatialite" # for DB Manager
  depends_on "qt-mysql" => :optional # for eVis plugin (non-functional in 2.x?)

  # core processing plugin extras
  # see `postgis` and `grass` above
  depends_on "grass-70" if build.with? "grass7"
  depends_on "orfeo-40" if build.with? "orfeo"
  depends_on "homebrew/science/r" => :optional
  depends_on "saga-gis" => :optional
  # TODO: LASTools straight build (2 reporting tools), or via `wine` (10 tools)
  # TODO: Fusion from USFS (via `wine`?)

  resource "pyqgis-startup" do
    url "https://gist.githubusercontent.com/dakcarto/11385561/raw/7af66d0c8885a888831da6f12298a906484a1471/pyqgis_startup.py"
    sha1 "13d624e8ccc6bf072bbaeaf68cd6f7309abc1e74"
    version "2.0.0"
  end

  # # patches that represent all backports to release-2_6 branch, since 2.6.1 tag, e2a51df (2014-11-28)
  # # see: https://github.com/qgis/QGIS/commits/release-2_6
  # #      and https://github.com/qgis/QGIS/commits/final-2_6_1
  # stable do
  #   patch do
  #     # SHA1HASH (date) through SHA1HASH (date)
  #     url ""
  #     sha1 ""
  #   end
  # end

  def install
    # Set bundling level back to 0 (the default in all versions prior to 1.8.0)
    # so that no time and energy is wasted copying the Qt frameworks into QGIS.
    qwt_fw = Formula["qwt"].opt_lib/"qwt.framework"
    qwtpolar_fw = Formula["qwtpolar"].opt_lib/"qwtpolar.framework"
    dev_fw = lib/"qgis-dev"
    dev_fw.mkpath
    qsci_opt = Formula["qscintilla2"].opt_prefix
    args = std_cmake_args
    args << "-DCMAKE_BUILD_TYPE=RelWithDebInfo" if build.with? "debug" # override
    args += %W[
      -DBISON_EXECUTABLE=#{Formula["bison"].opt_bin}/bison
      -DENABLE_TESTS=FALSE
      -DQWT_INCLUDE_DIR=#{qwt_fw}/Headers
      -DQWT_LIBRARY=#{qwt_fw}/qwt
      -DQWTPOLAR_INCLUDE_DIR=#{qwtpolar_fw}/Headers
      -DQWTPOLAR_LIBRARY=#{qwtpolar_fw}/qwtpolar
      -DQSCINTILLA_INCLUDE_DIR=#{qsci_opt}/include
      -DQSCINTILLA_LIBRARY=#{qsci_opt}/lib/libqscintilla2.dylib
      -DWITH_INTERNAL_QWTPOLAR=FALSE
      -DQGIS_MACAPP_BUNDLE=0
      -DQGIS_MACAPP_DEV_PREFIX='#{dev_fw}'
      -DQGIS_MACAPP_INSTALL_DEV=TRUE
      -DWITH_QSCIAPI=FALSE
      -DWITH_STAGED_PLUGINS=FALSE
    ]

    args << "-DPYTHON_EXECUTABLE='#{python_exec}'"
    # brewed python is used if installed
    if brewed_python?
      args << "-DPYTHON_CUSTOM_FRAMEWORK='#{brewed_python_framework}'"
    end

    # find git revision for HEAD build
    if build.head? && File.exists?("#{cached_download}/.git/index")
      args << "-DGITCOMMAND=#{Formula["git"].opt_bin}/git"
      args << "-DGIT_MARKER=#{cached_download}/.git/index"
    else
      args << "-DGIT_MARKER=''" # if git clone borked, or release tarball, ends up defined as 'exported'
    end

    args << "-DWITH_MAPSERVER=#{build.with?("server") ? "TRUE" : "FALSE"}"
    if build.with? "server"
      fcgi_opt = Formula["fcgi"].opt_prefix
      args << "-DFCGI_INCLUDE_DIR=#{fcgi_opt}/include"
      args << "-DFCGI_LIBRARY=#{fcgi_opt}/lib/libfcgi.dylib"
    end

    args << "-DPOSTGRES_CONFIG=#{Formula["postgresql"].opt_bin}/pg_config" if build.with? "postgresql"

    args << "-DWITH_GRASS=#{build.with?("grass") ? "TRUE" : "FALSE"}"
    if build.with? "grass"
      # this is to build the GRASS Plugin, not for Processing plugin support
      grass = Formula["grass-64"]
      args << "-DGRASS_PREFIX='#{grass.opt_prefix}/grass-#{grass.version.to_s}'"
      # So that `libintl.h` can be found
      ENV.append "CXXFLAGS", "-I'#{Formula["gettext"].opt_include}'"
    end
<commit_msg>qgis-26: update Server CMake option name for head builds<commit_after>require "formula"
require File.expand_path("../../Requirements/qgis_requirements",
                         Pathname.new(__FILE__).realpath)

class UnlinkedQGIS26 < UnlinkedQGIS
  fatal true
  def qgis_formula_name
    "qgis-26"
  end
  satisfy(:build_env => false) { no_linked_qgis[0] }
end

class Qgis26 < Formula
  homepage "http://www.qgis.org"
  url "https://github.com/qgis/QGIS/archive/final-2_6_1.tar.gz"
  sha1 "44f11f227658034c96b1bb8de52e84765422308c"

  bottle do
    root_url "http://qgis.dakotacarto.com/osgeo4mac/bottles"
    sha1 "c149eacf36355a18d026b054771140c08b03585d" => :mavericks
  end

  def pour_bottle?
    brewed_python?
  end

  def bottle_caveat
    (MacOS.version == :mavericks) ? "Bottle supports only Homebrew Python\n\n" : ""
  end

  head "https://github.com/qgis/QGIS.git", :branch => "master"

  option "enable-isolation", "Isolate .app's environment to HOMEBREW_PREFIX, to coexist with other QGIS installs"
  option "with-debug", "Enable debug build, which outputs info to system.log or console"
  option "without-server", "Build without QGIS Server (qgis_mapserv.fcgi)"
  option "without-postgresql", "Build without current PostgreSQL client"
  option "without-globe", "Build without Globe plugin, based upon osgEarth"
  option "without-postgis", "Build without extra PostGIS geospatial database extender"
  option "without-grass", "Build without GRASS 6 integration plugin and Processing plugin support"
  option "with-grass7", "Build with GRASS 7 for Processing plugin"
  option "with-oracle", "Build extra Oracle geospatial database and raster support"
  option "with-orfeo", "Build extra Orfeo Toolbox for Processing plugin"
  option "with-r", "Build extra R for Processing plugin"
  option "with-saga-gis", "Build extra Saga GIS for Processing plugin"
  option "with-qt-mysql", "Build extra Qt MySQL plugin for eVis plugin"
  option "with-api-docs", "Build the API documentation with Doxygen and Graphviz"

  depends_on UnlinkedQGIS26

  # core qgis
  depends_on "cmake" => :build
  depends_on "bison" => :build
  if build.with? "api-docs"
    depends_on "graphviz" => [:build, "with-freetype"]
    depends_on "doxygen" => [:build, "with-dot"] # with graphviz support
  end
  depends_on (build.include? "enable-isolation" || MacOS.version < :lion ) ? "python" : :python
  depends_on "qt"
  depends_on "pyqt"
  depends_on SipBinary
  depends_on PyQtConfig
  depends_on "qscintilla2" # will probably be a C++ lib deps in near future
  depends_on "qwt"
  depends_on "qwtpolar"
  depends_on "gsl"
  depends_on "sqlite" # keg_only
  depends_on "expat" # keg_only
  depends_on "proj"
  depends_on "spatialindex"
  depends_on "fcgi" if build.with? "server"
  # use newer postgresql client than Apple's, also needed by `psycopg2`
  depends_on "postgresql" => :recommended

  # core providers
  depends_on "gdal"
  depends_on "postgis" => :recommended
  depends_on "oracle-client-sdk" if build.with? "oracle"
  # TODO: add MSSQL third-party support formula?, :optional

  # core plugins (c++ and python)
  if build.with? "grass"
    depends_on "grass-64"
    depends_on "gdal-grass64"
    depends_on "gettext"
  end

  if build.with? "globe"
    depends_on "open-scene-graph" => ["with-qt"]
    depends_on "homebrew/science/osgearth"
  end
  depends_on "gpsbabel" => [:recommended, "with-libusb"]
  # TODO: remove "pyspatialite" when PyPi package supports spatialite 4.x
  #       or DB Manager supports libspatialite >= 4.2.0 (with mod_spatialite)
  depends_on "pyspatialite" # for DB Manager
  depends_on "qt-mysql" => :optional # for eVis plugin (non-functional in 2.x?)

  # core processing plugin extras
  # see `postgis` and `grass` above
  depends_on "grass-70" if build.with? "grass7"
  depends_on "orfeo-40" if build.with? "orfeo"
  depends_on "homebrew/science/r" => :optional
  depends_on "saga-gis" => :optional
  # TODO: LASTools straight build (2 reporting tools), or via `wine` (10 tools)
  # TODO: Fusion from USFS (via `wine`?)

  resource "pyqgis-startup" do
    url "https://gist.githubusercontent.com/dakcarto/11385561/raw/7af66d0c8885a888831da6f12298a906484a1471/pyqgis_startup.py"
    sha1 "13d624e8ccc6bf072bbaeaf68cd6f7309abc1e74"
    version "2.0.0"
  end

  # # patches that represent all backports to release-2_6 branch, since 2.6.1 tag, e2a51df (2014-11-28)
  # # see: https://github.com/qgis/QGIS/commits/release-2_6
  # #      and https://github.com/qgis/QGIS/commits/final-2_6_1
  # stable do
  #   patch do
  #     # SHA1HASH (date) through SHA1HASH (date)
  #     url ""
  #     sha1 ""
  #   end
  # end

  def install
    # Set bundling level back to 0 (the default in all versions prior to 1.8.0)
    # so that no time and energy is wasted copying the Qt frameworks into QGIS.
    qwt_fw = Formula["qwt"].opt_lib/"qwt.framework"
    qwtpolar_fw = Formula["qwtpolar"].opt_lib/"qwtpolar.framework"
    dev_fw = lib/"qgis-dev"
    dev_fw.mkpath
    qsci_opt = Formula["qscintilla2"].opt_prefix
    args = std_cmake_args
    args << "-DCMAKE_BUILD_TYPE=RelWithDebInfo" if build.with? "debug" # override
    args += %W[
      -DBISON_EXECUTABLE=#{Formula["bison"].opt_bin}/bison
      -DENABLE_TESTS=FALSE
      -DQWT_INCLUDE_DIR=#{qwt_fw}/Headers
      -DQWT_LIBRARY=#{qwt_fw}/qwt
      -DQWTPOLAR_INCLUDE_DIR=#{qwtpolar_fw}/Headers
      -DQWTPOLAR_LIBRARY=#{qwtpolar_fw}/qwtpolar
      -DQSCINTILLA_INCLUDE_DIR=#{qsci_opt}/include
      -DQSCINTILLA_LIBRARY=#{qsci_opt}/lib/libqscintilla2.dylib
      -DWITH_INTERNAL_QWTPOLAR=FALSE
      -DQGIS_MACAPP_BUNDLE=0
      -DQGIS_MACAPP_DEV_PREFIX='#{dev_fw}'
      -DQGIS_MACAPP_INSTALL_DEV=TRUE
      -DWITH_QSCIAPI=FALSE
      -DWITH_STAGED_PLUGINS=FALSE
    ]

    args << "-DPYTHON_EXECUTABLE='#{python_exec}'"
    # brewed python is used if installed
    if brewed_python?
      args << "-DPYTHON_CUSTOM_FRAMEWORK='#{brewed_python_framework}'"
    end

    # find git revision for HEAD build
    if build.head? && File.exists?("#{cached_download}/.git/index")
      args << "-DGITCOMMAND=#{Formula["git"].opt_bin}/git"
      args << "-DGIT_MARKER=#{cached_download}/.git/index"
    else
      args << "-DGIT_MARKER=''" # if git clone borked, or release tarball, ends up defined as 'exported'
    end

    args << "-DWITH_#{build.head? ? "" : "MAP"}SERVER=#{build.with?("server") ? "TRUE" : "FALSE"}"
    if build.with? "server"
      fcgi_opt = Formula["fcgi"].opt_prefix
      args << "-DFCGI_INCLUDE_DIR=#{fcgi_opt}/include"
      args << "-DFCGI_LIBRARY=#{fcgi_opt}/lib/libfcgi.dylib"
    end

    args << "-DPOSTGRES_CONFIG=#{Formula["postgresql"].opt_bin}/pg_config" if build.with? "postgresql"

    args << "-DWITH_GRASS=#{build.with?("grass") ? "TRUE" : "FALSE"}"
    if build.with? "grass"
      # this is to build the GRASS Plugin, not for Processing plugin support
      grass = Formula["grass-64"]
      args << "-DGRASS_PREFIX='#{grass.opt_prefix}/grass-#{grass.version.to_s}'"
      # So that `libintl.h` can be found
      ENV.append "CXXFLAGS", "-I'#{Formula["gettext"].opt_include}'"
    end

{'fraction_non_alphanumeric': 0.12311504424778762, 'fraction_numerical': 0.027185840707964603, 'mean_word_length': 3.8063967335828512, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 33, 'https://': 10, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '186516', 'n_tokens_mistral': 5534, 'n_tokens_neox': 5195, 'n_words': 1191}