Skip to content

Commit

Permalink
plan file for windows
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin <[email protected]>
  • Loading branch information
Sachin committed Sep 9, 2024
1 parent b2d6056 commit 9a55ccb
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
source "https://rubygems.org"

gemspec

group :development do
gem 'appbundler'
end
86 changes: 86 additions & 0 deletions habitat/plan.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
$ErrorActionPreference = "Stop"
$PSDefaultParameterValues['*:ErrorAction']='Stop'

$pkg_name="fauxhai"
$pkg_origin="core"
$pkg_version="9.3.16"
$pkg_revision="1"
$pkg_maintainer="The Chef Maintainers <[email protected]>"

$pkg_deps=@(
"chef/ruby31-plus-devkit"
"core/git"
)
$pkg_bin_dirs=@("bin"
"vendor/bin")
$project_root= (Resolve-Path "$PLAN_CONTEXT/../").Path

function Invoke-SetupEnvironment {
Push-RuntimeEnv -IsPath GEM_PATH "$pkg_prefix/vendor"

Set-RuntimeEnv APPBUNDLER_ALLOW_RVM "true" # prevent appbundler from clearing out the carefully constructed runtime GEM_PATH
Set-RuntimeEnv FORCE_FFI_YAJL "ext"
Set-RuntimeEnv LANG "en_US.UTF-8"
Set-RuntimeEnv LC_CTYPE "en_US.UTF-8"
}

function Invoke-Build {
try {
$env:Path += ";c:\\Program Files\\Git\\bin"
Push-Location $project_root
$env:GEM_HOME = "$HAB_CACHE_SRC_PATH/$pkg_dirname/vendor"

Write-BuildLine " ** Configuring bundler for this build environment"
bundle config --local without integration deploy maintenance
bundle config --local jobs 4
bundle config --local retry 5
bundle config --local silence_root_warning 1
Write-BuildLine " ** Using bundler to retrieve the Ruby dependencies"
bundle install

gem build fauxhai.gemspec
Write-BuildLine " ** Using gem to install"
gem install fauxhai-*.gem --no-document


If ($lastexitcode -ne 0) { Exit $lastexitcode }
} finally {
Pop-Location
}
}

function Invoke-Install {
Write-BuildLine "** Copy built & cached gems to install directory"
Copy-Item -Path "$HAB_CACHE_SRC_PATH/$pkg_dirname/*" -Destination $pkg_prefix -Recurse -Force -Exclude @("gem_make.out", "mkmf.log", "Makefile",
"*/latest", "latest",
"*/JSON-Schema-Test-Suite", "JSON-Schema-Test-Suite")

try {
Push-Location $pkg_prefix
bundle config --local gemfile $project_root/Gemfile
Write-BuildLine "** generating binstubs for fauxhai with precise version pins"
Write-BuildLine "** generating binstubs for fauxhai with precise version pins $project_root $pkg_prefix/bin "
Invoke-Expression -Command "appbundler.bat $project_root $pkg_prefix/bin fauxhai"
If ($lastexitcode -ne 0) { Exit $lastexitcode }
Write-BuildLine " ** Running the fauxhai project's 'rake install' to install the path-based gems so they look like any other installed gem."

If ($lastexitcode -ne 0) { Exit $lastexitcode }
} finally {
Pop-Location
}
}

function Invoke-After {
# We don't need the cache of downloaded .gem files ...
Remove-Item $pkg_prefix/vendor/cache -Recurse -Force
# We don't need the gem docs.
Remove-Item $pkg_prefix/vendor/doc -Recurse -Force
# We don't need to ship the test suites for every gem dependency,
# only inspec's for package verification.
Get-ChildItem $pkg_prefix/vendor/gems -Filter "spec" -Directory -Recurse -Depth 1 `
| Where-Object -FilterScript { $_.FullName -notlike "*fauxhai*" } `
| Remove-Item -Recurse -Force
# Remove the byproducts of compiling gems with extensions
Get-ChildItem $pkg_prefix/vendor/gems -Include @("gem_make.out", "mkmf.log", "Makefile") -File -Recurse `
| Remove-Item -Force
}

0 comments on commit 9a55ccb

Please sign in to comment.