Skip to content

Commit

Permalink
Merge pull request #95 from mattpolzin/alt-json
Browse files Browse the repository at this point in the history
Use alternative JSON parsing library
  • Loading branch information
mattpolzin authored Dec 27, 2023
2 parents 35b471e + ce1763f commit 5d19344
Show file tree
Hide file tree
Showing 21 changed files with 587 additions and 602 deletions.
14 changes: 12 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ jobs:
uses: actions/checkout@v3
- name: Build
shell: bash
run: make
run: |
echo ''
echo 'Building with Idris 2 version:'
idris2 --version
echo ''
make
# - name: Test
# run: make test

Expand All @@ -37,7 +42,12 @@ jobs:
uses: actions/checkout@v3
- name: Build
shell: bash
run: make
run: |
echo ''
echo 'Building with Idris 2 version:'
idris2 --version
echo ''
make
# - name: Test
# run: make test

114 changes: 111 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

idris2 = idris2

idris-adds-version = 0.3.0
idris-json-version = 0.5.0
idris-json-hash = 2e54a37ed3c35c2d12c8927c923ad253355812a8
idris-elab-util-version = 0.6.0
idris-elab-util-hash = 2fc2d188640ce6822b5e250db73b62f5a952ca4d
idris-parser-version = 0.1.0
idris-parser-hash = 0fde36cf11c12a61edcfe09d585c5a60426bc706

idris2-version = $(shell $(idris2) --version | sed -En 's/Idris 2, version ([^-]+).*/\1/p')
idris2-build = $(shell $(idris2) --version | sed -En 's/Idris 2, version [^-]+(.*)/\1/p')
Expand All @@ -15,7 +22,9 @@ depends/idris-adds-${idris-adds-version}:
mkdir -p build/deps
ifeq ($(IDRIS_ADDS_SRC),)
cd build/deps && \
git clone https://github.com/mattpolzin/idris-adds.git && \
if [ ! -d ./idris-adds ]; then \
git clone https://github.com/mattpolzin/idris-adds.git; \
fi && \
cd idris-adds && \
git checkout ${idris-adds-version} && \
make && \
Expand All @@ -29,12 +38,109 @@ else
cp -R ./build/ttc/* ../../../depends/idris-adds-${idris-adds-version}/
endif

depends/elab-util-${idris-elab-util-version}:
mkdir -p depends/elab-util-${idris-elab-util-version}
mkdir -p build/deps
ifeq ($(IDRIS_ELAB_UTIL_SRC),)
cd build/deps && \
if [ ! -d ./idris2-elab-util ]; then \
git clone https://github.com/stefan-hoeck/idris2-elab-util.git; \
fi && \
cd idris2-elab-util && \
git checkout ${idris-elab-util-hash} && \
$(idris2) --build elab-util.ipkg && \
cp -R ./build/ttc/* ../../../depends/elab-util-${idris-elab-util-version}/
else
cd build/deps && \
cp -R $(IDRIS_ELAB_UTIL_SRC) ./elab-util && \
chmod -R +rw ./elab-util && \
cd elab-util && \
$(idris2) --build elab-util.ipkg && \
cp -R ./build/ttc/* ../../../depends/elab-util-${idris-elab-util-version}/
endif

depends/parser-${idris-parser-version}: depends/elab-util-${idris-elab-util-version}
mkdir -p depends/parser-${idris-parser-version}
mkdir -p build/deps
ifeq ($(IDRIS_PARSER_SRC),)
cd build/deps && \
if [ ! -d ./idris2-parser ]; then \
git clone https://github.com/stefan-hoeck/idris2-parser.git; \
fi && \
cd idris2-parser && \
git checkout ${idris-parser-hash} && \
IDRIS2_PACKAGE_PATH="$IDRIS2_PACKAGE_PATH:../../../depends" $(idris2) --build parser.ipkg && \
cp -R ./build/ttc/* ../../../depends/parser-${idris-parser-version}/
else
cd build/deps && \
cp -R $(IDRIS_PARSER_SRC) ./idris2-parser && \
chmod -R +rw ./idris2-parser && \
cd idris2-parser && \
IDRIS2_PACKAGE_PATH="$IDRIS2_PACKAGE_PATH:../../../depends" $(idris2) --build parser.ipkg && \
cp -R ./build/ttc/* ../../../depends/parser-${idris-parser-version}/
endif

define PATCH
5c5,6
< depends = parser
---
> depends = elab-util
> , parser
endef

export PATCH
depends/parser-json-${idris-parser-version}: depends/parser-${idris-parser-version}
mkdir -p depends/parser-json-${idris-parser-version}
mkdir -p build/deps
ifeq ($(IDRIS_PARSER_SRC),)
cd build/deps && \
if [ ! -d ./idris2-parser ]; then \
git clone https://github.com/stefan-hoeck/idris2-parser.git; \
fi && \
cd idris2-parser/json && \
git checkout ${idris-parser-hash} && \
echo "$$PATCH" | patch parser-json.ipkg - && \
IDRIS2_PACKAGE_PATH="$IDRIS2_PACKAGE_PATH:../../../../depends" $(idris2) --build parser-json.ipkg && \
cp -R ./build/ttc/* ../../../../depends/parser-json-${idris-parser-version}/
else
cd build/deps && \
if [ ! -d ./idris2-parser ]; then \
cp -R $(IDRIS_PARSER_SRC) ./idris2-parser && \
chmod -R +rw ./idris2-parser; \
fi && \
cd idris2-parser/json && \
echo "$$PATCH" | patch parser-json.ipkg - && \
IDRIS2_PACKAGE_PATH="$IDRIS2_PACKAGE_PATH:../../../../depends" $(idris2) --build parser-json.ipkg && \
cp -R ./build/ttc/* ../../../../depends/parser-json-${idris-parser-version}/
endif

depends/json-${idris-json-version}: depends/elab-util-${idris-elab-util-version} depends/parser-${idris-parser-version} depends/parser-json-${idris-parser-version}
mkdir -p depends/json-${idris-json-version}
mkdir -p build/deps
ifeq ($(IDRIS_JSON_SRC),)
cd build/deps && \
if [ ! -d ./idris2-json ]; then \
git clone https://github.com/stefan-hoeck/idris2-json.git; \
fi && \
cd idris2-json && \
git checkout ${idris-json-hash} && \
IDRIS2_PACKAGE_PATH="$IDRIS2_PACKAGE_PATH:../../../depends" $(idris2) --build json.ipkg && \
cp -R ./build/ttc/* ../../../depends/json-${idris-json-version}/
else
cd build/deps && \
cp -R $(IDRIS_JSON_SRC) ./idris2-json && \
chmod -R +rw ./idris2-json && \
cd idris2-json && \
IDRIS2_PACKAGE_PATH="$IDRIS2_PACKAGE_PATH:../../../depends" $(idris2) --build json.ipkg && \
cp -R ./build/ttc/* ../../../depends/json-${idris-json-version}/
endif

./node_modules/: package.json
npm install

build: ./node_modules/ depends/idris-adds-${idris-adds-version}
build: ./node_modules/ depends/idris-adds-${idris-adds-version} depends/json-${idris-json-version}
IDRIS2_DATA=./support $(idris2) --build harmony.ipkg
@if [[ ${idris2-minor-version} -gt 6 ]] || [[ "${idris2-build}" != '' ]]; then \
@if [ ${idris2-minor-version} -gt 6 ] || [ "${idris2-build}" != '' ]; then \
cp ./build/exec/harmony ./harmony; \
else \
echo "#!/usr/bin/env node" > ./harmony; \
Expand All @@ -46,6 +152,8 @@ harmony: build

node2nix ?= nix run nixpkgs\#node2nix

# This executes a Nix build. Call as `make nix-build` from CLI, not
# from a Nix file.
nix-build:
${MAKE} clean
$(node2nix) -- --composition node2nix.nix # -l # <- can't use -l for lockfile because lockfile version 3 not supported yet.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Harmony offers a heuristic for PR assignments that is different than GitHub's ro

## Dependencies
### Runtime
Running Harmony requires NodeJS 14+ (and a local installation of `git`) or alternatively Nix with flakes enabled.
Running Harmony requires NodeJS 18+ (and a local installation of `git`) or alternatively Nix with flakes enabled.

If you'd like to try Harmony out without even "installing" it and you have Nix installed with flakes enabled, you can run it as `nix run github:mattpolzin/harmony`.

Expand Down Expand Up @@ -61,7 +61,7 @@ docker pull mattpolzin2/idris-docker:nightly

Then, from a directory containing this Harmony git repository, build Harmony:
```shell
docker run --rm -v "$(pwd):/build" mattpolzin2/idris-docker:nightly bash -c "cd /build && make"
docker run --rm -v "$(pwd):/build" mattpolzin2/idris-docker:nightly bash -c "apt-get update && apt-get install -y git && cd /build && make"
```

At this point you are done with Docker. From the same directory, install Harmony globally:
Expand Down
39 changes: 32 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, lib, callPackage, fetchFromGitHub, idris2, makeWrapper, nodejs }:
{ stdenv, lib, callPackage, fetchFromGitHub, idris2, git, makeWrapper, nodejs }:
let
nodeDependencies = (callPackage ./node2nix.nix { inherit nodejs; }).nodeDependencies;
idrisAddsVersion = "0.3.0";
Expand All @@ -8,22 +8,47 @@ let
rev = "${idrisAddsVersion}";
hash = "sha256-OSu381nUNZqFJs4HzmMxGda60k7xsa1GulQq7kU/R2o=";
};
elabUtilRev = "2fc2d188640ce6822b5e250db73b62f5a952ca4d";
elabUtilSrc = fetchFromGitHub {
owner = "stefan-hoeck";
repo = "idris2-elab-util";
rev = "${elabUtilRev}";
hash = "sha256-CYPrhB9y4CMk2Wiecpk+5isybcf3ZsbmaKdKOyo0JWk=";
};
idrisJsonRev = "2e54a37ed3c35c2d12c8927c923ad253355812a8";
idrisJsonSrc = fetchFromGitHub {
owner = "stefan-hoeck";
repo = "idris2-json";
rev = "${idrisJsonRev}";
hash = "sha256-+lwOdkovhOsvaSKH+jJY7uhr40JjXpUJ4ECR9qxZv14=";
};
idrisParserRev = "0fde36cf11c12a61edcfe09d585c5a60426bc706";
idrisParserSrc = fetchFromGitHub {
owner = "stefan-hoeck";
repo = "idris2-parser";
rev = "${idrisParserRev}";
hash = "sha256-ShwVAUsobrwmuYszYld1RqlRUvnrACpyyqK2JKaIWYM=";
};
in
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "harmony";
version = "2.6.2";
version = "3.0.0";

nativeBuildInputs = [ idris2 makeWrapper ];
buildInputs = [ nodejs ];
buildInputs = [ nodejs git ];

src = ./.;

IDRIS_ADDS_SRC = "${idrisAddsSrc}";
IDRIS_ELAB_UTIL_SRC = "${elabUtilSrc}";
IDRIS_PARSER_SRC = "${idrisParserSrc}";
IDRIS_JSON_SRC = "${idrisJsonSrc}";

buildPhase = ''
runHook preBuild
ln -s ${nodeDependencies}/lib/node_modules ./node_modules
export PATH="${nodeDependencies}/bin:$PATH"
export IDRIS_ADDS_SRC="${idrisAddsSrc}"
make build
Expand All @@ -37,10 +62,10 @@ stdenv.mkDerivation {
cp harmony $out/bin/
wrapProgram $out/bin/harmony \
--prefix PATH : ${lib.makeBinPath [ nodeDependencies ]} \
--prefix PATH : ${lib.makeBinPath [ nodeDependencies git "$out" ]} \
--prefix NODE_PATH : ${nodeDependencies}/lib/node_modules
runHook postInstall
'';

}
})
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions harmony.ipkg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package harmony
version = 2.6.2
version = 3.0.0
authors = "Mathew Polzin"
license = "MIT"
-- brief =
Expand All @@ -8,10 +8,14 @@ license = "MIT"
-- sourceloc =
-- bugtracker =

langversion >= 0.6.0
langversion >= 0.7.0

depends = contrib
, idris-adds >= 0.3.0
, elab-util >= 0.1.0
, parser >= 0.1.0
, parser-json >= 0.1.0
, json >= 0.5.0

modules = Main
main = Main
Expand Down
Loading

0 comments on commit 5d19344

Please sign in to comment.