Skip to content

Commit

Permalink
autobuild working
Browse files Browse the repository at this point in the history
  • Loading branch information
billywhizz committed Dec 18, 2020
1 parent 64da9e3 commit 1112b08
Show file tree
Hide file tree
Showing 8 changed files with 296 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CC=g++
RELEASE=0.0.11
RELEASE=0.0.12
INSTALL=/usr/local/bin
LIBS=lib/loop.js lib/path.js lib/fs.js lib/process.js lib/build.js lib/repl.js
LIBS=lib/loop.js lib/path.js lib/fs.js lib/process.js lib/build.js lib/repl.js lib/acorn.js lib/configure.js
MODULES=modules/net/net.o modules/epoll/epoll.o modules/fs/fs.o modules/sys/sys.o modules/vm/vm.o
TARGET=just
LIB=-ldl
Expand Down
10 changes: 10 additions & 0 deletions builtins.S
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ _binary_lib_repl_js_start:
.incbin "lib/repl.js"
.global _binary_lib_repl_js_end
_binary_lib_repl_js_end:
.global _binary_lib_configure_js_start
_binary_lib_configure_js_start:
.incbin "lib/configure.js"
.global _binary_lib_configure_js_end
_binary_lib_configure_js_end:
.global _binary_lib_acorn_js_start
_binary_lib_acorn_js_start:
.incbin "lib/acorn.js"
.global _binary_lib_acorn_js_end
_binary_lib_acorn_js_end:
.global _binary_just_cc_start
_binary_just_cc_start:
.incbin "just.cc"
Expand Down
4 changes: 3 additions & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ const libs = [
'lib/path.js',
'lib/process.js',
'lib/build.js',
'lib/repl.js'
'lib/repl.js',
'lib/configure.js',
'lib/acorn.js'
]

const version = just.version.just
Expand Down
42 changes: 23 additions & 19 deletions just.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function wrapRequire (cache = {}) {
const { vm } = just
const params = ['exports', 'require', 'module']
const exports = {}
const module = { exports, type: 'native' }
const module = { exports, type: 'native', dirName: appRoot }
module.text = just.builtin(path)
if (!module.text) return
const fun = vm.compile(module.text, path, params, [])
Expand Down Expand Up @@ -213,7 +213,7 @@ function clearTimeout (fd, loop = just.factory.loop) {
}

class SystemError extends Error {
constructor (syscall) {
constructor (syscall) {
const { sys } = just
const errno = sys.errno()
const message = `${syscall} (${errno}) ${sys.strerror(errno)}`
Expand All @@ -230,36 +230,35 @@ function setNonBlocking (fd) {
}

function parseArgs (args) {
let clean = false
let cleanall = false
let dump = false
let inspector = false
let silent = false
// TODO: most of these are build args - only parse them in the build script
const opts = { args }
args = args.filter(arg => {
if (arg === '--clean') {
clean = true
opts.clean = true
return false
}
if (arg === '--cleanall') {
cleanall = true
opts.cleanall = true
return false
}
if (arg === '--silent') {
silent = true
opts.silent = true
return false
}
if (arg === '--inspector') {
inspector = true
opts.inspector = true
return false
}
if (arg === '--dump') {
dump = true
opts.dump = true
return false
}
if (arg === '--static') {
opts.static = true
return false
}
return true
})
return { args, inspector, clean, cleanall, dump, silent }
return opts
}

function main () {
Expand Down Expand Up @@ -314,9 +313,9 @@ function main () {
just.hrtime = wrapHrtime(just.sys.hrtime)

delete global.console
const { args, dump, clean, cleanall, inspector, silent } = parseArgs(just.args)
just.waitForInspector = inspector
just.args = args
const opts = parseArgs(just.args)
just.waitForInspector = opts.inspector
just.args = opts.args

function startup () {
if (!just.args.length) return true
Expand Down Expand Up @@ -355,8 +354,13 @@ function main () {
if (just.args[1] === 'build') {
const buildModule = just.require('build')
if (!buildModule) throw new Error('Build not Available')
const config = require(just.args[2] || 'config.json') || require('config.js') || {}
buildModule.run(config, { dump, clean, cleanall, silent })
let config
if (just.args.length > 2 && just.args[2].indexOf('.js') > -1) {
config = just.require('configure').configure(just.args[2], opts)
} else {
config = require(just.args[2] || 'config.json') || require('config.js') || {}
}
buildModule.run(config, opts)
.catch(err => just.error(err.stack))
return
}
Expand Down
1 change: 1 addition & 0 deletions lib/acorn.js

Large diffs are not rendered by default.

26 changes: 19 additions & 7 deletions lib/build.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
// TODO
/*
allow merging of modules
check all missing files before compilation
filter duplicates before generating .S file
*/
const { print, error, builtin } = just
const { launch, watch } = just.process
const { cwd } = just.sys
Expand Down Expand Up @@ -168,7 +162,22 @@ async function run (config = {}, { cleanall = false, clean = false, dump = false
for (const fileName of runtime.embeds) {
links[fileName] = linkFile(fileName, fileName)
}
if (config.target !== 'just') {
if (config.target === 'just') {
for (const fileName of config.libs) {
if (isFile(`${appDir}/${fileName}`)) {
links[fileName] = linkFile(fileName, fileName)
} else {
links[fileName] = linkFile(`${justDir}/${fileName}`, fileName)
}
}
for (const fileName of config.embeds) {
if (isFile(`${appDir}/${fileName}`)) {
links[fileName] = linkFile(fileName, fileName)
} else {
links[fileName] = linkFile(`${justDir}/${fileName}`, fileName)
}
}
} else {
for (const fileName of config.libs) {
if (fileName[0] === '/') {
links[fileName] = linkFile(fileName, fileName.replace(`${justDir}/`, ''))
Expand Down Expand Up @@ -294,6 +303,7 @@ function init (name) {

function clean () {
// we don't want to do this for main build
// todo unlink linker file
unlink('Makefile')
unlink('just.js')
unlink('just.cc')
Expand All @@ -311,6 +321,8 @@ function clean () {
unlink('lib/process.js')
unlink('lib/repl.js')
unlink('lib/websocket.js')
unlink('lib/acorn.js')
unlink('lib/configure.js')
const files = readDir('lib').filter(f => !(['.', '..'].indexOf(f.name) > -1))
if (files.length === 0) {
rmrf('lib')
Expand Down
Loading

0 comments on commit 1112b08

Please sign in to comment.