Skip to content

Commit

Permalink
Merge pull request #8 from fraya/master
Browse files Browse the repository at this point in the history
Create basic library structure

Co-authored-by: @cgay
  • Loading branch information
fraya authored May 30, 2024
2 parents 1d9ee8b + e672849 commit 567f514
Show file tree
Hide file tree
Showing 20 changed files with 382 additions and 23 deletions.
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
38 changes: 38 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and test

on:
push:
# all branches
pull_request:
# all branches

# This enables the Run Workflow button on the Actions tab.
workflow_dispatch:

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Install Opendylan
uses: dylan-lang/install-opendylan@v3

- name: Add zlib dev dependency
run: sudo apt-get install -y zlib1g-dev

- name: Download dependencies
run: dylan update

- name: Build tests
run: dylan build zlib-test-suite

- name: Run tests
run: _build/bin/zlib-test-suite --progress none --report surefire > _build/TEST-zlib.xml

- name: Publish Test Report
if: success() || failure()
uses: mikepenz/action-junit-report@v4
with:
report_paths: '**/_build/TEST-*.xml'
56 changes: 56 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and deploy documentation

on:
push:
# all branches
paths:
- 'documentation/**'

# This enables the Run Workflow button on the Actions tab.
workflow_dispatch:

# https://github.com/JamesIves/github-pages-deploy-action#readme
permissions:
contents: write

# Set DYLAN environment variable to GITHUB_WORKSPACE so packages are
# installed in ../../_packages relative to documentation's Makefile
env:
DYLAN: ${{ github.workspace }}

jobs:

build-and-deploy:
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Check links
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/fraya/dylan-docs
options: -v ${{ github.workspace }}/documentation:/docs
run: make linkcheck

- name: Build docs with Furo theme
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/fraya/dylan-docs
options: -v ${{ github.workspace }}/documentation:/docs
run: make html

- name: Upload html artifact
uses: actions/upload-artifact@v4
with:
name: zlib-doc-html
path: documentation/build/html/

- name: Bypassing Jekyll on GH Pages
run: sudo touch documentation/build/html/.nojekyll

- name: Deploy documents to GH pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: documentation/build/html
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Development directories

/_build/
/_packages/
/registry/

# Backup files

*~

/documentation/build/
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2024 dylan-hackers

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.
31 changes: 31 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Zlib
====

Opendylan binding around Zlib library.

Building
--------

Install development libraries

.. code-block:: console
$ sudo apt install zlib1g-dev
Download dependencies:

.. code-block:: console
$ dylan update
Build:

.. code-block:: console
$ dylan build --all
Run tests:

.. code-block:: console
$ _build/bin/zlib-test-suite
20 changes: 20 additions & 0 deletions documentation/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
35 changes: 35 additions & 0 deletions documentation/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
33 changes: 33 additions & 0 deletions documentation/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

import sys, os
sys.path.insert(0, os.path.abspath('../../_packages/sphinx-extensions/current/src/sphinxcontrib'))

import dylan.themes as dylan_themes
extensions = ['dylan.domain']

templates_path = ['_templates']
exclude_patterns = []

primary_domain = 'dylan'


# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'Zlib'
copyright = '2024, Dylan Hackers'
author = 'Dylan Hackers'
release = '0.1.0'

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
html_static_path = ['_static']
17 changes: 17 additions & 0 deletions documentation/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Welcome to Zlib's documentation!
================================

.. toctree::
:maxdepth: 2
:caption: Contents:
:hidden:

reference

This is the beginning of a binding to the `Zlib
<https://www.zlib.net/>`_ library.

Indices and tables
==================

* :ref:`genindex`
33 changes: 33 additions & 0 deletions documentation/source/reference.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Reference
=========

.. current-library:: zlib
.. current-module:: zlib

Utility functions
-----------------

These functions are implemented on top of the basic zlib
stream-oriented functions. To simplify the interface, some default
options are assumed (compression level and memory usage).


.. function:: compress

Compress a string.

:signature: compress *string* => (compressed-string)

:parameter string: String to compress. An instance of :drm:`<string>`
:value compressed-string: An instance of :drm:`<string>`

:description:

Compress the source string into a new string. If there is a problem
in the compression process it raises an error.

:example:

.. code-block:: dylan
let compressed = compress("Hello");
15 changes: 15 additions & 0 deletions dylan-package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"dependencies": [ ],
"dev-dependencies": [
"testworks",
"sphinx-extensions"
],
"description": "Bindings to Zlib library",
"name": "zlib",
"version": "0.1.0",
"url": "https://github.com/dylan-lang/zlib",
"keywords": [ "zlib", "binding" ],
"contact": "[email protected]",
"license": "MIT",
"license-url": "https://opensource.org/license/mit"
}
13 changes: 0 additions & 13 deletions library.dylan

This file was deleted.

26 changes: 26 additions & 0 deletions source/library.dylan
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module: dylan-user
define library zlib
use common-dylan;
use c-ffi;

export
zlib,
zlib-impl;
end library;

define module zlib
create
compress;
end module;

define module zlib-impl
use common-dylan;
use c-ffi;

use zlib;

export
zlib-compress,
zlib-compress-bound;
end module;
6 changes: 1 addition & 5 deletions main.dylan → source/zlib.dylan
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module: zlib
module: zlib-impl
define C-function zlib-compress
parameter destination :: <C-string>;
Expand Down Expand Up @@ -26,7 +26,3 @@ define function compress (string :: <string>)
result;
end if;
end;
/*
define variable foobar = "foobar";
format-out("%= => %=\n", foobar, compress(foobar));
*/
5 changes: 5 additions & 0 deletions source/zlib.lid
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Library: zlib
Target-Type: dll
C-Libraries: -lz
Files: library
zlib
Loading

0 comments on commit 567f514

Please sign in to comment.