Skip to content

Commit 7ece5f8

Browse files
committed
Initial code commit
0 parents  commit 7ece5f8

File tree

16 files changed

+657
-0
lines changed

16 files changed

+657
-0
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: analytech-solutions

.github/workflows/CI.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
name: CI
2+
on:
3+
- push
4+
- pull_request
5+
jobs:
6+
test:
7+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.container }}
8+
runs-on: ${{ matrix.os }}
9+
container: ${{ matrix.container }}
10+
strategy:
11+
fail-fast: false
12+
matrix:
13+
version:
14+
- '1.5'
15+
- '1.6-nightly'
16+
- 'nightly'
17+
os:
18+
- ubuntu-latest
19+
container:
20+
# - 'alpine:3'
21+
- 'amazonlinux:2'
22+
- 'archlinux:base'
23+
- 'centos:7'
24+
- 'centos:8'
25+
- 'debian:8'
26+
- 'debian:9'
27+
- 'debian:10'
28+
- 'fedora:34'
29+
# - 'opensuse/leap:15'
30+
- 'ubuntu:16.04'
31+
- 'ubuntu:18.04'
32+
- 'ubuntu:20.04'
33+
arch:
34+
- x64
35+
# include:
36+
# - os: macos-latest
37+
# version: '1.5'
38+
# arch: x64
39+
# - os: macos-latest
40+
# version: '1.6-nightly'
41+
# arch: x64
42+
# - os: macos-latest
43+
# version: 'nightly'
44+
# arch: x64
45+
# - os: windows-latest
46+
# version: '1.5'
47+
# arch: x64
48+
# - os: windows-latest
49+
# version: '1.6-nightly'
50+
# arch: x64
51+
# - os: windows-latest
52+
# version: 'nightly'
53+
# arch: x64
54+
steps:
55+
- name: Install deps
56+
if: ${{ runner.os == 'Linux' }}
57+
run: |
58+
set -eu
59+
60+
case "${{ matrix.container }}" in
61+
'debian:'* | 'ubuntu:'*)
62+
apt-get update
63+
apt-get install -y --no-install-recommends curl ca-certificates libc6-dev libasound2 libasound2-dev
64+
;;
65+
'amazonlinux:'* | 'centos:'* | 'fedora:'*)
66+
yum -y install tar gzip glibc-headers alsa-lib alsa-lib-devel
67+
;;
68+
'opensuse/leap:'*)
69+
zypper install -y tar gzip curl
70+
;;
71+
'archlinux:'*)
72+
yes | pacman -Syu --needed alsa-lib
73+
;;
74+
*)
75+
;;
76+
esac
77+
78+
- uses: actions/checkout@v2
79+
- uses: julia-actions/setup-julia@latest
80+
with:
81+
version: ${{ matrix.version }}
82+
arch: ${{ matrix.arch }}
83+
- uses: julia-actions/julia-buildpkg@latest
84+
- uses: julia-actions/julia-runtest@latest

.github/workflows/TagBot.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: TagBot
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
7+
jobs:
8+
TagBot:
9+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: JuliaRegistries/TagBot@v1
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
*.jl.cov
2+
*.jl.*.cov
3+
*.jl.mem
4+
deps/deps.jl
5+
/gen

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2021 Analytech Solutions
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Project.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name = "System"
2+
uuid = "75a07032-1394-4a60-8011-bf81691479e2"
3+
authors = ["Keith Rutkowski <keith@analytech-solutions.com>"]
4+
version = "0.1.0"
5+
6+
[deps]
7+
CBinding = "d43a6710-96b8-4a2d-833c-c424785e5374"
8+
9+
[compat]
10+
julia = "^1.5"
11+
CBinding = "^1.0.2"

README.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# System.jl
2+
3+
[![Build Status](https://github.com/analytech-solutions/System.jl/workflows/CI/badge.svg)](https://github.com/analytech-solutions/System.jl/actions)
4+
5+
A framework for interfacing with system-installed software from Julia.
6+
7+
System.jl allows for the use of trusted system software without relying on the binaries downloaded as Julia artifacts.
8+
We view System.jl as an essential component for proprietary and secure computing environments.
9+
This package does not yet support all platforms (only common Linux distributions at present), but it provides a path to that goal.
10+
It also requires that the header files are installed for libraries so that bindings can be automatically generated from them.
11+
12+
13+
# Usage
14+
15+
System.jl is a framework providing bindings to operating system and system-installed software API's.
16+
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).
17+
These packages can be found in the `System.jl/pkgs` directory and are only available for use once System.jl has been imported.
18+
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.
19+
20+
Bindings for a system resource are loaded with the `@sys using libxyz` macro syntax.
21+
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.
22+
23+
```jl
24+
julia> using System
25+
26+
julia> @sys using libc.C99
27+
28+
julia> c"printf"("printf is the best!\n")
29+
printf is the best!
30+
20
31+
32+
julia> @sys using alsa.libasound
33+
34+
julia> for val in 0:Int(SND_PCM_STREAM_LAST)
35+
name = snd_pcm_stream_name(val)
36+
c"printf"("%s\n", name)
37+
end
38+
PLAYBACK
39+
CAPTURE
40+
```
41+
42+
43+
# Developing a framework package
44+
45+
Packages within the System.jl framework, found in `System.jl/pkgs`, are not known about by Pkg.jl when packages are installed.
46+
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).
47+
Framework packages are generally light-weight uses of CBinding.jl, but the special `sys` package introduces tools to facilitate the process.
48+
49+
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.
50+
The following example demonstrates the usage of this macro:
51+
52+
```jl
53+
module libpkg
54+
using sys
55+
56+
@pkgconf begin
57+
using libdep1, libdep2
58+
c`-I/path/to/include -L/path/to/libs -lpkg`
59+
c"""
60+
#include <pkg/header-1.h>
61+
#include <pkg/header-2.h>
62+
"""ji
63+
end
64+
end
65+
```
66+
67+
And what the manually written equivalent might look like:
68+
69+
```jl
70+
module libpkg
71+
using sys
72+
73+
using libdep1
74+
using libdep2
75+
76+
c`-L/dep1/lib -ldep1 -DDEP2_USE_DEP1=1 -L/dep2/lib -ldep2 -I/path/to/include -L/path/to/lib -lpkg`
77+
78+
c"""
79+
#include <dep1/header-1.h>
80+
#include <dep1/header-2.h>
81+
"""s
82+
83+
c"""
84+
#include <dep2/header-1.h>
85+
#include <dep2/header-2.h>
86+
"""s
87+
88+
c"""
89+
#include <pkg/header-1.h>
90+
#include <pkg/header-2.h>
91+
"""ji
92+
end
93+
```
94+
95+
Further details will become available as the package grows and is tested on more systems.
96+

pkgs/alsa.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module alsa
2+
module libasound
3+
using sys
4+
5+
@pkgconf begin
6+
using libc.POSIX
7+
8+
c`-lasound`
9+
c"""
10+
#include <alsa/asoundlib.h>
11+
"""ji
12+
end
13+
end
14+
end

0 commit comments

Comments
 (0)