Commit 3b014dd2 authored by Mart Lubbers's avatar Mart Lubbers
Browse files

Merge branch 'nitrile' into 'master'

Nitrile

See merge request !8
parents fa308984 7412db2a
Pipeline #61153 passed with stage
in 1 minute and 12 seconds
......@@ -14,8 +14,8 @@ Clean System Files
*.o
*.obj
# System specific files
src/_MQTT.*
# Other
.clang-format
*.tar.gz
nitrile-packages
variables:
GIT_SUBMODULE_STRATEGY: recursive
stages:
- compile
- package
compile:
stage: compile
image: "camilstaps/clean:nightly"
before_script:
- install_clean_nightly.sh bundle-complete
- apt-get update -qq
- apt-get install -yqq build-essential autoconf libtool
- ( cd cdeps/wolfMQTT; ./autogen.sh; ./configure --enable-mqtt5 --disable-tls; make; )
script:
- make
package-linux:
stage: package
image: debian
before_script:
- apt-get update -qq
- apt-get install -yqq build-essential autoconf libtool
script:
- ( cd cdeps/wolfMQTT; ./autogen.sh; ./configure --enable-mqtt5 --disable-tls; make; )
- make buildLib
- tar czf MQTTClient-linux-x64.tar.gz src --transform s/src/MQTTClient/
artifacts:
paths:
- ./*.tar.gz
package-windows:
stage: package
image: debian
before_script:
- apt-get update -qq
- apt-get install -yqq build-essential autoconf libtool mingw-w64
script:
- cp cdeps/vs_settings.h cdeps/wolfMQTT/wolfmqtt
- ( cd cdeps/wolfMQTT; ./autogen.sh; ./configure --enable-mqtt5 --disable-tls --host=x86_64-pc-mingw32 --disable-examples --enable-static CFLAGS=-Wno-error=attributes LIBS=-lws2_32 CC=x86_64-w64-mingw32-gcc; make; )
- OS=Windows_NT CC=x86_64-w64-mingw32-gcc make buildLib
- tar czf MQTTClient-windows-x64.tar.gz src --transform s/src/MQTTClient/
artifacts:
paths:
- ./*.tar.gz
image: cleanlang/nitrile:0.3
stages: [build, publish]
build-linux-x64:
stage: build
before_script:
- apt-get update -qq
- apt-get install -yqq build-essential autoconf libtool
- nitrile update
- nitrile fetch
script:
- nitrile build
- nitrile test
- nitrile package
artifacts:
paths:
- itask-mqtt*.tar.gz
build-windows-x64:
stage: build
before_script:
- apt-get update -qq
- apt-get install -yqq build-essential mingw-w64 autoconf libtool
- nitrile update
- nitrile --platform=windows fetch
script:
- nitrile --platform=windows build
- nitrile --platform=windows package
artifacts:
paths:
- itask-mqtt*.tar.gz
publish:
stage: publish
rules:
- if: $CI_COMMIT_TAG
script:
- nitrile publish --targets=linux-x64,windows-x64
artifacts:
paths:
- itask-mqtt*.tar.gz
[submodule "cdeps/wolfMQTT"]
path = cdeps/wolfMQTT
[submodule "src/c-any/wolfMQTT"]
path = src/c-any/wolfMQTT
url = https://github.com/wolfSSL/wolfMQTT
# Changelog
# v1.0
- Initial nitrile version
Copyright (c) 2022 Mart Lubbers.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
CFLAGS?=-Wall -Wextra -Wno-unused-parameter
ifeq ($(OS), Windows_NT)
SUFFIX:=obj
else
SUFFIX:=o
endif
.PHONY: clean
all: buildLib buildDemo
buildLib:
$(MAKE) -C cdeps
mkdir -p src/Clean\ System\ Files
cp cdeps/libWrapper.o src/Clean\ System\ Files/libWrapper.$(SUFFIX)
ifeq ($(OS), Windows_NT)
cp cdeps/wolfMQTT/src/libwolfmqtt_la-mqtt_client.o src/Clean\ System\ Files/libwolfmqtt_la-mqtt_client.$(SUFFIX)
cp cdeps/wolfMQTT/src/libwolfmqtt_la-mqtt_packet.o src/Clean\ System\ Files/libwolfmqtt_la-mqtt_packet.$(SUFFIX)
cp cdeps/wolfMQTT/src/libwolfmqtt_la-mqtt_socket.o src/Clean\ System\ Files/libwolfmqtt_la-mqtt_socket.$(SUFFIX)
cp cdeps/_chkstk_ms.obj src/Clean\ System\ Files/
cp src-win/* src/
else
cp cdeps/wolfMQTT/src/.libs/libwolfmqtt_la-mqtt_client.o src/Clean\ System\ Files/libwolfmqtt_la-mqtt_client.$(SUFFIX)
cp cdeps/wolfMQTT/src/.libs/libwolfmqtt_la-mqtt_packet.o src/Clean\ System\ Files/libwolfmqtt_la-mqtt_packet.$(SUFFIX)
cp cdeps/wolfMQTT/src/.libs/libwolfmqtt_la-mqtt_socket.o src/Clean\ System\ Files/libwolfmqtt_la-mqtt_socket.$(SUFFIX)
cp src-posix/* src/
endif
buildDemo: buildLib
$(MAKE) -C demo
clean:
$(RM) -r $(addsuffix /Clean\ System\ Files, src src/MQTT)
$(RM) -r $(addprefix src/_MQTT., icl dcl)
$(MAKE) -C cdeps clean
$(MAKE) -C demo clean
# MQTTClient
# Clean iTask mqtt client using [WolfMQTT](https://github.com/wolfSSL/wolfMQTT)
## Installation instructions
## Maintainer
1. Install [WolfMQTT](https://github.com/wolfSSL/wolfMQTT) (optionally with --enable-mqtt5 flag)
2. Run the `make` command
\ No newline at end of file
Mart Lubbers (mart@cs.ru.nl)
## License
`itasks-mqtt` is licensed under the BSD 2-Clause "Simplified" License (see [LICENSE](LICENSE)).
`itasks-mqtt` uses WolfMQTT (is statically linked with) which is licensed under GPLv2.
CLEAN_HOME?=/opt/clean
.SECONDARY: MQTTClient.prj
.PHONY: clean
all: MQTTClient
%.prj: %.icl
cpm project $* create $(CLEAN_HOME)/etc/iTasks.prt
cpm project $@ root ..
cpm project $@ path add ../src
%: %.prj
cpm project $^ build
clean:
rm -rf Clean\ System\ Files
rm -rf MQTTClient-www
rm -f MQTTClient *.bc *.pbc *.prj
module MQTTClient
import MQTT
import MQTT.Client
import MQTT.Util
import iTasks.Extensions.MQTT
import iTasks.Extensions.MQTT.Client
import iTasks.Extensions.MQTT.Util
import iTasks
import TCPDef
import StdDebug
......@@ -52,4 +52,4 @@ received :: (SimpleSDSLens MQTTClient) -> Task [MQTTMsg]
received sds
# lens = createReceiveLens sds
= viewSharedInformation [ViewAs \res.map format res] lens
where format (MQTTMsg t p opts) = "Topic: " +++ t +++ " Payload: " +++ p +++ " Qos: " +++ (toString opts.qos) +++ " Retained: " +++ (toString opts.retain)
\ No newline at end of file
where format (MQTTMsg t p opts) = "Topic: " +++ t +++ " Payload: " +++ p +++ " Qos: " +++ (toString opts.qos) +++ " Retained: " +++ (toString opts.retain)
{"packages":{"linux-x64":[{"name":"abc-interpreter"
,"version":"1.0.0"}
,{"name":"argenv"
,"version":"1.0.1"}
,{"name":"base"
,"version":"1.0.0"}
,{"name":"base-clm"
,"version":"1.4.2"}
,{"name":"base-code-generator"
,"version":"1.0.0"}
,{"name":"base-compiler"
,"version":"2.0.1"}
,{"name":"base-compiler-itasks"
,"version":"1.0.0"}
,{"name":"base-rts"
,"version":"1.1.0"}
,{"name":"base-stdenv"
,"version":"1.0.0"}
,{"name":"clean-platform"
,"version":"0.3.4"}
,{"name":"gast"
,"version":"0.2.1"}
,{"name":"graph-copy"
,"version":"2.0.1"}
,{"name":"itasks"
,"version":"0.2.0"}
,{"name":"lib-compiler-itasks"
,"version":"2.0.1"}
,{"name":"tcpip"
,"version":"2.0.1"}]
,"windows-x64":[{"name":"abc-interpreter"
,"version":"1.0.0"}
,{"name":"argenv"
,"version":"1.0.1"}
,{"name":"base"
,"version":"1.0.0"}
,{"name":"base-clm"
,"version":"1.4.2"}
,{"name":"base-code-generator"
,"version":"1.0.0"}
,{"name":"base-compiler"
,"version":"2.0.1"}
,{"name":"base-compiler-itasks"
,"version":"1.0.0"}
,{"name":"base-linker"
,"version":"1.0.2"}
,{"name":"base-rts"
,"version":"1.1.0"}
,{"name":"base-stdenv"
,"version":"1.0.0"}
,{"name":"clean-platform"
,"version":"0.3.4"}
,{"name":"gast"
,"version":"0.2.1"}
,{"name":"graph-copy"
,"version":"2.0.1"}
,{"name":"itasks"
,"version":"0.2.0"}
,{"name":"lib-compiler-itasks"
,"version":"2.0.1"}
,{"name":"tcpip"
,"version":"2.0.1"}]}}
\ No newline at end of file
name: itasks-mqtt
url: https://gitlab.com/mtask/mqttclient
maintainer: Mart Lubbers
contact_email: mart@cs.ru.nl
description: iTasks library for MQTT using WolfMQTT
version: 1.0
license: BSD-2-Clause
type: Library
clm_options:
bytecode: prelinked
compiler: cocl-itasks
export_local_labels: true
fusion: GenericFusion
generate_descriptors: true
post_link: web-resource-collector
print_result: false
print_time: false
strip: false
dependencies:
base: ^1.0.0
clean-platform: ^0.3.4
itasks: ^0.2.0
package:
core_modules:
- iTasks.Extensions._MQTT
extra_files:
- README.md
- LICENSE
tests:
compilation:
compilation:
{}
# Sources
src:
- src/clean-any
rules:
posix:
extra_src:
- src/clean-posix
extra_build:
cdeps:
script:
- ( cd src/c-any/wolfMQTT; ./autogen.sh; ./configure --enable-mqtt5 --disable-tls; make; )
- make -C src/c-any
- mkdir -p src/clean-posix/Clean\ System\ Files
- cp src/c-any/libWrapper.o src/clean-posix/Clean\ System\ Files/libWrapper.o
- cp src/c-any/wolfMQTT/src/.libs/libwolfmqtt_la-mqtt_client.o src/clean-posix/Clean\ System\ Files/libwolfmqtt_la-mqtt_client.o
- cp src/c-any/wolfMQTT/src/.libs/libwolfmqtt_la-mqtt_packet.o src/clean-posix/Clean\ System\ Files/libwolfmqtt_la-mqtt_packet.o
- cp src/c-any/wolfMQTT/src/.libs/libwolfmqtt_la-mqtt_socket.o src/clean-posix/Clean\ System\ Files/libwolfmqtt_la-mqtt_socket.o
extra_package:
include:
- libWrapper.o
- libwolfmqtt_la-mqtt_client.o
- libwolfmqtt_la-mqtt_packet.o
- libwolfmqtt_la-mqtt_socket.o
windows:
extra_src:
- src/clean-windows
extra_build:
cdeps:
script:
- cp src/c-any/vs_settings.h src/c-any/wolfMQTT/wolfmqtt
- ( cd src/c-any/wolfMQTT; ./autogen.sh; ./configure --enable-mqtt5 --disable-tls --host=x86_64-pc-mingw32 --disable-examples --enable-static CFLAGS=-Wno-error=attributes LIBS=-lws2_32 CC=x86_64-w64-mingw32-gcc; make; )
- make CC=x86_64-w64-mingw32-gcc -C src/c-any
- mkdir -p src/clean-windows/Clean\ System\ Files
- cp src/c-any/libWrapper.o src/clean-windows/Clean\ System\ Files/libWrapper.obj
- cp src/c-any/wolfMQTT/src/libwolfmqtt_la-mqtt_client.o src/clean-windows/Clean\ System\ Files/libwolfmqtt_la-mqtt_client.obj
- cp src/c-any/wolfMQTT/src/libwolfmqtt_la-mqtt_packet.o src/clean-windows/Clean\ System\ Files/libwolfmqtt_la-mqtt_packet.obj
- cp src/c-any/wolfMQTT/src/libwolfmqtt_la-mqtt_socket.o src/clean-windows/Clean\ System\ Files/libwolfmqtt_la-mqtt_socket.obj
- cp src/c-any/_chkstk_ms.obj src/clean-windows/Clean\ System\ Files/_chkstk_ms.obj
extra_package:
include:
- libWrapper.obj
- libwolfmqtt_la-mqtt_client.obj
- libwolfmqtt_la-mqtt_packet.obj
- libwolfmqtt_la-mqtt_socket.obj
- _chkstk_ms.obj
---
name: itasks-mqtt-demo
url: https://gitlab.com/mlubbers/clean-itasks-mqtt
maintainer: Mart Lubbers
contact_email: mart@cs.ru.nl
description: Demo application for itasks-mqtt
version: 0.1
license: BSD-2-Clause
type: Application
dependencies:
base: ^1.0.0
base-compiler-itasks: ^1.0.0
clean-platform: ^0.3.4
itasks: ^0.2.0
clm_options:
bytecode: prelinked
compiler: cocl-itasks
export_local_labels: true
fusion: GenericFusion
generate_descriptors: true
heap: 500M
post_link: web-resource-collector
print_result: false
print_time: false
strip: false
src:
- examples
- src/clean-any
rules:
posix:
extra_src:
- src/clean-posix
windows:
extra_src:
- src/clean-windows
build:
demo:
script:
- nitrile build --name=itasks-mqtt
- clm:
main: MQTTClient
target: examples/MQTTClient
definition module _MQTT
implementation module _MQTT
definition module _MQTT
definition module MQTT.Errors
errorCodeToString :: Int -> String
\ No newline at end of file
definition module MQTT.Util
import iTasks
import MQTT
createReceiveLens :: (SimpleSDSLens MQTTClient) -> (SimpleSDSLens [MQTTMsg])
mqttSend :: MQTTMsg (SimpleSDSLens MQTTClient) -> Task ()
mqttSubscribe :: MQTTSubscribe (SimpleSDSLens MQTTClient) -> Task ()
mqttUnsubscribe :: MQTTTopicFilter (SimpleSDSLens MQTTClient) -> Task ()
mqttDisconnect :: (SimpleSDSLens MQTTClient) -> Task ()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment