Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Commit

Permalink
refactor file structure and introduce nix involvement in js builds
Browse files Browse the repository at this point in the history
  • Loading branch information
hlolli committed Jul 21, 2020
1 parent 404d31c commit 34fb158
Show file tree
Hide file tree
Showing 16 changed files with 2,582 additions and 203 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
with:
name: csound-wasm
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Compile csound to wasm
run: nix-env -i -f nix/compile.nix
- name: Install npm dependencies via yarn
run: yarn
- name: Test
run: yarn lint
- name: Compile csound natively to wasm
run: yarn compile
- name: Build javascript bundle
run: yarn build
175 changes: 0 additions & 175 deletions nix/clangCustom.nix

This file was deleted.

20 changes: 0 additions & 20 deletions nix/compile.nix

This file was deleted.

File renamed without changes.
13 changes: 13 additions & 0 deletions nix/native/compile.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{ pkgs ? import <nixpkgs> {}, dev ? false }:
let
L = pkgs.callPackage ./libcsound_objects.nix {};
clangCustom = import ./clangCustom.nix { pkgsOrig = pkgs; };

in pkgs.runCommand "csound-native-wasm" {} ''
mkdir $out
cp ${L.csoundP}/lib/libcsound.wasm $out
# cp ${L.csoundP}/lib/csound_exe.wasm $out
# make a compressed version for the browser bundle
${pkgs.zopfli}/bin/zopfli --zlib -c \
${L.csoundP}/lib/libcsound.wasm > $out/libcsound.wasm.zlib
''
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ pkgs.callPackage

buildPhase = ''
mkdir -p build && cd build
cp ${../c/csound_wasm.c} ./csound_wasm.c
cp ${../c/unsupported_opcodes.c} ./unsupported_opcodes.c
cp ${../../c/csound_wasm.c} ./csound_wasm.c
cp ${../../c/unsupported_opcodes.c} ./unsupported_opcodes.c
# ../OOps/lpred.c
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions nix/nodejs/build.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
with (import <nixpkgs> {});
with builtins;
pkgs.mkYarnPackage rec {
name = "csound-wasm";
# shellHook = pkgs.yarn2nix-moretea.linkNodeModulesHook;
src = ../..;
packageJSON = "${src}/package.json";
yarnLock = "${src}/yarn.lock";
yarnNix = "${src}/yarn.nix";
buildPhase = "npx rollup -c";
installPhase = ''
mkdir -p $out
cp deps/csound-wasm/dist/libcsound.mjs $out
cp deps/csound-wasm/dist/libcsound.mjs.map $out
'';
distPhase = "true";
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
"wasi"
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"compile": "nix-shell nix/compile.nix",
"compile:debug": "nix-shell nix/compile.nix --arg debug true",
"compile": "nix build '(with import <nixpkgs> {}; import ./nix/native/compile.nix)' -o lib",
"compile:debug": "nix-shell nix/native/compile.nix --arg debug true",
"compile:dev": "nix-shell nix/compile.nix --arg debug true --arg dev true",
"lint": "eslint 'src/**/*.js'",
"build": "npx rollup -c"
"build": "nix build '(with import <nixpkgs> {}; import ./nix/nodejs/build.nix)' -o dist"
},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.1",
Expand Down
Loading

0 comments on commit 34fb158

Please sign in to comment.