Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
zhfnjust committed Nov 8, 2024
0 parents commit def00e6
Show file tree
Hide file tree
Showing 10 changed files with 370 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This is a basic workflow to help you get started with Actions

name: Download Compiler

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ master ]
pull_request:
branches: [ master ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v2
with:
node-version: 14.x

- name: Download Compiler
run: npm run dl
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
scryptc
out
node_modules

**/.DS_Store
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# compiler_dist
distribute compiler binaries for various operating systems
31 changes: 31 additions & 0 deletions checkdl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const { spawn, spawnSync } = require('child_process');
const { join } = require('path');
const { platform } = require('os');
const { exit } = require('process');

let FILENAME = "./scryptc/win32/scryptc.exe"

if (platform() === 'linux') {
FILENAME = "./scryptc/linux/scryptc"
} else if (platform() === 'darwin') {
FILENAME = "./scryptc/mac/scryptc"
}

const output = spawnSync(join(__dirname, FILENAME), ['version']).stdout.toString();

const content = require("fs").readFileSync("./tag.json");

const version = JSON.parse(content).tag_name.toString().substr(1);

console.log('version', version, 'output', output)


if(version.indexOf("beta") > -1) {
console.warn('beta version skip check')
exit(0)
}
if(output.indexOf(version) < 0){
console.error('version check fail')
exit(-1)
}

51 changes: 51 additions & 0 deletions downloadcompiler.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
COMPILER_VERSION=1.19.1
GITHUB_OWNER=sCrypt-Inc
GITHUB_REPO=compiler_dist
GITHUB_TAG="v$COMPILER_VERSION"
GITHUB_ASSET_FILENAME_WINDOWS="./scryptc/win32/scryptc.exe"
GITHUB_ASSET_FILENAME_LINUX="./scryptc/linux/scryptc"
GITHUB_ASSET_FILENAME_LINUX_ARM="./scryptc/linux-aarch64/scryptc"
GITHUB_ASSET_FILENAME_MACOS="./scryptc/mac/scryptc"
echo "$GITHUB_OWNER"
echo "$GITHUB_REPO"
echo "$GITHUB_TAG"

rm -rf "./scryptc"

mkdir -p "./scryptc/win32/"
mkdir -p "./scryptc/linux/"
mkdir -p "./scryptc/linux-aarch64/"
mkdir -p "./scryptc/mac/"

#we just update tag.json locally when you change COMPILER_VERSION, because github api has daily limit.
#curl -sSL -J "https://api.github.com/repos/${GITHUB_OWNER}/${GITHUB_REPO}/releases/tags/${GITHUB_TAG}" > tag.json

GITHUB_LINUX_ASSET_URL=$(node parser.js Linux-x86_64)
GITHUB_LINUX_ARM_ASSET_URL=$(node parser.js Linux-aarch64)
GITHUB_MACOS_ASSET_URL=$(node parser.js macOS-x86_64)
GITHUB_WINDOWS_ASSET_URL=$(node parser.js Windows-AMD64)


echo "$GITHUB_MACOS_ASSET_URL"
echo "$GITHUB_WINDOWS_ASSET_URL"
echo "$GITHUB_LINUX_ASSET_URL"
echo "$GITHUB_LINUX_ARM_ASSET_URL"

if [ $GITHUB_MACOS_ASSET_URL != "no_assets" ]; then
curl -L -J ${GITHUB_MACOS_ASSET_URL} -o ${GITHUB_ASSET_FILENAME_MACOS} -H 'Accept: application/octet-stream'
chmod u+x "$GITHUB_ASSET_FILENAME_MACOS"
fi

if [ $GITHUB_LINUX_ASSET_URL != "no_assets" ]; then
curl -L -J ${GITHUB_LINUX_ASSET_URL} -o ${GITHUB_ASSET_FILENAME_LINUX} -H 'Accept: application/octet-stream'
chmod u+x "$GITHUB_ASSET_FILENAME_LINUX"
fi

if [ $GITHUB_LINUX_ARM_ASSET_URL != "no_assets" ]; then
curl -L -J ${GITHUB_LINUX_ARM_ASSET_URL} -o ${GITHUB_ASSET_FILENAME_LINUX_ARM} -H 'Accept: application/octet-stream'
chmod u+x "$GITHUB_ASSET_FILENAME_LINUX_ARM"
fi

if [ $GITHUB_WINDOWS_ASSET_URL != "no_assets" ]; then
curl -L -J ${GITHUB_WINDOWS_ASSET_URL} -o ${GITHUB_ASSET_FILENAME_WINDOWS} -H 'Accept: application/octet-stream'
fi
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "compiler",
"version": "0.0.10",
"description": "sCryptc compiler wrapper",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dl": "sh ./downloadcompiler.sh",
"postdl": "node checkdl.js"
},
"author": "",
"license": "ISC",
"hash": {
"win32": "d486f586e31e4623473effec41dde430036b34cf254f564ba938451d23781c65",
"linux": "1ce35d405657a76eaa4a0e9fff0d0e4ea2b9c231e9cf846f25f55aa7b65c68a8",
"mac": "589bfb5de3ee22c5df453743e83ace8e4ecd24a00d2d87d316af855e3247058e"
}
}
26 changes: 26 additions & 0 deletions parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@



const content = require("fs").readFileSync("./tag.json");

const tagInfo = JSON.parse(content);

if(!Array.isArray(tagInfo["assets"])) {
console.log("no_assets")
process.exit(0);
}

getAssetId(process.argv[2]);


function getAssetId(p) {
for(let i=0; i< tagInfo["assets"].length; i++ ) {
if(tagInfo["assets"][i].name.indexOf(p) > -1) {
console.log(tagInfo["assets"][i].browser_download_url);
process.exit(0);
return;
}
}

console.log("no_assets");
}
7 changes: 7 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const SCRYPTC_VERSION = "0.0.10";
export const DEFAULT_COMPILE_OPTS = Object.freeze({
ast: false,
debug: false,
asm: true,
cmdArgs: '--std'
});
176 changes: 176 additions & 0 deletions tag.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
{
"url": "https://api.github.com/repos/sCrypt-Inc/compiler_dist/releases/125140960",
"assets_url": "https://api.github.com/repos/sCrypt-Inc/compiler_dist/releases/125140960/assets",
"upload_url": "https://uploads.github.com/repos/sCrypt-Inc/compiler_dist/releases/125140960/assets{?name,label}",
"html_url": "https://github.com/sCrypt-Inc/compiler_dist/releases/tag/v1.19.1",
"id": 125140960,
"author": {
"login": "scrypt-sv",
"id": 52027588,
"node_id": "MDQ6VXNlcjUyMDI3NTg4",
"avatar_url": "https://avatars.githubusercontent.com/u/52027588?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/scrypt-sv",
"html_url": "https://github.com/scrypt-sv",
"followers_url": "https://api.github.com/users/scrypt-sv/followers",
"following_url": "https://api.github.com/users/scrypt-sv/following{/other_user}",
"gists_url": "https://api.github.com/users/scrypt-sv/gists{/gist_id}",
"starred_url": "https://api.github.com/users/scrypt-sv/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/scrypt-sv/subscriptions",
"organizations_url": "https://api.github.com/users/scrypt-sv/orgs",
"repos_url": "https://api.github.com/users/scrypt-sv/repos",
"events_url": "https://api.github.com/users/scrypt-sv/events{/privacy}",
"received_events_url": "https://api.github.com/users/scrypt-sv/received_events",
"type": "User",
"site_admin": false
},
"node_id": "RE_kwDOEskUbM4HdX_g",
"tag_name": "v1.19.1",
"target_commitish": "master",
"name": "refs/tags/v1.19.1",
"draft": false,
"prerelease": false,
"created_at": "2022-11-01T09:44:49Z",
"published_at": "2023-10-15T20:44:20Z",
"assets": [
{
"url": "https://api.github.com/repos/sCrypt-Inc/compiler_dist/releases/assets/130747220",
"id": 130747220,
"node_id": "RA_kwDOEskUbM4HywtU",
"name": "scrypt-1.19.1-Linux-aarch64",
"label": "",
"uploader": {
"login": "scrypt-sv",
"id": 52027588,
"node_id": "MDQ6VXNlcjUyMDI3NTg4",
"avatar_url": "https://avatars.githubusercontent.com/u/52027588?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/scrypt-sv",
"html_url": "https://github.com/scrypt-sv",
"followers_url": "https://api.github.com/users/scrypt-sv/followers",
"following_url": "https://api.github.com/users/scrypt-sv/following{/other_user}",
"gists_url": "https://api.github.com/users/scrypt-sv/gists{/gist_id}",
"starred_url": "https://api.github.com/users/scrypt-sv/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/scrypt-sv/subscriptions",
"organizations_url": "https://api.github.com/users/scrypt-sv/orgs",
"repos_url": "https://api.github.com/users/scrypt-sv/repos",
"events_url": "https://api.github.com/users/scrypt-sv/events{/privacy}",
"received_events_url": "https://api.github.com/users/scrypt-sv/received_events",
"type": "User",
"site_admin": false
},
"content_type": "binary/octet-stream",
"state": "uploaded",
"size": 17801560,
"download_count": 1,
"created_at": "2023-10-15T20:59:11Z",
"updated_at": "2023-10-15T20:59:13Z",
"browser_download_url": "https://github.com/sCrypt-Inc/compiler_dist/releases/download/v1.19.1/scrypt-1.19.1-Linux-aarch64"
},
{
"url": "https://api.github.com/repos/sCrypt-Inc/compiler_dist/releases/assets/130745812",
"id": 130745812,
"node_id": "RA_kwDOEskUbM4HywXU",
"name": "scrypt-1.19.1-Linux-x86_64",
"label": "",
"uploader": {
"login": "scrypt-sv",
"id": 52027588,
"node_id": "MDQ6VXNlcjUyMDI3NTg4",
"avatar_url": "https://avatars.githubusercontent.com/u/52027588?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/scrypt-sv",
"html_url": "https://github.com/scrypt-sv",
"followers_url": "https://api.github.com/users/scrypt-sv/followers",
"following_url": "https://api.github.com/users/scrypt-sv/following{/other_user}",
"gists_url": "https://api.github.com/users/scrypt-sv/gists{/gist_id}",
"starred_url": "https://api.github.com/users/scrypt-sv/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/scrypt-sv/subscriptions",
"organizations_url": "https://api.github.com/users/scrypt-sv/orgs",
"repos_url": "https://api.github.com/users/scrypt-sv/repos",
"events_url": "https://api.github.com/users/scrypt-sv/events{/privacy}",
"received_events_url": "https://api.github.com/users/scrypt-sv/received_events",
"type": "User",
"site_admin": false
},
"content_type": "binary/octet-stream",
"state": "uploaded",
"size": 13048224,
"download_count": 0,
"created_at": "2023-10-15T20:44:21Z",
"updated_at": "2023-10-15T20:44:22Z",
"browser_download_url": "https://github.com/sCrypt-Inc/compiler_dist/releases/download/v1.19.1/scrypt-1.19.1-Linux-x86_64"
},
{
"url": "https://api.github.com/repos/sCrypt-Inc/compiler_dist/releases/assets/130746783",
"id": 130746783,
"node_id": "RA_kwDOEskUbM4Hywmf",
"name": "scrypt-1.19.1-macOS-x86_64",
"label": "",
"uploader": {
"login": "scrypt-sv",
"id": 52027588,
"node_id": "MDQ6VXNlcjUyMDI3NTg4",
"avatar_url": "https://avatars.githubusercontent.com/u/52027588?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/scrypt-sv",
"html_url": "https://github.com/scrypt-sv",
"followers_url": "https://api.github.com/users/scrypt-sv/followers",
"following_url": "https://api.github.com/users/scrypt-sv/following{/other_user}",
"gists_url": "https://api.github.com/users/scrypt-sv/gists{/gist_id}",
"starred_url": "https://api.github.com/users/scrypt-sv/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/scrypt-sv/subscriptions",
"organizations_url": "https://api.github.com/users/scrypt-sv/orgs",
"repos_url": "https://api.github.com/users/scrypt-sv/repos",
"events_url": "https://api.github.com/users/scrypt-sv/events{/privacy}",
"received_events_url": "https://api.github.com/users/scrypt-sv/received_events",
"type": "User",
"site_admin": false
},
"content_type": "binary/octet-stream",
"state": "uploaded",
"size": 5539504,
"download_count": 0,
"created_at": "2023-10-15T20:53:53Z",
"updated_at": "2023-10-15T20:53:54Z",
"browser_download_url": "https://github.com/sCrypt-Inc/compiler_dist/releases/download/v1.19.1/scrypt-1.19.1-macOS-x86_64"
},
{
"url": "https://api.github.com/repos/sCrypt-Inc/compiler_dist/releases/assets/130746634",
"id": 130746634,
"node_id": "RA_kwDOEskUbM4HywkK",
"name": "scrypt-1.19.1-Windows-AMD64.exe",
"label": "",
"uploader": {
"login": "scrypt-sv",
"id": 52027588,
"node_id": "MDQ6VXNlcjUyMDI3NTg4",
"avatar_url": "https://avatars.githubusercontent.com/u/52027588?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/scrypt-sv",
"html_url": "https://github.com/scrypt-sv",
"followers_url": "https://api.github.com/users/scrypt-sv/followers",
"following_url": "https://api.github.com/users/scrypt-sv/following{/other_user}",
"gists_url": "https://api.github.com/users/scrypt-sv/gists{/gist_id}",
"starred_url": "https://api.github.com/users/scrypt-sv/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/scrypt-sv/subscriptions",
"organizations_url": "https://api.github.com/users/scrypt-sv/orgs",
"repos_url": "https://api.github.com/users/scrypt-sv/repos",
"events_url": "https://api.github.com/users/scrypt-sv/events{/privacy}",
"received_events_url": "https://api.github.com/users/scrypt-sv/received_events",
"type": "User",
"site_admin": false
},
"content_type": "binary/octet-stream",
"state": "uploaded",
"size": 13845504,
"download_count": 0,
"created_at": "2023-10-15T20:52:47Z",
"updated_at": "2023-10-15T20:52:48Z",
"browser_download_url": "https://github.com/sCrypt-Inc/compiler_dist/releases/download/v1.19.1/scrypt-1.19.1-Windows-AMD64.exe"
}
],
"tarball_url": "https://api.github.com/repos/sCrypt-Inc/compiler_dist/tarball/v1.19.1",
"zipball_url": "https://api.github.com/repos/sCrypt-Inc/compiler_dist/zipball/v1.19.1",
"body": "Compiler binaries"
}
20 changes: 20 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"outDir": "./out",
"alwaysStrict": true,
"sourceMap": true,
"resolveJsonModule": true,
"moduleResolution": "node",
"declaration": true,
"declarationDir": "./out",
"rootDir": "src",
"lib": [
"es2020"
],
"composite": true
},
"include": ["src"],
"exclude": ["node_modules", "scryptc"]
}

0 comments on commit def00e6

Please sign in to comment.