diff --git a/.github/workflows/llvm.yml b/.github/workflows/llvm.yml new file mode 100644 index 00000000..11a3129f --- /dev/null +++ b/.github/workflows/llvm.yml @@ -0,0 +1,79 @@ +name: Darwin LLVM build + +on: + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: false + default: 'warn' + type: choice + options: + - info + - warn + - debug + push: + branches: + - 267-llvm_bin-universal + - '*build-llvm*' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + LLVM_VERSION: 15.0.7 + MACOSX_DEPLOYMENT_TARGET: 10.11 + LOG_LEVEL: ${{ inputs.logLevel || 'warn' }} + +jobs: + llvm-build: + runs-on: macos-11 + defaults: + run: + working-directory: ./omnibus + + steps: + - name: Select Xcode + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '13.2.1' + + - name: Download sources + uses: actions/checkout@v4 + + - name: Update development environment + run: | + brew update + brew install --display-times pkgconfig libtool cmake + + - name: Prepare folders + run: | + sudo mkdir -p /opt/llvm + sudo chown $(whoami) /opt/llvm/ + sudo mkdir -p /var/cache + sudo chown $(whoami) /var/cache + + - name: Install omnibus + run: bundle check || bundle install + + - name: Build llvm + run: bundle exec omnibus build llvm --log-level ${{ env.LOG_LEVEL }} --override use_git_caching:false + + # Reference: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files + - name: Extract the package name to be used for the artifact name + run: | + cd pkg + filename=$(ls -1 llvm-*.tar.gz) + echo "ARTIFACT_NAME=${filename%.tar.gz}" >> "$GITHUB_ENV" + + # When an Artifact is uploaded, all the files are assembled into an immutable Zip archive. + # https://github.com/actions/upload-artifact#zip-archives + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARTIFACT_NAME }} + path: omnibus/pkg/*.tar.gz + retention-days: 1 + if-no-files-found: error + compression-level: 0 # package is already compressed diff --git a/darwin/README.md b/darwin/README.md index 6f74d168..22e6d424 100644 --- a/darwin/README.md +++ b/darwin/README.md @@ -9,12 +9,18 @@ The whole process is automated using a `Makefile`. * `pkgconfig`, `libtool` (Can be installed by `$ brew install pkgconfig libtool`) * Own `/opt/crystal`, `/var/cache`. -``` +```shell sudo mkdir -p /opt/crystal sudo chown $(whoami) /opt/crystal/ sudo mkdir -p /var/cache sudo chown $(whoami) /var/cache ``` +* Optional: If you need to build LLVM, ensure the existence of the /opt/llvm directory. + +```shell +sudo mkdir -p /opt/llvm +sudo chown $(whoami) /opt/llvm/ +``` # Getting started diff --git a/omnibus/config/projects/llvm.rb b/omnibus/config/projects/llvm.rb index e0c0032b..02769cf1 100644 --- a/omnibus/config/projects/llvm.rb +++ b/omnibus/config/projects/llvm.rb @@ -18,6 +18,9 @@ def valid_cmake_version? dependency 'cmake' unless valid_cmake_version? dependency 'llvm' + +# Requires for tgz_package to generate a proper archive name with sufix universal. +ohai['target_arch'] = 'universal' dependency 'tgz_package' if macos? || mac_os_x? || centos? exclude '\.git*' diff --git a/omnibus/config/software/llvm_bin.rb b/omnibus/config/software/llvm_bin.rb index eaa62b1f..5b0eacb0 100644 --- a/omnibus/config/software/llvm_bin.rb +++ b/omnibus/config/software/llvm_bin.rb @@ -18,7 +18,11 @@ raise "llvm_bin not supported" end -source url: "http://crystal-lang.s3.amazonaws.com/llvm/llvm-#{version}-#{ohai['os']}-#{ohai['kernel']['machine']}.tar.gz", +platform = ohai['os'] +# Currently, it is considered `universal` based on the alterations made in the commit 'ed5f1f97e0a67157d886dd6675902e35199a1ab3' +arch = "x86_64" + +source url: "http://crystal-lang.s3.amazonaws.com/llvm/llvm-#{version}-#{platform}-#{arch}.tar.gz", md5: source_md5 relative_path "llvm-#{version}" diff --git a/omnibus/config/software/tgz_package.rb b/omnibus/config/software/tgz_package.rb index 200754f8..45482301 100644 --- a/omnibus/config/software/tgz_package.rb +++ b/omnibus/config/software/tgz_package.rb @@ -4,10 +4,12 @@ build do block do + platform = ohai['os'] + target_arch = ohai['target_arch'] || ohai['kernel']['machine'] destination = File.expand_path('pkg', Omnibus::Config.project_root) version = "#{project.build_version}-#{project.build_iteration}" version.gsub!("/", "-") - tgz_name = "#{project.name}-#{version}-#{ohai['os']}-#{ohai['kernel']['machine']}.tar.gz" + tgz_name = "#{project.name}-#{version}-#{platform}-#{target_arch}.tar.gz" if macos? || mac_os_x? transform = "-s /./#{project.name}-#{version}/" else @@ -16,5 +18,10 @@ command "tar czf #{destination}/#{tgz_name} #{transform} -C #{install_dir} .", env: {"COPYFILE_DISABLE" => "1"} + + # NOTE: For environments not in English, git_cache function expected to see message + # from git `nothing to commit`, otherwise it raises the error. + # It creates a empty file to commit something. + command "date > #{install_dir}/tgz_package_done.log" end end