Skip to content

Commit

Permalink
try out bazel_upgradable (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
fenollp authored May 1, 2020
1 parent 1244625 commit c4210ad
Show file tree
Hide file tree
Showing 28 changed files with 1,439 additions and 305 deletions.
8 changes: 7 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@ build --jobs 128
build --cxxopt='-std=c++17'

build --copt=-fdiagnostics-color=always
run --copt=-fdiagnostics-color=always
run --copt=-fdiagnostics-color=always

# Dependencies locking
sync --experimental_repository_resolved_file=resolved.bzl
build --experimental_resolved_file_instead_of_workspace=resolved.bzl
build --experimental_repository_hash_file=resolved.bzl
build --experimental_verify_repository_rules=@bazel_tools//tools/build_defs/repo:git.bzl%git_repository
17 changes: 17 additions & 0 deletions .github/workflows/vsenv.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@echo off

SET VSWHERE="C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere"

:: See https://github.com/microsoft/vswhere/wiki/Find-VC
for /f "usebackq delims=*" %%i in (`%VSWHERE% -latest -property installationPath`) do (
call "%%i"\Common7\Tools\vsdevcmd.bat %*
)

:: Loop over all environment variables and make them global using set-env.
:: See: https://help.github.com/en/articles/development-tools-for-github-actions#set-an-environment-variable-set-env
:: See: https://stackoverflow.com/questions/39183272/loop-through-all-environmental-variables-and-take-actions-depending-on-prefix
setlocal
for /f "delims== tokens=1,2" %%a in ('set') do (
echo ::set-env name=%%a::%%b
)
endlocal
66 changes: 66 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
on: push
name: Build
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BAZELISK_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build_on_ubuntu:
name: Build on ubuntu
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install
run: sudo apt update && sudo apt-get install -y libgl1-mesa-dev xorg-dev
- run: bazelisk build voidstar

build_on_macos:
name: Build on macos
runs-on: macos-latest
steps:
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- uses: actions/checkout@v2
- run: bazelisk build voidstar

build_on_windows:
name: Build on windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v2

# Trying to install & use GCC
# From https://github.com/onqtam/doctest/pull/285/files
- name: Install (Windows)
shell: powershell
run: |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
scoop install ninja --global
#if ("${{ matrix.compiler }}".StartsWith("clang")) {
# scoop install llvm --global
#}
#if ("${{ matrix.compiler }}" -eq "gcc") {
# Chocolatey GCC is broken on the windows-2019 image.
# See: https://github.com/DaanDeMeyer/doctest/runs/231595515
# See: https://github.community/t5/GitHub-Actions/Something-is-wrong-with-the-chocolatey-installed-version-of-gcc/td-p/32413
scoop install gcc --global
echo "::set-env name=CC::gcc"
echo "::set-env name=CXX::g++"
#} elseif ("${{ matrix.compiler }}" -eq "clang") {
# echo "::set-env name=CC::clang"
# echo "::set-env name=CXX::clang++"
#} else {
# echo "::set-env name=CC::${{ matrix.compiler }}"
# echo "::set-env name=CXX::${{ matrix.compiler }}"
#}
# Scoop modifies the PATH so we make the modified PATH global.
echo "::set-env name=PATH::$env:PATH"
- name: Configure x64
run: .github\workflows\vsenv.bat -arch=x64 -host_arch=x64

- shell: bash
run: |
gcc --version || true
clang --version || true
- run: bazelisk build voidstar
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
travis-miners

/build

/parts
/prime
/snap/.snapcraft
/stage
/voidstar_*.snap
/bazel-*
74 changes: 2 additions & 72 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,11 @@
sudo: false
language: cpp
compiler:
- clang
- gcc
os:
- osx
- linux

addons:
apt:
packages:
- libglew-dev
- xorg-dev
- libgl1-mesa-dev
- libc++-dev
- cppcheck

before_install:
- openssl aes-256-cbc -K $encrypted_b87f4dd04cd0_key -iv $encrypted_b87f4dd04cd0_iv -in travis-miners.enc -out travis-miners -d

install:
- |
case "$TRAVIS_OS_NAME" in
'osx')
travis_wait 15 brew update
travis_wait 15 brew install glew
curl -#fSLo ./bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-darwin-amd64 && chmod +x ./bazel
;;
'linux')
curl -#fSLo ./bazel https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 && chmod +x ./bazel
;;
esac
before_script:
- ./bazel --version || true
- $CC --version || true
- $CXX --version || true

script:
- ./bazel build //voidstar
- ./bazel-bin/voidstar/voidstar -h
- ./bazel-bin/voidstar/voidstar --help
- ./bazel-bin/voidstar/voidstar -l
- ./bazel-bin/voidstar/voidstar --list
#- ./bazel-bin/voidstar/voidstar $(echo */)
- mv -v bazel-bin/voidstar/voidstar "bazel-bin/voidstar/voidstar-$(git describe --abbrev --dirty --always --tags)-$TRAVIS_OS_NAME-$(basename $CC)"
- if [[ "$TRAVIS_OS_NAME" = 'linux' ]]; then cppcheck --error-exitcode=1 --enable=all -Ivoidstar/include/ voids tar/; fi

after_success:
- |
if [[ "$TRAVIS_SECURE_ENV_VARS" == 'true' ]] && [[ "$TRAVIS_BRANCH" == 'master' ]] && [[ "$TRAVIS_PULL_REQUEST" == 'false' ]] && [[ "$TRAVIS_OS_NAME" == 'linux' ]]; then
major=v1
minor="$(($(git describe --tags | grep $major | cut -d. -f2) + 1))"
tag=$major.$minor.$TRAVIS_BUILD_ID
echo Tag: $tag
msg="$(git log -1 --pretty=%B | head -n 1)"
echo "Message: $msg"
echo Commit: $TRAVIS_COMMIT
if [[ 0 -ne "$(git tag --contains $TRAVIS_COMMIT | wc -l)" ]]; then echo 'Already tagged this commit!' && exit 0; fi
git config --global user.email '[email protected]'
git config --global user.name 'Autotag'
git remote set-url origin [email protected]:$TRAVIS_REPO_SLUG.git
git tag -a $tag -m "$msg" $TRAVIS_COMMIT
chmod 600 travis-miners
eval `ssh-agent -s`
ssh-add travis-miners
echo Tagging $TRAVIS_COMMIT with $tag
git push --tags || true
fi
deploy:
provider: releases
api_key:
secure: cu/xvTwEXo4SD9BUb84dRSBCu8NB5KaHEFhERVlwGd9feKllpRpo1Vaflwzmoa/JEpdq5cgIV4b4f8OUtmPHlCeHq0nq6l7+Sl0p0yW0juSH0rDvJgJTde+Rma70RKVjz4mgtgLHa/PKNBHbdPl3kmVQ/aUZtF1qYN6ObiS+a+gIFQcUX0IQfJhBHRLxmc94ozW/9FxXzz0zhENeE8PWAMhAWdmxHnlYQPBuWw6EYsbzhD5s1lkywzBNprJ+XTqtc7dgTUUwZ7UkkhpQ4RrfRzjJUpKb2pjDo+8WZhsCjYnQRTCquKF4eoDM2barD/KuzRx/W+pD+eLZG7NLlm4t592mVwO+p9py330+UgS8JdNl+GJfq9QrK23Uo6FMaG/SoHO1qFd5J5RHdFO0QhCKj/BxSirayc0Jv4e04X7a8ssasIX19KpINiZO/kQZAhioumm7UXLo6cKn1nzPbPkZJ7efvKkauSMCkQgd/UZ07P3ZxgEYn9eU3KLohNq1HFxCoBsCwSXSqSkUAVRA0QAgJBUCeD/ZCuRi5icgbi7AT/OeiP0YXoi1o6aGqMIp5AQ3ysSOosJRuwSjbeZ1YgxonqVYATH1jJPg0fzyPASLGIx90UN8MmBxe/CXk0gNOrf3TTYYgdWErwB1lRcbb0fZvYfu/FDb3vp2tQjTrM/Q+qY=
skip_cleanup: true
overwrite: true
file_glob: true
file: bazel-bin/voidstar/voidstar-*
on:
tags: true
# - mv -v bazel-bin/voidstar/voidstar "bazel-bin/voidstar/voidstar-$(git describe --abbrev --dirty --always --tags)-$TRAVIS_OS_NAME-$(basename $CC)"
- cppcheck --error-exitcode=1 --enable=all -Ivoidstar/include/ voids tar/
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
licenses(["notice"])
exports_files(["LICENSE"])
15 changes: 0 additions & 15 deletions Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions Dockerfile.dev

This file was deleted.

5 changes: 0 additions & 5 deletions LOCKFILE.bzl

This file was deleted.

27 changes: 4 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ The actual file being represented below [is data/BigPictureBG.tga](http://www.do
## Usage

```shell
bazel build //voidstar
./bazel-bin/voidstar/voidstar --move ../data/*
bazel build voidstar
./bazel-bin/voidstar/voidstar --move bazel-bin/voidstar/voidstar data/*
```

```
Expand Down Expand Up @@ -83,14 +83,13 @@ mv your/interesting/files/* data/

1. Download one of the `osx` files of [the latest release](https://github.com/fenollp/voidstar/releases/latest)
1. Open Terminal.app (you can search for it in Spotlight)
1. Type `brew install glew` then press ENTER. This installs the GLEW dependency.
1. Type `chmod u+x ` then drag and drop the file you downloaded then press ENTER (now this file can be executed)
1. Now drag and drop your executable then drag a file you want to look at (e.g. `data/dragon.vox`) then press ENTER
1. A window should appear. Move your mouse and play with your keyboard's arrows. You should see some colored dots in 3D.

### on any Linux distribution

`sudo snap install voidstar`
`snap install voidstar`

This relies on [snaps](https://snapcraft.io/docs/core/install).

Expand All @@ -107,23 +106,5 @@ https://github.com/fenollp/voidstar/issues/2
### Debian

```shell
sudo apt install libglew-dev
sudo apt-get install mesa-common-dev libegl1-mesa-dev libgles2-mesa-dev xorg-dev
```

### OSX

```shell
brew install glew
```

### Web

https://github.com/fenollp/voidstar/issues/9

### Android

https://github.com/fenollp/voidstar/issues/7

### iOS

https://github.com/fenollp/voidstar/issues/8
72 changes: 45 additions & 27 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,46 +1,64 @@
workspace(name = "voidstar")

load("@bazel_tools//tools/build_defs/repo:http.bzl", bare_http_archive = "http_archive")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

bare_http_archive(
name = "bazel_lock",
# Locked on 2020-04-04
sha256 = "ce1a1c3753b970419c8d5ea3e5afbc24ad62beacbb32c48672186c78411540f8",
strip_prefix = "bazel_lock-081217b3d17d9a8a817eb8fd4ec6058145126a2c",
type = "zip",
url = "https://github.com/fenollp/bazel_lock/archive/081217b3d17d9a8a817eb8fd4ec6058145126a2c.zip",
http_archive(
name = "bazel_upgradable",
strip_prefix = "bazel_upgradable-0.1.1",
url = "https://github.com/fenollp/bazel_upgradable/archive/0.1.1.zip",
)

load("@bazel_lock//rules:locked.bzl", "http_archive")
load("//:LOCKFILE.bzl", "locked")
load("@bazel_upgradable//:rule.bzl", "upgradable_repository")

http_archive(
upgradable_repository(
name = "rules_cc",
locked = locked,
type = "zip",
upgrades_slug = "github.com/bazelbuild/rules_cc",
remote = "git://github.com/bazelbuild/rules_cc.git",
)

http_archive(
upgradable_repository(
name = "khronos_opengl_registry",
build_file = "@//third_party:gl.BUILD",
locked = locked,
type = "tar.gz",
upgrades_slug = "github.com/KhronosGroup/OpenGL-Registry",
remote = "git://github.com/KhronosGroup/OpenGL-Registry.git",
)

http_archive(
upgradable_repository(
name = "glfw",
build_file = "@//third_party:glfw3.BUILD",
locked = locked,
type = "zip",
upgrades_slug = "github.com/glfw/glfw",
remote = "git://github.com/glfw/glfw.git",
)

http_archive(
name = "com_github_gtruc_glm",
upgradable_repository(
name = "glfw_osx",
build_file = "@//third_party:glfw3_osx.BUILD",
release = "glfw-{tag_digits}.bin.MACOS.zip",
remote = "git://github.com/glfw/glfw.git",
strip_prefix = "glfw-{tag_digits}.bin.MACOS",
tag = "~3",
)

upgradable_repository(
name = "glm",
build_file = "@//third_party:glm.BUILD",
locked = locked,
type = "zip",
upgrades_slug = "github.com/g-truc/glm",
remote = "git://github.com/g-truc/glm.git",
)

glew_version_constraint = "<=2"

upgradable_repository(
name = "glew",
build_file = "@//third_party:glew.BUILD",
release = "{tag}.tgz",
remote = "git://github.com/nigels-com/glew.git",
strip_prefix = "glew-{tag_digits}",
tag = glew_version_constraint,
type = "tar.gz",
)

upgradable_repository(
name = "glew_win64",
build_file = "@//third_party:glew_win64.BUILD",
release = "{tag}-win32.zip",
remote = "git://github.com/nigels-com/glew.git",
strip_prefix = "glew-{tag_digits}",
tag = glew_version_constraint,
)
17 changes: 0 additions & 17 deletions docker-dev.sh

This file was deleted.

Loading

0 comments on commit c4210ad

Please sign in to comment.