#
# Copyright:: 2015-2026 Chef Software, Inc.
# Copyright:: 2026 Cinc Project
# Copyright:: 2026 Oregon State University
#
# 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.
#

name "omnibus-toolchain"
friendly_name "Omnibus Toolchain"
maintainer "Cinc Project <maintainers@cinc.sh>"
homepage   "https://cinc.sh"
license "Apache-2.0"
license_file "LICENSE"

build_iteration 1
version_file = File.expand_path("../../VERSION", __dir__)
build_version IO.read(version_file).strip

if windows?
  # Use an explicit uppercase "C:" drive prefix, not default_root.
  # default_root returns lowercase "c:" on Windows, and omnibus's
  # install_dir setter does File.expand_path on the value — on
  # RubyInstaller-DevKit Ruby that strips a lowercase "c:" prefix
  # entirely, producing "/cinc-project/omnibus-toolchain" and breaking
  # git_cache's --work-tree argument.
  install_dir  "C:/cinc-project/#{name}"
  package_name "omnibus-toolchain"
else
  install_dir "#{default_root}/#{name}"
end

# creates required build directories
dependency "preparation"

dependency "omnibus-toolchain"

# Rewrite "#!/usr/bin/env ruby" shebangs in embedded/bin/* to point at
# the embedded ruby. Without this, RubyGems-generated binstubs (bundle,
# rake, etc.) and the bin/* symlinks that point at them fail to run
# when the system PATH has no ruby on it. Must come after every gem-
# installing dep so it sees all the binstubs.
dependency "shebang-cleanup"

dependency "ruby-cleanup"

exclude '\.git*'
exclude 'bundler\/git'

package :pkg do
  identifier "sh.cinc.pkg.omnibus-toolchain"
end
compress :dmg

package :msi do
  fast_msi true
  upgrade_code "86116364-7CF9-4BF7-B99D-C121337B44BB"
  wix_candle_extension "WixUtilExtension"
  wix_light_extension "WixUtilExtension"
  wix_light_delay_validation true
  parameters ProjectLocationDir: "omnibus-toolchain"
end
