-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
240 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import os | ||
import yaml | ||
import tempfile | ||
import argparse | ||
import get_asset_info | ||
from typing import Optional, List | ||
|
||
from deploy import download, mkdir_p, extract, rm_rf | ||
|
||
|
||
# デプロイしたいコンパイラ | ||
def get_heads(filename) -> List[str]: | ||
with open(filename) as f: | ||
data = yaml.load(f, Loader=yaml.Loader) | ||
r = [] | ||
for name in data['jobs']['heads']['strategy']['matrix']['name']: | ||
r.append(name) | ||
return r | ||
|
||
|
||
def find_download_url(asset_info, name): | ||
name = f"{name}.tar.gz" | ||
for obj in asset_info: | ||
if obj['name'] == name: | ||
return name, obj['url'] | ||
raise Exception(f'{name} not in asset info') | ||
|
||
|
||
# デプロイする | ||
def deploy(head: str, version_dir: str, deploy_dir: str, download_url: str, archive_name: str, github_token: Optional[str] = None): | ||
with tempfile.TemporaryDirectory() as tempdir: | ||
# コンパイラをダウンロード | ||
header_args = ["-H", "Accept: application/octet-stream"] | ||
if github_token is not None: | ||
header_args += ["-H", f"Authorization: token {github_token}"] | ||
# なんかよく切断されるのでリトライを設定する | ||
header_args += ["--retry", "5"] | ||
|
||
archive_path = download(download_url, tempdir, archive_name, header_args) | ||
|
||
# テンポラリディレクトリ上に解凍 | ||
mkdir_p(version_dir) | ||
extract_path = extract(archive_path, tempdir) | ||
|
||
# バージョンファイルと本体を消して、解凍した新しいバージョンを配置する | ||
version_path = os.path.join(version_dir, head) | ||
if os.path.exists(version_path): | ||
with open(version_path, 'rb') as f: | ||
rm_rf(f.read().decode('utf-8')) | ||
rm_rf(version_path) | ||
|
||
mkdir_p(deploy_dir) | ||
deploy_path = os.path.join(deploy_dir, head) | ||
os.rename(extract_path, deploy_path) | ||
|
||
# デプロイ完了したのでバージョン情報とパスを書き込む | ||
with open(version_path, 'wb') as f: | ||
f.write(deploy_path.encode('utf-8')) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("url") | ||
parser.add_argument("--github_token", default=None) | ||
|
||
args = parser.parse_args() | ||
|
||
# 各コンパイラのダウンロード URL を取得する | ||
asset_info = get_asset_info.get_asset_info(args.url, args.github_token) | ||
|
||
version_dir = '/opt/wandbox-data/wandbox-deploy-heads' | ||
deploy_dir = '/opt/wandbox' | ||
|
||
heads = get_heads('.github/workflows/heads.yml') | ||
for head in heads: | ||
name, download_url = find_download_url(asset_info, head) | ||
deploy(head, version_dir, deploy_dir, download_url, name, args.github_token) | ||
|
||
|
||
BASE_DIR = os.path.abspath(os.path.dirname(__file__)) | ||
|
||
|
||
if __name__ == '__main__': | ||
os.chdir(BASE_DIR) | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
PREFIX=/opt/wandbox/clang-head | ||
|
||
apt-get update | ||
apt-get install -y \ | ||
build-essential \ | ||
clang-12 \ | ||
coreutils \ | ||
git \ | ||
libgmp-dev \ | ||
libmpc-dev \ | ||
libmpfr-dev \ | ||
libtool \ | ||
python3 \ | ||
wget | ||
|
||
CMAKE_VERSION="3.16.3" | ||
CMAKE_SHA256="3e15dadfec8d54eda39c2f266fc1e571c1b88bf32f9d221c8a039b07234206fa" | ||
|
||
CMAKE_PREFIX="/usr/local/wandbox/camke-${CMAKE_VERSION}" | ||
|
||
wget https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz | ||
echo "${CMAKE_SHA256} *cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz" | sha256sum -c | ||
tar xf cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz | ||
mkdir -p /usr/local/wandbox/ | ||
mv cmake-${CMAKE_VERSION}-Linux-x86_64 $CMAKE_PREFIX | ||
|
||
mkdir -p ~/tmp/clang-head/ | ||
cd ~/tmp/clang-head/ | ||
|
||
# get sources | ||
|
||
git clone --depth 1 https://github.com/llvm/llvm-project.git | ||
|
||
# build | ||
|
||
mkdir build | ||
|
||
# case %{_host_cpu} in | ||
# i?86* | amd64* | x86_64*) arch="X86" ;; | ||
# sparc*) arch="Sparc" ;; | ||
# powerpc*) arch="PowerPC" ;; | ||
# arm*) arch="ARM" ;; | ||
# aarch64*) arch="AArch64" ;; | ||
# mips* | mips64*) arch="Mips" ;; | ||
# xcore*) arch="XCore" ;; | ||
# msp430*) arch="MSP430" ;; | ||
# hexagon*) arch="Hexagon" ;; | ||
# nvptx*) arch="NVPTX" ;; | ||
# s390x*) arch="SystemZ" ;; | ||
# *) arch="Unknown" ;; | ||
# esac | ||
cd build | ||
|
||
export CC="clang-12" | ||
export CXX="clang++-12" | ||
/usr/local/wandbox/camke-3.16.3/bin/cmake -G "Unix Makefiles" \ | ||
-DCMAKE_BUILD_TYPE=Release \ | ||
-DCMAKE_INSTALL_PREFIX=$PREFIX \ | ||
-DLLVM_ENABLE_PROJECTS="clang;compiler-rt;clang-tools-extra;libcxx;libcxxabi" \ | ||
../llvm-project/llvm | ||
make -j`nproc` | ||
make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
set -ex | ||
|
||
PREFIX=/opt/wandbox/gcc-head | ||
|
||
apt-get update | ||
apt-get install -y \ | ||
bison \ | ||
build-essential \ | ||
coreutils \ | ||
curl \ | ||
flex \ | ||
git \ | ||
libgmp-dev \ | ||
libmpc-dev \ | ||
libmpfr-dev \ | ||
libtool \ | ||
m4 \ | ||
unzip \ | ||
wget | ||
|
||
# get sources | ||
|
||
mkdir ~/gcc-head | ||
cd ~/gcc-head | ||
|
||
git clone --depth 1 https://github.com/gcc-mirror/gcc.git source | ||
|
||
# build | ||
|
||
mkdir build | ||
cd build | ||
../source/configure \ | ||
--prefix=$PREFIX \ | ||
--enable-languages=c,c++ \ | ||
--disable-multilib \ | ||
--without-ppl \ | ||
--without-cloog-ppl \ | ||
--enable-checking=release \ | ||
--disable-nls \ | ||
--enable-lto \ | ||
LDFLAGS="-Wl,-rpath,$PREFIX/lib,-rpath,$PREFIX/lib64,-rpath,$PREFIX/lib32" | ||
|
||
make -j`nproc` | ||
rm -rf $PREFIX | ||
make install |