summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2024-04-28 22:52:57 -0700
committerWilfred Hughes <me@wilfred.me.uk>2024-04-28 22:54:18 -0700
commita5b2587eaa17b78a12d47b37b509e18e24704729 (patch)
tree2dbcf1e78986e0a5d64401ef3753e80bde15e4e9
parentc2df185d4928e78c879f9bc45ffb1793e9876358 (diff)
parenteb68645662a3f7bf7fdd4bcb9531585f54c8570e (diff)
-rw-r--r--CHANGELOG.md2
-rw-r--r--vendored_parsers/tree-sitter-go/.editorconfig39
-rw-r--r--vendored_parsers/tree-sitter-go/.eslintrc.js21
-rw-r--r--vendored_parsers/tree-sitter-go/.gitattributes15
-rw-r--r--vendored_parsers/tree-sitter-go/.github/dependabot.yml8
-rw-r--r--vendored_parsers/tree-sitter-go/.github/pull_request_template.md8
-rw-r--r--vendored_parsers/tree-sitter-go/.github/workflows/ci.yml89
-rw-r--r--vendored_parsers/tree-sitter-go/.github/workflows/lint.yml19
-rw-r--r--vendored_parsers/tree-sitter-go/.github/workflows/publish.yml23
-rw-r--r--vendored_parsers/tree-sitter-go/.github/workflows/release.yml103
-rw-r--r--vendored_parsers/tree-sitter-go/.gitignore44
-rw-r--r--vendored_parsers/tree-sitter-go/.npmignore7
-rw-r--r--vendored_parsers/tree-sitter-go/Cargo.toml15
-rw-r--r--vendored_parsers/tree-sitter-go/Makefile143
-rw-r--r--vendored_parsers/tree-sitter-go/Package.swift33
-rw-r--r--vendored_parsers/tree-sitter-go/README.md16
-rw-r--r--vendored_parsers/tree-sitter-go/binding.gyp12
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/c/tree-sitter-go.h16
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/c/tree-sitter-go.pc.in11
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/c/tree-sitter.h.in16
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/c/tree-sitter.pc.in11
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/go/binding.go12
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/go/binding_test.go15
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/go/go.mod5
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/node/binding.cc38
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/node/index.d.ts28
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/node/index.js20
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/python/tree_sitter_go/__init__.py5
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/python/tree_sitter_go/__init__.pyi1
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/python/tree_sitter_go/binding.c27
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/python/tree_sitter_go/py.typed0
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/rust/README.md36
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/rust/build.rs11
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/rust/lib.rs40
-rw-r--r--vendored_parsers/tree-sitter-go/bindings/swift/TreeSitterGo/go.h2
-rw-r--r--vendored_parsers/tree-sitter-go/grammar.js204
-rw-r--r--vendored_parsers/tree-sitter-go/package-lock.json1490
-rw-r--r--vendored_parsers/tree-sitter-go/package.json98
-rw-r--r--vendored_parsers/tree-sitter-go/pyproject.toml33
-rw-r--r--vendored_parsers/tree-sitter-go/queries/highlights.scm6
-rw-r--r--vendored_parsers/tree-sitter-go/script/known-failures.txt1
-rwxr-xr-xvendored_parsers/tree-sitter-go/script/parse-examples47
-rw-r--r--vendored_parsers/tree-sitter-go/setup.py56
-rw-r--r--vendored_parsers/tree-sitter-go/src/grammar.json349
-rw-r--r--vendored_parsers/tree-sitter-go/src/node-types.json153
-rw-r--r--vendored_parsers/tree-sitter-go/src/parser.c51039
-rw-r--r--vendored_parsers/tree-sitter-go/src/tree_sitter/alloc.h54
-rw-r--r--vendored_parsers/tree-sitter-go/src/tree_sitter/array.h290
-rw-r--r--vendored_parsers/tree-sitter-go/src/tree_sitter/parser.h16
-rw-r--r--vendored_parsers/tree-sitter-go/test/corpus/declarations.txt90
-rw-r--r--vendored_parsers/tree-sitter-go/test/corpus/expressions.txt54
-rw-r--r--vendored_parsers/tree-sitter-go/test/corpus/literals.txt13
-rw-r--r--vendored_parsers/tree-sitter-go/test/corpus/types.txt113
53 files changed, 28671 insertions, 26326 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 105f2a255..59fa2ca2f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,7 +12,7 @@ Since difftastic is now conservative with parse errors
(DFT_PARSE_ERROR_LIMIT is 0 by default), this seems like a better
tradeoff.
-Updated CSS and Lua parsers.
+Updated CSS, Go and Lua parsers.
### Diffing
diff --git a/vendored_parsers/tree-sitter-go/.editorconfig b/vendored_parsers/tree-sitter-go/.editorconfig
new file mode 100644
index 000000000..d3a8b5b69
--- /dev/null
+++ b/vendored_parsers/tree-sitter-go/.editorconfig
@@ -0,0 +1,39 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+trim_trailing_whitespace = true
+
+[*.{json,toml,yml,gyp}]
+indent_style = space
+indent_size = 2
+
+[*.js]
+indent_style = space
+indent_size = 2
+
+[*.rs]
+indent_style = space
+indent_size = 4
+
+[*.{c,cc,h}]
+indent_style = space
+indent_size = 4
+
+[*.{py,pyi}]
+indent_style = space
+indent_size = 4
+
+[*.swift]
+indent_style = space
+indent_size = 4
+
+[*.go]
+indent_style = tab
+indent_size = 8
+
+[Makefile]
+indent_style = tab
+indent_size = 8
diff --git a/vendored_parsers/tree-sitter-go/.eslintrc.js b/vendored_parsers/tree-sitter-go/.eslintrc.js
deleted file mode 100644
index de1cc0506..000000000
--- a/vendored_parsers/tree-sitter-go/.eslintrc.js
+++ /dev/null
@@ -1,21 +0,0 @@
-module.exports = {
- 'env': {
- 'commonjs': true,
- 'es2021': true,
- },
- 'extends': 'google',
- 'overrides': [
- ],
- 'parserOptions': {
- 'ecmaVersion': 'latest',
- 'sourceType': 'module',
- },
- 'rules': {
- 'indent': ['error', 2, {'SwitchCase': 1}],
- 'max-len': [
- 'error',
- {'code': 160, 'ignoreComments': true, 'ignoreUrls': true, 'ignoreStrings': true},
- ],
- 'one-var': ['error', 'consecutive'],
- },
-};
diff --git a/vendored_parsers/tree-sitter-go/.gitattributes b/vendored_parsers/tree-sitter-go/.gitattributes
index c647c2bf4..ffb52abec 100644
--- a/vendored_parsers/tree-sitter-go/.gitattributes
+++ b/vendored_parsers/tree-sitter-go/.gitattributes
@@ -1,6 +1,11 @@
-/src/** linguist-vendored
-/examples/* linguist-vendored
+* text eol=lf
-src/grammar.json -diff
-src/node-types.json -diff
-src/parser.c -diff
+src/*.json linguist-generated
+src/parser.c linguist-generated
+src/tree_sitter/* linguist-generated
+
+bindings/** linguist-generated
+binding.gyp linguist-generated
+setup.py linguist-generated
+Makefile linguist-generated
+Package.swift linguist-generated
diff --git a/vendored_parsers/tree-sitter-go/.github/dependabot.yml b/vendored_parsers/tree-sitter-go/.github/dependabot.yml
new file mode 100644
index 000000000..4c39a334b
--- /dev/null
+++ b/vendored_parsers/tree-sitter-go/.github/dependabot.yml
@@ -0,0 +1,8 @@
+version: 2
+updates:
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
+ commit-message:
+ prefix: "ci"
diff --git a/vendored_parsers/tree-sitter-go/.github/pull_request_template.md b/vendored_parsers/tree-sitter-go/.github/pull_request_template.md
deleted file mode 100644
index 2714bb61f..000000000
--- a/vendored_parsers/tree-sitter-go/.github/pull_request_template.md
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-Checklist:
-- [ ] All tests pass in CI.
-- [ ] There are sufficient tests for the new fix/feature.
-- [ ] Grammar rules have not been renamed unless absolutely necessary.
-- [ ] The conflicts section hasn't grown too much.
-- [ ] The parser size hasn't grown too much (check the value of STATE_COUNT in src/parser.c).
diff --git a/vendored_parsers/tree-sitter-go/.github/workflows/ci.yml b/vendored_parsers/tree-sitter-go/.github/workflows/ci.yml
index 07afc2fdf..86a5dfb1c 100644
--- a/vendored_parsers/tree-sitter-go/.github/workflows/ci.yml
+++ b/vendored_parsers/tree-sitter-go/.github/workflows/ci.yml
@@ -1,31 +1,82 @@
name: CI
on:
- pull_request: null
push:
- branches:
- - master
+ branches: [master]
+ paths:
+ - grammar.js
+ - src/**
+ - test/**
+ - bindings/**
+ - binding.gyp
+ pull_request:
+ paths:
+ - grammar.js
+ - src/**
+ - test/**
+ - bindings/**
+ - binding.gyp
+
+concurrency:
+ group: ${{github.workflow}}-${{github.ref}}
+ cancel-in-progress: true
jobs:
test:
- runs-on: ${{ matrix.os }}
+ name: Test parser
+ runs-on: ${{matrix.os}}
strategy:
- fail-fast: true
+ fail-fast: false
matrix:
- os: [macos-latest, ubuntu-latest]
+ os: [ubuntu-latest, windows-latest, macos-14]
steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-node@v3
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ - name: Set up tree-sitter
+ uses: tree-sitter/setup-action/cli@v1
+ - name: Set up examples
+ run: |-
+ git clone https://github.com/golang/go examples/go --single-branch --depth=1 --filter=blob:none
+ git clone https://github.com/moby/moby examples/moby --single-branch --depth=1 --filter=blob:none
+ - name: Run tests
+ uses: tree-sitter/parser-test-action@v2
with:
- node-version: 18
- - run: npm install
- - run: npm test
- test_windows:
- runs-on: windows-latest
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-node@v3
+ test-rust: ${{runner.os == 'Linux'}}
+ - name: Parse examples
+ id: examples
+ continue-on-error: true
+ uses: tree-sitter/parse-action@v4
+ with:
+ files: examples/**/*.go
+ invalid-files: |
+ examples/go/src/cmd/compile/internal/syntax/testdata/*.go
+ examples/go/src/cmd/compile/internal/types2/testdata/local/issue47996.go
+ examples/go/src/go/parser/testdata/issue42951/not_a_file.go/invalid.go
+ examples/go/src/internal/types/testdata/**/*.go
+ examples/go/test/bombad.go
+ examples/go/test/const2.go
+ examples/go/test/ddd1.go
+ examples/go/test/fixedbugs/**/*.go
+ examples/go/test/import5.go
+ examples/go/test/makenew.go
+ examples/go/test/method4.dir/prog.go
+ examples/go/test/method7.go
+ examples/go/test/slice3err.go
+ examples/go/test/switch2.go
+ examples/go/test/syntax/chan.go
+ examples/go/test/syntax/chan1.go
+ examples/go/test/syntax/ddd.go
+ examples/go/test/syntax/else.go
+ examples/go/test/syntax/if.go
+ examples/go/test/syntax/import.go
+ examples/go/test/syntax/initvar.go
+ examples/go/test/syntax/semi*.go
+ examples/go/test/syntax/vareq.go
+ examples/go/test/syntax/vareq1.go
+ examples/go/test/typeparam/issue*.go
+ examples/moby/daemon/logger/journald/read_test.go
+ - uses: actions/upload-artifact@v4
+ if: steps.examples.outputs.failures != ''
with:
- node-version: 18
- - run: npm install
- - run: npm run-script test-windows
+ name: failures-${{matrix.os}}
+ path: ${{steps.examples.outputs.failures}}
diff --git a/vendored_parsers/tree-sitter-go/.github/workflows/lint.yml b/vendored_parsers/tree-sitter-go/.github/workflows/lint.yml
index d94f7f39d..96f1a4df0 100644
--- a/vendored_parsers/tree-sitter-go/.github/workflows/lint.yml
+++ b/vendored_parsers/tree-sitter-go/.github/workflows/lint.yml
@@ -2,18 +2,25 @@ name: Lint
on:
push:
- branches:
- - master
+ branches: [master]
+ paths:
+ - grammar.js
pull_request:
- branches:
- - "**"
+ paths:
+ - grammar.js
jobs:
lint:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v3
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ - name: Set up Node.js
+ uses: actions/setup-node@v4
+ with:
+ cache: npm
+ node-version: ${{vars.NODE_VERSION}}
- name: Install modules
- run: npm install
+ run: npm ci --legacy-peer-deps
- name: Run ESLint
run: npm run lint
diff --git a/vendored_parsers/tree-sitter-go/.github/workflows/publish.yml b/vendored_parsers/tree-sitter-go/.github/workflows/publish.yml
new file mode 100644
index 000000000..cb7e16b8b
--- /dev/null
+++ b/vendored_parsers/tree-sitter-go/.github/workflows/publish.yml
@@ -0,0 +1,23 @@
+name: Publish packages
+
+on:
+ push:
+ tags: ["*"]
+
+concurrency:
+ group: ${{github.workflow}}-${{github.ref}}
+ cancel-in-progress: true
+
+jobs:
+ npm:
+ uses: tree-sitter/workflows/.github/workflows/package-npm.yml@main
+ secrets:
+ NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
+ crates:
+ uses: tree-sitter/workflows/.github/workflows/package-crates.yml@main
+ secrets:
+ CARGO_REGISTRY_TOKEN: ${{secrets.CARGO_REGISTRY_TOKEN}}
+ pypi:
+ uses: tree-sitter/workflows/.github/workflows/package-pypi.yml@main
+ secrets:
+ PYPI_API_TOKEN: ${{secrets.PYPI_API_TOKEN}}
diff --git a/vendored_parsers/tree-sitter-go/.github/workflows/release.yml b/vendored_parsers/tree-sitter-go/.github/workflows/release.yml
deleted file mode 100644
index c2020e92f..000000000
--- a/vendored_parsers/tree-sitter-go/.github/workflows/release.yml
+++ /dev/null
@@ -1,103 +0,0 @@
-name: Release
-
-on:
- workflow_run:
- workflows: ["CI"]
- branches:
- - master
- types:
- - completed
-
-jobs:
- release:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout code
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
-
- - name: Get previous commit SHA
- id: get_previous_commit
- run: |
- LATEST_TAG=$(git describe --tags --abbrev=0)
- if [[ -z "$LATEST_TAG" ]]; then
- echo "No tag found. Failing..."
- exit 1
- fi
- echo "latest_tag=${LATEST_TAG#v}" >> "$GITHUB_ENV" # Remove 'v' prefix from the tag
-
- - name: Check if version changed and is greater than the previous
- id: version_check
- run: |
- # Compare the current version with the version from the previous commit
- PREVIOUS_NPM_VERSION=${{ env.latest_tag }}
- CURRENT_NPM_VERSION=$(jq -r '.version' package.json)
- CURRENT_CARGO_VERSION=$(awk -F '"' '/^version/ {print $2}' Cargo.toml)
- if [[ "$CURRENT_NPM_VERSION" != "$CURRENT_CARGO_VERSION" ]]; then # Cargo.toml and package.json versions must match
- echo "Mismatch: NPM version ($CURRENT_NPM_VERSION) and Cargo.toml version ($CURRENT_CARGO_VERSION)"
- echo "version_changed=false" >> "$GITHUB_ENV"
- else
- if [[ "$PREVIOUS_NPM_VERSION" == "$CURRENT_NPM_VERSION" ]]; then
- echo "version_changed=" >> "$GITHUB_ENV"
- else
- IFS='.' read -ra PREVIOUS_VERSION_PARTS <<< "$PREVIOUS_NPM_VERSION"
- IFS='.' read -ra CURRENT_VERSION_PARTS <<< "$CURRENT_NPM_VERSION"
- VERSION_CHANGED=false
- for i in "${!PREVIOUS_VERSION_PARTS[@]}"; do
- if [[ ${CURRENT_VERSION_PARTS[i]} -gt ${PREVIOUS_VERSION_PARTS[i]} ]]; then
- VERSION_CHANGED=true
- break
- elif [[ ${CURRENT_VERSION_PARTS[i]} -lt ${PREVIOUS_VERSION_PARTS[i]} ]]; then
- break
- fi
- done
-
- echo "version_changed=$VERSION_CHANGED" >> "$GITHUB_ENV"
- echo "current_version=${CURRENT_NPM_VERSION}" >> "$GITHUB_ENV"
- fi
- fi
-
- - name: Display result
- run: |
- echo "Version bump detected: ${{ env.version_changed }}"
-
- - name: Fail if version is lower
- if: env.version_changed == 'false'
- run: exit 1
-
- - name: Setup Node
- if: env.version_changed == 'true'
- uses: actions/setup-node@v3
- with:
- node-version: 18
- registry-url: "https://registry.npmjs.org"
- - name: Publish to NPM
- if: env.version_changed == 'true'
- env:
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
- run: npm publish
-
- - name: Setup Rust
- if: env.version_changed == 'true'
- uses: actions-rs/toolchain@v1
- with:
- profile: minimal
- toolchain: stable
- override: true
- - name: Publish to Crates.io
- if: env.version_changed == 'true'
- uses: katyo/publish-crates@v2
- with:
- registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
-
- - name: Tag versions
- if: env.version_changed == 'true'
- run: |
- git checkout master
- git config user.name github-actions[bot]
- git config user.email github-actions[bot]@users.noreply.github.com
- git tag -d "v${{ env.current_version }}" || true
- git push origin --delete "v${{ env.current_version }}" || true
- git tag -a "v${{ env.current_version }}" -m "Version ${{ env.current_version }}"
- git push origin "v${{ env.current_version }}"
diff --git a/vendored_parsers/tree-sitter-go/.gitignore b/vendored_parsers/tree-sitter-go/.gitignore
index 5f5c27a2a..27fc43f72 100644
--- a/vendored_parsers/tree-sitter-go/.gitignore
+++ b/vendored_parsers/tree-sitter-go/.gitignore
@@ -1,16 +1,38 @@
+# Rust artifacts
Cargo.lock
-node_modules
-build
-*.log
-package-lock.json
-examples/go
-examples/moby
-target
+target/
+# Node artifacts
+build/
+prebuilds/
+node_modules/
+*.tgz
+
+# Swift artifacts
+.build/
+
+# Go artifacts
+go.sum
+_obj/
+
+# Python artifacts
+.venv/
+dist/
+*.egg-info
+*.whl
+
+# C artifacts
*.a
-*.dylib
*.so
+*.so.*
+*.dylib
+*.dll
+*.pc
+
+# Example dirs
+/examples/*/
+
+# Grammar volatiles
+*.wasm
+*.obj
*.o
-bindings/c/*.h
-bindings/c/tree-sitter-*.pc
-.build/
diff --git a/vendored_parsers/tree-sitter-go/.npmignore b/vendored_parsers/tree-sitter-go/.npmignore
deleted file mode 100644
index 8043cee9c..000000000
--- a/vendored_parsers/tree-sitter-go/.npmignore
+++ /dev/null
@@ -1,7 +0,0 @@
-corpus
-examples
-build
-script
-.travis.yml
-.gitattributes
-target
diff --git a/vendored_parsers/tree-sitter-go/Cargo.toml b/vendored_parsers/tree-sitter-go/Cargo.toml
index afd9f0441..bd534c184 100644
--- a/vendored_parsers/tree-sitter-go/Cargo.toml
+++ b/vendored_parsers/tree-sitter-go/Cargo.toml
@@ -1,17 +1,16 @@
[package]
name = "tree-sitter-go"
description = "Go grammar for tree-sitter"
-version = "0.20.0"
+version = "0.21.0"
authors = [
- "Max Brunsfeld <maxbrunsfeld@gmail.com>",
- "Douglas Creager <dcreager@dcreager.net>",
+ "Max Brunsfeld <maxbrunsfeld@gmail.com>",
+ "Amaan Qureshi <amaanq12@gmail.com>",
]
license = "MIT"
-readme = "bindings/rust/README.md"
-keywords = ["incremental", "parsing", "go"]
+keywords = ["incremental", "parsing", "tree-sitter", "go"]
categories = ["parsing", "text-editors"]
repository = "https://github.com/tree-sitter/tree-sitter-go"
-edition = "2018"
+edition = "2021"
autoexamples = false
build = "bindings/rust/build.rs"
@@ -21,7 +20,7 @@ include = ["bindings/rust/*", "grammar.js", "queries/*", "src/*"]
path = "bindings/rust/lib.rs"
[dependencies]
-tree-sitter = ">= 0.20, < 0.21"
+tree-sitter = ">=0.21.0"
[build-dependencies]
-cc = "1.0"
+cc = "1.0.90"
diff --git a/vendored_parsers/tree-sitter-go/Makefile b/vendored_parsers/tree-sitter-go/Makefile
index 50a1f2781..b9346c961 100644
--- a/vendored_parsers/tree-sitter-go/Makefile
+++ b/vendored_parsers/tree-sitter-go/Makefile
@@ -1,23 +1,25 @@
-VERSION := 0.20.0
+VERSION := 0.21.0
-# Repository
-SRC_DIR := src
+LANGUAGE_NAME := tree-sitter-go
-PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin )
+# repository
+SRC_DIR := src
-ifeq (, $(PARSER_NAME))
- PARSER_NAME := $(shell basename $(PARSER_REPO_URL))
- PARSER_NAME := $(subst tree-sitter-,,$(PARSER_NAME))
- PARSER_NAME := $(subst .git,,$(PARSER_NAME))
-endif
+PARSER_REPO_URL := $(shell git -C $(SRC_DIR) remote get-url origin 2>/dev/null)
-ifeq (, $(PARSER_URL))
- PARSER_URL := $(subst :,/,$(PARSER_REPO_URL))
+ifeq ($(PARSER_URL),)
+ PARSER_URL := $(subst .git,,$(PARSER_REPO_URL))
+ifeq ($(shell echo $(PARSER_URL) | grep '^[a-z][-+.0-9a-z]*://'),)
+ PARSER_URL := $(subst :,/,$(PARSER_URL))
PARSER_URL := $(subst git@,https://,$(PARSER_URL))
- PARSER_URL := $(subst .git,,$(PARSER_URL))
+endif
endif
-UPPER_PARSER_NAME := $(shell echo $(PARSER_NAME) | tr a-z A-Z )
+TS ?= tree-sitter
+
+# ABI versioning
+SONAME_MAJOR := $(word 1,$(subst ., ,$(VERSION)))
+SONAME_MINOR := $(word 2,$(subst ., ,$(VERSION)))
# install directory layout
PREFIX ?= /usr/local
@@ -25,90 +27,85 @@ INCLUDEDIR ?= $(PREFIX)/include
LIBDIR ?= $(PREFIX)/lib
PCLIBDIR ?= $(LIBDIR)/pkgconfig
-# collect C++ sources, and link if necessary
-CPPSRC := $(wildcard $(SRC_DIR)/*.cc)
-
-ifeq (, $(CPPSRC))
- ADDITIONALLIBS :=
-else
- ADDITIONALLIBS := -lc++
-endif
+# object files
+OBJS := $(patsubst %.c,%.o,$(wildcard $(SRC_DIR)/*.c))
-# collect sources
-SRC := $(wildcard $(SRC_DIR)/*.c)
-SRC += $(CPPSRC)
-OBJ := $(addsuffix .o,$(basename $(SRC)))
-
-# ABI versioning
-SONAME_MAJOR := 0
-SONAME_MINOR := 0
-
-CFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR)
-CXXFLAGS ?= -O3 -Wall -Wextra -I$(SRC_DIR)
-override CFLAGS += -std=gnu99 -fPIC
-override CXXFLAGS += -fPIC
+# flags
+ARFLAGS := rcs
+override CFLAGS += -I$(SRC_DIR) -std=c11 -fPIC
# OS-specific bits
-ifeq ($(shell uname),Darwin)
+ifeq ($(OS),Windows_NT)
+ $(error "Windows is not supported")
+else ifeq ($(shell uname),Darwin)
SOEXT = dylib
SOEXTVER_MAJOR = $(SONAME_MAJOR).dylib
SOEXTVER = $(SONAME_MAJOR).$(SONAME_MINOR).dylib
LINKSHARED := $(LINKSHARED)-dynamiclib -Wl,
- ifneq ($(ADDITIONALLIBS),)