Skip to content

Commit

Permalink
porting from gitlab
Browse files Browse the repository at this point in the history
  • Loading branch information
orzklv committed Aug 3, 2024
0 parents commit bf6829e
Show file tree
Hide file tree
Showing 45 changed files with 11,053 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release

permissions:
contents: write

on:
push:
tags:
- v[0-9]+.*

jobs:
create-release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: taiki-e/create-gh-release-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}

upload-assets:
strategy:
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@v1
with:
target: ${{ matrix.target }}

- name: Update system packages
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get upgrade -y

- name: Install required libraries (Linux)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install build-essential llvm clang libgccjit-12-dev
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/12/libgccjit.so /usr/lib/libgccjit.so
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/12/include/libgccjit.h /usr/include/libgccjit.h
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/12/include/libgccjit++.h /usr/include/libgccjit++.h
- name: Install required libraries (MacOS)
if: matrix.os == 'macos-latest'
run: brew install llvm gcc libgccjit cmake autoconf automake

- name: Link libgccjit at global path
if: matrix.os == 'macos-latest'
run: |
ln -s "$(brew --prefix)/lib/gcc/current/libgccjit.0.dylib" "$(brew --prefix)/lib/libgccjit.0.dylib"
ln -s "$(brew --prefix)/lib/gcc/current/libgccjit.dylib" "$(brew --prefix)/lib/libgccjit.dylib"
- name: Export required PATHes
if: matrix.os == 'macos-latest'
run: |
export PATH="$(brew --prefix)/opt/llvm/bin:$PATH"
export CPATH="$(brew --prefix)/include"
export LIBRARY_PATH="$(brew --prefix)/lib"
export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib/gcc/current"
- name: Set complete profile
run: rustup set profile complete

- name: Change rust channel
run: rustup default nightly

- uses: taiki-e/upload-rust-binary-action@v1
with:
bin: osmon
tar: none
zip: all
target: ${{ matrix.target }}
token: ${{ secrets.GITHUB_TOKEN }}
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test CI

on: [push, pull_request]

env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Update system
run: sudo apt-get update && sudo apt-get upgrade -y

- name: Install required libs (gcc, llvm, clang, libgccjit)
run: sudo apt-get install build-essential llvm clang libgccjit-12-dev

- name: Include libgccjit library and header files
run: |
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/12/libgccjit.so /usr/lib/libgccjit.so
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/12/include/libgccjit.h /usr/include/libgccjit.h
sudo ln -s /usr/lib/gcc/x86_64-linux-gnu/12/include/libgccjit++.h /usr/include/libgccjit++.h
- name: Change rust channel
run: rustup default nightly

- name: Build
run: cargo build --release --verbose

# - name: Run lint
# run: cargo clippy --verbose

# - name: Run tests
# run: cargo test --verbose
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
target
Cargo.lock

# Compiled files
a.out
output.cc
output

# Compiled .so files
lib/osmon_cstd.o
lib/libosmonstd.so

# Uncompiled libosmonstd
std/libosmonstd.so

# Copy of the standard library
stage_1/src/std
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"nixEnvSelector.nixFile": "${workspaceRoot}/shell.nix"
}
27 changes: 27 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[package]
name = "osmon"
version = "0.4.3"
edition = "2021"
homepage = "https://osmon-lang.uz"
documentation = "https://wiki.osmon-lang.uz"
repository = "https://github.com/osmon-lang/osmon"
description = "Static compiler built for Osmon Programming Language"
authors = ["Sokhibjon Orzikulov <[email protected]>"]
readme = "readme.md"
keywords = ["compiler", "uzbek", "osmon"]
license = "Apache-2.0"
exclude = ["target"]

[dependencies]
parking_lot = "0.12.1"
wrc = "2.0.0"
lazy_static = "1.4.0"
colored = "2.0.0"
osmojit = "0.4.1"
clap = { version = "4", features = ["derive"] }
linked-hash-map = "0.5.6"

[dev-dependencies]
lang_tester = { git = "https://github.com/softdevteam/lang_tester", branch = "master" }
tempdir = "0.3"

47 changes: 47 additions & 0 deletions gc.osm
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
link "gc"

extern func GC_malloc(size: i32) *u8;
extern func GC_malloc_ignore_off_page(n: i32) *u8;
extern func GC_init() void;
extern func GC_clear_roots() void;
extern func GC_gcollect() void;
extern func GC_collect_a_little() void;
extern var GC_no_dls: i32;
extern var GC_java_finalization: i32;

pub func gc_alloc(size: i32) *u8 {
if size > 256 {
return GC_malloc_ignore_off_page(size);
} else {
return GC_malloc(size);
}

return null;
}

pub func gc_initialize() void {
GC_java_finalization = 1;
GC_init();
GC_clear_roots();

return;
}

pub func gc_collect() void {
GC_gcollect();
return;
}

pub func gc_collect_minor() void {
GC_collect_a_little();
return;
}

extern func GC_get_heap_size() usize;
extern func GC_get_free_bytes() usize;

pub func gc_get_stats(heap: *i32,free: *i32) void {
*free = GC_get_free_bytes() as i32;
*heap = GC_get_heap_size() as i32;
return;
}
36 changes: 36 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env just --justfile

release:
cargo build --release

lint:
cargo clippy

format:
cargo fmt

init:
cargo build --release
cd lib && gcc -c -o osmon_cstd.o osmon_cstd.c
cd lib && gcc -shared -o libosmonstd.so osmon_cstd.o
cp ./lib/libosmonstd.so ./std
cp -R ./std ./stage_1/src/

# Self host
selfhost-init:
cp -R ./std ./stage_1/src/

selfhost-all:
cd stage_1 && ../target/release/osmon --backend gccjit src/main.osmx -o osmc

selfhost-run:
cd stage_1 && ../target/release/osmon src/main.osmx --jit

# Standard library build
std-compile:
cd lib
gcc -c -o osmon_cstd.o osmon_cstd.c
gcc -shared -o libosmonstd.so osmon_cstd.o

std-install:
cp ./lib/libosmonstd.so ./std
Binary file added lib/libhavostd.so
Binary file not shown.
Loading

0 comments on commit bf6829e

Please sign in to comment.