Skip to content

Commit

Permalink
Merge pull request #1 from status-im/nim12devel
Browse files Browse the repository at this point in the history
Nim-1.2.x support
  • Loading branch information
stefantalpalaru committed Feb 10, 2021
2 parents 3983a1b + aeef2fb commit ca82b5e
Show file tree
Hide file tree
Showing 2,274 changed files with 10,331 additions and 3,987 deletions.
157 changes: 157 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
name: NimYAML CI
on: [push, pull_request]

jobs:
build:
strategy:
fail-fast: false
max-parallel: 20
matrix:
target:
- os: linux
cpu: amd64
- os: linux
cpu: i386
- os: macos
cpu: amd64
- os: windows
cpu: amd64
branch: [version-1-2, version-1-4, devel]
include:
- target:
os: linux
builder: ubuntu-18.04
- target:
os: macos
builder: macos-10.15
- target:
os: windows
builder: windows-2019
name: '${{ matrix.target.os }}-${{ matrix.target.cpu }} (Nim ${{ matrix.branch }})'
runs-on: ${{ matrix.builder }}
steps:
- name: Git checkout
uses: actions/checkout@v2
with:
path: NimYAML

- name: Derive environment variables
shell: bash
run: |
if [[ '${{ matrix.target.cpu }}' == 'amd64' ]]; then
ARCH=64
PLATFORM=x64
else
ARCH=32
PLATFORM=x86
fi
echo "ARCH=$ARCH" >> $GITHUB_ENV
echo "PLATFORM=$PLATFORM" >> $GITHUB_ENV
if [[ '${{ matrix.target.os }}' == 'windows' ]]; then
MAKE_CMD="mingw32-make"
else
MAKE_CMD="make"
fi
echo "MAKE_CMD=$MAKE_CMD" >> $GITHUB_ENV
ncpu=
case '${{ runner.os }}' in
'Linux')
ncpu=$(nproc)
;;
'macOS')
ncpu=$(sysctl -n hw.ncpu)
;;
'Windows')
ncpu=$NUMBER_OF_PROCESSORS
;;
esac
[[ -z "$ncpu" || $ncpu -le 0 ]] && ncpu=1
echo "ncpu=$ncpu" >> $GITHUB_ENV
- name: Install build dependencies (Linux i386)
if: runner.os == 'Linux' && matrix.target.cpu == 'i386'
run: |
sudo dpkg --add-architecture i386
sudo apt-fast update -qq
sudo DEBIAN_FRONTEND='noninteractive' apt-fast install \
--no-install-recommends -yq gcc-multilib g++-multilib
mkdir -p external/bin
cat << EOF > external/bin/gcc
#!/bin/bash
exec $(which gcc) -m32 -mno-adx "\$@"
EOF
cat << EOF > external/bin/g++
#!/bin/bash
exec $(which g++) -m32 -mno-adx "\$@"
EOF
chmod 755 external/bin/gcc external/bin/g++
echo "${{ github.workspace }}/external/bin" >> $GITHUB_PATH
- name: Restore MinGW-W64 (Windows) from cache
if: runner.os == 'Windows'
id: windows-mingw-cache
uses: actions/cache@v2
with:
path: external/mingw-${{ matrix.target.cpu }}
key: 'mingw-${{ matrix.target.cpu }}'

- name: Restore Nim DLLs dependencies (Windows) from cache
if: runner.os == 'Windows'
id: windows-dlls-cache
uses: actions/cache@v2
with:
path: external/dlls-${{ matrix.target.cpu }}
key: 'dlls-${{ matrix.target.cpu }}'

- name: Install MinGW64 dependency (Windows)
if: >
steps.windows-mingw-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
shell: bash
run: |
mkdir -p external
curl -L "https://nim-lang.org/download/mingw$ARCH-6.3.0.7z" -o "external/mingw-${{ matrix.target.cpu }}.7z"
7z x -y "external/mingw-${{ matrix.target.cpu }}.7z" -oexternal/
mv external/mingw$ARCH external/mingw-${{ matrix.target.cpu }}
- name: Install DLLs dependencies (Windows)
if: >
steps.windows-dlls-cache.outputs.cache-hit != 'true' &&
runner.os == 'Windows'
shell: bash
run: |
mkdir -p external
curl -L "https://nim-lang.org/download/windeps.zip" -o external/windeps.zip
7z x -y external/windeps.zip -oexternal/dlls-${{ matrix.target.cpu }}
- name: Path to cached dependencies (Windows)
if: >
runner.os == 'Windows'
shell: bash
run: |
echo "${{ github.workspace }}/external/mingw-${{ matrix.target.cpu }}/bin" >> $GITHUB_PATH
echo "${{ github.workspace }}/external/dlls-${{ matrix.target.cpu }}" >> $GITHUB_PATH
- name: Build the Nim compiler
shell: bash
run: |
git clone -b ${{ matrix.branch }} --depth 1 git://github.com/nim-lang/nim nim/
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
env MAKE="${MAKE_CMD} -j${ncpu}" ARCH_OVERRIDE=${PLATFORM} CC=gcc QUICK_AND_DIRTY_COMPILER=1 bash build_nim.sh nim csources dist/nimble NimBinaries
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
- name: Run tests
shell: bash
working-directory: NimYAML
run: |
nim lexerTests
if [[ '${{ matrix.target.os }}' != 'windows' ]]; then
nim parserTests
nim quickstartTests
fi
nim jsonTests
nim domTests
nim serializationTests
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
## 0.14.0

Features:

* **Breaking change**:
transient, defaultVal, ignore and implicit are now annotations.
* Added ``sparse`` annotation to treat all ``Option`` fields as optional.

Bugfixes:

* can now use default values with ref objects (#66)

## 0.13.1

Bugfixes:

* Changed `nim tests` to `nim test` to make nim ci happy.

## 0.13.0

Bugfixes:

* Fixed submodule link to yaml-test-suite.

Features:

* Added support for `Option` type.

## 0.12.0

Bugfixes:
Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# NimYAML - YAML implementation for Nim

[![Build Status](https://travis-ci.org/flyx/NimYAML.svg?branch=devel)](https://travis-ci.org/flyx/NimYAML)

NimYAML is a pure Nim YAML implementation without any dependencies other than
Nim's standard library. It enables you to serialize Nim objects to a YAML stream
and back. It also provides a low-level event-based API, and a document object
Expand Down Expand Up @@ -29,7 +27,7 @@ PRs for bugs are welcome. If you want to add a feature, you are free to; but be
## Developers

```bash
nim tests # runs all tests
nim test # runs all tests
nim lexerTests # run lexer tests
nim parserTests # run parser tests (git-clones yaml-dev-kit)
nim serializationTests # runs serialization tests
Expand Down
4 changes: 2 additions & 2 deletions config.nims
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ task build, "Compile the YAML module into a library":
--d:release
setCommand "c", "yaml"

task tests, "Run all tests":
task test, "Run all tests":
--r
--verbosity:0
setCommand "c", "test/tests"
Expand Down Expand Up @@ -77,4 +77,4 @@ task server, "Compile server daemon":

task testSuiteEvents, "Compile the testSuiteEvents tool":
--d:release
setCommand "c", "tools/testSuiteEvents"
setCommand "c", "tools/testSuiteEvents"
24 changes: 12 additions & 12 deletions doc/rstPreproc.nim
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
## available as source files for automatic testing. This way, we can make sure
## that the code in the docs actually works.

import parseopt2, streams, tables, strutils, os
import parseopt2, streams, tables, strutils, os, options

var
infile = ""
path: string = nil
path = none(string)
for kind, key, val in getopt():
case kind
of cmdArgument:
Expand All @@ -36,7 +36,7 @@ for kind, key, val in getopt():
of cmdLongOption, cmdShortOption:
case key
of "out", "o":
if isNil(path): path = val
if path.isNone: path = some(val)
else:
echo "Duplicate output path!"
quit 1
Expand All @@ -49,15 +49,15 @@ if infile == "":
echo "Missing input file!"
quit 1

if isNil(path):
if path.isNone:
for i in countdown(infile.len - 1, 0):
if infile[i] == '.':
if infile[i..^1] == ".rst": path = infile & ".rst"
else: path = infile[0..i] & "rst"
if infile[i..^1] == ".rst": path = some(infile & ".rst")
else: path = some(infile[0..i] & "rst")
break
if isNil(path): path = infile & ".rst"
if path.isNone: path = some(infile & ".rst")

var tmpOut = newFileStream(path, fmWrite)
var tmpOut = newFileStream(path.get(), fmWrite)

proc append(s: string) =
tmpOut.writeLine(s)
Expand Down Expand Up @@ -118,17 +118,17 @@ var lineNum = 0
for line in infile.lines():
if line.len > 0 and line[0] == '%':
var
srcPath: string = nil
srcPath = none(string)
level = 0
for i in 1..<line.len:
if line[i] == '%':
srcPath = line[1 .. i - 1]
srcPath = some(line[1 .. i - 1])
level = parseInt(line[i + 1 .. ^1])
break
if isNil(srcPath):
if srcPath.isNone:
echo "Second % missing in line " & $lineNum & "! content:\n"
echo line
quit 1
outputExamples("snippets" / srcPath, level)
outputExamples("snippets" / srcPath.get(), level)
else:
append(line)
Loading

0 comments on commit ca82b5e

Please sign in to comment.