From 3cfea847c5beea8d414ed8411b0a55b072d93a69 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Thu, 25 Jul 2019 22:49:03 +0100 Subject: [PATCH] Added npm setup and remove old Makefile - automatically checkout submodule - add missing browserify.js entry point Signed-off-by: Stefan Marr --- .gitignore | 1 + Makefile | 54 --------------------------------------------- jsconfig.json | 12 ++++++++++ package.json | 29 ++++++++++++++++++++++++ som.sh | 2 ++ tests/browserify.js | 12 ++++++++++ 6 files changed, 56 insertions(+), 54 deletions(-) delete mode 100644 Makefile create mode 100644 jsconfig.json create mode 100644 package.json create mode 100644 tests/browserify.js diff --git a/.gitignore b/.gitignore index f7c1110..1510ee3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ build src_gen +node_modules diff --git a/Makefile b/Makefile deleted file mode 100644 index f0c40d6..0000000 --- a/Makefile +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env make -f - -JS_SRC=$(shell libs/deps.py) -CLOJURE_JAR=build/closure-compiler/compiler.jar - -AWFY_ROOT?=../../benchmarks/SOM -AWFY_SRC=$(wildcard $(AWFY_ROOT)/*.som) $(wildcard $(AWFY_ROOT)/**/*.som) - -SOM_SRC=$(wildcard core-lib/**/*.som) - -all: build/som.min.js build/node.min.js build/som.full.js build/som-repl.min.js build/som-repl.full.js - -src_gen: - mkdir src_gen - -test: build/node.min.js - ./som.sh -cp Smalltalk TestSuite/TestHarness.som - -$(CLOJURE_JAR): - -mkdir -p build/closure-compiler - wget http://dl.google.com/closure-compiler/compiler-latest.zip -O build/closure-compiler/compiler-latest.zip - unzip build/closure-compiler/compiler-latest.zip -d build/closure-compiler/ - mv build/closure-compiler/closure-compiler-*.jar build/closure-compiler/compiler.jar - -build/som.min.js: $(JS_SRC) $(CLOJURE_JAR) - java -jar $(CLOJURE_JAR) --language_in=ECMASCRIPT6_STRICT --js_output_file=$@ $(JS_SRC) - -build/node.min.js: $(JS_SRC) src/som/vm/Shell.js src/node.js - java -jar $(CLOJURE_JAR) --language_in=ECMASCRIPT6_STRICT --js_output_file=$@ $(JS_SRC) src/som/vm/Shell.js src/node.js - -build/som.full.js: $(JS_SRC) - cat $(JS_SRC) > $@ - -build/som-repl.full.js: $(JS_SRC) src/web-repl.js - cat $(JS_SRC) src/web-repl.js > $@ - -build/som-repl.min.js: $(JS_SRC) src/web-repl.js $(CLOJURE_JAR) - java -jar $(CLOJURE_JAR) --language_in=ECMASCRIPT6_STRICT --js_output_file=$@ $(JS_SRC) src/web-repl.js - -src_gen/core_lib.js: core-lib src_gen $(SOM_SRC) $(AWFY_SRC) - libs/jsify-core-lib.py $(SOM_SRC) $(AWFY_SRC) > $@ - -core-lib: core-lib/Smalltalk - -core-lib/Smalltalk: - git submodule update --init --recursive - -clean: - @rm -Rf build/*.js - @rm -Rf src_gen/*.js - -clobber: - @rm -Rf build - @rm -Rf src_gen diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 0000000..b09d9da --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es2016", + "jsx": "preserve" + }, + "exclude": [ + "node_modules", + "**/node_modules/*", + "build" + ] +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..6bcd300 --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "jssom", + "displayName": "JsSOM", + "version": "0.1.0", + "description": "A JavaScript implementation of the SOM (Simple Object Machine", + "repository": { + "type": "git", + "url": "https://github.com/SOM-st/JsSOM.git" + }, + "author": { + "name": "Stefan Marr", + "email": "git@stefan-marr.de" + }, + "license": "MIT", + "devDependencies": { + "browserify": "^16.3.0", + "tinyify": "^2.5.1" + }, + "scripts": { + "browserify": "mkdir -p build && npm run core-lib && npm run browserify:som-core && npm run browserify:main && npm run browserify:test", + "_re-add": "--plugin tinyify", + "browserify:test": "browserify tests/browserify.js -o build/test.js", + "browserify:main": "browserify src/node.js -o build/node.js", + "browserify:som-core": "./libs/jsify-core-lib.py core-lib > build/som.js", + "clean": "rm -Rf build/*.js", + "clobber": "rm -Rf build/", + "core-lib": "git submodule update --init --recursive", + } +} diff --git a/som.sh b/som.sh index 1f58144..3409e6d 100755 --- a/som.sh +++ b/som.sh @@ -1,2 +1,4 @@ #!/bin/sh +git submodule update --init --recursive > /dev/null 2>&1 + exec node src/node.js "$@" diff --git a/tests/browserify.js b/tests/browserify.js new file mode 100644 index 0000000..88f2ed1 --- /dev/null +++ b/tests/browserify.js @@ -0,0 +1,12 @@ +const u = require('../src/som/vm/Universe'); +const compileClassString = require('../src/som/compiler/SourcecodeCompiler').compileClassString; +const universe = u.universe; + +if (document) { + document.u = u; + document.compileClassString = compileClassString; +} + +universe.interpret(["-cp", "core-lib/Smalltalk", "core-lib/TestSuite/TestHarness.som "]); + +