Skip to content

Commit

Permalink
Merge branch 'dev', releasing version 0.2.9.
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyash committed Oct 4, 2020
2 parents 5b94fd6 + ce7d1e8 commit d3900cf
Show file tree
Hide file tree
Showing 61 changed files with 1,018 additions and 1,335 deletions.
166 changes: 166 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
name: Build
on: push

jobs:
build-internal:
timeout-minutes: 5
name: Build
runs-on: ${{ matrix.os }}
strategy:
matrix:
name: [
ubuntu-latest-gcc-6,
ubuntu-latest-gcc-7,
ubuntu-latest-gcc-8,
ubuntu-latest-gcc-9,
ubuntu-latest-gcc-10,
ubuntu-latest-clang-6.0,
ubuntu-latest-clang-7,
ubuntu-latest-clang-8,
ubuntu-latest-clang-9,
ubuntu-latest-clang-10,
macOS-10.14-xcode-10.3,
macOS-10.14-gcc-9,
]
include:
- name: ubuntu-latest-gcc-6
os: ubuntu-latest
compiler: gcc
version: "6"

- name: ubuntu-latest-gcc-7
os: ubuntu-latest
compiler: gcc
version: "7"

- name: ubuntu-latest-gcc-8
os: ubuntu-latest
compiler: gcc
version: "8"

- name: ubuntu-latest-gcc-9
os: ubuntu-latest
compiler: gcc
version: "9"

- name: ubuntu-latest-gcc-10
os: ubuntu-latest
compiler: gcc
version: "10"

- name: ubuntu-latest-clang-6.0
os: ubuntu-latest
compiler: clang
version: "6.0"

- name: ubuntu-latest-clang-7
os: ubuntu-latest
compiler: clang
version: "7"

- name: ubuntu-latest-clang-8
os: ubuntu-latest
compiler: clang
version: "8"

- name: ubuntu-latest-clang-9
os: ubuntu-latest
compiler: clang
version: "9"

- name: ubuntu-latest-clang-10
os: ubuntu-latest
compiler: clang
version: "10"

- name: macOS-10.14-xcode-10.3
os: macOS-10.14
compiler: xcode
version: "10.3"

- name: macOS-10.14-gcc-9
os: macOS-10.14
compiler: gcc
version: "9"
steps:
- uses: actions/checkout@v1
- name: Install Compiler (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
if [ "${{ matrix.compiler }}" = "gcc" ]; then
sudo apt-get install -y g++-${{ matrix.version }}
echo "::set-env name=CC::gcc-${{ matrix.version }}"
echo "::set-env name=CXX::g++-${{ matrix.version }}"
else
sudo apt-get install -y clang-${{ matrix.version }}
echo "::set-env name=CC::clang-${{ matrix.version }}"
echo "::set-env name=CXX::clang++-${{ matrix.version }}"
fi
- name: Install and Test (Linux)
if: runner.os == 'Linux'
run: (sudo ./install-linux.sh && make tests)
- name: Install Compiler (macOS)
if: runner.os == 'macOS'
run: |
brew install cmake ninja
if [ "${{ matrix.compiler }}" = "gcc" ]; then
brew install gcc@${{ matrix.version }}
echo "::set-env name=CC::gcc-${{ matrix.version }}"
echo "::set-env name=CXX::g++-${{ matrix.version }}"
else
sudo xcode-select -switch /Applications/Xcode_${{ matrix.version }}.app
echo "::set-env name=CC::clang"
echo "::set-env name=CXX::clang++"
fi
- name: Install and Test (macOS)
if: runner.os == 'macOS'
run: (./install-mac.sh && make tests)

build-external:
timeout-minutes: 5
name: Build External
runs-on: ubuntu-latest
container:
image: ${{ matrix.container }}
options: --user root
strategy:
matrix:
name: [
debian-stable-gcc-7,
debian-stable-gcc-8,
debian-stable-clang-7,
]
include:
- name: debian-stable-gcc-7
container: debian:stable
compiler: gcc
version: "7"

- name: debian-stable-gcc-8
container: debian:stable
compiler: gcc
version: "8"

- name: debian-stable-clang-7
container: debian:stable
compiler: clang
version: "7"

steps:
- uses: actions/checkout@v1
- name: Install Compiler
run: |
apt-get update
apt-get install -y sudo # sudo is not present on the image
if [ "${{ matrix.compiler }}" = "gcc" ]; then
apt-get install -y g++-${{ matrix.version }}
echo "::set-env name=CC::gcc-${{ matrix.version }}"
echo "::set-env name=CXX::g++-${{ matrix.version }}"
else
apt-get install -y clang-${{ matrix.version }}
echo "::set-env name=CC::clang-${{ matrix.version }}"
echo "::set-env name=CXX::clang++-${{ matrix.version }}"
fi
- name: Install and Test
run: (./install-linux.sh && make tests)
13 changes: 0 additions & 13 deletions .travis.yml

This file was deleted.

27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
## 2020-10-04 Version 0.2.9

### New features

* Homebrew formula and readme instructions (Thanks, @SeekingMeaning)
* Homebrew badge (Thanks, @organom)
* `main()` can now be defined as part of `Namespace` of the main file: `ns { F main(...) ...}`
* Add experimental `only(val, predicate, mapper)`
* Add `realpath(Str)`
* Use `NGS_PATH` environment variable for `require()`. `NGS_DIR` is deprecated.

### Fixes and improvements

* Github actions instead of Travis (Thanks, @organom)
* `$(log ...)` now logs i/o redirections
* Remove unused `ValueWrapper` type
* Bootstrapping - `MY_NAMESPACE::main` works even if `main` is not defined in the main file, allowing `ngs -e 'require("my_module.ngs")` to run its own `main()`
* `filterk()`, `rejectk()`, `filterv()`, `rejectv()` - the predicate is now optional and defaults to `identity`.
* Got rid of `xxd` build time dependency
* make `sys/poll.h` dependency optional


### Breaking changes

* Remove deprecated `n()`
* `switch` and `cond` are now consistent with if, accepting `{...}` code blocks for the LHS (`switch {a=1; a+a} {...}`, `cond { {a=b+c; a>0 } ... }`).

## 2020-07-26 Version 0.2.8

### New features
Expand Down
36 changes: 32 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
cmake_minimum_required(VERSION 3.0)
include(FindPkgConfig)
project(NGS)

include(CheckFunctionExists)
include(CheckIncludeFile)
include(FindPkgConfig)


# -D_DARWIN_C_SOURCE - SIGWINCH and friends on MacOS
# -D_XOPEN_SOURCE - strptime on Linux
# -D_DEFAULT_SOURCE - MAP_ANONYMOUS on Linux
Expand All @@ -16,14 +20,31 @@ pkg_check_modules(LIBFFI libffi REQUIRED)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${LIBFFI_INCLUDE_DIRS} /usr/local/include)
link_directories(/usr/local/lib)

add_executable(ngs version.h ngs.c syntax.include syntax.auto.h pcre_constants.include errno.include obj.c vm.c compile.c debug.c ast.c malloc.c decompile.c)
add_executable(ngs
version.h
ngs.c
syntax.include syntax.auto.h
pcre_constants.include errno.include
obj.c vm.c compile.c debug.c ast.c malloc.c decompile.c
stdlib.ngs.h
)

include(CheckFunctionExists)
check_function_exists(fmemopen FMEMOPEN)
IF(NOT FMEMOPEN)
target_sources(ngs PRIVATE fmemopen.c)
ENDIF()

check_include_file(execinfo.h EXECINFO_H)
IF(EXECINFO_H)
add_definitions(-DHAVE_EXECINFO_H)
ENDIF()

check_include_file(sys/poll.h POLL_H)
IF(POLL_H)
add_definitions(-DHAVE_POLL_H)
ENDIF()


find_program(SED NAMES gsed sed) # gsed - MacOS, sed - all the rest
find_file(PCRE_H pcre.h)
add_custom_command(
Expand Down Expand Up @@ -60,6 +81,13 @@ add_custom_command(
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/build-scripts/include_errno.c
)
add_custom_command(
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/stdlib.ngs.h
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build-scripts/bin2c.sh lib/stdlib.ngs >${CMAKE_CURRENT_BINARY_DIR}/stdlib.ngs.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/lib/stdlib.ngs
)


target_link_libraries(ngs m pthread gc ffi dl json-c pcre)

Expand All @@ -78,4 +106,4 @@ install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE DESTINATION doc/ngs)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/doc/ DESTINATION man/man1 FILES_MATCHING PATTERN "*.1")

enable_testing()
add_test(all bash -c "NGS_BOOTSTRAP=${CMAKE_CURRENT_SOURCE_DIR}/lib/bootstrap.ngs NGS_DIR=${CMAKE_CURRENT_SOURCE_DIR}/lib ${CMAKE_CURRENT_BINARY_DIR}/ngs ${CMAKE_CURRENT_SOURCE_DIR}/test.ngs")
add_test(all bash -c "${CMAKE_CURRENT_BINARY_DIR}/ngs ${CMAKE_CURRENT_SOURCE_DIR}/test.ngs")
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ WORKDIR /root/
COPY --from=0 /usr/local/lib/ngs /usr/local/lib/ngs
COPY --from=0 /usr/local/bin/ngs /usr/local/bin/ngs
COPY --from=0 /src/test.ngs /root/test.ngs
RUN ngs test.ngs
RUN env NGS_TESTS_BASE_DIR=/usr/local/lib/ngs ngs test.ngs

CMD ["/bin/bash"]
4 changes: 2 additions & 2 deletions bin/ec2din.ngs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ F main(filters:Arr, allreg:Bool=false, j:Bool=false, c:Str=null, out_lines:Int=5
local_filters = AllOf()

filters = ['--filters'] +? collector filters.each(F(arg) {
kv = arg.split('=')

econd {

arg == 'windows' collect("Name=platform,Values=windows")
Expand Down Expand Up @@ -58,7 +58,7 @@ F main(filters:Arr, allreg:Bool=false, j:Bool=false, c:Str=null, out_lines:Int=5

arg in AWS::INSTANCE_STATES collect("Name=instance-state-name,Values=$arg")

kv.len() == 2 collect("Name=tag:${kv[0]},Values=${kv[1]}")
{kv = arg.split('='); kv.len() == 2} collect("Name=tag:${kv[0]},Values=${kv[1]}")
}
})

Expand Down
18 changes: 18 additions & 0 deletions build-scripts/bin2c.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/sh

# Contributed by Steven Penny, https://github.com/nu8
# Cosmetical changes and minor fixes by Ilya Sher

file_name=$1
var_name=$(tr /. __ <<eof
$file_name
eof
)
len=$(wc -c < "$file_name")
data=$(od -A n -t u1 -v "$file_name" | sed 's/ \+/,/g;1s/,//')
printf '// Generated by %s from input file %s
unsigned char %s[] = {
%s
};
unsigned int %s_len = %s;
' "$0" "$file_name" "$var_name" "$data" "$var_name" "$len"
11 changes: 8 additions & 3 deletions doc/make.ngs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
DocGroup = Doc::Group

commit = `line: git rev-parse HEAD`
pfx = Pfx("$NGS_DIR/")
pfx = Pfx(realpath('../lib'))
github_user = ENV.get('NGS_GITHUB_USER', 'ilyash')

F is_public_name(s:Str) s ~ /^[^_]/
Expand Down Expand Up @@ -779,9 +779,14 @@
md.source_ref= Box(if method is UserDefinedMethod {
# Handling UserDefinedMethod, not handling built-ins yet
location_info = method.ip().resolve_instruction_pointer()
if m = location_info.file ~ pfx {
f = if location_info.file == '<builtin-stdlib>' {
pfx.val / 'stdlib.ngs'
} else {
location_info.file
}
if m = f ~ pfx {
{
'file': m.after
'file': m.after[1..null]
'line': location_info.first_line
}
}
Expand Down
Loading

0 comments on commit d3900cf

Please sign in to comment.