├── script ├── cibuild ├── lint ├── specs ├── syntax └── cardboard-exec ├── spec ├── fixtures │ ├── manifests │ │ └── site.pp │ ├── modules │ │ └── gcc │ │ │ └── manifests │ ├── Puppetfile │ └── Puppetfile.lock ├── spec_helper.rb └── classes │ └── gcc_spec.rb ├── Gemfile ├── .travis.yml ├── Rakefile ├── .gitignore ├── README.md ├── CONTRIBUTING.md ├── manifests └── init.pp ├── Gemfile.lock └── files └── brews └── gcc.rb /script/cibuild: -------------------------------------------------------------------------------- 1 | cardboard-exec -------------------------------------------------------------------------------- /script/lint: -------------------------------------------------------------------------------- 1 | cardboard-exec -------------------------------------------------------------------------------- /script/specs: -------------------------------------------------------------------------------- 1 | cardboard-exec -------------------------------------------------------------------------------- /script/syntax: -------------------------------------------------------------------------------- 1 | cardboard-exec -------------------------------------------------------------------------------- /spec/fixtures/manifests/site.pp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /spec/fixtures/modules/gcc/manifests: -------------------------------------------------------------------------------- 1 | ../../../../manifests -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gem "cardboard", "~> 1.0" 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | --- 2 | script: "./script/cibuild" 3 | gemfile: "this/does/not/exist" 4 | rvm: 5 | - "1.8.7" 6 | - "2.0.0" 7 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'rake' 2 | 3 | require 'rspec/core/rake_task' 4 | 5 | RSpec::Core::RakeTask.new(:spec) do |t| 6 | t.pattern = 'spec/*/*_spec.rb' 7 | end 8 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle 2 | /.ruby-version 3 | /spec/fixtures/.librarian 4 | /spec/fixtures/.tmp 5 | /spec/fixtures/Puppetfile.lock 6 | /spec/fixtures/modules 7 | /spec/fixtures/vendor 8 | -------------------------------------------------------------------------------- /spec/fixtures/Puppetfile: -------------------------------------------------------------------------------- 1 | mod "boxen", "2.3.3", :github_tarball => "boxen/puppet-boxen" 2 | mod "homebrew", "1.2.0", :github_tarball => "boxen/puppet-homebrew" 3 | mod "repository", "2.2.0", :github_tarball => "boxen/puppet-repository" 4 | mod "stdlib", "4.0.0", :github_tarball => "puppetlabs/puppetlabs-stdlib" 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GCC Puppet Module for Boxen 2 | 3 | [![Build Status](https://travis-ci.org/boxen/puppet-gcc.svg?branch=master)](https://travis-ci.org/boxen/puppet-gcc) 4 | 5 | ## Usage 6 | 7 | ```puppet 8 | include gcc 9 | ``` 10 | 11 | ## Required Puppet Modules 12 | 13 | * `boxen` 14 | * `homebrew` 15 | * `stdlib` 16 | 17 | -------------------------------------------------------------------------------- /script/cardboard-exec: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Make sure deps are available and run a Cardboard command. 3 | 4 | set -e 5 | 6 | cd $(dirname "$0")/.. 7 | 8 | BUNDLE=.bundle 9 | BIN=$BUNDLE/binstubs 10 | SCRIPT=$(basename "$0") 11 | 12 | BUNDLE_ARGS="--binstubs $BIN --path $BUNDLE --quiet" 13 | [ "cibuild" = "$SCRIPT" ] && BUNDLE_ARGS="$BUNDLE_ARGS --no-quiet" 14 | 15 | rm -rf {$BIN,$BUNDLE/config} 16 | bundle install $BUNDLE_ARGS 17 | 18 | bundle exec cardboard bootstrap 19 | exec bundle exec cardboard "$SCRIPT" "$@" 20 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Thanks for contributing to Boxen! A couple of notes to help you out: 2 | 3 | * We're conservative with version bumps, especially on services. We 4 | tend to keep things aligned with what we're personally using in 5 | development. If that doesn't work for your team, fork the module and 6 | use it in your Boxen instead. 7 | 8 | * Otherwise, go crazy! Fork it, fix it, test it, pull request it. 9 | Remember that a PR is the start of a conversation, not the end of one. 10 | 11 | :heart:, 12 | Boxen 13 | -------------------------------------------------------------------------------- /spec/fixtures/Puppetfile.lock: -------------------------------------------------------------------------------- 1 | GITHUBTARBALL 2 | remote: boxen/puppet-boxen 3 | specs: 4 | boxen (2.3.3) 5 | 6 | GITHUBTARBALL 7 | remote: boxen/puppet-homebrew 8 | specs: 9 | homebrew (1.2.0) 10 | 11 | GITHUBTARBALL 12 | remote: boxen/puppet-repository 13 | specs: 14 | repository (2.2.0) 15 | 16 | GITHUBTARBALL 17 | remote: puppetlabs/puppetlabs-stdlib 18 | specs: 19 | stdlib (4.0.0) 20 | 21 | DEPENDENCIES 22 | boxen (= 2.3.3) 23 | homebrew (= 1.2.0) 24 | repository (= 2.2.0) 25 | stdlib (= 4.0.0) 26 | 27 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'rspec-puppet' 2 | 3 | fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) 4 | 5 | RSpec.configure do |c| 6 | c.module_path = File.join(fixture_path, 'modules') 7 | c.manifest_dir = File.join(fixture_path, 'manifests') 8 | end 9 | 10 | def default_test_facts 11 | { 12 | :boxen_home => "/test/boxen", 13 | :boxen_user => "testuser", 14 | :macosx_productversion_major => "10.8", 15 | :operatingsystem => "Darwin", 16 | :osfamily => "Darwin", 17 | } 18 | end 19 | -------------------------------------------------------------------------------- /spec/classes/gcc_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe 'gcc' do 4 | let(:facts) { default_test_facts.merge(:macosx_productversion_major => 10.9) } 5 | 6 | it do 7 | should contain_homebrew__tap('homebrew/versions'). 8 | with_ensure('present') 9 | 10 | should contain_package('boxen/brews/gcc5').with({ 11 | :ensure => '5.1.0', 12 | :require => 'Homebrew::Tap[homebrew/versions]' 13 | }) 14 | 15 | should contain_package('boxen/brews/apple-gcc42').with({ 16 | :ensure => 'absent' 17 | }) 18 | 19 | should contain_package('boxen/brews/gcc48').with({ 20 | :ensure => 'absent' 21 | }) 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /manifests/init.pp: -------------------------------------------------------------------------------- 1 | # Public: Install gcc via homebrew 2 | # 3 | # Examples 4 | # 5 | # include gcc 6 | class gcc { 7 | 8 | case $::operatingsystem { 9 | 'Darwin': { 10 | include homebrew 11 | 12 | ensure_resource('homebrew::tap', 13 | 'homebrew/versions', { 'ensure' => 'present' }) 14 | 15 | homebrew::formula { 'gcc': } 16 | 17 | package { 'boxen/brews/gcc': 18 | ensure => '7.2.0', 19 | require => Homebrew::Tap['homebrew/versions'] 20 | } 21 | 22 | package { ['boxen/brews/apple-gcc42', 'boxen/brews/gcc48']: 23 | ensure => 'absent' 24 | } 25 | } 26 | 27 | default: { 28 | package { 'gcc': } 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | addressable (2.3.5) 5 | ansi (1.4.3) 6 | boxen (1.4.2) 7 | ansi (~> 1.4) 8 | hiera (~> 1.0) 9 | highline (~> 1.6) 10 | json_pure (>= 1.7.7, < 2.0) 11 | librarian-puppet (~> 0.9.9) 12 | octokit (~> 1.15) 13 | puppet (~> 3.0) 14 | cardboard (1.0.4) 15 | boxen (~> 1.0) 16 | puppet-lint (~> 0.3) 17 | puppetlabs_spec_helper (~> 0.4) 18 | rspec-puppet (~> 0.1) 19 | diff-lcs (1.2.4) 20 | facter (1.7.2) 21 | faraday (0.8.7) 22 | multipart-post (~> 1.1) 23 | faraday_middleware (0.9.0) 24 | faraday (>= 0.7.4, < 0.9) 25 | hashie (2.0.5) 26 | hiera (1.2.1) 27 | json_pure 28 | highline (1.6.19) 29 | json (1.8.0) 30 | json_pure (1.8.0) 31 | librarian-puppet (0.9.9) 32 | json 33 | thor (~> 0.15) 34 | metaclass (0.0.1) 35 | mocha (0.14.0) 36 | metaclass (~> 0.0.1) 37 | multi_json (1.7.7) 38 | multipart-post (1.2.0) 39 | netrc (0.7.7) 40 | octokit (1.25.0) 41 | addressable (~> 2.2) 42 | faraday (~> 0.8) 43 | faraday_middleware (~> 0.9) 44 | hashie (~> 2.0) 45 | multi_json (~> 1.3) 46 | netrc (~> 0.7.7) 47 | puppet (3.2.2) 48 | facter (~> 1.6) 49 | hiera (~> 1.0) 50 | rgen (~> 0.6) 51 | puppet-lint (0.3.2) 52 | puppetlabs_spec_helper (0.4.1) 53 | mocha (>= 0.10.5) 54 | rake 55 | rspec (>= 2.9.0) 56 | rspec-puppet (>= 0.1.1) 57 | rake (10.1.0) 58 | rgen (0.6.5) 59 | rspec (2.14.1) 60 | rspec-core (~> 2.14.0) 61 | rspec-expectations (~> 2.14.0) 62 | rspec-mocks (~> 2.14.0) 63 | rspec-core (2.14.2) 64 | rspec-expectations (2.14.0) 65 | diff-lcs (>= 1.1.3, < 2.0) 66 | rspec-mocks (2.14.1) 67 | rspec-puppet (0.1.6) 68 | rspec 69 | thor (0.18.1) 70 | 71 | PLATFORMS 72 | ruby 73 | 74 | DEPENDENCIES 75 | cardboard (~> 1.0) 76 | -------------------------------------------------------------------------------- /files/brews/gcc.rb: -------------------------------------------------------------------------------- 1 | class Gcc < Formula 2 | desc "GNU compiler collection" 3 | homepage "https://gcc.gnu.org/" 4 | 5 | head "svn://gcc.gnu.org/svn/gcc/trunk" 6 | 7 | stable do 8 | url "https://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.xz" 9 | mirror "https://ftpmirror.gnu.org/gcc/gcc-7.2.0/gcc-7.2.0.tar.xz" 10 | sha256 "1cf7adf8ff4b5aa49041c8734bbcf1ad18cc4c94d0029aae0f4e48841088479a" 11 | end 12 | 13 | bottle do 14 | sha256 "3b7606d2b98cf9ca5c25d2620d2c9d6c146a910f6063c071ac4bf5abdeb73faa" => :high_sierra 15 | sha256 "bc96bddd0e9f7c074eab7c4036973bc60d5d5ef4489e65db64018363d63d248d" => :sierra 16 | sha256 "755ed27d3aa9b60523aead68f36d17f6396b9f4b622a0972c05eae3302922d5c" => :el_capitan 17 | sha256 "eecedf7c9233bd1553d3e22027f415f15a9d1a7ad11e486855bf3a8f7d36ed23" => :yosemite 18 | end 19 | 20 | option "with-jit", "Build just-in-time compiler" 21 | option "with-nls", "Build with native language support (localization)" 22 | 23 | depends_on "gmp" 24 | depends_on "libmpc" 25 | depends_on "mpfr" 26 | depends_on "isl" 27 | 28 | # GCC bootstraps itself, so it is OK to have an incompatible C++ stdlib 29 | cxxstdlib_check :skip 30 | 31 | # The bottles are built on systems with the CLT installed, and do not work 32 | # out of the box on Xcode-only systems due to an incorrect sysroot. 33 | pour_bottle? do 34 | reason "The bottle needs the Xcode CLT to be installed." 35 | satisfy { MacOS::CLT.installed? } 36 | end 37 | 38 | def version_suffix 39 | if build.head? 40 | (stable.version.to_s.slice(/\d/).to_i + 1).to_s 41 | else 42 | version.to_s.slice(/\d/) 43 | end 44 | end 45 | 46 | # Fix for libgccjit.so linkage on Darwin 47 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64089 48 | # https://github.com/Homebrew/homebrew-core/issues/1872#issuecomment-225625332 49 | # https://github.com/Homebrew/homebrew-core/issues/1872#issuecomment-225626490 50 | patch do 51 | url "https://raw.githubusercontent.com/Homebrew/formula-patches/e9e0ee09389a54cc4c8fe1c24ebca3cd765ed0ba/gcc/6.1.0-jit.patch" 52 | sha256 "863957f90a934ee8f89707980473769cff47ca0663c3906992da6afb242fb220" 53 | end 54 | 55 | # Use -headerpad_max_install_names in the build, 56 | # otherwise lto1 load commands cannot be edited on El Capitan 57 | if MacOS.version == :el_capitan 58 | patch do 59 | url "https://raw.githubusercontent.com/Homebrew/formula-patches/32cf103/gcc/7.1.0-headerpad.patch" 60 | sha256 "dd884134e49ae552b51085116e437eafa63460b57ce84252bfe7a69df8401640" 61 | end 62 | end 63 | 64 | # Fix parallel build on APFS filesystem 65 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81797 66 | if MacOS.version >= :high_sierra 67 | patch do 68 | url "https://raw.githubusercontent.com/Homebrew/formula-patches/df0465c02a/gcc/apfs.patch" 69 | sha256 "f7772a6ba73f44a6b378e4fe3548e0284f48ae2d02c701df1be93780c1607074" 70 | end 71 | end 72 | 73 | def install 74 | # GCC will suffer build errors if forced to use a particular linker. 75 | ENV.delete "LD" 76 | 77 | # We avoiding building: 78 | # - Ada, which requires a pre-existing GCC Ada compiler to bootstrap 79 | # - Go, currently not supported on macOS 80 | # - BRIG 81 | languages = %w[c c++ objc obj-c++ fortran] 82 | 83 | # JIT compiler is off by default, enabling it has performance cost 84 | languages << "jit" if build.with? "jit" 85 | 86 | osmajor = `uname -r`.chomp 87 | 88 | args = [ 89 | "--build=x86_64-apple-darwin#{osmajor}", 90 | "--prefix=#{prefix}", 91 | "--libdir=#{lib}/gcc/#{version_suffix}", 92 | "--enable-languages=#{languages.join(",")}", 93 | # Make most executables versioned to avoid conflicts. 94 | "--program-suffix=-#{version_suffix}", 95 | "--with-gmp=#{Formula["gmp"].opt_prefix}", 96 | "--with-mpfr=#{Formula["mpfr"].opt_prefix}", 97 | "--with-mpc=#{Formula["libmpc"].opt_prefix}", 98 | "--with-isl=#{Formula["isl"].opt_prefix}", 99 | "--with-system-zlib", 100 | "--enable-checking=release", 101 | "--with-pkgversion=Homebrew GCC #{pkg_version} #{build.used_options*" "}".strip, 102 | "--with-bugurl=https://github.com/Homebrew/homebrew-core/issues", 103 | ] 104 | 105 | args << "--disable-nls" if build.without? "nls" 106 | args << "--enable-host-shared" if build.with?("jit") 107 | 108 | # Ensure correct install names when linking against libgcc_s; 109 | # see discussion in https://github.com/Homebrew/homebrew/pull/34303 110 | inreplace "libgcc/config/t-slibgcc-darwin", "@shlib_slibdir@", "#{HOMEBREW_PREFIX}/lib/gcc/#{version_suffix}" 111 | 112 | mkdir "build" do 113 | unless MacOS::CLT.installed? 114 | # For Xcode-only systems, we need to tell the sysroot path. 115 | # "native-system-headers" will be appended 116 | args << "--with-native-system-header-dir=/usr/include" 117 | args << "--with-sysroot=#{MacOS.sdk_path}" 118 | end 119 | 120 | system "../configure", *args 121 | system "make" 122 | system "make", "install" 123 | 124 | bin.install_symlink bin/"gfortran-#{version_suffix}" => "gfortran" 125 | end 126 | 127 | # Handle conflicts between GCC formulae and avoid interfering 128 | # with system compilers. 129 | # Rename man7. 130 | Dir.glob(man7/"*.7") { |file| add_suffix file, version_suffix } 131 | # Even when we disable building info pages some are still installed. 132 | info.rmtree 133 | end 134 | 135 | def add_suffix(file, suffix) 136 | dir = File.dirname(file) 137 | ext = File.extname(file) 138 | base = File.basename(file, ext) 139 | File.rename file, "#{dir}/#{base}-#{suffix}#{ext}" 140 | end 141 | 142 | test do 143 | (testpath/"hello-c.c").write <<~EOS 144 | #include 145 | int main() 146 | { 147 | puts("Hello, world!"); 148 | return 0; 149 | } 150 | EOS 151 | system "#{bin}/gcc-#{version_suffix}", "-o", "hello-c", "hello-c.c" 152 | assert_equal "Hello, world!\n", `./hello-c` 153 | 154 | (testpath/"hello-cc.cc").write <<~EOS 155 | #include 156 | int main() 157 | { 158 | std::cout << "Hello, world!" << std::endl; 159 | return 0; 160 | } 161 | EOS 162 | system "#{bin}/g++-#{version_suffix}", "-o", "hello-cc", "hello-cc.cc" 163 | assert_equal "Hello, world!\n", `./hello-cc` 164 | 165 | (testpath/"test.f90").write <<~EOS 166 | integer,parameter::m=10000 167 | real::a(m), b(m) 168 | real::fact=0.5 169 | 170 | do concurrent (i=1:m) 171 | a(i) = a(i) + fact*b(i) 172 | end do 173 | write(*,"(A)") "Done" 174 | end 175 | EOS 176 | system "#{bin}/gfortran", "-o", "test", "test.f90" 177 | assert_equal "Done\n", `./test` 178 | end 179 | end 180 | --------------------------------------------------------------------------------