Skip to content

Commit

Permalink
NPM and Docker ARGs
Browse files Browse the repository at this point in the history
  • Loading branch information
DrSnuggles committed Mar 15, 2024
1 parent 3b8bae5 commit 45cfc7d
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 194 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
*.br
.npmrc
11 changes: 11 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
All code in this project is MIT (X11) licensed. The only exception are the compiled libopenmpt parts which remain under the OpenMPT project BSD license.

License text below:

Copyright © 2013-2024 The chiptune2.js and chiptune3 contributers.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 changes: 1 addition & 1 deletion chiptune3.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ChiptuneJsPlayer {
this.handlers = []

// worklet
this.context.audioWorklet.addModule( new URL('./chiptune3.worklet.min.js', import.meta.url) )
this.context.audioWorklet.addModule( new URL('./chiptune3.worklet.js', import.meta.url) )
.then(()=>{
this.processNode = new AudioWorkletNode(this.context, 'libopenmpt-processor', {
numberOfInputs: 0,
Expand Down
11 changes: 7 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# 3.1.51 worked
# 3.1.56 worked
FROM emscripten/emsdk:latest

ARG BASE
ARG FILE

# update / install
RUN apt update -y && apt upgrade -y && apt install pkg-config -y

# download
RUN wget https://lib.openmpt.org/files/libopenmpt/src/libopenmpt-0.7.4+release.makefile.tar.gz
RUN wget $BASE$FILE.makefile.tar.gz

# unpack
RUN tar xzvf libopenmpt-0.7.4+release.makefile.tar.gz && rm libopenmpt-0.7.4+release.makefile.tar.gz
RUN mkdir libopenmpt && tar xzvf $FILE.makefile.tar.gz -C ./libopenmpt --strip-components=1

WORKDIR /src/libopenmpt-0.7.4+release
WORKDIR /src/libopenmpt

# next line updates EXPORTED_FUNCTIONS
RUN sed -i "s/'_malloc','_free'/'_malloc','_free','stackAlloc','stackSave','stackRestore','UTF8ToString'/g" build/make/config-emscripten.mk
Expand Down
8 changes: 6 additions & 2 deletions docker/build.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
docker build -t emscripten:libopenmpt .
docker build --build-arg BASE=https://lib.openmpt.org/files/libopenmpt/src/ --build-arg FILE=libopenmpt-0.7.4+release -t emscripten:libopenmpt .
docker create --name mpt emscripten:libopenmpt
docker cp mpt:/src/libopenmpt-0.7.4+release/bin/libopenmpt.js ../libopenmpt.worklet.js
docker rm mpt
docker rmi emscripten:libopenmpt
REM docker rmi emscripten/emsdk:latest
docker rmi emscripten/emsdk:latest

cd ..
npm run minify
brotli -f *.min.js libopenmpt.worklet.js
13 changes: 10 additions & 3 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
docker build -t emscripten:libopenmpt . && \
# relases: https://lib.openmpt.org/files/libopenmpt/src/libopenmpt-0.7.4+release.makefile.tar.gz
# autobuilds: https://builds.openmpt.org/builds/auto/libopenmpt/src.makefile/0.7.5-pre.0/libopenmpt-0.7.5-pre.0+r20329.makefile.tar.gz
# https://builds.openmpt.org/builds/auto/libopenmpt/src.makefile/0.8.0-pre.4/libopenmpt-0.8.0-pre.4+r20328.makefile.tar.gz
docker build --build-arg BASE=https://lib.openmpt.org/files/libopenmpt/src/ --build-arg FILE=libopenmpt-0.7.4+release -t emscripten:libopenmpt . && \
docker create --name mpt emscripten:libopenmpt && \
docker cp mpt:/src/libopenmpt-0.7.4+release/bin/libopenmpt.js ../libopenmpt.worklet.js && \
docker cp mpt:/src/libopenmpt/bin/libopenmpt.js ../libopenmpt.worklet.js && \
docker rm mpt && \
docker rmi emscripten:libopenmpt
#docker rmi emscripten/emsdk:latest
docker rmi emscripten/emsdk:latest

cd ..
npm run minify
brotli -f *.min.js libopenmpt.worklet.js
325 changes: 146 additions & 179 deletions libopenmpt.worklet.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions minify.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const fs = require('fs'),
{ minify } = require('terser')
const { mainModule } = require('process')
import fs from 'fs'
import { minify } from 'terser'

main()
async function main() {
Expand Down Expand Up @@ -28,6 +27,7 @@ async function main() {
}
}
let code = fs.readFileSync('chiptune3.js', 'utf8')
code = code.replace('./chiptune3.worklet.js','./chiptune3.worklet.min.js')
let minified = await minify(code, config)
fs.writeFileSync('chiptune3.min.js', minified.code)

Expand Down
21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
{
"scripts": {"minify": "node minify.js"},
"name": "chiptune3",
"version": "0.7.4",
"description": "Chiptune3 the AudioWorklet successor of chiptune2",
"browser": "./chiptune3.js",
"author": "drsnuggles",
"license": "MIT",
"type": "module",
"repository": "https://github.com/DrSnuggles/chiptune",
"homepage": "https://github.com/DrSnuggles/chiptune#readme",
"bugs": "https://github.com/DrSnuggles/chiptune/issues",
"scripts": {
"minify": "node minify.js"
},
"files": [
"chiptune3.js",
"chiptune3.worklet.js",
"libopenmpt.worklet.js"
],
"devDependencies": {
"terser": "^4.0.2"
"terser": "^5.27.0"
}
}

0 comments on commit 45cfc7d

Please sign in to comment.