Skip to content

Commit

Permalink
Initial code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
krrutkow committed Mar 26, 2021
0 parents commit 7ece5f8
Show file tree
Hide file tree
Showing 16 changed files with 657 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
github: analytech-solutions
84 changes: 84 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.container }}
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
strategy:
fail-fast: false
matrix:
version:
- '1.5'
- '1.6-nightly'
- 'nightly'
os:
- ubuntu-latest
container:
# - 'alpine:3'
- 'amazonlinux:2'
- 'archlinux:base'
- 'centos:7'
- 'centos:8'
- 'debian:8'
- 'debian:9'
- 'debian:10'
- 'fedora:34'
# - 'opensuse/leap:15'
- 'ubuntu:16.04'
- 'ubuntu:18.04'
- 'ubuntu:20.04'
arch:
- x64
# include:
# - os: macos-latest
# version: '1.5'
# arch: x64
# - os: macos-latest
# version: '1.6-nightly'
# arch: x64
# - os: macos-latest
# version: 'nightly'
# arch: x64
# - os: windows-latest
# version: '1.5'
# arch: x64
# - os: windows-latest
# version: '1.6-nightly'
# arch: x64
# - os: windows-latest
# version: 'nightly'
# arch: x64
steps:
- name: Install deps
if: ${{ runner.os == 'Linux' }}
run: |
set -eu
case "${{ matrix.container }}" in
'debian:'* | 'ubuntu:'*)
apt-get update
apt-get install -y --no-install-recommends curl ca-certificates libc6-dev libasound2 libasound2-dev
;;
'amazonlinux:'* | 'centos:'* | 'fedora:'*)
yum -y install tar gzip glibc-headers alsa-lib alsa-lib-devel
;;
'opensuse/leap:'*)
zypper install -y tar gzip curl
;;
'archlinux:'*)
yes | pacman -Syu --needed alsa-lib
;;
*)
;;
esac
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@latest
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
14 changes: 14 additions & 0 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: TagBot
on:
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.jl.cov
*.jl.*.cov
*.jl.mem
deps/deps.jl
/gen
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Analytech Solutions

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 11 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name = "System"
uuid = "75a07032-1394-4a60-8011-bf81691479e2"
authors = ["Keith Rutkowski <[email protected]>"]
version = "0.1.0"

[deps]
CBinding = "d43a6710-96b8-4a2d-833c-c424785e5374"

[compat]
julia = "^1.5"
CBinding = "^1.0.2"
96 changes: 96 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# System.jl

[![Build Status](https://github.com/analytech-solutions/System.jl/workflows/CI/badge.svg)](https://github.com/analytech-solutions/System.jl/actions)

A framework for interfacing with system-installed software from Julia.

System.jl allows for the use of trusted system software without relying on the binaries downloaded as Julia artifacts.
We view System.jl as an essential component for proprietary and secure computing environments.
This package does not yet support all platforms (only common Linux distributions at present), but it provides a path to that goal.
It also requires that the header files are installed for libraries so that bindings can be automatically generated from them.


# Usage

System.jl is a framework providing bindings to operating system and system-installed software API's.
System resources are available as Julia packages that encapsulate dynamically generated bindings (automatically created by [CBinding.jl](https://github.com/analytech-solutions/CBinding.jl) when you import the package).
These packages can be found in the `System.jl/pkgs` directory and are only available for use once System.jl has been imported.
Therefore, [similar to Revise.jl](https://timholy.github.io/Revise.jl/stable/config), `using System` must occur before any packages utilizing the framework are loaded, or just add it to your `~/.julia/config/startup.jl` file.

Bindings for a system resource are loaded with the `@sys using libxyz` macro syntax.
The bindings can always be referenced with the CBinding.jl `c"..."` string macro, but usually the bindings are free of name collisions so Julian names are available as well.

```jl
julia> using System

julia> @sys using libc.C99

julia> c"printf"("printf is the best!\n")
printf is the best!
20

julia> @sys using alsa.libasound

julia> for val in 0:Int(SND_PCM_STREAM_LAST)
name = snd_pcm_stream_name(val)
c"printf"("%s\n", name)
end
PLAYBACK
CAPTURE
```


# Developing a framework package

Packages within the System.jl framework, found in `System.jl/pkgs`, are not known about by Pkg.jl when packages are installed.
Therefore, the framework packages are unable to use _any_ packages that are not referenced by the System.jl package itself (its dependencies are all Pkg.jl knows about).
Framework packages are generally light-weight uses of CBinding.jl, but the special `sys` package introduces tools to facilitate the process.

It provides the `@pkgconf` macro to automatically inject the dependency packages' compilation command line arguments and header file inclusions in order to prepare both the Julia and C definitions needed to declare the package's bindings.
The following example demonstrates the usage of this macro:

```jl
module libpkg
using sys

@pkgconf begin
using libdep1, libdep2
c`-I/path/to/include -L/path/to/libs -lpkg`
c"""
#include <pkg/header-1.h>
#include <pkg/header-2.h>
"""ji
end
end
```

And what the manually written equivalent might look like:

```jl
module libpkg
using sys

using libdep1
using libdep2

c`-L/dep1/lib -ldep1 -DDEP2_USE_DEP1=1 -L/dep2/lib -ldep2 -I/path/to/include -L/path/to/lib -lpkg`

c"""
#include <dep1/header-1.h>
#include <dep1/header-2.h>
"""s

c"""
#include <dep2/header-1.h>
#include <dep2/header-2.h>
"""s

c"""
#include <pkg/header-1.h>
#include <pkg/header-2.h>
"""ji
end
```

Further details will become available as the package grows and is tested on more systems.

14 changes: 14 additions & 0 deletions pkgs/alsa.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module alsa
module libasound
using sys

@pkgconf begin
using libc.POSIX

c`-lasound`
c"""
#include <alsa/asoundlib.h>
"""ji
end
end
end
Loading

2 comments on commit 7ece5f8

@krrutkow
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/32933

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 7ece5f868f0ca8975956f77a0fc097f13df3bbf8
git push origin v0.1.0

Please sign in to comment.