diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..91db047a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,93 @@ +name: Build & CI + +on: [push] + +jobs: + build_and_test_windows: + runs-on: windows-2019 + steps: + - name: Checkout wren-console + uses: actions/checkout@v2 + - name: Checkout wren-essentials + uses: actions/checkout@v2 + with: + repository: joshgoebel/wren-essentials + path: deps/wren-essentials + - name: Checkout wren-package + uses: actions/checkout@v2 + with: + repository: joshgoebel/wren-package + path: wren_modules/wren-package + - name: build + run: | + cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\" + dir $Env:GITHUB_WORKSPACE + .\MSBuild.exe $Env:GITHUB_WORKSPACE\projects\vs2019\wrenc.vcxproj /p:Configuration="Debug 64bit" /p:Platform="x64" + cd $Env:GITHUB_WORKSPACE + dir $Env:GITHUB_WORKSPACE + .\bin\wrenc_d.exe package.wren install + - name: Archive production artifacts + uses: actions/upload-artifact@v2 + with: + name: wrenc-windows + path: | + bin/wrenc.exe + - name: test + run: | + cd $Env:GITHUB_WORKSPACE + python3 .\util\test.py --suffix=_d + + + build_and_test_mac: + runs-on: macos-10.15 + steps: + - name: Checkout wren-console + uses: actions/checkout@v2 + - name: Checkout wren-essentials + uses: actions/checkout@v2 + with: + repository: joshgoebel/wren-essentials + path: deps/wren-essentials + - name: Checkout wren-package + uses: actions/checkout@v2 + with: + repository: joshgoebel/wren-package + path: wren_modules/wren-package + - name: build & test + run: | + make -j8 -C projects/make.mac/ + ./bin/wrenc package.wren install + python3 ./util/test.py + - name: Archive production artifacts + uses: actions/upload-artifact@v2 + with: + name: wrenc-mac + path: | + bin/wrenc + + build_and_test: + runs-on: ubuntu-latest + steps: + - name: Checkout wren-console + uses: actions/checkout@v2 + - name: Checkout wren-essentials + uses: actions/checkout@v2 + with: + repository: joshgoebel/wren-essentials + path: deps/wren-essentials + - name: Checkout wren-package + uses: actions/checkout@v2 + with: + repository: joshgoebel/wren-package + path: wren_modules/wren-package + - name: build & test + run: | + make -j8 -C projects/make/ + ./bin/wrenc package.wren install + python3 ./util/test.py + - name: Archive production artifacts + uses: actions/upload-artifact@v2 + with: + name: wrenc-linux + path: | + bin/wrenc diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..404c4b6c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,165 @@ +--- +name: "Release" + +on: + push: + tags: + - "v*" + +jobs: + tagged-release: + name: "New Release (Linux)" + runs-on: "ubuntu-latest" + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} + release_version: ${{ env.RELEASE_VERSION }} + prerelease: ${{ env.PRERELEASE }} + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Set env & pre-setup + run: | + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + mkdir wren_modules + echo "PRERELEASE=false" >> $GITHUB_ENV + # determine if we are a pre-release or not + - if: contains(github.ref, 'beta') || contains(github.ref, 'test') + run: | + echo "PRERELEASE=true" >> $GITHUB_ENV + - name: Checkout repository + uses: actions/checkout@v2 + with: + repository: joshgoebel/wren-essentials + path: deps/wren-essentials + - name: "Build & test" + run: | + make -j8 -C projects/make/ + cd wren_modules + git clone --depth 1 https://github.com/RobLoach/wren-assert.git + git clone --depth 1 https://github.com/joshgoebel/wren-testie.git + cd .. + python3 ./util/test.py + - name: "Build distributable" + run: | + mkdir -p dist/bin + cp LICENSE dist + cp README.md dist + cp bin/wrenc dist/bin + - name: Compress action step + uses: master-atul/tar-action@v1.0.2 + id: compress + with: + command: c + cwd: ./dist + files: | + ./bin/wrenc + ./README.md + ./LICENSE + outPath: wren-console-${{ env.RELEASE_VERSION }}-linux.tar.gz + - uses: "marvinpinto/action-automatic-releases@latest" + id: create_release + with: + automatic_release_tag: "${{ env.RELEASE_VERSION }}" + repo_token: "${{ secrets.GITHUB_TOKEN }}" + prerelease: "${{ env.PRERELEASE }}" + files: | + wren-console-${{ env.RELEASE_VERSION }}-linux.tar.gz + + windows-assets: + needs: tagged-release + runs-on: windows-2019 + if: ${{ false }} # disable for now + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Set env + shell: bash + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: "Build & test" + run: | + cd deps + git clone --depth 1 https://github.com/joshgoebel/wren-essentials.git + cd .. + cd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\" + dir $Env:GITHUB_WORKSPACE + .\MSBuild.exe $Env:GITHUB_WORKSPACE\projects\vs2019\wrenc.vcxproj /p:Configuration="Release 64bit" /p:Platform="x64" + cd $Env:GITHUB_WORKSPACE + dir $Env:GITHUB_WORKSPACE + mkdir wren_modules + cd wren_modules + git clone --depth 1 https://github.com/RobLoach/wren-assert.git + git clone --depth 1 https://github.com/joshgoebel/wren-testie.git + cd .. + # ./bin/wrenc test/unit/path_test.wren + # python3 ./util/test.py + mkdir -p dist/bin + cp LICENSE dist/LICENSE.txt + cp README.md dist + cp bin/wrenc.exe dist/bin + 7z a -mm=deflate -mx=9 wren-console.zip dist + 7z rn wren-console.zip dist wren-console-${{ env.RELEASE_VERSION }}-windows + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.tagged-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./wren-console.zip + asset_name: wren-console-${{ env.RELEASE_VERSION }}-windows.zip + asset_content_type: application/zip + + mac-assets: + name: "Mac build assets" + needs: tagged-release + runs-on: macos-10.15 + if: ${{ true }} + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Copy environment from our release runner + run: | + echo "RELEASE_VERSION=${{ needs.tagged-release.outputs.release_version }}" >> $GITHUB_ENV + echo "PRERELEASE=${{ needs.tagged-release.outputs.prerelease }}" >> $GITHUB_ENV + - name: Checkout repository + uses: actions/checkout@v2 + with: + repository: joshgoebel/wren-essentials + path: deps/wren-essentials + - name: "Build & test" + run: | + make -j8 -C projects/make.mac/ + mkdir wren_modules + cd wren_modules + git clone --depth 1 https://github.com/RobLoach/wren-assert.git + git clone --depth 1 https://github.com/joshgoebel/wren-testie.git + cd .. + python3 ./util/test.py + - name: "Build distributable" + run: | + mkdir -p dist/bin + cp LICENSE dist/LICENSE.txt + cp README.md dist + cp bin/wrenc dist/bin + - name: Create tarball package + uses: master-atul/tar-action@v1.0.2 + id: compress + with: + command: c + cwd: ./dist + files: | + ./bin/wrenc + ./README.md + ./LICENSE.txt + outPath: wren-console-${{ env.RELEASE_VERSION }}-mac.tar.gz + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.tagged-release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps + asset_path: ./wren-console-${{ env.RELEASE_VERSION }}-mac.tar.gz + asset_name: wren-console-${{ env.RELEASE_VERSION }}-mac.tar.gz + asset_content_type: application/gzip \ No newline at end of file diff --git a/.gitignore b/.gitignore index c7ce8c2d..bdd32dc0 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,15 @@ obj/ /.sass-cache *.pyc +# scratch junk +/work + +# sample test script +/samples + +# installed Wren modules +/wren_modules + # I leave a temporary Wren script at the top level so that I can quickly test # stuff. /scratch.wren diff --git a/.travis.sh b/.travis.sh deleted file mode 100755 index bc19f033..00000000 --- a/.travis.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/bash -set -e - -# This build script only builds mac or linux right now, for CI. -WREN_WD="projects/make" -if [ -n "$WREN_TARGET_MAC" ]; then - WREN_WD="projects/make.mac" -fi - -WREN_PY=${WREN_PY_BINARY:-python3} - -echo "using working directory '$WREN_WD' ..." -echo "using python binary '$WREN_PY' ..." - -make -C $WREN_WD config=debug_64bit-no-nan-tagging -$WREN_PY ./util/test.py --suffix=_d - -make -C $WREN_WD config=debug_64bit -$WREN_PY ./util/test.py --suffix=_d - -make -C $WREN_WD config=release_64bit-no-nan-tagging -$WREN_PY ./util/test.py - -make -C $WREN_WD config=release_64bit -$WREN_PY ./util/test.py diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b94e7efd..00000000 --- a/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: c - -# https://docs.travis-ci.com/user/languages/c/#gcc-on-macos -# On mac, gcc is aliased to clang, so we only have one row -# in build the matrix, not two like on linux -compiler: - - clang - - gcc - -jobs: - include: - - os: linux - - os: osx - env: WREN_TARGET_MAC=1 - -# Travis VMs are 64-bit but we compile both for 32 and 64 bit. To enable the -# 32-bit builds to work, we need gcc-multilib. -addons: - apt: - packages: - - gcc-multilib - - g++-multilib - -dist: trusty - -script: ./.travis.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 990375ee..cf241ef7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,64 +1,34 @@ -## 0.3.0 +## 0.2.x (in progress) -The CLI has been split to it's own repo in this release, and therefore the changelog from here on will be CLI only. -For Wren language/VM changes, see https://github.com/wren-lang/wren. - -This release was focused on streamlining the build process and making platform support consistent. -All platforms build out of the box, and the pre-build steps have been removed. The CLI should build as is. - -This release also includes [prebuilt binaries on the GitHub page](https://github.com/wren-lang/wren-cli/releases). -The docs for the CLI have their own home now, http://wren.io/cli - -### CLI - -- Added prebuilt binaries -- Use premake for project generation, see projects/ -- Vendor libuv and wren directly into repo, no complex pre-build steps -- Use S_IFDIR in `isDirectory`, portability fix. -- Fix memory leak in findModulesDirectory() -- Update libuv to latest at the time (1.34.2) +- (enh) `wren_modules` are searched until a matching library is found + - this means you can now use both `$HOME/wren_modules` (global modules) + - as well a local `./wren_modules` for individual projects + - the "closest" match wins, allowing local to win out over global + - this is technically a breaking change from `wren-cli` which stops at the first `wren_modules` it finds ## 0.2.0 -0.2.0 spans a pretty wide time period with [around 290 commits](https://github.com/wren-lang/wren/compare/0.1.0...main). -This includes many bug fixes, improvements, clarity in the -code and documentation and so on. There's too many to explicitly list. -Below is the obvious user facing stuff that was easy to spot in the history. - -Most noteworthy is that 'relative imports' are a slightly breaking change, -but help pave the way forward toward a consistency for modules. - -### Language/VM - -- `import` was made smarter, differentiating relative from logical -- `Fiber` can now accept a value from the first `call`/`transfer` -- Added `String.trim`, `String.trimEnd`, `String.trimStart` variants -- Added `String.split`, `String.replace`, `String.fromByte` -- Added `String.indexOf(needle, startIndex)` -- Added `Sequence.take` and `Sequence.skip` -- Added `List.filled(count, value)` -- Added `Num.pow`, `Num.log`, `Num.round` -- Added `Num.largest`, `Num.smallest` -- Added `Map` iteration (`MapEntry`) - -#### C API - -- Added `wren.hpp` for use in c++ -- Added void* user data to `WrenVM` -- Allow hosts with no module loader to still load optional modules. -- Added `wrenAbortFiber` - -### CLI -Please note that beyond 0.2.0 the CLI will have it's own changelog. -This list is not exhaustive. For a fuller history see the commit log above. - -- Add path module -- Add `--version` -- Add REPL written in Wren -- Add Stdin.isTerminal -- Added Platform class -- Rename `process` module to `os` - -## 0.1.0 - -First declared version. Everything is new! +- (chore) Auto-build and test binary releases for Windows, Mac, Linux platforms on tagged versions +- (enh) Integrate `Mirror` functionality for stack trace introspection (via wren-essentials) +- (fix) Stdin.readByte now propery removes single bytes from buffer +- (enh) support scripts at absolute paths +- (enh) controlled crashes should not include CLI script in stack trace +- (enh) Add `Runtime` API for getting information about the runtime +- (enh) Add `Process.exit()` and `Process.exit(code)` +- (enh) Add `Stderr.write(_)` and `Stderr.print(_)` +- (fix) `Process.exit()` should actually work properly now +- (enh) Add `Process.exec(command, [arguments, [workingDirectory, [environment]]])` + +## 0.1.0 + +- includes Wren Core 0.4 +- rewrite a good portion of CLI codebase in pure Wren code (as much as possible) +- module resolution and loading is now brokered by Wren code +- flush stdout before quitting https://github.com/wren-lang/wren-cli/pull/77 +- add `-e` flag for code evaluation https://github.com/wren-lang/wren-cli/issues/11 +- add `-h` and `-v` flags https://github.com/wren-lang/wren-cli/pull/88 +- add `-` flag for read script from stdin https://github.com/wren-lang/wren-cli/issues/55#issuecomment-844474733 +- add experimental native binary module/library loading support https://github.com/wren-lang/wren-cli/issues/52 + - see https://github.com/joshgoebel/wren-essentials for how to build a sample binary library + - `import "wren_essentials:essentials"` loads the library from `wren_modules/libwren_essentials.dylib` and then imports the `essentials` module from that library +- based on wren-cli codebase (9c6b6933722) \ No newline at end of file diff --git a/CHANGELOG_CLI.md b/CHANGELOG_CLI.md new file mode 100644 index 00000000..990375ee --- /dev/null +++ b/CHANGELOG_CLI.md @@ -0,0 +1,64 @@ +## 0.3.0 + +The CLI has been split to it's own repo in this release, and therefore the changelog from here on will be CLI only. +For Wren language/VM changes, see https://github.com/wren-lang/wren. + +This release was focused on streamlining the build process and making platform support consistent. +All platforms build out of the box, and the pre-build steps have been removed. The CLI should build as is. + +This release also includes [prebuilt binaries on the GitHub page](https://github.com/wren-lang/wren-cli/releases). +The docs for the CLI have their own home now, http://wren.io/cli + +### CLI + +- Added prebuilt binaries +- Use premake for project generation, see projects/ +- Vendor libuv and wren directly into repo, no complex pre-build steps +- Use S_IFDIR in `isDirectory`, portability fix. +- Fix memory leak in findModulesDirectory() +- Update libuv to latest at the time (1.34.2) + +## 0.2.0 + +0.2.0 spans a pretty wide time period with [around 290 commits](https://github.com/wren-lang/wren/compare/0.1.0...main). +This includes many bug fixes, improvements, clarity in the +code and documentation and so on. There's too many to explicitly list. +Below is the obvious user facing stuff that was easy to spot in the history. + +Most noteworthy is that 'relative imports' are a slightly breaking change, +but help pave the way forward toward a consistency for modules. + +### Language/VM + +- `import` was made smarter, differentiating relative from logical +- `Fiber` can now accept a value from the first `call`/`transfer` +- Added `String.trim`, `String.trimEnd`, `String.trimStart` variants +- Added `String.split`, `String.replace`, `String.fromByte` +- Added `String.indexOf(needle, startIndex)` +- Added `Sequence.take` and `Sequence.skip` +- Added `List.filled(count, value)` +- Added `Num.pow`, `Num.log`, `Num.round` +- Added `Num.largest`, `Num.smallest` +- Added `Map` iteration (`MapEntry`) + +#### C API + +- Added `wren.hpp` for use in c++ +- Added void* user data to `WrenVM` +- Allow hosts with no module loader to still load optional modules. +- Added `wrenAbortFiber` + +### CLI +Please note that beyond 0.2.0 the CLI will have it's own changelog. +This list is not exhaustive. For a fuller history see the commit log above. + +- Add path module +- Add `--version` +- Add REPL written in Wren +- Add Stdin.isTerminal +- Added Platform class +- Rename `process` module to `os` + +## 0.1.0 + +First declared version. Everything is new! diff --git a/LICENSE b/LICENSE index 85468a8a..39ee2715 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2013-2020 Robert Nystrom and Wren CLI contributors +Copyright (c) 2013-2021 Robert Nystrom, Wren CLI & Wren Console contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 17f3f31b..77822f35 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,132 @@ -# Wren CLI +# Wren Console - `wrenc` -## The CLI project is a small and simple REPL and CLI tool for running Wren scripts. +[![](https://badgen.net/badge/latest/0.2.0/)](https://github.com/joshgoebel/wren-console/releases) +[![](https://badgen.net/badge/license/MIT/cyan)](https://github.com/joshgoebel/wren-console/blob/main/LICENSE) +[![](https://badgen.net/badge/wren/0.4.0/?color=purple)](https://github.com/wren-lang/wren) +[![](https://badgen.net/badge/icon/discord?icon=discord&label&color=pink)][discord] +![](https://badgen.net/badge/build/TODO?color=orange) -It is backed by [libuv](http://libuv.org/) to implement IO functionality, and is a work in progress. -For documentation and usage, see http://wren.io/cli -For more information about Wren, the language used by the CLI, see http://wren.io -Like with Wren itself, we welcome [contributions][contribute]. +The Wren Console project is a small and simple REPL and CLI tool for running Wren scripts. It is backed by [libuv](http://libuv.org/) to implement IO functionality. It is based on the official [Wren CLI](https://github.com/wren-lang/wren-cli) project and very much a work in progress. -[contribute]: http://wren.io/contributing.html +The goals and priorities are slightly different than the Wren CLI project. + +- To be written as much as possible in pure Wren, not C. This greatly simplifies much, expands the list of potential contributors, as makes developing new features faster (for everyone who knows Wren). +- Provide the best learning environment for the forthcoming [Exercism](https://exercism.io) Wren track. For starters this means providing full introspection of stack traces when a Fiber aborts - allowing test suites to show helpful debugging information, including source code snippets. (thanks to [@mhermier](https://github.com/mhermier)) +- Serve as a development playground for good ideas that may or may not ever make it into Wren CLI proper. If much of what we do makes it into Wren CLI, great. If we end up going different directions, that's ok too. + +For now the idea is to try to maintain compatibility with whe Wren CLI modules themselves, so that [reference documentation](https://wren.io/cli/modules) may prove useful. + +For more information about Wren, the language that Wren Console is embedding, see http://wren.io. + +We welcome contributions. Feel free to [open an issue][issues] to start a discussion or [join our Discord][discord]. You can also find me on the main Wren Discord as well. + +[issues]: https://github.com/joshgoebel/wren-console +[discord]: https://discord.gg/6YjUdym5Ap -[![Build Status](https://travis-ci.org/wren-lang/wren-cli.svg?branch=main)](https://travis-ci.org/wren-lang/wren-cli) --- -## To build the Wren CLI +## FAQ + +### Pure Wren? Why? + +- It's much higher level and therefore easier to read, write, and iterate than C. +- [It's more than fast enough.](https://wren.io/performance.html) +- **I've fallen a bit in love with Wren.** +- *It's fun.* Is there any better reason? +- Many (including myself) don't know C nearly well enough to be proficient with major CLI contributions. + +### Exercism? + +Thousands of helpful mentors, hundreds of thousands of fellow students to learn alongside. If you're wanting to learn a new language, improve your Wren, or just sharpen your skills on an entirely different language, [Exercism is the place to be](https://exercism.io/about). + + + +--- + +## Usage Examples + +Run a script from the console: + +```sh +$ wrenc ./path_to_script.wren +``` + +Evaluate code directly: + +```sh +$ wrenc -e 'System.print("Hello world")' +``` + +Embed inside shell scripting with heredocs: + +```sh +#!/bin/sh +wrenc /dev/fd/5 < input.txt 5<< 'EOF' +import "io" for Stdin +System.print(Stdin.readLine()) +EOF + +``` + +Start up an interactive REPL session: + +```sh +$ wrenc +``` + +--- + +## Extended Library Support + +Our hope is to extend the libraries available without breaking forwards compatibility - meaning that a script running successfully on Wren CLI should run as-is on Wren Console - but once you start using the newer library features your script may no longer run be backwards compatible with Wren CLI. + +### `io` module + +`Stderr.write(s)` - Write a string to srderr +`Stderr.print(s)` - Write a string to stderr followed by a newline + +### `os` module + +- `Process.exec(command, [arguments, [workingDirectory, [environment]]])` - Run an external command and display it's output +- `Process.exit()` - Exit immediately with 0 status code +- `Process.exit(code)` - Exit immediately with the specified exit status code. (https://github.com/wren-lang/wren-cli/pull/74) + +### `runtime` module + +Retrieve details about the runtime environment. + +- `Runtime.NAME` - The runtime name +- `Runtime.VERSION` - The runtime version number +- `Runtime.WREN_VERSION` - The Wren version the runtime is built against +- `Runtime.details` - retrieve additional details about the runtime environment + +### `mirror` module + +Experimental. See https://github.com/wren-lang/wren/pull/1006. + +- `Mirror.reflect(object)` - Reflect on an object +- `Mirror.reflect(class)` - Reflect on a class +- `Mirror.reflect(fiber)` - Reflect on a fiber, it's stacktrace, etc. + +### `essentials` module + +Wren Console includes the [Wren Essentials](https://github.com/joshgoebel/wren-essentials) library built right into the binary. + +- `Time.now()` - number of milliseconds since Epoch +- `Time.highResolution()` - high resolution time counter (for benchmarking, etc.) +- `Strings.upcase(string)` - convert an ASCII string to uppercase +- `Strings.lowercase(string)` - convert an ASCII string to lowercase + +--- + +## To build Wren Console + +**Pre-requisites** + +- Git clone the `wren-essentials` project ([link](https://github.com/joshgoebel/wren-essentials)) into `deps` (TODO: vendor?) ### Windows diff --git a/deps/wren/src/optional/wren_opt_meta.c b/deps/wren/src/optional/wren_opt_meta.c index d161cf28..21905938 100644 --- a/deps/wren/src/optional/wren_opt_meta.c +++ b/deps/wren/src/optional/wren_opt_meta.c @@ -10,19 +10,29 @@ void metaCompile(WrenVM* vm) { const char* source = wrenGetSlotString(vm, 1); - bool isExpression = wrenGetSlotBool(vm, 2); - bool printErrors = wrenGetSlotBool(vm, 3); + bool isExpression = wrenGetSlotBool(vm, 3); + bool printErrors = wrenGetSlotBool(vm, 4); - // TODO: Allow passing in module? - // Look up the module surrounding the callsite. This is brittle. The -2 walks - // up the callstack assuming that the meta module has one level of - // indirection before hitting the user's code. Any change to meta may require - // this constant to be tweaked. - ObjFiber* currentFiber = vm->fiber; - ObjFn* fn = currentFiber->frames[currentFiber->numFrames - 2].closure->fn; - ObjString* module = fn->module->name; + const char* module; + if (wrenGetSlotType(vm, 2) != WREN_TYPE_NULL) { + module = wrenGetSlotString(vm, 2); + if (wrenHasModule(vm,module)) { + wrenSetSlotString(vm, 0, "Security: Cannot compile into an existing named module."); + wrenAbortFiber(vm, 0); + } + } else { + // TODO: Allow passing in module? + // Look up the module surrounding the callsite. This is brittle. The -2 walks + // up the callstack assuming that the meta module has one level of + // indirection before hitting the user's code. Any change to meta may require + // this constant to be tweaked. + ObjFiber* currentFiber = vm->fiber; + ObjFn* fn = currentFiber->frames[currentFiber->numFrames - 2].closure->fn; + ObjString* moduleName = fn->module->name; + module = moduleName->value; + } - ObjClosure* closure = wrenCompileSource(vm, module->value, source, + ObjClosure* closure = wrenCompileSource(vm, module, source, isExpression, printErrors); // Return the result. We can't use the public API for this since we have a @@ -79,7 +89,7 @@ WrenForeignMethodFn wrenMetaBindForeignMethod(WrenVM* vm, ASSERT(strcmp(className, "Meta") == 0, "Should be in Meta class."); ASSERT(isStatic, "Should be static."); - if (strcmp(signature, "compile_(_,_,_)") == 0) + if (strcmp(signature, "compile_(_,_,_,_)") == 0) { return metaCompile; } diff --git a/deps/wren/src/optional/wren_opt_meta.wren b/deps/wren/src/optional/wren_opt_meta.wren index d6fdecf4..2afcc0ee 100644 --- a/deps/wren/src/optional/wren_opt_meta.wren +++ b/deps/wren/src/optional/wren_opt_meta.wren @@ -7,26 +7,29 @@ class Meta { Fiber.abort("Could not find a module named '%(module)'.") } - static eval(source) { + static eval(source) { eval(source, null) } + static eval(source, module) { if (!(source is String)) Fiber.abort("Source code must be a string.") - var closure = compile_(source, false, false) + var closure = compile_(source, module, false, false) // TODO: Include compile errors. if (closure == null) Fiber.abort("Could not compile source code.") closure.call() } - static compileExpression(source) { + static compileExpression(source) { compileExpression(source, null) } + static compileExpression(source, module) { if (!(source is String)) Fiber.abort("Source code must be a string.") - return compile_(source, true, true) + return compile_(source, module, true, true) } - static compile(source) { + static compile(source) { compile(source, null) } + static compile(source, module) { if (!(source is String)) Fiber.abort("Source code must be a string.") - return compile_(source, false, true) + return compile_(source, module, false, true) } - foreign static compile_(source, isExpression, printErrors) + foreign static compile_(source, module, isExpression, printErrors) foreign static getModuleVariables_(module) } diff --git a/deps/wren/src/optional/wren_opt_meta.wren.inc b/deps/wren/src/optional/wren_opt_meta.wren.inc index a372e10b..1c8fc5c5 100644 --- a/deps/wren/src/optional/wren_opt_meta.wren.inc +++ b/deps/wren/src/optional/wren_opt_meta.wren.inc @@ -1,4 +1,6 @@ -// Generated automatically from src/optional/wren_opt_meta.wren. Do not edit. +// Please do not edit this file. It has been generated automatically +// from `deps/wren/src/optional/wren_opt_meta.wren` using `util/wren_to_c_string.py` + static const char* metaModuleSource = "class Meta {\n" " static getModuleVariables(module) {\n" @@ -9,26 +11,29 @@ static const char* metaModuleSource = " Fiber.abort(\"Could not find a module named '%(module)'.\")\n" " }\n" "\n" -" static eval(source) {\n" +" static eval(source) { eval(source, null) }\n" +" static eval(source, module) {\n" " if (!(source is String)) Fiber.abort(\"Source code must be a string.\")\n" "\n" -" var closure = compile_(source, false, false)\n" +" var closure = compile_(source, module, false, false)\n" " // TODO: Include compile errors.\n" " if (closure == null) Fiber.abort(\"Could not compile source code.\")\n" "\n" " closure.call()\n" " }\n" "\n" -" static compileExpression(source) {\n" +" static compileExpression(source) { compileExpression(source, null) }\n" +" static compileExpression(source, module) {\n" " if (!(source is String)) Fiber.abort(\"Source code must be a string.\")\n" -" return compile_(source, true, true)\n" +" return compile_(source, module, true, true)\n" " }\n" "\n" -" static compile(source) {\n" +" static compile(source) { compile(source, null) }\n" +" static compile(source, module) {\n" " if (!(source is String)) Fiber.abort(\"Source code must be a string.\")\n" -" return compile_(source, false, true)\n" +" return compile_(source, module, false, true)\n" " }\n" "\n" -" foreign static compile_(source, isExpression, printErrors)\n" +" foreign static compile_(source, module, isExpression, printErrors)\n" " foreign static getModuleVariables_(module)\n" "}\n"; diff --git a/deps/wren/src/optional/wren_opt_random.wren.inc b/deps/wren/src/optional/wren_opt_random.wren.inc index 164f9d58..b48974ae 100644 --- a/deps/wren/src/optional/wren_opt_random.wren.inc +++ b/deps/wren/src/optional/wren_opt_random.wren.inc @@ -1,4 +1,6 @@ -// Generated automatically from src/optional/wren_opt_random.wren. Do not edit. +// Please do not edit this file. It has been generated automatically +// from `deps/wren/src/optional/wren_opt_random.wren` using `util/wren_to_c_string.py` + static const char* randomModuleSource = "foreign class Random {\n" " construct new() {\n" diff --git a/package.wren b/package.wren new file mode 100644 index 00000000..d4437714 --- /dev/null +++ b/package.wren @@ -0,0 +1,15 @@ +import "wren-package/package" for WrenPackage, Dependency +import "os" for Process + +class Package is WrenPackage { + construct new() {} + name { "wren-console" } + dependencies { + return [ + Dependency.new("wren-testie", "0.1.1", "https://github.com/joshgoebel/wren-testie.git"), + Dependency.new("wren-assert", "HEAD", "https://github.com/RobLoach/wren-assert.git") + ] + } +} + +Package.new().default() diff --git a/projects/make.bsd/Makefile b/projects/make.bsd/Makefile index 530fff6d..58a6c4e2 100644 --- a/projects/make.bsd/Makefile +++ b/projects/make.bsd/Makefile @@ -9,41 +9,41 @@ ifndef verbose endif ifeq ($(config),release_64bit) - wren_cli_config = release_64bit + wrenc_config = release_64bit else ifeq ($(config),release_32bit) - wren_cli_config = release_32bit + wrenc_config = release_32bit else ifeq ($(config),release_64bit-no-nan-tagging) - wren_cli_config = release_64bit-no-nan-tagging + wrenc_config = release_64bit-no-nan-tagging else ifeq ($(config),debug_64bit) - wren_cli_config = debug_64bit + wrenc_config = debug_64bit else ifeq ($(config),debug_32bit) - wren_cli_config = debug_32bit + wrenc_config = debug_32bit else ifeq ($(config),debug_64bit-no-nan-tagging) - wren_cli_config = debug_64bit-no-nan-tagging + wrenc_config = debug_64bit-no-nan-tagging else $(error "invalid configuration $(config)") endif -PROJECTS := wren_cli +PROJECTS := wrenc .PHONY: all clean help $(PROJECTS) all: $(PROJECTS) -wren_cli: -ifneq (,$(wren_cli_config)) - @echo "==== Building wren_cli ($(wren_cli_config)) ====" - @${MAKE} --no-print-directory -C . -f wren_cli.make config=$(wren_cli_config) +wrenc: +ifneq (,$(wrenc_config)) + @echo "==== Building wrenc ($(wrenc_config)) ====" + @${MAKE} --no-print-directory -C . -f wrenc.make config=$(wrenc_config) endif clean: - @${MAKE} --no-print-directory -C . -f wren_cli.make clean + @${MAKE} --no-print-directory -C . -f wrenc.make clean help: @echo "Usage: make [config=name] [target]" @@ -59,6 +59,6 @@ help: @echo "TARGETS:" @echo " all (default)" @echo " clean" - @echo " wren_cli" + @echo " wrenc" @echo "" @echo "For more information, see https://github.com/premake/premake-core/wiki" \ No newline at end of file diff --git a/projects/make.bsd/wren_cli.make b/projects/make.bsd/wrenc.make similarity index 79% rename from projects/make.bsd/wren_cli.make rename to projects/make.bsd/wrenc.make index 28c86e3e..314080a5 100644 --- a/projects/make.bsd/wren_cli.make +++ b/projects/make.bsd/wrenc.make @@ -19,7 +19,7 @@ endif # ############################################# RESCOMP = windres -INCLUDES += -I../../src/cli -I../../src/module -I../../deps/wren/include -I../../deps/wren/src/vm -I../../deps/wren/src/optional -I../../deps/libuv/include -I../../deps/libuv/src +INCLUDES += -I../../src/cli -I../../src/module -I../../deps/wren-essentials/src -I../../deps/wren/include -I../../deps/wren/src/vm -I../../deps/wren/src/optional -I../../deps/libuv/include -I../../deps/libuv/src FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) @@ -35,7 +35,7 @@ endef ifeq ($(config),release_64bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli +TARGET = $(TARGETDIR)/wrenc OBJDIR = obj/64bit/Release DEFINES += -DNDEBUG ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -std=c99 @@ -44,7 +44,7 @@ ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -s else ifeq ($(config),release_32bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli +TARGET = $(TARGETDIR)/wrenc OBJDIR = obj/32bit/Release DEFINES += -DNDEBUG ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -std=c99 @@ -53,7 +53,7 @@ ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 -s else ifeq ($(config),release_64bit-no-nan-tagging) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli +TARGET = $(TARGETDIR)/wrenc OBJDIR = obj/64bit-no-nan-tagging/Release DEFINES += -DNDEBUG -DWREN_NAN_TAGGING=0 ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O3 -std=c99 @@ -62,7 +62,7 @@ ALL_LDFLAGS += $(LDFLAGS) -s else ifeq ($(config),debug_64bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli_d +TARGET = $(TARGETDIR)/wrenc_d OBJDIR = obj/64bit/Debug DEFINES += -DDEBUG ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -std=c99 @@ -71,7 +71,7 @@ ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 else ifeq ($(config),debug_32bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli_d +TARGET = $(TARGETDIR)/wrenc_d OBJDIR = obj/32bit/Debug DEFINES += -DDEBUG ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -std=c99 @@ -80,15 +80,13 @@ ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 else ifeq ($(config),debug_64bit-no-nan-tagging) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli_d +TARGET = $(TARGETDIR)/wrenc_d OBJDIR = obj/64bit-no-nan-tagging/Debug DEFINES += -DDEBUG -DWREN_NAN_TAGGING=0 ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -std=c99 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g ALL_LDFLAGS += $(LDFLAGS) -else - $(error "invalid configuration $(config)") endif # Per File Configurations @@ -98,13 +96,73 @@ endif # File sets # ############################################# +GENERATED := OBJECTS := +GENERATED += $(OBJDIR)/async.o +GENERATED += $(OBJDIR)/bsd-ifaddrs.o +GENERATED += $(OBJDIR)/bsd-proctitle.o +GENERATED += $(OBJDIR)/cli.o +GENERATED += $(OBJDIR)/core.o +GENERATED += $(OBJDIR)/dl.o +GENERATED += $(OBJDIR)/essentials.o +GENERATED += $(OBJDIR)/freebsd.o +GENERATED += $(OBJDIR)/fs-poll.o +GENERATED += $(OBJDIR)/fs.o +GENERATED += $(OBJDIR)/getaddrinfo.o +GENERATED += $(OBJDIR)/getnameinfo.o +GENERATED += $(OBJDIR)/idna.o +GENERATED += $(OBJDIR)/inet.o +GENERATED += $(OBJDIR)/io.o +GENERATED += $(OBJDIR)/kqueue.o +GENERATED += $(OBJDIR)/loop-watcher.o +GENERATED += $(OBJDIR)/loop.o +GENERATED += $(OBJDIR)/main.o +GENERATED += $(OBJDIR)/mirror.o +GENERATED += $(OBJDIR)/modules.o +GENERATED += $(OBJDIR)/os.o +GENERATED += $(OBJDIR)/path.o +GENERATED += $(OBJDIR)/pipe.o +GENERATED += $(OBJDIR)/poll.o +GENERATED += $(OBJDIR)/posix-hrtime.o +GENERATED += $(OBJDIR)/process.o +GENERATED += $(OBJDIR)/random-devurandom.o +GENERATED += $(OBJDIR)/random-getrandom.o +GENERATED += $(OBJDIR)/random.o +GENERATED += $(OBJDIR)/repl.o +GENERATED += $(OBJDIR)/resolver.o +GENERATED += $(OBJDIR)/scheduler.o +GENERATED += $(OBJDIR)/signal.o +GENERATED += $(OBJDIR)/stream.o +GENERATED += $(OBJDIR)/strscpy.o +GENERATED += $(OBJDIR)/tcp.o +GENERATED += $(OBJDIR)/thread.o +GENERATED += $(OBJDIR)/threadpool.o +GENERATED += $(OBJDIR)/time.o +GENERATED += $(OBJDIR)/timer.o +GENERATED += $(OBJDIR)/timer1.o +GENERATED += $(OBJDIR)/tty.o +GENERATED += $(OBJDIR)/udp.o +GENERATED += $(OBJDIR)/uv-common.o +GENERATED += $(OBJDIR)/uv-data-getter-setters.o +GENERATED += $(OBJDIR)/version.o +GENERATED += $(OBJDIR)/vm.o +GENERATED += $(OBJDIR)/wren_compiler.o +GENERATED += $(OBJDIR)/wren_core.o +GENERATED += $(OBJDIR)/wren_debug.o +GENERATED += $(OBJDIR)/wren_opt_meta.o +GENERATED += $(OBJDIR)/wren_opt_random.o +GENERATED += $(OBJDIR)/wren_primitive.o +GENERATED += $(OBJDIR)/wren_utils.o +GENERATED += $(OBJDIR)/wren_value.o +GENERATED += $(OBJDIR)/wren_vm.o OBJECTS += $(OBJDIR)/async.o OBJECTS += $(OBJDIR)/bsd-ifaddrs.o OBJECTS += $(OBJDIR)/bsd-proctitle.o +OBJECTS += $(OBJDIR)/cli.o OBJECTS += $(OBJDIR)/core.o OBJECTS += $(OBJDIR)/dl.o +OBJECTS += $(OBJDIR)/essentials.o OBJECTS += $(OBJDIR)/freebsd.o OBJECTS += $(OBJDIR)/fs-poll.o OBJECTS += $(OBJDIR)/fs.o @@ -117,6 +175,7 @@ OBJECTS += $(OBJDIR)/kqueue.o OBJECTS += $(OBJDIR)/loop-watcher.o OBJECTS += $(OBJDIR)/loop.o OBJECTS += $(OBJDIR)/main.o +OBJECTS += $(OBJDIR)/mirror.o OBJECTS += $(OBJDIR)/modules.o OBJECTS += $(OBJDIR)/os.o OBJECTS += $(OBJDIR)/path.o @@ -128,6 +187,7 @@ OBJECTS += $(OBJDIR)/random-devurandom.o OBJECTS += $(OBJDIR)/random-getrandom.o OBJECTS += $(OBJDIR)/random.o OBJECTS += $(OBJDIR)/repl.o +OBJECTS += $(OBJDIR)/resolver.o OBJECTS += $(OBJDIR)/scheduler.o OBJECTS += $(OBJDIR)/signal.o OBJECTS += $(OBJDIR)/stream.o @@ -135,6 +195,7 @@ OBJECTS += $(OBJDIR)/strscpy.o OBJECTS += $(OBJDIR)/tcp.o OBJECTS += $(OBJDIR)/thread.o OBJECTS += $(OBJDIR)/threadpool.o +OBJECTS += $(OBJDIR)/time.o OBJECTS += $(OBJDIR)/timer.o OBJECTS += $(OBJDIR)/timer1.o OBJECTS += $(OBJDIR)/tty.o @@ -159,9 +220,9 @@ OBJECTS += $(OBJDIR)/wren_vm.o all: $(TARGET) @: -$(TARGET): $(OBJECTS) $(LDDEPS) | $(TARGETDIR) +$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR) $(PRELINKCMDS) - @echo Linking wren_cli + @echo Linking wrenc $(SILENT) $(LINKCMD) $(POSTBUILDCMDS) @@ -182,12 +243,14 @@ else endif clean: - @echo Cleaning wren_cli + @echo Cleaning wrenc ifeq (posix,$(SHELLTYPE)) $(SILENT) rm -f $(TARGET) + $(SILENT) rm -rf $(GENERATED) $(SILENT) rm -rf $(OBJDIR) else $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) + $(SILENT) if exist $(subst /,\\,$(GENERATED)) rmdir /s /q $(subst /,\\,$(GENERATED)) $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) endif @@ -315,6 +378,15 @@ $(OBJDIR)/uv-data-getter-setters.o: ../../deps/libuv/src/uv-data-getter-setters. $(OBJDIR)/version.o: ../../deps/libuv/src/version.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/essentials.o: ../../deps/wren-essentials/src/essentials.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/mirror.o: ../../deps/wren-essentials/src/modules/mirror.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/time.o: ../../deps/wren-essentials/src/modules/time.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/wren_opt_meta.o: ../../deps/wren/src/optional/wren_opt_meta.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" @@ -342,6 +414,9 @@ $(OBJDIR)/wren_value.o: ../../deps/wren/src/vm/wren_value.c $(OBJDIR)/wren_vm.o: ../../deps/wren/src/vm/wren_vm.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/cli.o: ../../src/cli/cli.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/main.o: ../../src/cli/main.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" @@ -351,6 +426,9 @@ $(OBJDIR)/modules.o: ../../src/cli/modules.c $(OBJDIR)/path.o: ../../src/cli/path.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/resolver.o: ../../src/cli/resolver.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/vm.o: ../../src/cli/vm.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" diff --git a/projects/make.mac/Makefile b/projects/make.mac/Makefile index 530fff6d..58a6c4e2 100644 --- a/projects/make.mac/Makefile +++ b/projects/make.mac/Makefile @@ -9,41 +9,41 @@ ifndef verbose endif ifeq ($(config),release_64bit) - wren_cli_config = release_64bit + wrenc_config = release_64bit else ifeq ($(config),release_32bit) - wren_cli_config = release_32bit + wrenc_config = release_32bit else ifeq ($(config),release_64bit-no-nan-tagging) - wren_cli_config = release_64bit-no-nan-tagging + wrenc_config = release_64bit-no-nan-tagging else ifeq ($(config),debug_64bit) - wren_cli_config = debug_64bit + wrenc_config = debug_64bit else ifeq ($(config),debug_32bit) - wren_cli_config = debug_32bit + wrenc_config = debug_32bit else ifeq ($(config),debug_64bit-no-nan-tagging) - wren_cli_config = debug_64bit-no-nan-tagging + wrenc_config = debug_64bit-no-nan-tagging else $(error "invalid configuration $(config)") endif -PROJECTS := wren_cli +PROJECTS := wrenc .PHONY: all clean help $(PROJECTS) all: $(PROJECTS) -wren_cli: -ifneq (,$(wren_cli_config)) - @echo "==== Building wren_cli ($(wren_cli_config)) ====" - @${MAKE} --no-print-directory -C . -f wren_cli.make config=$(wren_cli_config) +wrenc: +ifneq (,$(wrenc_config)) + @echo "==== Building wrenc ($(wrenc_config)) ====" + @${MAKE} --no-print-directory -C . -f wrenc.make config=$(wrenc_config) endif clean: - @${MAKE} --no-print-directory -C . -f wren_cli.make clean + @${MAKE} --no-print-directory -C . -f wrenc.make clean help: @echo "Usage: make [config=name] [target]" @@ -59,6 +59,6 @@ help: @echo "TARGETS:" @echo " all (default)" @echo " clean" - @echo " wren_cli" + @echo " wrenc" @echo "" @echo "For more information, see https://github.com/premake/premake-core/wiki" \ No newline at end of file diff --git a/projects/make.mac/wren_cli.make b/projects/make.mac/wrenc.make similarity index 75% rename from projects/make.mac/wren_cli.make rename to projects/make.mac/wrenc.make index 5bc032e9..c1c33f2d 100644 --- a/projects/make.mac/wren_cli.make +++ b/projects/make.mac/wrenc.make @@ -27,7 +27,7 @@ endif ifeq ($(origin AR), default) AR = ar endif -INCLUDES += -I../../src/cli -I../../src/module -I../../deps/wren/include -I../../deps/wren/src/vm -I../../deps/wren/src/optional -I../../deps/libuv/include -I../../deps/libuv/src +INCLUDES += -I../../src/cli -I../../src/module -I../../deps/wren-essentials/src -I../../deps/wren/include -I../../deps/wren/src/vm -I../../deps/wren/src/optional -I../../deps/libuv/include -I../../deps/libuv/src FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) @@ -43,60 +43,58 @@ endef ifeq ($(config),release_64bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli +TARGET = $(TARGETDIR)/wrenc OBJDIR = obj/64bit/Release DEFINES += -DNDEBUG -D_DARWIN_USE_64_BIT_INODE=1 -D_DARWIN_UNLIMITED_SELECT=1 -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -std=c99 -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O3 +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -std=c99 -mmacosx-version-min=10.12 +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -mmacosx-version-min=10.12 ALL_LDFLAGS += $(LDFLAGS) -m64 else ifeq ($(config),release_32bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli +TARGET = $(TARGETDIR)/wrenc OBJDIR = obj/32bit/Release DEFINES += -DNDEBUG -D_DARWIN_USE_64_BIT_INODE=1 -D_DARWIN_UNLIMITED_SELECT=1 -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -std=c99 -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O3 +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -std=c99 -mmacosx-version-min=10.12 +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -mmacosx-version-min=10.12 ALL_LDFLAGS += $(LDFLAGS) -m32 else ifeq ($(config),release_64bit-no-nan-tagging) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli +TARGET = $(TARGETDIR)/wrenc OBJDIR = obj/64bit-no-nan-tagging/Release DEFINES += -DNDEBUG -DWREN_NAN_TAGGING=0 -D_DARWIN_USE_64_BIT_INODE=1 -D_DARWIN_UNLIMITED_SELECT=1 -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O3 -std=c99 -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O3 +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O3 -std=c99 -mmacosx-version-min=10.12 +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -O3 -mmacosx-version-min=10.12 ALL_LDFLAGS += $(LDFLAGS) else ifeq ($(config),debug_64bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli_d +TARGET = $(TARGETDIR)/wrenc_d OBJDIR = obj/64bit/Debug DEFINES += -DDEBUG -D_DARWIN_USE_64_BIT_INODE=1 -D_DARWIN_UNLIMITED_SELECT=1 -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -std=c99 -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -std=c99 -mmacosx-version-min=10.12 +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m64 -g -mmacosx-version-min=10.12 ALL_LDFLAGS += $(LDFLAGS) -m64 else ifeq ($(config),debug_32bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli_d +TARGET = $(TARGETDIR)/wrenc_d OBJDIR = obj/32bit/Debug DEFINES += -DDEBUG -D_DARWIN_USE_64_BIT_INODE=1 -D_DARWIN_UNLIMITED_SELECT=1 -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -std=c99 -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -g +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -std=c99 -mmacosx-version-min=10.12 +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -m32 -g -mmacosx-version-min=10.12 ALL_LDFLAGS += $(LDFLAGS) -m32 else ifeq ($(config),debug_64bit-no-nan-tagging) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli_d +TARGET = $(TARGETDIR)/wrenc_d OBJDIR = obj/64bit-no-nan-tagging/Debug DEFINES += -DDEBUG -DWREN_NAN_TAGGING=0 -D_DARWIN_USE_64_BIT_INODE=1 -D_DARWIN_UNLIMITED_SELECT=1 -ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -std=c99 -ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g +ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -std=c99 -mmacosx-version-min=10.12 +ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g -mmacosx-version-min=10.12 ALL_LDFLAGS += $(LDFLAGS) -else - $(error "invalid configuration $(config)") endif # Per File Configurations @@ -106,14 +104,75 @@ endif # File sets # ############################################# +GENERATED := OBJECTS := +GENERATED += $(OBJDIR)/async.o +GENERATED += $(OBJDIR)/bsd-ifaddrs.o +GENERATED += $(OBJDIR)/cli.o +GENERATED += $(OBJDIR)/core.o +GENERATED += $(OBJDIR)/darwin-proctitle.o +GENERATED += $(OBJDIR)/darwin.o +GENERATED += $(OBJDIR)/dl.o +GENERATED += $(OBJDIR)/essentials.o +GENERATED += $(OBJDIR)/fs-poll.o +GENERATED += $(OBJDIR)/fs.o +GENERATED += $(OBJDIR)/fsevents.o +GENERATED += $(OBJDIR)/getaddrinfo.o +GENERATED += $(OBJDIR)/getnameinfo.o +GENERATED += $(OBJDIR)/idna.o +GENERATED += $(OBJDIR)/inet.o +GENERATED += $(OBJDIR)/io.o +GENERATED += $(OBJDIR)/kqueue.o +GENERATED += $(OBJDIR)/loop-watcher.o +GENERATED += $(OBJDIR)/loop.o +GENERATED += $(OBJDIR)/main.o +GENERATED += $(OBJDIR)/mirror.o +GENERATED += $(OBJDIR)/modules.o +GENERATED += $(OBJDIR)/os.o +GENERATED += $(OBJDIR)/path.o +GENERATED += $(OBJDIR)/pipe.o +GENERATED += $(OBJDIR)/poll.o +GENERATED += $(OBJDIR)/process.o +GENERATED += $(OBJDIR)/proctitle.o +GENERATED += $(OBJDIR)/random-devurandom.o +GENERATED += $(OBJDIR)/random-getentropy.o +GENERATED += $(OBJDIR)/random.o +GENERATED += $(OBJDIR)/repl.o +GENERATED += $(OBJDIR)/resolver.o +GENERATED += $(OBJDIR)/scheduler.o +GENERATED += $(OBJDIR)/signal.o +GENERATED += $(OBJDIR)/stream.o +GENERATED += $(OBJDIR)/strscpy.o +GENERATED += $(OBJDIR)/tcp.o +GENERATED += $(OBJDIR)/thread.o +GENERATED += $(OBJDIR)/threadpool.o +GENERATED += $(OBJDIR)/time.o +GENERATED += $(OBJDIR)/timer.o +GENERATED += $(OBJDIR)/timer1.o +GENERATED += $(OBJDIR)/tty.o +GENERATED += $(OBJDIR)/udp.o +GENERATED += $(OBJDIR)/uv-common.o +GENERATED += $(OBJDIR)/uv-data-getter-setters.o +GENERATED += $(OBJDIR)/version.o +GENERATED += $(OBJDIR)/vm.o +GENERATED += $(OBJDIR)/wren_compiler.o +GENERATED += $(OBJDIR)/wren_core.o +GENERATED += $(OBJDIR)/wren_debug.o +GENERATED += $(OBJDIR)/wren_opt_meta.o +GENERATED += $(OBJDIR)/wren_opt_random.o +GENERATED += $(OBJDIR)/wren_primitive.o +GENERATED += $(OBJDIR)/wren_utils.o +GENERATED += $(OBJDIR)/wren_value.o +GENERATED += $(OBJDIR)/wren_vm.o OBJECTS += $(OBJDIR)/async.o OBJECTS += $(OBJDIR)/bsd-ifaddrs.o +OBJECTS += $(OBJDIR)/cli.o OBJECTS += $(OBJDIR)/core.o OBJECTS += $(OBJDIR)/darwin-proctitle.o OBJECTS += $(OBJDIR)/darwin.o OBJECTS += $(OBJDIR)/dl.o +OBJECTS += $(OBJDIR)/essentials.o OBJECTS += $(OBJDIR)/fs-poll.o OBJECTS += $(OBJDIR)/fs.o OBJECTS += $(OBJDIR)/fsevents.o @@ -126,6 +185,7 @@ OBJECTS += $(OBJDIR)/kqueue.o OBJECTS += $(OBJDIR)/loop-watcher.o OBJECTS += $(OBJDIR)/loop.o OBJECTS += $(OBJDIR)/main.o +OBJECTS += $(OBJDIR)/mirror.o OBJECTS += $(OBJDIR)/modules.o OBJECTS += $(OBJDIR)/os.o OBJECTS += $(OBJDIR)/path.o @@ -137,6 +197,7 @@ OBJECTS += $(OBJDIR)/random-devurandom.o OBJECTS += $(OBJDIR)/random-getentropy.o OBJECTS += $(OBJDIR)/random.o OBJECTS += $(OBJDIR)/repl.o +OBJECTS += $(OBJDIR)/resolver.o OBJECTS += $(OBJDIR)/scheduler.o OBJECTS += $(OBJDIR)/signal.o OBJECTS += $(OBJDIR)/stream.o @@ -144,6 +205,7 @@ OBJECTS += $(OBJDIR)/strscpy.o OBJECTS += $(OBJDIR)/tcp.o OBJECTS += $(OBJDIR)/thread.o OBJECTS += $(OBJDIR)/threadpool.o +OBJECTS += $(OBJDIR)/time.o OBJECTS += $(OBJDIR)/timer.o OBJECTS += $(OBJDIR)/timer1.o OBJECTS += $(OBJDIR)/tty.o @@ -168,9 +230,9 @@ OBJECTS += $(OBJDIR)/wren_vm.o all: $(TARGET) @: -$(TARGET): $(OBJECTS) $(LDDEPS) | $(TARGETDIR) +$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR) $(PRELINKCMDS) - @echo Linking wren_cli + @echo Linking wrenc $(SILENT) $(LINKCMD) $(POSTBUILDCMDS) @@ -191,12 +253,14 @@ else endif clean: - @echo Cleaning wren_cli + @echo Cleaning wrenc ifeq (posix,$(SHELLTYPE)) $(SILENT) rm -f $(TARGET) + $(SILENT) rm -rf $(GENERATED) $(SILENT) rm -rf $(OBJDIR) else $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) + $(SILENT) if exist $(subst /,\\,$(GENERATED)) rmdir /s /q $(subst /,\\,$(GENERATED)) $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) endif @@ -327,6 +391,15 @@ $(OBJDIR)/uv-data-getter-setters.o: ../../deps/libuv/src/uv-data-getter-setters. $(OBJDIR)/version.o: ../../deps/libuv/src/version.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/essentials.o: ../../deps/wren-essentials/src/essentials.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/mirror.o: ../../deps/wren-essentials/src/modules/mirror.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/time.o: ../../deps/wren-essentials/src/modules/time.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/wren_opt_meta.o: ../../deps/wren/src/optional/wren_opt_meta.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" @@ -354,6 +427,9 @@ $(OBJDIR)/wren_value.o: ../../deps/wren/src/vm/wren_value.c $(OBJDIR)/wren_vm.o: ../../deps/wren/src/vm/wren_vm.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/cli.o: ../../src/cli/cli.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/main.o: ../../src/cli/main.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" @@ -363,6 +439,9 @@ $(OBJDIR)/modules.o: ../../src/cli/modules.c $(OBJDIR)/path.o: ../../src/cli/path.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/resolver.o: ../../src/cli/resolver.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/vm.o: ../../src/cli/vm.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" diff --git a/projects/make/Makefile b/projects/make/Makefile index 530fff6d..58a6c4e2 100644 --- a/projects/make/Makefile +++ b/projects/make/Makefile @@ -9,41 +9,41 @@ ifndef verbose endif ifeq ($(config),release_64bit) - wren_cli_config = release_64bit + wrenc_config = release_64bit else ifeq ($(config),release_32bit) - wren_cli_config = release_32bit + wrenc_config = release_32bit else ifeq ($(config),release_64bit-no-nan-tagging) - wren_cli_config = release_64bit-no-nan-tagging + wrenc_config = release_64bit-no-nan-tagging else ifeq ($(config),debug_64bit) - wren_cli_config = debug_64bit + wrenc_config = debug_64bit else ifeq ($(config),debug_32bit) - wren_cli_config = debug_32bit + wrenc_config = debug_32bit else ifeq ($(config),debug_64bit-no-nan-tagging) - wren_cli_config = debug_64bit-no-nan-tagging + wrenc_config = debug_64bit-no-nan-tagging else $(error "invalid configuration $(config)") endif -PROJECTS := wren_cli +PROJECTS := wrenc .PHONY: all clean help $(PROJECTS) all: $(PROJECTS) -wren_cli: -ifneq (,$(wren_cli_config)) - @echo "==== Building wren_cli ($(wren_cli_config)) ====" - @${MAKE} --no-print-directory -C . -f wren_cli.make config=$(wren_cli_config) +wrenc: +ifneq (,$(wrenc_config)) + @echo "==== Building wrenc ($(wrenc_config)) ====" + @${MAKE} --no-print-directory -C . -f wrenc.make config=$(wrenc_config) endif clean: - @${MAKE} --no-print-directory -C . -f wren_cli.make clean + @${MAKE} --no-print-directory -C . -f wrenc.make clean help: @echo "Usage: make [config=name] [target]" @@ -59,6 +59,6 @@ help: @echo "TARGETS:" @echo " all (default)" @echo " clean" - @echo " wren_cli" + @echo " wrenc" @echo "" @echo "For more information, see https://github.com/premake/premake-core/wiki" \ No newline at end of file diff --git a/projects/make/wren_cli.make b/projects/make/wrenc.make similarity index 80% rename from projects/make/wren_cli.make rename to projects/make/wrenc.make index 575d8a56..df2862a8 100644 --- a/projects/make/wren_cli.make +++ b/projects/make/wrenc.make @@ -19,7 +19,7 @@ endif # ############################################# RESCOMP = windres -INCLUDES += -I../../src/cli -I../../src/module -I../../deps/wren/include -I../../deps/wren/src/vm -I../../deps/wren/src/optional -I../../deps/libuv/include -I../../deps/libuv/src +INCLUDES += -I../../src/cli -I../../src/module -I../../deps/wren-essentials/src -I../../deps/wren/include -I../../deps/wren/src/vm -I../../deps/wren/src/optional -I../../deps/libuv/include -I../../deps/libuv/src FORCE_INCLUDE += ALL_CPPFLAGS += $(CPPFLAGS) -MMD -MP $(DEFINES) $(INCLUDES) ALL_RESFLAGS += $(RESFLAGS) $(DEFINES) $(INCLUDES) @@ -35,7 +35,7 @@ endef ifeq ($(config),release_64bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli +TARGET = $(TARGETDIR)/wrenc OBJDIR = obj/64bit/Release DEFINES += -DNDEBUG -D_GNU_SOURCE ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -O3 -std=c99 @@ -44,7 +44,7 @@ ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 -s else ifeq ($(config),release_32bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli +TARGET = $(TARGETDIR)/wrenc OBJDIR = obj/32bit/Release DEFINES += -DNDEBUG -D_GNU_SOURCE ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -O3 -std=c99 @@ -53,7 +53,7 @@ ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 -s else ifeq ($(config),release_64bit-no-nan-tagging) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli +TARGET = $(TARGETDIR)/wrenc OBJDIR = obj/64bit-no-nan-tagging/Release DEFINES += -DNDEBUG -DWREN_NAN_TAGGING=0 -D_GNU_SOURCE ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -O3 -std=c99 @@ -62,7 +62,7 @@ ALL_LDFLAGS += $(LDFLAGS) -s else ifeq ($(config),debug_64bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli_d +TARGET = $(TARGETDIR)/wrenc_d OBJDIR = obj/64bit/Debug DEFINES += -DDEBUG -D_GNU_SOURCE ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m64 -g -std=c99 @@ -71,7 +71,7 @@ ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib64 -m64 else ifeq ($(config),debug_32bit) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli_d +TARGET = $(TARGETDIR)/wrenc_d OBJDIR = obj/32bit/Debug DEFINES += -DDEBUG -D_GNU_SOURCE ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -m32 -g -std=c99 @@ -80,15 +80,13 @@ ALL_LDFLAGS += $(LDFLAGS) -L/usr/lib32 -m32 else ifeq ($(config),debug_64bit-no-nan-tagging) TARGETDIR = ../../bin -TARGET = $(TARGETDIR)/wren_cli_d +TARGET = $(TARGETDIR)/wrenc_d OBJDIR = obj/64bit-no-nan-tagging/Debug DEFINES += -DDEBUG -DWREN_NAN_TAGGING=0 -D_GNU_SOURCE ALL_CFLAGS += $(CFLAGS) $(ALL_CPPFLAGS) -g -std=c99 ALL_CXXFLAGS += $(CXXFLAGS) $(ALL_CPPFLAGS) -g ALL_LDFLAGS += $(LDFLAGS) -else - $(error "invalid configuration $(config)") endif # Per File Configurations @@ -98,11 +96,73 @@ endif # File sets # ############################################# +GENERATED := OBJECTS := +GENERATED += $(OBJDIR)/async.o +GENERATED += $(OBJDIR)/cli.o +GENERATED += $(OBJDIR)/core.o +GENERATED += $(OBJDIR)/dl.o +GENERATED += $(OBJDIR)/essentials.o +GENERATED += $(OBJDIR)/fs-poll.o +GENERATED += $(OBJDIR)/fs.o +GENERATED += $(OBJDIR)/getaddrinfo.o +GENERATED += $(OBJDIR)/getnameinfo.o +GENERATED += $(OBJDIR)/idna.o +GENERATED += $(OBJDIR)/inet.o +GENERATED += $(OBJDIR)/io.o +GENERATED += $(OBJDIR)/linux-core.o +GENERATED += $(OBJDIR)/linux-inotify.o +GENERATED += $(OBJDIR)/linux-syscalls.o +GENERATED += $(OBJDIR)/loop-watcher.o +GENERATED += $(OBJDIR)/loop.o +GENERATED += $(OBJDIR)/main.o +GENERATED += $(OBJDIR)/mirror.o +GENERATED += $(OBJDIR)/modules.o +GENERATED += $(OBJDIR)/os.o +GENERATED += $(OBJDIR)/path.o +GENERATED += $(OBJDIR)/pipe.o +GENERATED += $(OBJDIR)/poll.o +GENERATED += $(OBJDIR)/process.o +GENERATED += $(OBJDIR)/procfs-exepath.o +GENERATED += $(OBJDIR)/proctitle.o +GENERATED += $(OBJDIR)/random-devurandom.o +GENERATED += $(OBJDIR)/random-getrandom.o +GENERATED += $(OBJDIR)/random-sysctl-linux.o +GENERATED += $(OBJDIR)/random.o +GENERATED += $(OBJDIR)/repl.o +GENERATED += $(OBJDIR)/resolver.o +GENERATED += $(OBJDIR)/scheduler.o +GENERATED += $(OBJDIR)/signal.o +GENERATED += $(OBJDIR)/stream.o +GENERATED += $(OBJDIR)/strscpy.o +GENERATED += $(OBJDIR)/sysinfo-loadavg.o +GENERATED += $(OBJDIR)/tcp.o +GENERATED += $(OBJDIR)/thread.o +GENERATED += $(OBJDIR)/threadpool.o +GENERATED += $(OBJDIR)/time.o +GENERATED += $(OBJDIR)/timer.o +GENERATED += $(OBJDIR)/timer1.o +GENERATED += $(OBJDIR)/tty.o +GENERATED += $(OBJDIR)/udp.o +GENERATED += $(OBJDIR)/uv-common.o +GENERATED += $(OBJDIR)/uv-data-getter-setters.o +GENERATED += $(OBJDIR)/version.o +GENERATED += $(OBJDIR)/vm.o +GENERATED += $(OBJDIR)/wren_compiler.o +GENERATED += $(OBJDIR)/wren_core.o +GENERATED += $(OBJDIR)/wren_debug.o +GENERATED += $(OBJDIR)/wren_opt_meta.o +GENERATED += $(OBJDIR)/wren_opt_random.o +GENERATED += $(OBJDIR)/wren_primitive.o +GENERATED += $(OBJDIR)/wren_utils.o +GENERATED += $(OBJDIR)/wren_value.o +GENERATED += $(OBJDIR)/wren_vm.o OBJECTS += $(OBJDIR)/async.o +OBJECTS += $(OBJDIR)/cli.o OBJECTS += $(OBJDIR)/core.o OBJECTS += $(OBJDIR)/dl.o +OBJECTS += $(OBJDIR)/essentials.o OBJECTS += $(OBJDIR)/fs-poll.o OBJECTS += $(OBJDIR)/fs.o OBJECTS += $(OBJDIR)/getaddrinfo.o @@ -116,6 +176,7 @@ OBJECTS += $(OBJDIR)/linux-syscalls.o OBJECTS += $(OBJDIR)/loop-watcher.o OBJECTS += $(OBJDIR)/loop.o OBJECTS += $(OBJDIR)/main.o +OBJECTS += $(OBJDIR)/mirror.o OBJECTS += $(OBJDIR)/modules.o OBJECTS += $(OBJDIR)/os.o OBJECTS += $(OBJDIR)/path.o @@ -129,6 +190,7 @@ OBJECTS += $(OBJDIR)/random-getrandom.o OBJECTS += $(OBJDIR)/random-sysctl-linux.o OBJECTS += $(OBJDIR)/random.o OBJECTS += $(OBJDIR)/repl.o +OBJECTS += $(OBJDIR)/resolver.o OBJECTS += $(OBJDIR)/scheduler.o OBJECTS += $(OBJDIR)/signal.o OBJECTS += $(OBJDIR)/stream.o @@ -137,6 +199,7 @@ OBJECTS += $(OBJDIR)/sysinfo-loadavg.o OBJECTS += $(OBJDIR)/tcp.o OBJECTS += $(OBJDIR)/thread.o OBJECTS += $(OBJDIR)/threadpool.o +OBJECTS += $(OBJDIR)/time.o OBJECTS += $(OBJDIR)/timer.o OBJECTS += $(OBJDIR)/timer1.o OBJECTS += $(OBJDIR)/tty.o @@ -161,9 +224,9 @@ OBJECTS += $(OBJDIR)/wren_vm.o all: $(TARGET) @: -$(TARGET): $(OBJECTS) $(LDDEPS) | $(TARGETDIR) +$(TARGET): $(GENERATED) $(OBJECTS) $(LDDEPS) | $(TARGETDIR) $(PRELINKCMDS) - @echo Linking wren_cli + @echo Linking wrenc $(SILENT) $(LINKCMD) $(POSTBUILDCMDS) @@ -184,12 +247,14 @@ else endif clean: - @echo Cleaning wren_cli + @echo Cleaning wrenc ifeq (posix,$(SHELLTYPE)) $(SILENT) rm -f $(TARGET) + $(SILENT) rm -rf $(GENERATED) $(SILENT) rm -rf $(OBJDIR) else $(SILENT) if exist $(subst /,\\,$(TARGET)) del $(subst /,\\,$(TARGET)) + $(SILENT) if exist $(subst /,\\,$(GENERATED)) rmdir /s /q $(subst /,\\,$(GENERATED)) $(SILENT) if exist $(subst /,\\,$(OBJDIR)) rmdir /s /q $(subst /,\\,$(OBJDIR)) endif @@ -323,6 +388,15 @@ $(OBJDIR)/uv-data-getter-setters.o: ../../deps/libuv/src/uv-data-getter-setters. $(OBJDIR)/version.o: ../../deps/libuv/src/version.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/essentials.o: ../../deps/wren-essentials/src/essentials.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/mirror.o: ../../deps/wren-essentials/src/modules/mirror.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/time.o: ../../deps/wren-essentials/src/modules/time.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/wren_opt_meta.o: ../../deps/wren/src/optional/wren_opt_meta.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" @@ -350,6 +424,9 @@ $(OBJDIR)/wren_value.o: ../../deps/wren/src/vm/wren_value.c $(OBJDIR)/wren_vm.o: ../../deps/wren/src/vm/wren_vm.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/cli.o: ../../src/cli/cli.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/main.o: ../../src/cli/main.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" @@ -359,6 +436,9 @@ $(OBJDIR)/modules.o: ../../src/cli/modules.c $(OBJDIR)/path.o: ../../src/cli/path.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" +$(OBJDIR)/resolver.o: ../../src/cli/resolver.c + @echo $(notdir $<) + $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" $(OBJDIR)/vm.o: ../../src/cli/vm.c @echo $(notdir $<) $(SILENT) $(CC) $(ALL_CFLAGS) $(FORCE_INCLUDE) -o "$@" -MF "$(@:%.o=%.d)" -c "$<" diff --git a/projects/premake/premake5.lua b/projects/premake/premake5.lua index 7b12f322..032837d0 100644 --- a/projects/premake/premake5.lua +++ b/projects/premake/premake5.lua @@ -1,4 +1,4 @@ -workspace "wren-cli" +workspace "wren-console" configurations { "Release", "Debug" } platforms { "64bit", "32bit", "64bit-no-nan-tagging" } defaultplatform "64bit" @@ -42,7 +42,7 @@ workspace "wren-cli" filter { "action:gmake2", "system:macosx" } location ("../make.mac") -project "wren_cli" +project "wrenc" kind "ConsoleApp" language "C" cdialect "C99" @@ -60,6 +60,20 @@ project "wren_cli" "../../src/module", } +-- wren-essentials dependency + +files { + "../../deps/wren-essentials/modules/**.c", + "../../deps/wren-essentials/modules/**.c", + "../../deps/wren-essentials/src/**.c", + "../../deps/wren-essentials/src/**.h" +} + +includedirs { + "../../deps/wren-essentials/src/", +} + + -- wren dependency files { diff --git a/projects/vs2017/wren-cli.sln b/projects/vs2017/wren-console.sln similarity index 52% rename from projects/vs2017/wren-cli.sln rename to projects/vs2017/wren-console.sln index b32b20d1..415b3a66 100644 --- a/projects/vs2017/wren-cli.sln +++ b/projects/vs2017/wren-console.sln @@ -1,34 +1,34 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren_cli", "wren_cli.vcxproj", "{F8A65189-E473-AC94-0D8D-9A3CF9B8E122}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|64bit = Debug|64bit - Release|64bit = Release|64bit - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|32bit = Debug|32bit - Debug|64bit-no-nan-tagging = Debug|64bit-no-nan-tagging - Release|32bit = Release|32bit - Release|64bit-no-nan-tagging = Release|64bit-no-nan-tagging - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|32bit.ActiveCfg = Debug 32bit|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|32bit.Build.0 = Debug 32bit|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|64bit.ActiveCfg = Debug 64bit|x64 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|64bit.Build.0 = Debug 64bit|x64 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|64bit-no-nan-tagging.ActiveCfg = Debug 64bit-no-nan-tagging|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|64bit-no-nan-tagging.Build.0 = Debug 64bit-no-nan-tagging|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|32bit.ActiveCfg = Release 32bit|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|32bit.Build.0 = Release 32bit|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|64bit.ActiveCfg = Release 64bit|x64 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|64bit.Build.0 = Release 64bit|x64 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|64bit-no-nan-tagging.ActiveCfg = Release 64bit-no-nan-tagging|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|64bit-no-nan-tagging.Build.0 = Release 64bit-no-nan-tagging|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wrenc", "wrenc.vcxproj", "{84A3A810-F0B7-D0C1-B939-7421250DCDF2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|64bit = Debug|64bit + Release|64bit = Release|64bit + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|32bit = Debug|32bit + Debug|64bit-no-nan-tagging = Debug|64bit-no-nan-tagging + Release|32bit = Release|32bit + Release|64bit-no-nan-tagging = Release|64bit-no-nan-tagging + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|32bit.ActiveCfg = Debug 32bit|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|32bit.Build.0 = Debug 32bit|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|64bit.ActiveCfg = Debug 64bit|x64 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|64bit.Build.0 = Debug 64bit|x64 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|64bit-no-nan-tagging.ActiveCfg = Debug 64bit-no-nan-tagging|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|64bit-no-nan-tagging.Build.0 = Debug 64bit-no-nan-tagging|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|32bit.ActiveCfg = Release 32bit|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|32bit.Build.0 = Release 32bit|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|64bit.ActiveCfg = Release 64bit|x64 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|64bit.Build.0 = Release 64bit|x64 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|64bit-no-nan-tagging.ActiveCfg = Release 64bit-no-nan-tagging|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|64bit-no-nan-tagging.Build.0 = Release 64bit-no-nan-tagging|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/projects/vs2017/wren_cli.vcxproj b/projects/vs2017/wrenc.vcxproj similarity index 88% rename from projects/vs2017/wren_cli.vcxproj rename to projects/vs2017/wrenc.vcxproj index 1b39cdf9..447edfd0 100644 --- a/projects/vs2017/wren_cli.vcxproj +++ b/projects/vs2017/wrenc.vcxproj @@ -1,402 +1,418 @@ - - - - - Release 64bit - x64 - - - Release 64bit - Win32 - - - Release 32bit - x64 - - - Release 32bit - Win32 - - - Release 64bit-no-nan-tagging - x64 - - - Release 64bit-no-nan-tagging - Win32 - - - Debug 64bit - x64 - - - Debug 64bit - Win32 - - - Debug 32bit - x64 - - - Debug 32bit - Win32 - - - Debug 64bit-no-nan-tagging - x64 - - - Debug 64bit-no-nan-tagging - Win32 - - - - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122} - true - Win32Proj - wren_cli - 10.0.18362.0 - - - - Application - false - Unicode - v141 - - - Application - false - Unicode - v141 - - - Application - false - Unicode - v141 - - - Application - true - Unicode - v141 - - - Application - true - Unicode - v141 - - - Application - true - Unicode - v141 - - - - - - - - - - - - - - - - - - - - - - - - - false - ..\..\bin\ - obj\64bit\Release\ - wren_cli - .exe - - - false - ..\..\bin\ - obj\32bit\Release\ - wren_cli - .exe - - - false - ..\..\bin\ - obj\64bit-no-nan-tagging\Release\ - wren_cli - .exe - - - true - ..\..\bin\ - obj\64bit\Debug\ - wren_cli_d - .exe - - - true - ..\..\bin\ - obj\32bit\Debug\ - wren_cli_d - .exe - - - true - ..\..\bin\ - obj\64bit-no-nan-tagging\Debug\ - wren_cli_d - .exe - - - - NotUsing - Level3 - NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - true - - - Console - true - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - true - - - Console - true - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - NDEBUG;WREN_NAN_TAGGING=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - true - - - Console - true - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - false - MultiThreadedDebug - true - - - Console - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - false - MultiThreadedDebug - true - - - Console - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - DEBUG;WREN_NAN_TAGGING=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - false - MultiThreadedDebug - true - - - Console - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(IntDir)\timer1.obj - - - - - - - - - - - - + + + + + Release 64bit + x64 + + + Release 64bit + Win32 + + + Release 32bit + x64 + + + Release 32bit + Win32 + + + Release 64bit-no-nan-tagging + x64 + + + Release 64bit-no-nan-tagging + Win32 + + + Debug 64bit + x64 + + + Debug 64bit + Win32 + + + Debug 32bit + x64 + + + Debug 32bit + Win32 + + + Debug 64bit-no-nan-tagging + x64 + + + Debug 64bit-no-nan-tagging + Win32 + + + + {84A3A810-F0B7-D0C1-B939-7421250DCDF2} + true + Win32Proj + wrenc + $([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0')) + $(LatestTargetPlatformVersion) + + + + Application + false + Unicode + v141 + + + Application + false + Unicode + v141 + + + Application + false + Unicode + v141 + + + Application + true + Unicode + v141 + + + Application + true + Unicode + v141 + + + Application + true + Unicode + v141 + + + + + + + + + + + + + + + + + + + + + + + + + false + ..\..\bin\ + obj\64bit\Release\ + wrenc + .exe + + + false + ..\..\bin\ + obj\32bit\Release\ + wrenc + .exe + + + false + ..\..\bin\ + obj\64bit-no-nan-tagging\Release\ + wrenc + .exe + + + true + ..\..\bin\ + obj\64bit\Debug\ + wrenc_d + .exe + + + true + ..\..\bin\ + obj\32bit\Debug\ + wrenc_d + .exe + + + true + ..\..\bin\ + obj\64bit-no-nan-tagging\Debug\ + wrenc_d + .exe + + + + NotUsing + Level3 + NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + true + + + Console + true + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + true + + + Console + true + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + NDEBUG;WREN_NAN_TAGGING=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + true + + + Console + true + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + false + MultiThreadedDebug + true + + + Console + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + false + MultiThreadedDebug + true + + + Console + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + DEBUG;WREN_NAN_TAGGING=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + false + MultiThreadedDebug + true + + + Console + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(IntDir)\timer1.obj + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/vs2017/wren_cli.vcxproj.filters b/projects/vs2017/wrenc.vcxproj.filters similarity index 86% rename from projects/vs2017/wren_cli.vcxproj.filters rename to projects/vs2017/wrenc.vcxproj.filters index 8101ea33..b99ee989 100644 --- a/projects/vs2017/wren_cli.vcxproj.filters +++ b/projects/vs2017/wrenc.vcxproj.filters @@ -1,374 +1,428 @@ - - - - - {F1A1957C-DDD8-960D-86C5-7C1072DB120F} - - - {E2A29D25-CE5A-DF72-3762-B8CE23397A63} - - - {558C8802-4170-4958-AAD0-43AB96D333DA} - - - {AF7F7CA2-1BEC-379D-E4DF-CFFA500B5A05} - - - {F901B42F-E5CF-A735-CE63-185CBAD0839A} - - - {7624820D-6208-4363-CB68-3DB6B76B2DE5} - - - {BC330366-289E-B7DC-71DC-6882DD859531} - - - {2F577609-9B6D-749F-E4E4-FFC0503A4527} - - - {D36FCA57-3F30-468E-086B-8F0B74EA8A6A} - - - {28C3CC3B-14BD-F58D-FD29-8C9EE9C25BFA} - - - {859ADCF8-7193-FB4A-9AC5-E0CF861DDB56} - - - {2DAB880B-99B4-887C-2230-9F7C8E38947C} - - - {F4F22FA9-60D2-AE44-69EA-391BD54815A6} - - - {62A0916B-4E58-D3B8-B75F-AC14A3366EA9} - - - - - deps\libuv\include - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\wren\include - - - deps\wren\src\optional - - - deps\wren\src\optional - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - src\cli - - - src\cli - - - src\cli - - - src\cli - - - src\module - - - src\module - - - src\module - - - src\module - - - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\wren\src\optional - - - deps\wren\src\optional - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - src\cli - - - src\cli - - - src\cli - - - src\cli - - - src\module - - - src\module - - - src\module - - - src\module - - - src\module - - - - - src\module - - - src\module - - - src\module - - - src\module - - - src\module - - + + + + + {F1A1957C-DDD8-960D-86C5-7C1072DB120F} + + + {E2A29D25-CE5A-DF72-3762-B8CE23397A63} + + + {558C8802-4170-4958-AAD0-43AB96D333DA} + + + {AF7F7CA2-1BEC-379D-E4DF-CFFA500B5A05} + + + {F901B42F-E5CF-A735-CE63-185CBAD0839A} + + + {7624820D-6208-4363-CB68-3DB6B76B2DE5} + + + {BC330366-289E-B7DC-71DC-6882DD859531} + + + {2F577609-9B6D-749F-E4E4-FFC0503A4527} + + + {D36FCA57-3F30-468E-086B-8F0B74EA8A6A} + + + {28C3CC3B-14BD-F58D-FD29-8C9EE9C25BFA} + + + {859ADCF8-7193-FB4A-9AC5-E0CF861DDB56} + + + {C42F2613-B0BE-AFDC-59DD-C3D7454BC082} + + + {DB2F9C96-C754-EB16-F09F-D0A6DC23EA34} + + + {C3FFB122-AF50-9D64-D8B4-8B26C46430CE} + + + {2DAB880B-99B4-887C-2230-9F7C8E38947C} + + + {F4F22FA9-60D2-AE44-69EA-391BD54815A6} + + + {62A0916B-4E58-D3B8-B75F-AC14A3366EA9} + + + + + deps\libuv\include + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\wren-essentials\src + + + deps\wren-essentials\src + + + deps\wren-essentials\src\modules + + + deps\wren-essentials\src\modules + + + deps\wren\include + + + deps\wren\src\optional + + + deps\wren\src\optional + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\module + + + src\module + + + src\module + + + src\module + + + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\wren-essentials\src + + + deps\wren-essentials\src\modules + + + deps\wren-essentials\src\modules + + + deps\wren\src\optional + + + deps\wren\src\optional + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\module + + + src\module + + + src\module + + + src\module + + + src\module + + + + + src\cli + + + src\module + + + src\module + + + src\module + + + src\module + + + src\module + + + src\module + + \ No newline at end of file diff --git a/projects/vs2019/wren-cli.sln b/projects/vs2019/wren-console.sln similarity index 51% rename from projects/vs2019/wren-cli.sln rename to projects/vs2019/wren-console.sln index 3e666bec..9e4a5dbc 100644 --- a/projects/vs2019/wren-cli.sln +++ b/projects/vs2019/wren-console.sln @@ -1,34 +1,34 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 16 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wren_cli", "wren_cli.vcxproj", "{F8A65189-E473-AC94-0D8D-9A3CF9B8E122}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|64bit = Debug|64bit - Release|64bit = Release|64bit - EndGlobalSection - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|32bit = Debug|32bit - Debug|64bit-no-nan-tagging = Debug|64bit-no-nan-tagging - Release|32bit = Release|32bit - Release|64bit-no-nan-tagging = Release|64bit-no-nan-tagging - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|32bit.ActiveCfg = Debug 32bit|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|32bit.Build.0 = Debug 32bit|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|64bit.ActiveCfg = Debug 64bit|x64 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|64bit.Build.0 = Debug 64bit|x64 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|64bit-no-nan-tagging.ActiveCfg = Debug 64bit-no-nan-tagging|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Debug|64bit-no-nan-tagging.Build.0 = Debug 64bit-no-nan-tagging|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|32bit.ActiveCfg = Release 32bit|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|32bit.Build.0 = Release 32bit|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|64bit.ActiveCfg = Release 64bit|x64 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|64bit.Build.0 = Release 64bit|x64 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|64bit-no-nan-tagging.ActiveCfg = Release 64bit-no-nan-tagging|Win32 - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122}.Release|64bit-no-nan-tagging.Build.0 = Release 64bit-no-nan-tagging|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wrenc", "wrenc.vcxproj", "{84A3A810-F0B7-D0C1-B939-7421250DCDF2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|64bit = Debug|64bit + Release|64bit = Release|64bit + EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|32bit = Debug|32bit + Debug|64bit-no-nan-tagging = Debug|64bit-no-nan-tagging + Release|32bit = Release|32bit + Release|64bit-no-nan-tagging = Release|64bit-no-nan-tagging + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|32bit.ActiveCfg = Debug 32bit|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|32bit.Build.0 = Debug 32bit|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|64bit.ActiveCfg = Debug 64bit|x64 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|64bit.Build.0 = Debug 64bit|x64 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|64bit-no-nan-tagging.ActiveCfg = Debug 64bit-no-nan-tagging|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Debug|64bit-no-nan-tagging.Build.0 = Debug 64bit-no-nan-tagging|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|32bit.ActiveCfg = Release 32bit|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|32bit.Build.0 = Release 32bit|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|64bit.ActiveCfg = Release 64bit|x64 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|64bit.Build.0 = Release 64bit|x64 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|64bit-no-nan-tagging.ActiveCfg = Release 64bit-no-nan-tagging|Win32 + {84A3A810-F0B7-D0C1-B939-7421250DCDF2}.Release|64bit-no-nan-tagging.Build.0 = Release 64bit-no-nan-tagging|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/projects/vs2019/wren_cli.vcxproj b/projects/vs2019/wrenc.vcxproj similarity index 89% rename from projects/vs2019/wren_cli.vcxproj rename to projects/vs2019/wrenc.vcxproj index 6c3e735c..a7124650 100644 --- a/projects/vs2019/wren_cli.vcxproj +++ b/projects/vs2019/wrenc.vcxproj @@ -1,402 +1,417 @@ - - - - - Release 64bit - x64 - - - Release 64bit - Win32 - - - Release 32bit - x64 - - - Release 32bit - Win32 - - - Release 64bit-no-nan-tagging - x64 - - - Release 64bit-no-nan-tagging - Win32 - - - Debug 64bit - x64 - - - Debug 64bit - Win32 - - - Debug 32bit - x64 - - - Debug 32bit - Win32 - - - Debug 64bit-no-nan-tagging - x64 - - - Debug 64bit-no-nan-tagging - Win32 - - - - {F8A65189-E473-AC94-0D8D-9A3CF9B8E122} - true - Win32Proj - wren_cli - 10.0 - - - - Application - false - Unicode - v142 - - - Application - false - Unicode - v142 - - - Application - false - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - Application - true - Unicode - v142 - - - - - - - - - - - - - - - - - - - - - - - - - false - ..\..\bin\ - obj\64bit\Release\ - wren_cli - .exe - - - false - ..\..\bin\ - obj\32bit\Release\ - wren_cli - .exe - - - false - ..\..\bin\ - obj\64bit-no-nan-tagging\Release\ - wren_cli - .exe - - - true - ..\..\bin\ - obj\64bit\Debug\ - wren_cli_d - .exe - - - true - ..\..\bin\ - obj\32bit\Debug\ - wren_cli_d - .exe - - - true - ..\..\bin\ - obj\64bit-no-nan-tagging\Debug\ - wren_cli_d - .exe - - - - NotUsing - Level3 - NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - true - - - Console - true - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - true - - - Console - true - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - NDEBUG;WREN_NAN_TAGGING=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - Full - true - true - false - true - MultiThreaded - true - - - Console - true - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - false - MultiThreadedDebug - true - - - Console - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - false - MultiThreadedDebug - true - - - Console - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - NotUsing - Level3 - DEBUG;WREN_NAN_TAGGING=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - ..\..\src\cli;..\..\src\module;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) - EditAndContinue - Disabled - false - MultiThreadedDebug - true - - - Console - true - imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) - /OPT:NOREF %(AdditionalOptions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(IntDir)\timer1.obj - - - - - - - - - - - - + + + + + Release 64bit + x64 + + + Release 64bit + Win32 + + + Release 32bit + x64 + + + Release 32bit + Win32 + + + Release 64bit-no-nan-tagging + x64 + + + Release 64bit-no-nan-tagging + Win32 + + + Debug 64bit + x64 + + + Debug 64bit + Win32 + + + Debug 32bit + x64 + + + Debug 32bit + Win32 + + + Debug 64bit-no-nan-tagging + x64 + + + Debug 64bit-no-nan-tagging + Win32 + + + + {84A3A810-F0B7-D0C1-B939-7421250DCDF2} + true + Win32Proj + wrenc + 10.0 + + + + Application + false + Unicode + v142 + + + Application + false + Unicode + v142 + + + Application + false + Unicode + v142 + + + Application + true + Unicode + v142 + + + Application + true + Unicode + v142 + + + Application + true + Unicode + v142 + + + + + + + + + + + + + + + + + + + + + + + + + false + ..\..\bin\ + obj\64bit\Release\ + wrenc + .exe + + + false + ..\..\bin\ + obj\32bit\Release\ + wrenc + .exe + + + false + ..\..\bin\ + obj\64bit-no-nan-tagging\Release\ + wrenc + .exe + + + true + ..\..\bin\ + obj\64bit\Debug\ + wrenc_d + .exe + + + true + ..\..\bin\ + obj\32bit\Debug\ + wrenc_d + .exe + + + true + ..\..\bin\ + obj\64bit-no-nan-tagging\Debug\ + wrenc_d + .exe + + + + NotUsing + Level3 + NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + true + + + Console + true + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + NDEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + true + + + Console + true + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + NDEBUG;WREN_NAN_TAGGING=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + Full + true + true + false + true + MultiThreaded + true + + + Console + true + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + false + MultiThreadedDebug + true + + + Console + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + DEBUG;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + false + MultiThreadedDebug + true + + + Console + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + NotUsing + Level3 + DEBUG;WREN_NAN_TAGGING=0;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + ..\..\src\cli;..\..\src\module;..\..\deps\wren-essentials\src;..\..\deps\wren\include;..\..\deps\wren\src\vm;..\..\deps\wren\src\optional;..\..\deps\libuv\include;..\..\deps\libuv\src;%(AdditionalIncludeDirectories) + EditAndContinue + Disabled + false + MultiThreadedDebug + true + + + Console + true + imm32.lib;winmm.lib;version.lib;wldap32.lib;ws2_32.lib;psapi.lib;iphlpapi.lib;userenv.lib;%(AdditionalDependencies) + /OPT:NOREF %(AdditionalOptions) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(IntDir)\timer1.obj + + + + + + + + + + + + + + \ No newline at end of file diff --git a/projects/vs2019/wren_cli.vcxproj.filters b/projects/vs2019/wrenc.vcxproj.filters similarity index 86% rename from projects/vs2019/wren_cli.vcxproj.filters rename to projects/vs2019/wrenc.vcxproj.filters index 8101ea33..b99ee989 100644 --- a/projects/vs2019/wren_cli.vcxproj.filters +++ b/projects/vs2019/wrenc.vcxproj.filters @@ -1,374 +1,428 @@ - - - - - {F1A1957C-DDD8-960D-86C5-7C1072DB120F} - - - {E2A29D25-CE5A-DF72-3762-B8CE23397A63} - - - {558C8802-4170-4958-AAD0-43AB96D333DA} - - - {AF7F7CA2-1BEC-379D-E4DF-CFFA500B5A05} - - - {F901B42F-E5CF-A735-CE63-185CBAD0839A} - - - {7624820D-6208-4363-CB68-3DB6B76B2DE5} - - - {BC330366-289E-B7DC-71DC-6882DD859531} - - - {2F577609-9B6D-749F-E4E4-FFC0503A4527} - - - {D36FCA57-3F30-468E-086B-8F0B74EA8A6A} - - - {28C3CC3B-14BD-F58D-FD29-8C9EE9C25BFA} - - - {859ADCF8-7193-FB4A-9AC5-E0CF861DDB56} - - - {2DAB880B-99B4-887C-2230-9F7C8E38947C} - - - {F4F22FA9-60D2-AE44-69EA-391BD54815A6} - - - {62A0916B-4E58-D3B8-B75F-AC14A3366EA9} - - - - - deps\libuv\include - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\include\uv - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\wren\include - - - deps\wren\src\optional - - - deps\wren\src\optional - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - src\cli - - - src\cli - - - src\cli - - - src\cli - - - src\module - - - src\module - - - src\module - - - src\module - - - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\libuv\src\win - - - deps\wren\src\optional - - - deps\wren\src\optional - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - deps\wren\src\vm - - - src\cli - - - src\cli - - - src\cli - - - src\cli - - - src\module - - - src\module - - - src\module - - - src\module - - - src\module - - - - - src\module - - - src\module - - - src\module - - - src\module - - - src\module - - + + + + + {F1A1957C-DDD8-960D-86C5-7C1072DB120F} + + + {E2A29D25-CE5A-DF72-3762-B8CE23397A63} + + + {558C8802-4170-4958-AAD0-43AB96D333DA} + + + {AF7F7CA2-1BEC-379D-E4DF-CFFA500B5A05} + + + {F901B42F-E5CF-A735-CE63-185CBAD0839A} + + + {7624820D-6208-4363-CB68-3DB6B76B2DE5} + + + {BC330366-289E-B7DC-71DC-6882DD859531} + + + {2F577609-9B6D-749F-E4E4-FFC0503A4527} + + + {D36FCA57-3F30-468E-086B-8F0B74EA8A6A} + + + {28C3CC3B-14BD-F58D-FD29-8C9EE9C25BFA} + + + {859ADCF8-7193-FB4A-9AC5-E0CF861DDB56} + + + {C42F2613-B0BE-AFDC-59DD-C3D7454BC082} + + + {DB2F9C96-C754-EB16-F09F-D0A6DC23EA34} + + + {C3FFB122-AF50-9D64-D8B4-8B26C46430CE} + + + {2DAB880B-99B4-887C-2230-9F7C8E38947C} + + + {F4F22FA9-60D2-AE44-69EA-391BD54815A6} + + + {62A0916B-4E58-D3B8-B75F-AC14A3366EA9} + + + + + deps\libuv\include + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\include\uv + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\wren-essentials\src + + + deps\wren-essentials\src + + + deps\wren-essentials\src\modules + + + deps\wren-essentials\src\modules + + + deps\wren\include + + + deps\wren\src\optional + + + deps\wren\src\optional + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\module + + + src\module + + + src\module + + + src\module + + + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\libuv\src\win + + + deps\wren-essentials\src + + + deps\wren-essentials\src\modules + + + deps\wren-essentials\src\modules + + + deps\wren\src\optional + + + deps\wren\src\optional + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + deps\wren\src\vm + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\cli + + + src\module + + + src\module + + + src\module + + + src\module + + + src\module + + + + + src\cli + + + src\module + + + src\module + + + src\module + + + src\module + + + src\module + + + src\module + + \ No newline at end of file diff --git a/projects/xcode/wren-cli.xcworkspace/contents.xcworkspacedata b/projects/xcode/wren-console.xcworkspace/contents.xcworkspacedata similarity index 71% rename from projects/xcode/wren-cli.xcworkspace/contents.xcworkspacedata rename to projects/xcode/wren-console.xcworkspace/contents.xcworkspacedata index 7833027a..af353ff7 100644 --- a/projects/xcode/wren-cli.xcworkspace/contents.xcworkspacedata +++ b/projects/xcode/wren-console.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "group:wrenc.xcodeproj"> \ No newline at end of file diff --git a/projects/xcode/wren_cli.xcodeproj/project.pbxproj b/projects/xcode/wrenc.xcodeproj/project.pbxproj similarity index 84% rename from projects/xcode/wren_cli.xcodeproj/project.pbxproj rename to projects/xcode/wrenc.xcodeproj/project.pbxproj index f25411a6..aeb73ede 100644 --- a/projects/xcode/wren_cli.xcodeproj/project.pbxproj +++ b/projects/xcode/wrenc.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ 3EE5E6A159B255535D82ECE1 /* wren_value.c in Sources */ = {isa = PBXBuildFile; fileRef = 165BEEA98383FD1B8516ECE9 /* wren_value.c */; }; 40602D279BAB7D5989DD6367 /* uv-data-getter-setters.c in Sources */ = {isa = PBXBuildFile; fileRef = FF72290F112969018697574F /* uv-data-getter-setters.c */; }; 42240B7CF51A152E463C71BC /* wren_opt_meta.c in Sources */ = {isa = PBXBuildFile; fileRef = BD161D04B115667636007B44 /* wren_opt_meta.c */; }; + 44968CA488E53216CB0C6AE4 /* resolver.c in Sources */ = {isa = PBXBuildFile; fileRef = F8423C6C1A0DE99E56C312AC /* resolver.c */; }; 505B1DD56284FA879675E415 /* strscpy.c in Sources */ = {isa = PBXBuildFile; fileRef = 5F4494DD5906514F9305531D /* strscpy.c */; }; 54A39645EA1A557758B6AC85 /* inet.c in Sources */ = {isa = PBXBuildFile; fileRef = B77B234DE70CF23FC21A318D /* inet.c */; }; 5D56F2708F503D22092F78B0 /* timer.c in Sources */ = {isa = PBXBuildFile; fileRef = 1C2A055872B76FCA4B308398 /* timer.c */; }; @@ -31,8 +32,10 @@ 733604C6642D72B8D030F306 /* getaddrinfo.c in Sources */ = {isa = PBXBuildFile; fileRef = 456D6BEEDDBA51A00C01522E /* getaddrinfo.c */; }; 76E8D1083D76C87AAB78EF48 /* thread.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E91C010B4087F4222A4D650 /* thread.c */; }; 778E3F34E4B64DA6E6493D74 /* pipe.c in Sources */ = {isa = PBXBuildFile; fileRef = 46315B7C939451AE09B351BC /* pipe.c */; }; + 79850B90A916DA82842419D0 /* cli.c in Sources */ = {isa = PBXBuildFile; fileRef = 179C7F98BA8AA64A49B085D8 /* cli.c */; }; 7C5F7B3616B9642852F1C976 /* random-getentropy.c in Sources */ = {isa = PBXBuildFile; fileRef = 5E55895EFC368A10D3B4CF9E /* random-getentropy.c */; }; 801477D4CD776E0643966E14 /* repl.c in Sources */ = {isa = PBXBuildFile; fileRef = ECA5597CD7917F6E1F7747BC /* repl.c */; }; + 851B636522FC6417FA7AA9A5 /* mirror.c in Sources */ = {isa = PBXBuildFile; fileRef = DFF7E00DA2B8407FFFED1E4D /* mirror.c */; }; 8581958A180F5F7C80E803CA /* udp.c in Sources */ = {isa = PBXBuildFile; fileRef = 91FD967255695824940CFCB2 /* udp.c */; }; 88095BE6DE96C658B70FDA26 /* vm.c in Sources */ = {isa = PBXBuildFile; fileRef = F460E68EF7D1B8C0793E5CCE /* vm.c */; }; 8E6A22C726B7087954FE0907 /* uv-common.c in Sources */ = {isa = PBXBuildFile; fileRef = 834C49AFC79AEF2109C227EF /* uv-common.c */; }; @@ -40,6 +43,7 @@ 91D3773A2461412C8D39E57A /* tty.c in Sources */ = {isa = PBXBuildFile; fileRef = 1E014522E16D06D42010AB62 /* tty.c */; }; A98FF85D3F06B78FADA30E9D /* idna.c in Sources */ = {isa = PBXBuildFile; fileRef = A56717E5D4F8E6D7B0062625 /* idna.c */; }; AAE7A4AAEF364A1C315D82EA /* fs.c in Sources */ = {isa = PBXBuildFile; fileRef = 898D2692AB58D3C4E80DFCD2 /* fs.c */; }; + ACF91E8D20E1963F432F44CD /* time.c in Sources */ = {isa = PBXBuildFile; fileRef = CC50B6B592DEAE2700E0D4F5 /* time.c */; }; B5D513B478957426D5CA51F4 /* fsevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 5F08F3FC434FFC2EC73D2A3C /* fsevents.c */; }; B812A9B9972FC3EB73391FF9 /* wren_core.c in Sources */ = {isa = PBXBuildFile; fileRef = A6A2BB4139308533A2092981 /* wren_core.c */; }; B9777BA42DD1C096ABB549E4 /* proctitle.c in Sources */ = {isa = PBXBuildFile; fileRef = B7ECC7ECCA16A49EFE078E2C /* proctitle.c */; }; @@ -50,6 +54,7 @@ C5FC7BA7AA4383D92E30B1E7 /* random.c in Sources */ = {isa = PBXBuildFile; fileRef = A414DF8FD4F8D781E8110DCF /* random.c */; }; CB4D48D2BC44B6C428483712 /* getnameinfo.c in Sources */ = {isa = PBXBuildFile; fileRef = 02A7B93A9AF49EECC93B9F7A /* getnameinfo.c */; }; D4BB20BFE6E4FD711AD5E6FF /* fs-poll.c in Sources */ = {isa = PBXBuildFile; fileRef = DC4FB627D611729910107467 /* fs-poll.c */; }; + D6EE9D7D74CF9E2F4C4DE3BD /* essentials.c in Sources */ = {isa = PBXBuildFile; fileRef = 07AE2E25CA6E8E9727A36C65 /* essentials.c */; }; D7D3A3F1E9FD80A31DEE6A31 /* version.c in Sources */ = {isa = PBXBuildFile; fileRef = 8B785739853A13ABBF391579 /* version.c */; }; DEDAE5283B61E99AC404A368 /* darwin-proctitle.c in Sources */ = {isa = PBXBuildFile; fileRef = D1349830E119C462CD8D4E70 /* darwin-proctitle.c */; }; E0B432BA3BF5862C0F4FD0FA /* path.c in Sources */ = {isa = PBXBuildFile; fileRef = D69A4422EDACDF54DDC8DA62 /* path.c */; }; @@ -67,17 +72,18 @@ 036EFC3D98E5BB6F0782127D /* sunos.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = sunos.h; path = ../../deps/libuv/include/uv/sunos.h; sourceTree = ""; }; 039D8737D1C0DAE958CF2D77 /* darwin.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = darwin.h; path = ../../deps/libuv/include/uv/darwin.h; sourceTree = ""; }; 0424D20BC6E5327D241A104B /* wren_primitive.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren_primitive.h; path = ../../deps/wren/src/vm/wren_primitive.h; sourceTree = ""; }; + 07AE2E25CA6E8E9727A36C65 /* essentials.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = essentials.c; path = "../../deps/wren-essentials/src/essentials.c"; sourceTree = ""; }; 08DCB67379FF57652FC604B3 /* heap-inl.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "heap-inl.h"; path = "../../deps/libuv/src/heap-inl.h"; sourceTree = ""; }; 098B94624D9F65944170EAA2 /* atomic-ops.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "atomic-ops.h"; path = "../../deps/libuv/src/unix/atomic-ops.h"; sourceTree = ""; }; 0A65426939F7115B150450A9 /* uv.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = uv.h; path = ../../deps/libuv/include/uv.h; sourceTree = ""; }; 0D1181295A74775BD0937769 /* win.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = win.h; path = ../../deps/libuv/include/uv/win.h; sourceTree = ""; }; 0F964BCA26A8E6FC16C4E20A /* stat.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = stat.h; path = ../../src/cli/stat.h; sourceTree = ""; }; 0FE01F0D41D969BFBBB8A54D /* tree.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = tree.h; path = ../../deps/libuv/include/uv/tree.h; sourceTree = ""; }; - 120A697C40B0BD6E99F217BC /* wren_cli */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = wren_cli; path = wren_cli; sourceTree = BUILT_PRODUCTS_DIR; }; 14B8844BA7464E3D101EF28B /* wren_core.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren_core.h; path = ../../deps/wren/src/vm/wren_core.h; sourceTree = ""; }; 14BF8226AD0C67D8DB536866 /* bsd-ifaddrs.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "bsd-ifaddrs.c"; path = "../../deps/libuv/src/unix/bsd-ifaddrs.c"; sourceTree = ""; }; 165BEEA98383FD1B8516ECE9 /* wren_value.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_value.c; path = ../../deps/wren/src/vm/wren_value.c; sourceTree = ""; }; 1726E409AC9DA33B1B39FA49 /* os390.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = os390.h; path = ../../deps/libuv/include/uv/os390.h; sourceTree = ""; }; + 179C7F98BA8AA64A49B085D8 /* cli.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = cli.c; path = ../../src/cli/cli.c; sourceTree = ""; }; 1C2A055872B76FCA4B308398 /* timer.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = timer.c; path = ../../src/module/timer.c; sourceTree = ""; }; 1E014522E16D06D42010AB62 /* tty.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = tty.c; path = ../../deps/libuv/src/unix/tty.c; sourceTree = ""; }; 1E91C010B4087F4222A4D650 /* thread.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = thread.c; path = ../../deps/libuv/src/unix/thread.c; sourceTree = ""; }; @@ -98,20 +104,26 @@ 4EBCAEFAE14A78EC4A231D3A /* timer.wren.inc */ = {isa = PBXFileReference; lastKnownFileType = text; name = timer.wren.inc; path = ../../src/module/timer.wren.inc; sourceTree = ""; }; 4EC9A0A44F7C9D96C35E6EE4 /* os.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = os.h; path = ../../src/module/os.h; sourceTree = ""; }; 550A8B6655BD8858C99F59A6 /* io.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = io.c; path = ../../src/module/io.c; sourceTree = ""; }; + 55546F42F84295F487687582 /* cli.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = cli.h; path = ../../src/cli/cli.h; sourceTree = ""; }; 594F904E4D4ED9C0D239EE8E /* wren_opt_meta.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren_opt_meta.h; path = ../../deps/wren/src/optional/wren_opt_meta.h; sourceTree = ""; }; + 59FA2B367BC5D868B87B0176 /* resolver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = resolver.h; path = ../../src/cli/resolver.h; sourceTree = ""; }; 5E55895EFC368A10D3B4CF9E /* random-getentropy.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "random-getentropy.c"; path = "../../deps/libuv/src/unix/random-getentropy.c"; sourceTree = ""; }; 5F08F3FC434FFC2EC73D2A3C /* fsevents.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = fsevents.c; path = ../../deps/libuv/src/unix/fsevents.c; sourceTree = ""; }; 5F4494DD5906514F9305531D /* strscpy.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = strscpy.c; path = ../../deps/libuv/src/strscpy.c; sourceTree = ""; }; 5FF4585060A75542D4892690 /* io.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = io.h; path = ../../src/module/io.h; sourceTree = ""; }; 6068A0F602523CE8F9794F36 /* scheduler.wren.inc */ = {isa = PBXFileReference; lastKnownFileType = text; name = scheduler.wren.inc; path = ../../src/module/scheduler.wren.inc; sourceTree = ""; }; 614DE241BC8F35B38FE98081 /* queue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = queue.h; path = ../../deps/libuv/src/queue.h; sourceTree = ""; }; + 69D91CCF2C997D4189CE5B0F /* essentials.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = essentials.h; path = "../../deps/wren-essentials/src/essentials.h"; sourceTree = ""; }; 6B50E6F2B8B3DD242ED2DD32 /* core.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = core.c; path = ../../deps/libuv/src/unix/core.c; sourceTree = ""; }; 6CB9D7B05100DFE2D4EE0DF0 /* spinlock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = spinlock.h; path = ../../deps/libuv/src/unix/spinlock.h; sourceTree = ""; }; 6D17D7650F017357062885A5 /* wren_compiler.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_compiler.c; path = ../../deps/wren/src/vm/wren_compiler.c; sourceTree = ""; }; 6FE208AD0558C7DF73F51EED /* linux.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = linux.h; path = ../../deps/libuv/include/uv/linux.h; sourceTree = ""; }; + 73E7C56EA5E110201FC04BAE /* binary_libs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = binary_libs.h; path = ../../src/cli/binary_libs.h; sourceTree = ""; }; 750F78B33B9D7025A99F96F3 /* wren_opcodes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren_opcodes.h; path = ../../deps/wren/src/vm/wren_opcodes.h; sourceTree = ""; }; 79CF94653D3B56177BDEFAA5 /* wren.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren.h; path = ../../deps/wren/include/wren.h; sourceTree = ""; }; 7D73C6BCAF6D116E294C4CFC /* async.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = async.c; path = ../../deps/libuv/src/unix/async.c; sourceTree = ""; }; + 7E4C5BF5F2A6A0E7708A2A35 /* binary_libs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = binary_libs.h; path = "../../deps/wren-essentials/src/binary_libs.h"; sourceTree = ""; }; + 7E99156821E49E9A3CB56BA8 /* wrenc */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; name = wrenc; path = wrenc; sourceTree = BUILT_PRODUCTS_DIR; }; 834C49AFC79AEF2109C227EF /* uv-common.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "uv-common.c"; path = "../../deps/libuv/src/uv-common.c"; sourceTree = ""; }; 898D2692AB58D3C4E80DFCD2 /* fs.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = fs.c; path = ../../deps/libuv/src/unix/fs.c; sourceTree = ""; }; 89FC45988D6D17CA0ED9BBD8 /* vm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = vm.h; path = ../../src/cli/vm.h; sourceTree = ""; }; @@ -120,6 +132,7 @@ 94C80D112D14F2C35B5BF351 /* threadpool.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = threadpool.h; path = ../../deps/libuv/include/uv/threadpool.h; sourceTree = ""; }; 950389A4BD3E4256A4D9CFE4 /* modules.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = modules.h; path = ../../src/cli/modules.h; sourceTree = ""; }; 99115178A59C03EA2080CFB8 /* wren_opt_random.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_opt_random.c; path = ../../deps/wren/src/optional/wren_opt_random.c; sourceTree = ""; }; + 9E3102CD30BECCBF9997710D /* wren_math.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren_math.h; path = ../../deps/wren/src/vm/wren_math.h; sourceTree = ""; }; A0902DE163508E53C0856C21 /* wren_primitive.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = wren_primitive.c; path = ../../deps/wren/src/vm/wren_primitive.c; sourceTree = ""; }; A12DD85936A4978BA540EE99 /* errno.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = errno.h; path = ../../deps/libuv/include/uv/errno.h; sourceTree = ""; }; A414DF8FD4F8D781E8110DCF /* random.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = random.c; path = ../../deps/libuv/src/random.c; sourceTree = ""; }; @@ -145,6 +158,8 @@ C6D53254143828868A572894 /* loop.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = loop.c; path = ../../deps/libuv/src/unix/loop.c; sourceTree = ""; }; C7206A03D7059635C3792043 /* android-ifaddrs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "android-ifaddrs.h"; path = "../../deps/libuv/include/uv/android-ifaddrs.h"; sourceTree = ""; }; C84918F85DBFD82ACC5C2F38 /* stream.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = stream.c; path = ../../deps/libuv/src/unix/stream.c; sourceTree = ""; }; + CB8208CCF3BCC17EDB584F0C /* _wren.inc */ = {isa = PBXFileReference; lastKnownFileType = text; name = _wren.inc; path = ../../src/cli/_wren.inc; sourceTree = ""; }; + CC50B6B592DEAE2700E0D4F5 /* time.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = time.c; path = "../../deps/wren-essentials/src/modules/time.c"; sourceTree = ""; }; CD8B5AEF6F74F6E1669C092F /* wren_compiler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren_compiler.h; path = ../../deps/wren/src/vm/wren_compiler.h; sourceTree = ""; }; D1349830E119C462CD8D4E70 /* darwin-proctitle.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "darwin-proctitle.c"; path = "../../deps/libuv/src/unix/darwin-proctitle.c"; sourceTree = ""; }; D69A4422EDACDF54DDC8DA62 /* path.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = path.c; path = ../../src/cli/path.c; sourceTree = ""; }; @@ -154,22 +169,27 @@ DC4FB627D611729910107467 /* fs-poll.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "fs-poll.c"; path = "../../deps/libuv/src/fs-poll.c"; sourceTree = ""; }; DC99886749C196D94B5486A7 /* wren_debug.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren_debug.h; path = ../../deps/wren/src/vm/wren_debug.h; sourceTree = ""; }; DD07C91EAB2B1CD032396F5E /* process.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = process.c; path = ../../deps/libuv/src/unix/process.c; sourceTree = ""; }; + DFDA5937A29AB9A9FFCF9777 /* mirror.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = mirror.h; path = "../../deps/wren-essentials/src/modules/mirror.h"; sourceTree = ""; }; + DFF7E00DA2B8407FFFED1E4D /* mirror.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = mirror.c; path = "../../deps/wren-essentials/src/modules/mirror.c"; sourceTree = ""; }; E00460BF512701B106EDAEFF /* wren_vm.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = wren_vm.h; path = ../../deps/wren/src/vm/wren_vm.h; sourceTree = ""; }; E02C363E247ADBB066A2147E /* repl.wren.inc */ = {isa = PBXFileReference; lastKnownFileType = text; name = repl.wren.inc; path = ../../src/module/repl.wren.inc; sourceTree = ""; }; E0AC076EA417C920E2BB6DAE /* tcp.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = tcp.c; path = ../../deps/libuv/src/unix/tcp.c; sourceTree = ""; }; E187FB9CDB49B80E1548B9DC /* os.wren.inc */ = {isa = PBXFileReference; lastKnownFileType = text; name = os.wren.inc; path = ../../src/module/os.wren.inc; sourceTree = ""; }; + E469429FAAF73A1118F960DF /* time.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = time.h; path = "../../deps/wren-essentials/src/modules/time.h"; sourceTree = ""; }; + E826CB603F8C3E52F19A59A0 /* runtime.wren.inc */ = {isa = PBXFileReference; lastKnownFileType = text; name = runtime.wren.inc; path = ../../src/module/runtime.wren.inc; sourceTree = ""; }; EBC4191202D6B444F2F2AF52 /* main.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = main.c; path = ../../src/cli/main.c; sourceTree = ""; }; ECA5597CD7917F6E1F7747BC /* repl.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = repl.c; path = ../../src/module/repl.c; sourceTree = ""; }; EF3F899384B648C5F3529FD3 /* posix.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = posix.h; path = ../../deps/libuv/include/uv/posix.h; sourceTree = ""; }; F460E68EF7D1B8C0793E5CCE /* vm.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = vm.c; path = ../../src/cli/vm.c; sourceTree = ""; }; F4B4EC1F4217E251B836E25F /* bsd.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = bsd.h; path = ../../deps/libuv/include/uv/bsd.h; sourceTree = ""; }; F78630E4DBCD39165FBA6724 /* internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = internal.h; path = ../../deps/libuv/src/unix/internal.h; sourceTree = ""; }; + F8423C6C1A0DE99E56C312AC /* resolver.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = resolver.c; path = ../../src/cli/resolver.c; sourceTree = ""; }; FF72290F112969018697574F /* uv-data-getter-setters.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = "uv-data-getter-setters.c"; path = "../../deps/libuv/src/uv-data-getter-setters.c"; sourceTree = ""; }; FF784D1C94EF0C4E038B635C /* signal.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = signal.c; path = ../../deps/libuv/src/unix/signal.c; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - 19EB00EC6C712BDE3EB58F2C /* Frameworks */ = { + A70896D8536B570A11F3CD18 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( @@ -178,6 +198,19 @@ }; /* End PBXFrameworksBuildPhase section */ +/* Begin PBXCopyFilesBuildPhase section */ + 6154FD44B16891F633E6C384 /* Embed Libraries */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + ); + name = "Embed Libraries"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + /* Begin PBXGroup section */ 042463BC5AB1CE2E332AE1FC /* include */ = { isa = PBXGroup; @@ -188,16 +221,6 @@ name = include; sourceTree = ""; }; - 1F48A9D313BF21056292C013 /* wren_cli */ = { - isa = PBXGroup; - children = ( - CE2ACC607A8D8C92391602A0 /* deps */, - 5775D4184366DFCA959E7A58 /* src */, - A6C936B49B3FADE6EA134CF4 /* Products */, - ); - name = wren_cli; - sourceTree = ""; - }; 208DD6B1E3F99863229D3CF1 /* optional */ = { isa = PBXGroup; children = ( @@ -209,6 +232,28 @@ name = optional; sourceTree = ""; }; + 2321F6DFB5AFC0D11E88651F /* modules */ = { + isa = PBXGroup; + children = ( + DFF7E00DA2B8407FFFED1E4D /* mirror.c */, + DFDA5937A29AB9A9FFCF9777 /* mirror.h */, + CC50B6B592DEAE2700E0D4F5 /* time.c */, + E469429FAAF73A1118F960DF /* time.h */, + ); + name = modules; + sourceTree = ""; + }; + 4493C7A6742596984F32D5E6 /* src */ = { + isa = PBXGroup; + children = ( + 7E4C5BF5F2A6A0E7708A2A35 /* binary_libs.h */, + 07AE2E25CA6E8E9727A36C65 /* essentials.c */, + 69D91CCF2C997D4189CE5B0F /* essentials.h */, + 2321F6DFB5AFC0D11E88651F /* modules */, + ); + name = src; + sourceTree = ""; + }; 5775D4184366DFCA959E7A58 /* src */ = { isa = PBXGroup; children = ( @@ -230,6 +275,7 @@ ECA5597CD7917F6E1F7747BC /* repl.c */, D8AD53A6C39979980B7F41E6 /* repl.h */, E02C363E247ADBB066A2147E /* repl.wren.inc */, + E826CB603F8C3E52F19A59A0 /* runtime.wren.inc */, AA867014A4482C86DE472E54 /* scheduler.c */, AAB8F95EA47AB5D0DE79B79E /* scheduler.h */, 6068A0F602523CE8F9794F36 /* scheduler.wren.inc */, @@ -242,11 +288,17 @@ 5E34860FAE481AC130C64C4F /* cli */ = { isa = PBXGroup; children = ( + CB8208CCF3BCC17EDB584F0C /* _wren.inc */, + 73E7C56EA5E110201FC04BAE /* binary_libs.h */, + 179C7F98BA8AA64A49B085D8 /* cli.c */, + 55546F42F84295F487687582 /* cli.h */, EBC4191202D6B444F2F2AF52 /* main.c */, A8FB8F7AD136482CB8D1D5BA /* modules.c */, 950389A4BD3E4256A4D9CFE4 /* modules.h */, D69A4422EDACDF54DDC8DA62 /* path.c */, C000D86CD713739EC72F6EAC /* path.h */, + F8423C6C1A0DE99E56C312AC /* resolver.c */, + 59FA2B367BC5D868B87B0176 /* resolver.h */, 0F964BCA26A8E6FC16C4E20A /* stat.h */, F460E68EF7D1B8C0793E5CCE /* vm.c */, 89FC45988D6D17CA0ED9BBD8 /* vm.h */, @@ -298,6 +350,16 @@ name = unix; sourceTree = ""; }; + 74E2513F0EFEC5B15B3A0F7F /* wrenc */ = { + isa = PBXGroup; + children = ( + CE2ACC607A8D8C92391602A0 /* deps */, + 5775D4184366DFCA959E7A58 /* src */, + A6C936B49B3FADE6EA134CF4 /* Products */, + ); + name = wrenc; + sourceTree = ""; + }; 76C1F5AB19B01C5DA8D5FBEB /* vm */ = { isa = PBXGroup; children = ( @@ -308,6 +370,7 @@ 14B8844BA7464E3D101EF28B /* wren_core.h */, B719EEBD2441FD2F25D4ECFD /* wren_debug.c */, DC99886749C196D94B5486A7 /* wren_debug.h */, + 9E3102CD30BECCBF9997710D /* wren_math.h */, 750F78B33B9D7025A99F96F3 /* wren_opcodes.h */, A0902DE163508E53C0856C21 /* wren_primitive.c */, 0424D20BC6E5327D241A104B /* wren_primitive.h */, @@ -321,6 +384,14 @@ name = vm; sourceTree = ""; }; + 8C329FCBFD5540BDB31BEE0B /* wren-essentials */ = { + isa = PBXGroup; + children = ( + 4493C7A6742596984F32D5E6 /* src */, + ); + name = "wren-essentials"; + sourceTree = ""; + }; 9E416B7EA1B23DB0231EE1BE /* src */ = { isa = PBXGroup; children = ( @@ -342,7 +413,7 @@ A6C936B49B3FADE6EA134CF4 /* Products */ = { isa = PBXGroup; children = ( - 120A697C40B0BD6E99F217BC /* wren_cli */, + 7E99156821E49E9A3CB56BA8 /* wrenc */, ); name = Products; sourceTree = ""; @@ -352,6 +423,7 @@ children = ( 63BE97C79264EBB9EBA64607 /* libuv */, A4F7631BB1B4128D269E815B /* wren */, + 8C329FCBFD5540BDB31BEE0B /* wren-essentials */, ); name = deps; sourceTree = ""; @@ -412,22 +484,23 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - 122D01E2B67F9F94C8B7E822 /* wren_cli */ = { + B85FE04E0AE60B40DD2A6E8E /* wrenc */ = { isa = PBXNativeTarget; - buildConfigurationList = 0826494B5AAC743D2CF0D78B /* Build configuration list for PBXNativeTarget "wren_cli" */; + buildConfigurationList = 9543DF3741A69F69002F1577 /* Build configuration list for PBXNativeTarget "wrenc" */; buildPhases = ( - 89D2818CDC58AC7EAE9D0FCC /* Resources */, - F37F9AE34605C5D5184A2923 /* Sources */, - 19EB00EC6C712BDE3EB58F2C /* Frameworks */, + 16F01778C352D7AA81DB4DB8 /* Resources */, + 809D30CF2CFFF101EB88670F /* Sources */, + A70896D8536B570A11F3CD18 /* Frameworks */, + 6154FD44B16891F633E6C384 /* Embed Libraries */, ); buildRules = ( ); dependencies = ( ); - name = wren_cli; + name = wrenc; productInstallPath = "$(HOME)/bin"; - productName = wren_cli; - productReference = 120A697C40B0BD6E99F217BC /* wren_cli */; + productName = wrenc; + productReference = 7E99156821E49E9A3CB56BA8 /* wrenc */; productType = "com.apple.product-type.tool"; }; /* End PBXNativeTarget section */ @@ -435,20 +508,20 @@ /* Begin PBXProject section */ 08FB7793FE84155DC02AAC07 /* Project object */ = { isa = PBXProject; - buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "wren_cli" */; + buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "wrenc" */; compatibilityVersion = "Xcode 3.2"; hasScannedForEncodings = 1; - mainGroup = 1F48A9D313BF21056292C013 /* wren_cli */; + mainGroup = 74E2513F0EFEC5B15B3A0F7F /* wrenc */; projectDirPath = ""; projectRoot = ""; targets = ( - 122D01E2B67F9F94C8B7E822 /* wren_cli */, + B85FE04E0AE60B40DD2A6E8E /* wrenc */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - 89D2818CDC58AC7EAE9D0FCC /* Resources */ = { + 16F01778C352D7AA81DB4DB8 /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( @@ -458,7 +531,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - F37F9AE34605C5D5184A2923 /* Sources */ = { + 809D30CF2CFFF101EB88670F /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( @@ -506,9 +579,14 @@ C1893749DC55A5FBE0263D89 /* wren_utils.c in Sources */, 3EE5E6A159B255535D82ECE1 /* wren_value.c in Sources */, 21B20AAD65C5DBDF599760ED /* wren_vm.c in Sources */, + D6EE9D7D74CF9E2F4C4DE3BD /* essentials.c in Sources */, + 851B636522FC6417FA7AA9A5 /* mirror.c in Sources */, + ACF91E8D20E1963F432F44CD /* time.c in Sources */, + 79850B90A916DA82842419D0 /* cli.c in Sources */, 11AB2EAA6CEC821C4046CCEA /* main.c in Sources */, E333D892545679840A1D26D2 /* modules.c in Sources */, E0B432BA3BF5862C0F4FD0FA /* path.c in Sources */, + 44968CA488E53216CB0C6AE4 /* resolver.c in Sources */, 88095BE6DE96C658B70FDA26 /* vm.c in Sources */, 3E35E55E600192909CB6BB9E /* io.c in Sources */, 1477D8F23643862472F8AF32 /* os.c in Sources */, @@ -524,31 +602,7 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 1377A691FE63CC83464994D1 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CONFIGURATION_BUILD_DIR = ../../bin; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_DYNAMIC_NO_PIC = NO; - INSTALL_PATH = /usr/local/bin; - PRODUCT_NAME = wren_cli_d; - }; - name = Debug; - }; - 16BEA9CB6D4C143D45C5280B /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CONFIGURATION_BUILD_DIR = ../../bin; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - GCC_DYNAMIC_NO_PIC = NO; - INSTALL_PATH = /usr/local/bin; - PRODUCT_NAME = wren_cli; - }; - name = Release; - }; - D5E9D7C2E2A687345790F602 /* Debug */ = { + 20C498AE70D82D60F3565EEE /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; @@ -572,6 +626,7 @@ USER_HEADER_SEARCH_PATHS = ( ../../src/cli, ../../src/module, + "../../deps/wren-essentials/src", ../../deps/wren/include, ../../deps/wren/src/vm, ../../deps/wren/src/optional, @@ -581,7 +636,7 @@ }; name = Debug; }; - EC26AA7C1ACCFE6E740E58BC /* Release */ = { + 58B55668FC00DF9A16D1ACA8 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { CONFIGURATION_BUILD_DIR = "$(SYMROOT)"; @@ -603,6 +658,7 @@ USER_HEADER_SEARCH_PATHS = ( ../../src/cli, ../../src/module, + "../../deps/wren-essentials/src", ../../deps/wren/include, ../../deps/wren/src/vm, ../../deps/wren/src/optional, @@ -612,31 +668,57 @@ }; name = Release; }; + B0397E7DC74C19AFB76814BD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CONFIGURATION_BUILD_DIR = ../../bin; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_DYNAMIC_NO_PIC = NO; + INSTALL_PATH = /usr/local/bin; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_NAME = wrenc_d; + }; + name = Debug; + }; + EB562CB7117C5C69788352F7 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CONFIGURATION_BUILD_DIR = ../../bin; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_DYNAMIC_NO_PIC = NO; + INSTALL_PATH = /usr/local/bin; + MACOSX_DEPLOYMENT_TARGET = 10.12; + PRODUCT_NAME = wrenc; + }; + name = Release; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 0826494B5AAC743D2CF0D78B /* Build configuration list for PBXNativeTarget "wren_cli" */ = { + 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "wrenc" */ = { isa = XCConfigurationList; buildConfigurations = ( - 16BEA9CB6D4C143D45C5280B /* Release */, - 16BEA9CB6D4C143D45C5280B /* Release */, - 16BEA9CB6D4C143D45C5280B /* Release */, - 1377A691FE63CC83464994D1 /* Debug */, - 1377A691FE63CC83464994D1 /* Debug */, - 1377A691FE63CC83464994D1 /* Debug */, + 58B55668FC00DF9A16D1ACA8 /* Release */, + 58B55668FC00DF9A16D1ACA8 /* Release */, + 58B55668FC00DF9A16D1ACA8 /* Release */, + 20C498AE70D82D60F3565EEE /* Debug */, + 20C498AE70D82D60F3565EEE /* Debug */, + 20C498AE70D82D60F3565EEE /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "wren_cli" */ = { + 9543DF3741A69F69002F1577 /* Build configuration list for PBXNativeTarget "wrenc" */ = { isa = XCConfigurationList; buildConfigurations = ( - EC26AA7C1ACCFE6E740E58BC /* Release */, - EC26AA7C1ACCFE6E740E58BC /* Release */, - EC26AA7C1ACCFE6E740E58BC /* Release */, - D5E9D7C2E2A687345790F602 /* Debug */, - D5E9D7C2E2A687345790F602 /* Debug */, - D5E9D7C2E2A687345790F602 /* Debug */, + EB562CB7117C5C69788352F7 /* Release */, + EB562CB7117C5C69788352F7 /* Release */, + EB562CB7117C5C69788352F7 /* Release */, + B0397E7DC74C19AFB76814BD /* Debug */, + B0397E7DC74C19AFB76814BD /* Debug */, + B0397E7DC74C19AFB76814BD /* Debug */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; diff --git a/src/cli/_wren.inc b/src/cli/_wren.inc new file mode 100644 index 00000000..2f141225 --- /dev/null +++ b/src/cli/_wren.inc @@ -0,0 +1,446 @@ +// Generated automatically from src/cli/*.wren. Do not edit. +static const char* resolverModuleSource = +"class Resolver {\n" +" // this is called at the end of this script when the CLI starts up\n" +" // and the Resolver VM is fired up\n" +" static boot() {\n" +" __modules = {}\n" +" }\n" +" static DEBUG { false }\n" +" static debug(s) { \n" +" if (this.DEBUG) System.print(s) \n" +" }\n" +" // load a dynamic library\n" +" static loadLibrary(name, file, root) {\n" +" var libPath\n" +" var moduleDirectories = findModulesDirectories(root)\n" +" if (moduleDirectories.isEmpty) {\n" +" Fiber.abort(\"dynamic libraries require a wren_modules folder\")\n" +" }\n" +" for (moduleDirectory in moduleDirectories ) {\n" +" libPath = Path.new(moduleDirectory).join(file).toString\n" +" if (!File.existsSync(libPath)) {\n" +" Fiber.abort(\"library not found -- %(libPath)\")\n" +" }\n" +" }\n" +" // System.print(libPath)\n" +" File.loadDynamicLibrary(name, libPath)\n" +" }\n" +" static isLibrary(module) { module.contains(\":\") }\n" +" // Applies the CLI's import resolution policy. The rules are:\n" +" //\n" +" // * If [module] starts with \"./\" or \"../\", it is a relative import, relative\n" +" // to [importer]. The resolved path is [name] concatenated onto the directory\n" +" // containing [importer] and then normalized.\n" +" //\n" +" // For example, importing \"./a/./b/../c\" from \"./d/e/f\" gives you \"./d/e/a/c\".\n" +" static resolveModule(importer, module, rootDir) {\n" +" if (isLibrary(module)) {\n" +" var pieces = module.split(\":\")\n" +" module = pieces[1]\n" +" var libraryName = pieces[0]\n" +" // TODO: linux, windows, etc.\n" +" var libraryFile = \"lib%(pieces[0]).dylib\"\n" +" loadLibrary(libraryName, libraryFile, rootDir)\n" +" return module\n" +" }\n" +" // System.print(\"importer: %(importer) module: %(module)\")\n" +" if (PathType.resolve(module) == PathType.SIMPLE) return module\n" +"\n" +" var path = Path.new(importer).dirname.join(module)\n" +" debug(\"resolved: %(path.toString)\")\n" +" return path.toString\n" +" }\n" +"\n" +" // walks the tree starting with current root and attemps to find \n" +" // `wren_modules` which will be used to resolve modules in addition\n" +" // to built-in modules\n" +" static findModulesDirectories(root) {\n" +" if (__modules[root]) return __modules[root]\n" +" var moduleCollections = []\n" +"\n" +" var path = Path.new(root + \"/\")\n" +" while(true) {\n" +" var modules = path.join(\"wren_modules/\").toString \n" +" debug(\" ? checking for existance: %(modules)\")\n" +" if (File.existsSync(modules)) {\n" +" debug(\"- found modules in %(modules)\")\n" +" // return modules\n" +" moduleCollections.add(modules)\n" +" }\n" +" if (path.isRoot) break\n" +" path = path.up()\n" +" }\n" +" __modules[root] = moduleCollections\n" +" return moduleCollections\n" +" }\n" +"\n" +" // searches for a module inside `wren_modules`\n" +" //\n" +" // If the module is a single bare name, treat it as a module with the same\n" +" // name inside the package. So \"foo\" means \"foo/foo\".\n" +" //\n" +" // returns the path to the .wren file that needs to be loaded\n" +" static findModule(root, module) {\n" +" var segment\n" +" if (module.contains(\"/\")) {\n" +" segment = \"%(module).wren\"\n" +" } else {\n" +" segment = \"%(module)/%(module).wren\"\n" +" }\n" +" var moduleDirectory = Path.new(root).join(segment).toString\n" +" debug(moduleDirectory)\n" +" if (File.existsSync(moduleDirectory)) return moduleDirectory\n" +" }\n" +"\n" +" // Attempts to find the source for [module] relative to the current root\n" +" // directory.\n" +" //\n" +" // Returns the filename to load if found, or `:%(module)` if not which\n" +" // is the pattern C uses to attempt a built-in module load, ie:\n" +" // returning `:os` will instruct C to use the internal `os` module.\n" +" static loadModule(module, rootDir) {\n" +" var type = PathType.resolve(module)\n" +" if (type == PathType.ABSOLUTE || type == PathType.RELATIVE) {\n" +" var path = \"%(module).wren\"\n" +" return path\n" +" }\n" +"\n" +" var root = File.realPathSync(rootDir)\n" +" debug(\"root: %(root)\")\n" +" for (wren_modules in findModulesDirectories(root)) {\n" +" var loc = findModule(wren_modules, module)\n" +" if (loc!=null) {\n" +" debug(\"found %(module) in %(wren_modules)\")\n" +" return loc\n" +" }\n" +" }\n" +" // must be built-in\n" +" return \":%(module)\"\n" +" }\n" +"}\n" +"\n" +"class File {\n" +" foreign static loadDynamicLibrary(name, path)\n" +" foreign static existsSync(s)\n" +" foreign static realPathSync(s)\n" +"}\n" +"\n" +"Resolver.boot()\n" +"\n" +"\n" +"\n\n" +"//module=resolver,cli\n" +"class PathType {\n" +" static SIMPLE { 1 }\n" +" static ABSOLUTE { 2 }\n" +" static RELATIVE { 3 }\n" +"\n" +" static unixAbsolute(path) { path.startsWith(\"/\") }\n" +" static windowsAbsolute(path) {\n" +" // TODO: is this not escaped properly by the stock Python code generator\n" +" return path.count >= 3 && path[1..2] == \":\\\\\"\n" +" }\n" +" static resolve(path) {\n" +" if (path.startsWith(\".\")) return PathType.RELATIVE\n" +" if (unixAbsolute(path)) return PathType.ABSOLUTE\n" +" if (windowsAbsolute(path)) return PathType.ABSOLUTE\n" +"\n" +" return PathType.SIMPLE\n" +" }\n" +"}\n" +"\n\n" +"//module=resolver,cli\n" +"class Path {\n" +" construct new(path) { \n" +" _path = path \n" +" _sep = appearsWindows() ? \"\\\\\" : \"/\"\n" +" }\n" +" appearsWindows() {\n" +" if (_path.contains(\"\\\\\")) return true\n" +" if (_path.count>=2 && _path[1] == \":\") return true\n" +" }\n" +" sep { _sep || \"/\" }\n" +" toString { _path }\n" +" up() { join(\"..\") }\n" +" join(path) { Path.new(_path + sep + path).normalize }\n" +" isRoot { \n" +" return _path == \"/\" || \n" +" // C:\n" +" (_path.count == 2 && _path[1] == \":\") ||\n" +" // F:\\\n" +" (_path.count == 3 && _path[1..2] == \":\\\\\") \n" +" }\n" +" dirname {\n" +" if (_path==\"/\") return this\n" +" if (_path.endsWith(sep)) return Path.new(_path[0..-2])\n" +" return up()\n" +" }\n" +" static split(path) {\n" +" var segments = []\n" +" var last = 0\n" +" var i = 0\n" +" while (i < path.count) {\n" +" var char = path[i]\n" +" if (char == \"/\" || char == \"\\\\\") {\n" +" if (last==i) {\n" +" segments.add(\"\")\n" +" } else {\n" +" segments.add(path[last...i])\n" +" }\n" +" last = i + 1\n" +" }\n" +" i = i + 1\n" +" }\n" +" if (last0 ? finalPaths[-1] : null\n" +" if (path == \"..\") {\n" +" if (last == \"/\") continue\n" +" if (last == \"..\" || last == null) {\n" +" finalPaths.add(\"%(path)\") \n" +" } else {\n" +" if (finalPaths.count > 0) finalPaths.removeAt(finalPaths.count - 1)\n" +" }\n" +" } else if (path == \"\" || path == \".\") {\n" +" continue\n" +" } else {\n" +" finalPaths.add(path)\n" +" }\n" +" }\n" +" if (finalPaths.count>1 && finalPaths[0] == \"/\") finalPaths[0] = \"\"\n" +" var path = finalPaths.join(sep)\n" +" if (path == \"\") path = \".\"\n" +" return Path.new(path)\n" +" }\n" +"}"; + +// Generated automatically from src/cli/*.wren. Do not edit. +static const char* cliModuleSource = +"//module=resolver,cli\n" +"class PathType {\n" +" static SIMPLE { 1 }\n" +" static ABSOLUTE { 2 }\n" +" static RELATIVE { 3 }\n" +"\n" +" static unixAbsolute(path) { path.startsWith(\"/\") }\n" +" static windowsAbsolute(path) {\n" +" // TODO: is this not escaped properly by the stock Python code generator\n" +" return path.count >= 3 && path[1..2] == \":\\\\\"\n" +" }\n" +" static resolve(path) {\n" +" if (path.startsWith(\".\")) return PathType.RELATIVE\n" +" if (unixAbsolute(path)) return PathType.ABSOLUTE\n" +" if (windowsAbsolute(path)) return PathType.ABSOLUTE\n" +"\n" +" return PathType.SIMPLE\n" +" }\n" +"}\n" +"\n\n" +"import \"repl\" for Repl, AnsiRepl, SimpleRepl\n" +"import \"os\" for Platform, Process\n" +"import \"io\" for Stdin, Stderr, File, Stdout, Stat\n" +"import \"mirror\" for Mirror\n" +"import \"meta\" for Meta\n" +"import \"runtime\" for Runtime\n" +"\n" +"class StackTrace {\n" +" construct new(fiber) {\n" +" _fiber = fiber\n" +" _trace = Mirror.reflect(fiber).stackTrace\n" +" }\n" +" print() {\n" +" Stderr.print(_fiber.error)\n" +" var out = _trace.frames.map { |f|\n" +" return \"at %( f.methodMirror.signature ) (%( f.methodMirror.moduleMirror.name ) line %( f.line ))\"\n" +" }.join(\"\\n\")\n" +" Stderr.print(out)\n" +" }\n" +"}\n" +"\n" +"class CLI {\n" +" static start() {\n" +" // TODO: pull out argument processing into it's own class\n" +" if (Process.allArguments.count >=2) {\n" +" var flag = Process.allArguments[1]\n" +" if (flag == \"--version\" || flag == \"-v\") {\n" +" showVersion()\n" +" return\n" +" }\n" +" if (flag == \"--help\" || flag == \"-h\") {\n" +" showHelp()\n" +" return\n" +" }\n" +" if (flag == \"-e\" && Process.allArguments.count >= 3) {\n" +" var code = Process.allArguments[2]\n" +" runCode(code,\"\")\n" +" return\n" +" }\n" +" }\n" +"\n" +" if (Process.allArguments.count == 1) {\n" +" repl()\n" +" } else {\n" +" runFile(Process.allArguments[1])\n" +" }\n" +" Stdout.flush()\n" +" }\n" +" static versionInfo { \"wrenc v%(Runtime.VERSION) (wren v%(Runtime.WREN_VERSION))\" }\n" +" static showVersion() {\n" +" System.print(versionInfo) \n" +" }\n" +" static showHelp() {\n" +" System.print(\"Usage: wrenc [file] [arguments...]\")\n" +" System.print(\"\")\n" +" System.print(\"Optional arguments:\")\n" +" System.print(\" - read script from stdin\")\n" +" System.print(\" -h, --help print wrenc command line options\")\n" +" System.print(\" -v, --version print wrenc and Wren version\")\n" +" System.print(\" -e '[code]' evaluate code\")\n" +" System.print()\n" +" System.print(\"Documentation can be found at https://github.com/joshgoebel/wren-console\")\n" +" \n" +" }\n" +" static dirForModule(file) {\n" +" return Path.new(file).dirname.toString\n" +" }\n" +" static missingScript(file) {\n" +" Stderr.print(\"wrenc: No such file -- %(file)\")\n" +" }\n" +" static runCode(code,moduleName) {\n" +" var fn = Meta.compile(code,moduleName)\n" +" if (fn != null) {\n" +" var fb = Fiber.new (fn)\n" +" fb.try()\n" +" if (fb.error) {\n" +" StackTrace.new(fb).print()\n" +" Process.exit(70)\n" +" }\n" +" } else {\n" +" Process.exit(65)\n" +" }\n" +" }\n" +" static runInput() {\n" +" var code = \"\"\n" +" while(!Stdin.isClosed) code = code + Stdin.read()\n" +" runCode(code,\"(script)\")\n" +" return\n" +" }\n" +" static runFile(file) {\n" +" var moduleName\n" +"\n" +" if (file == \"-\") return runInput()\n" +" if (!File.exists(file)) return missingScript(file)\n" +" \n" +" if (PathType.resolve(file) == PathType.ABSOLUTE) {\n" +" moduleName = file\n" +" } else {\n" +" moduleName = \"./\" + file\n" +" }\n" +" \n" +" var code = File.read(file)\n" +" setRootDirectory_(dirForModule(moduleName))\n" +" // System.print(moduleName)\n" +" runCode(code,moduleName)\n" +" }\n" +" static repl() {\n" +" System.print(\"\"\" -\"\\//\"\"\")\n" +" System.print(\" \\\\_/ \\n%(versionInfo) (based on wren-cli@9c6b6933722)\") \n" +" // \" fix broken VS Code highlighting (not understaning escapes)\n" +"\n" +" Repl.start()\n" +" }\n" +" foreign static setRootDirectory_(dir) \n" +"}\n" +"// CLI.start()\n" +"\n" +"\n\n" +"//module=resolver,cli\n" +"class Path {\n" +" construct new(path) { \n" +" _path = path \n" +" _sep = appearsWindows() ? \"\\\\\" : \"/\"\n" +" }\n" +" appearsWindows() {\n" +" if (_path.contains(\"\\\\\")) return true\n" +" if (_path.count>=2 && _path[1] == \":\") return true\n" +" }\n" +" sep { _sep || \"/\" }\n" +" toString { _path }\n" +" up() { join(\"..\") }\n" +" join(path) { Path.new(_path + sep + path).normalize }\n" +" isRoot { \n" +" return _path == \"/\" || \n" +" // C:\n" +" (_path.count == 2 && _path[1] == \":\") ||\n" +" // F:\\\n" +" (_path.count == 3 && _path[1..2] == \":\\\\\") \n" +" }\n" +" dirname {\n" +" if (_path==\"/\") return this\n" +" if (_path.endsWith(sep)) return Path.new(_path[0..-2])\n" +" return up()\n" +" }\n" +" static split(path) {\n" +" var segments = []\n" +" var last = 0\n" +" var i = 0\n" +" while (i < path.count) {\n" +" var char = path[i]\n" +" if (char == \"/\" || char == \"\\\\\") {\n" +" if (last==i) {\n" +" segments.add(\"\")\n" +" } else {\n" +" segments.add(path[last...i])\n" +" }\n" +" last = i + 1\n" +" }\n" +" i = i + 1\n" +" }\n" +" if (last0 ? finalPaths[-1] : null\n" +" if (path == \"..\") {\n" +" if (last == \"/\") continue\n" +" if (last == \"..\" || last == null) {\n" +" finalPaths.add(\"%(path)\") \n" +" } else {\n" +" if (finalPaths.count > 0) finalPaths.removeAt(finalPaths.count - 1)\n" +" }\n" +" } else if (path == \"\" || path == \".\") {\n" +" continue\n" +" } else {\n" +" finalPaths.add(path)\n" +" }\n" +" }\n" +" if (finalPaths.count>1 && finalPaths[0] == \"/\") finalPaths[0] = \"\"\n" +" var path = finalPaths.join(sep)\n" +" if (path == \"\") path = \".\"\n" +" return Path.new(path)\n" +" }\n" +"}"; + diff --git a/src/cli/binary_libs.h b/src/cli/binary_libs.h new file mode 100644 index 00000000..4738c752 --- /dev/null +++ b/src/cli/binary_libs.h @@ -0,0 +1,63 @@ +#ifndef binary_libs_h + +// The maximum number of foreign methods a single class defines. Ideally, we +// would use variable-length arrays for each class in the table below, but +// C++98 doesn't have any easy syntax for nested global static data, so we +// just use worst-case fixed-size arrays instead. +// +// If you add a new method to the longest class below, make sure to bump this. +// Note that it also includes an extra slot for the sentinel value indicating +// the end of the list. +#define MAX_METHODS_PER_CLASS 14 + +// The maximum number of foreign classes a single built-in module defines. +// +// If you add a new class to the largest module below, make sure to bump this. +// Note that it also includes an extra slot for the sentinel value indicating +// the end of the list. +#define MAX_CLASSES_PER_MODULE 10 + +#define MAX_MODULES_PER_LIBRARY 20 +#define MAX_LIBRARIES 20 +typedef struct +{ + bool isStatic; + const char* signature; + WrenForeignMethodFn method; +} MethodRegistry; + +// Describes one class in a built-in module. +typedef struct +{ + const char* name; + + MethodRegistry methods[MAX_METHODS_PER_CLASS]; +} ClassRegistry; + +// Describes one built-in module. +typedef struct +{ + // The name of the module. + const char* name; + + // Pointer to the string containing the source code of the module. We use a + // pointer here because the string variable itself is not a constant + // expression so can't be used in the initializer below. + const char **source; + + ClassRegistry classes[MAX_CLASSES_PER_MODULE]; +} ModuleRegistry; + +typedef struct +{ + const char* name; + + ModuleRegistry (*modules)[MAX_MODULES_PER_LIBRARY]; +} LibraryRegistry; + +void registerLibrary(const char* name, ModuleRegistry* registry); + +typedef ModuleRegistry* (*registryGiverFunc)(); + +#define binary_libs_h +#endif diff --git a/src/cli/cli.c b/src/cli/cli.c new file mode 100644 index 00000000..3a40b0e7 --- /dev/null +++ b/src/cli/cli.c @@ -0,0 +1,14 @@ +#include "vm.h" +#include "cli.h" + +void setRootDirectory(WrenVM* vm) { + const char* dir = wrenGetSlotString(vm,1); + // const char* boo = malloc(20); + // boo = "test"; + // fprintf(stderr, "setting root dir: %s %d\n", dir, strlen(dir)); + char* copydir = malloc(strlen(dir)+1); + strcpy(copydir, dir); + // fprintf(stderr, "setting root dir: %s %d\n", copydir, strlen(copydir)); + // memcpy(copydir, dir, strlen(dir)+20); + rootDirectory = copydir; +} \ No newline at end of file diff --git a/src/cli/cli.h b/src/cli/cli.h new file mode 100644 index 00000000..3b81969f --- /dev/null +++ b/src/cli/cli.h @@ -0,0 +1,8 @@ +#ifndef cli_h +#define cli_h + +void setRootDirectory(WrenVM* vm); + +#endif + + diff --git a/src/cli/cli.wren b/src/cli/cli.wren new file mode 100644 index 00000000..de80ed37 --- /dev/null +++ b/src/cli/cli.wren @@ -0,0 +1,117 @@ +import "repl" for Repl, AnsiRepl, SimpleRepl +import "os" for Platform, Process +import "io" for Stdin, Stderr, File, Stdout, Stat +import "mirror" for Mirror +import "meta" for Meta +import "runtime" for Runtime + +class StackTrace { + construct new(fiber) { + _fiber = fiber + _trace = Mirror.reflect(fiber).stackTrace + } + print() { + Stderr.print(_fiber.error) + var out = _trace.frames.map { |f| + return "at %( f.methodMirror.signature ) (%( f.methodMirror.moduleMirror.name ) line %( f.line ))" + }.join("\n") + Stderr.print(out) + } +} + +class CLI { + static start() { + // TODO: pull out argument processing into it's own class + if (Process.allArguments.count >=2) { + var flag = Process.allArguments[1] + if (flag == "--version" || flag == "-v") { + showVersion() + return + } + if (flag == "--help" || flag == "-h") { + showHelp() + return + } + if (flag == "-e" && Process.allArguments.count >= 3) { + var code = Process.allArguments[2] + runCode(code,"") + return + } + } + + if (Process.allArguments.count == 1) { + repl() + } else { + runFile(Process.allArguments[1]) + } + Stdout.flush() + } + static versionInfo { "wrenc v%(Runtime.VERSION) (wren v%(Runtime.WREN_VERSION))" } + static showVersion() { + System.print(versionInfo) + } + static showHelp() { + System.print("Usage: wrenc [file] [arguments...]") + System.print("") + System.print("Optional arguments:") + System.print(" - read script from stdin") + System.print(" -h, --help print wrenc command line options") + System.print(" -v, --version print wrenc and Wren version") + System.print(" -e '[code]' evaluate code") + System.print() + System.print("Documentation can be found at https://github.com/joshgoebel/wren-console") + + } + static dirForModule(file) { + return Path.new(file).dirname.toString + } + static missingScript(file) { + Stderr.print("wrenc: No such file -- %(file)") + } + static runCode(code,moduleName) { + var fn = Meta.compile(code,moduleName) + if (fn != null) { + var fb = Fiber.new (fn) + fb.try() + if (fb.error) { + StackTrace.new(fb).print() + Process.exit(70) + } + } else { + Process.exit(65) + } + } + static runInput() { + var code = "" + while(!Stdin.isClosed) code = code + Stdin.read() + runCode(code,"(script)") + return + } + static runFile(file) { + var moduleName + + if (file == "-") return runInput() + if (!File.exists(file)) return missingScript(file) + + if (PathType.resolve(file) == PathType.ABSOLUTE) { + moduleName = file + } else { + moduleName = "./" + file + } + + var code = File.read(file) + setRootDirectory_(dirForModule(moduleName)) + // System.print(moduleName) + runCode(code,moduleName) + } + static repl() { + System.print(""" -"\//""") + System.print(" \\_/ \n%(versionInfo) (based on wren-cli@9c6b6933722)") + // " fix broken VS Code highlighting (not understaning escapes) + + Repl.start() + } + foreign static setRootDirectory_(dir) +} +// CLI.start() + diff --git a/src/cli/cli_common.h b/src/cli/cli_common.h new file mode 100644 index 00000000..ceda8ed3 --- /dev/null +++ b/src/cli/cli_common.h @@ -0,0 +1,24 @@ +#ifndef cli_common_h +#define cli_common_h + +#include +#include + +char* cli_strdup(const char* s) { + size_t len = strlen(s) + 1; + char* m = (char*)malloc(len); + if (m == NULL) return NULL; + return memcpy(m, s, len); +} + +inline char* cli_strndup(const char* s, size_t n) { + char* m; + size_t len = strlen(s); + if (n < len) len = n; + m = (char*)malloc(len + 1); + if (m == NULL) return NULL; + m[len] = '\0'; + return memcpy(m, s, len); +} + +#endif \ No newline at end of file diff --git a/src/cli/main.c b/src/cli/main.c index a277537a..8cb72d79 100644 --- a/src/cli/main.c +++ b/src/cli/main.c @@ -7,37 +7,19 @@ int main(int argc, const char* argv[]) { - if (argc == 2 && strcmp(argv[1], "--help") == 0) - { - printf("Usage: wren [file] [arguments...]\n"); - printf("\n"); - printf("Optional arguments:\n"); - printf(" --help Show command line usage\n"); - printf(" --version Show version\n"); - return 0; - } - - if (argc == 2 && strcmp(argv[1], "--version") == 0) - { - printf("wren %s\n", WREN_VERSION_STRING); - return 0; - } - osSetArguments(argc, argv); WrenInterpretResult result; - if (argc == 1) - { - result = runRepl(); - } - else - { - result = runFile(argv[1]); + result = runCLI(); + + if (getExitCode() != 0) { + return getExitCode(); } - // Exit with an error code if the script failed. - if (result == WREN_RESULT_COMPILE_ERROR) return 65; // EX_DATAERR. + // Exit with an error code if the script failed. if (result == WREN_RESULT_RUNTIME_ERROR) return 70; // EX_SOFTWARE. + // TODO: 65 is impossible now and will need to be handled inside `cli.wren` + if (result == WREN_RESULT_COMPILE_ERROR) return 65; // EX_DATAERR. return getExitCode(); } diff --git a/src/cli/modules.c b/src/cli/modules.c index a3c7f6c1..ff6d6bee 100644 --- a/src/cli/modules.c +++ b/src/cli/modules.c @@ -1,5 +1,6 @@ #include #include +#include #include "modules.h" @@ -7,8 +8,12 @@ #include "os.wren.inc" #include "repl.wren.inc" #include "scheduler.wren.inc" +#include "runtime.wren.inc" #include "timer.wren.inc" +#include "_wren.inc" +#include "essentials.h" +extern void setRootDirectory(WrenVM* vm); extern void directoryList(WrenVM* vm); extern void directoryCreate(WrenVM* vm); extern void directoryDelete(WrenVM* vm); @@ -32,6 +37,8 @@ extern void processCwd(WrenVM* vm); extern void processPid(WrenVM* vm); extern void processPpid(WrenVM* vm); extern void processVersion(WrenVM* vm); +extern void processExit(WrenVM* vm); +extern void processExec(WrenVM* vm); extern void statPath(WrenVM* vm); extern void statBlockCount(WrenVM* vm); extern void statBlockSize(WrenVM* vm); @@ -51,55 +58,11 @@ extern void stdinIsTerminal(WrenVM* vm); extern void stdinReadStart(WrenVM* vm); extern void stdinReadStop(WrenVM* vm); extern void stdoutFlush(WrenVM* vm); +extern void stderrWrite(WrenVM* vm); extern void schedulerCaptureMethods(WrenVM* vm); extern void timerStartTimer(WrenVM* vm); -// The maximum number of foreign methods a single class defines. Ideally, we -// would use variable-length arrays for each class in the table below, but -// C++98 doesn't have any easy syntax for nested global static data, so we -// just use worst-case fixed-size arrays instead. -// -// If you add a new method to the longest class below, make sure to bump this. -// Note that it also includes an extra slot for the sentinel value indicating -// the end of the list. -#define MAX_METHODS_PER_CLASS 14 - -// The maximum number of foreign classes a single built-in module defines. -// -// If you add a new class to the largest module below, make sure to bump this. -// Note that it also includes an extra slot for the sentinel value indicating -// the end of the list. -#define MAX_CLASSES_PER_MODULE 6 - -// Describes one foreign method in a class. -typedef struct -{ - bool isStatic; - const char* signature; - WrenForeignMethodFn method; -} MethodRegistry; - -// Describes one class in a built-in module. -typedef struct -{ - const char* name; - - MethodRegistry methods[MAX_METHODS_PER_CLASS]; -} ClassRegistry; - -// Describes one built-in module. -typedef struct -{ - // The name of the module. - const char* name; - - // Pointer to the string containing the source code of the module. We use a - // pointer here because the string variable itself is not a constant - // expression so can't be used in the initializer below. - const char **source; - ClassRegistry classes[MAX_CLASSES_PER_MODULE]; -} ModuleRegistry; // To locate foreign classes and modules, we build a big directory for them in // static data. The nested collection initializer syntax gets pretty noisy, so @@ -120,8 +83,15 @@ typedef struct #define FINALIZE(fn) { true, "", (WrenForeignMethodFn)fn }, // The array of built-in modules. -static ModuleRegistry modules[] = +static ModuleRegistry coreCLImodules[] = { + MODULE(runtime) + END_MODULE + MODULE(cli) + CLASS(CLI) + STATIC_METHOD("setRootDirectory_(_)", setRootDirectory) + END_CLASS + END_MODULE MODULE(io) CLASS(Directory) STATIC_METHOD("create_(_,_)", directoryCreate) @@ -167,6 +137,9 @@ static ModuleRegistry modules[] = CLASS(Stdout) STATIC_METHOD("flush()", stdoutFlush) END_CLASS + CLASS(Stderr) + STATIC_METHOD("write(_)", stderrWrite) + END_CLASS END_MODULE MODULE(os) CLASS(Platform) @@ -180,6 +153,8 @@ static ModuleRegistry modules[] = STATIC_METHOD("pid", processPid) STATIC_METHOD("ppid", processPpid) STATIC_METHOD("version", processVersion) + STATIC_METHOD("exit_(_)", processExit) + STATIC_METHOD("exec_(_,_,_,_,_)", processExec) END_CLASS END_MODULE MODULE(repl) @@ -209,14 +184,35 @@ static ModuleRegistry modules[] = #undef STATIC_METHOD #undef FINALIZER +static LibraryRegistry libraries[MAX_LIBRARIES] = { + { "core", (ModuleRegistry (*)[MAX_MODULES_PER_LIBRARY])&coreCLImodules}, + { "essential", (ModuleRegistry (*)[MAX_MODULES_PER_LIBRARY])&essentialRegistry}, + { NULL, NULL } +}; + +void registerLibrary(const char* name, ModuleRegistry* registry) { + int j = 0; + while(libraries[j].name != NULL) { + j += 1; + } + if (j>MAX_LIBRARIES) { + fprintf(stderr, "Too many libraries, sorry."); + return; + } + libraries[j].name = name; + libraries[j].modules = (ModuleRegistry (*)[MAX_MODULES_PER_LIBRARY])registry; +} + // Looks for a built-in module with [name]. // // Returns the BuildInModule for it or NULL if not found. static ModuleRegistry* findModule(const char* name) { - for (int i = 0; modules[i].name != NULL; i++) - { - if (strcmp(name, modules[i].name) == 0) return &modules[i]; + for (int j = 0; libraries[j].name != NULL; j++) { + ModuleRegistry *modules = &(*libraries[j].modules)[0]; + for (int i = 0; modules[i].name != NULL; i++) { + if (strcmp(name, modules[i].name) == 0) return &modules[i]; + } } return NULL; diff --git a/src/cli/modules.h b/src/cli/modules.h index 3150f382..82b50e57 100644 --- a/src/cli/modules.h +++ b/src/cli/modules.h @@ -5,6 +5,7 @@ // modules bundled with the CLI. #include "wren.h" +#include "binary_libs.h" // Returns the source for built-in module [name]. WrenLoadModuleResult loadBuiltInModule(const char* module); @@ -21,4 +22,16 @@ WrenForeignMethodFn bindBuiltInForeignMethod( WrenForeignClassMethods bindBuiltInForeignClass( WrenVM* vm, const char* moduleName, const char* className); + // Looks up a foreign method in a built-in module. +// +// Returns `NULL` if [moduleName] is not a built-in module. +WrenForeignMethodFn bindBuiltInForeignMethod( + WrenVM* vm, const char* moduleName, const char* className, bool isStatic, + const char* signature); + +// Binds foreign classes declared in a built-in modules. +WrenForeignClassMethods bindBuiltInForeignClass( + WrenVM* vm, const char* moduleName, const char* className); + + #endif diff --git a/src/cli/path.wren b/src/cli/path.wren new file mode 100644 index 00000000..ad95558f --- /dev/null +++ b/src/cli/path.wren @@ -0,0 +1,76 @@ +//module=resolver,cli +class Path { + construct new(path) { + _path = path + _sep = appearsWindows() ? "\\" : "/" + } + appearsWindows() { + if (_path.contains("\\")) return true + if (_path.count>=2 && _path[1] == ":") return true + } + sep { _sep || "/" } + toString { _path } + up() { join("..") } + join(path) { Path.new(_path + sep + path).normalize } + isRoot { + return _path == "/" || + // C: + (_path.count == 2 && _path[1] == ":") || + // F:\ + (_path.count == 3 && _path[1..2] == ":\\") + } + dirname { + if (_path=="/") return this + if (_path.endsWith(sep)) return Path.new(_path[0..-2]) + return up() + } + static split(path) { + var segments = [] + var last = 0 + var i = 0 + while (i < path.count) { + var char = path[i] + if (char == "/" || char == "\\") { + if (last==i) { + segments.add("") + } else { + segments.add(path[last...i]) + } + last = i + 1 + } + i = i + 1 + } + if (last0 ? finalPaths[-1] : null + if (path == "..") { + if (last == "/") continue + if (last == ".." || last == null) { + finalPaths.add("%(path)") + } else { + if (finalPaths.count > 0) finalPaths.removeAt(finalPaths.count - 1) + } + } else if (path == "" || path == ".") { + continue + } else { + finalPaths.add(path) + } + } + if (finalPaths.count>1 && finalPaths[0] == "/") finalPaths[0] = "" + var path = finalPaths.join(sep) + if (path == "") path = "." + return Path.new(path) + } +} \ No newline at end of file diff --git a/src/cli/path_type.wren b/src/cli/path_type.wren new file mode 100644 index 00000000..17a0180b --- /dev/null +++ b/src/cli/path_type.wren @@ -0,0 +1,19 @@ +//module=resolver,cli +class PathType { + static SIMPLE { 1 } + static ABSOLUTE { 2 } + static RELATIVE { 3 } + + static unixAbsolute(path) { path.startsWith("/") } + static windowsAbsolute(path) { + // TODO: is this not escaped properly by the stock Python code generator + return path.count >= 3 && path[1..2] == ":\\" + } + static resolve(path) { + if (path.startsWith(".")) return PathType.RELATIVE + if (unixAbsolute(path)) return PathType.ABSOLUTE + if (windowsAbsolute(path)) return PathType.ABSOLUTE + + return PathType.SIMPLE + } +} diff --git a/src/cli/resolver.c b/src/cli/resolver.c new file mode 100644 index 00000000..3e95cf50 --- /dev/null +++ b/src/cli/resolver.c @@ -0,0 +1,145 @@ +#include "resolver.h" +#include "uv.h" +#include "wren.h" +#include "vm.h" +#include "_wren.inc" +#include "modules.h" +#include + +WrenVM *resolver; + +void fileLoadDynamicLibrary(WrenVM* vm) { + const char* name = wrenGetSlotString(vm,1); + const char* path = wrenGetSlotString(vm,2); + // fprintf(stderr,"loading dylib %s at %s\n",name,path); + + uv_lib_t *lib = (uv_lib_t*) malloc(sizeof(uv_lib_t)); + // fprintf(stderr, "importing TIME OH BOY"); + int r = uv_dlopen(path, lib); + if (r !=0) { + fprintf(stderr, "error with lib %s dlopen of %s", name, path); + } + registryGiverFunc registryGiver; + if (uv_dlsym(lib, "returnRegistry", (void **) ®istryGiver)) { + fprintf(stderr, "dlsym error: %s\n", uv_dlerror(lib)); + } + ModuleRegistry* m = registryGiver(); + registerLibrary(name, m); +} + +void fileExistsSync(WrenVM* vm) { + uv_fs_t req; + int r = uv_fs_stat(NULL,&req,wrenGetSlotString(vm,1),NULL); + // fprintf(stderr,"fileExists, %s %d\n", wrenGetSlotString(vm,1), r); + wrenEnsureSlots(vm, 1); + // non zero is error and means we don't have a file + wrenSetSlotBool(vm, 0, r == 0); +} + +void fileRealPathSync(WrenVM* vm) +{ + const char* path = wrenGetSlotString(vm, 1); + + uv_fs_t request; + uv_fs_realpath(getLoop(), &request, path, NULL); + + // fprintf("%s", request.ptr); + // Path* result = pathNew((char*)request.ptr); + wrenSetSlotString(vm, 0, (const char*)request.ptr); + + uv_fs_req_cleanup(&request); + // return result; +} + +WrenHandle* resolveModuleFn; +WrenHandle* loadModuleFn; +WrenHandle* resolverClass; + +void freeResolver() { + WrenVM* vm = resolver; + if (resolverClass != NULL) { + wrenReleaseHandle(vm, resolverClass); + wrenReleaseHandle(vm, loadModuleFn); + wrenReleaseHandle(vm, resolveModuleFn); + resolverClass = NULL; + loadModuleFn = NULL; + resolveModuleFn = NULL; + } + wrenFreeVM(resolver); +} + +void saveResolverHandles(WrenVM* vm) { + wrenEnsureSlots(vm,1); + wrenGetVariable(resolver, "", "Resolver", 0); + resolverClass = wrenGetSlotHandle(vm, 0); + resolveModuleFn = wrenMakeCallHandle(resolver,"resolveModule(_,_,_)"); + loadModuleFn = wrenMakeCallHandle(resolver,"loadModule(_,_)"); +} + +static WrenForeignMethodFn bindResolverForeignMethod(WrenVM* vm, const char* module, + const char* className, bool isStatic, const char* signature) +{ + if (strcmp(signature,"existsSync(_)")==0) { + return fileExistsSync; + } + if (strcmp(signature,"realPathSync(_)")==0) { + return fileRealPathSync; + } + if (strcmp(signature,"loadDynamicLibrary(_,_)")==0) { + return fileLoadDynamicLibrary; + } + return NULL; +} + +static void write(WrenVM* vm, const char* text) +{ + printf("%s", text); +} + +char* wrenLoadModule(const char* module) { + WrenVM *vm = resolver; + wrenEnsureSlots(vm,3); + wrenSetSlotHandle(vm,0, resolverClass); + wrenSetSlotString(vm,1, module); + wrenSetSlotString(vm,2, rootDirectory); + wrenCall(resolver,loadModuleFn); + const char *tmp = wrenGetSlotString(vm,0); + char *result = malloc(strlen(tmp)+1); + strcpy(result,tmp); + return result; +} + +char* wrenResolveModule(const char* importer, const char* module) { + WrenVM *vm = resolver; + wrenEnsureSlots(vm,4); + wrenSetSlotHandle(vm,0, resolverClass); + wrenSetSlotString(vm,1, importer); + wrenSetSlotString(vm,2, module); + wrenSetSlotString(vm,3, rootDirectory); + wrenCall(resolver,resolveModuleFn); + const char *tmp = wrenGetSlotString(vm,0); + char *result = malloc(strlen(tmp)+1); + strcpy(result,tmp); + return result; +} + +void initResolverVM() +{ + WrenConfiguration config; + wrenInitConfiguration(&config); + + config.bindForeignMethodFn = bindResolverForeignMethod; + // config.bindForeignClassFn = bindForeignClass; + // config.resolveModuleFn = resolveModule; + // config.loadModuleFn = readModule; + config.writeFn = write; + config.errorFn = reportError; + + // Since we're running in a standalone process, be generous with memory. + config.initialHeapSize = 1024 * 1024 * 100; + resolver = wrenNewVM(&config); + + // Initialize the event loop. + WrenInterpretResult result = wrenInterpret(resolver, "", resolverModuleSource); + saveResolverHandles(resolver); +} diff --git a/src/cli/resolver.h b/src/cli/resolver.h new file mode 100644 index 00000000..878ea421 --- /dev/null +++ b/src/cli/resolver.h @@ -0,0 +1,12 @@ +#ifndef resolver_h +#define resolver_h + +#include "wren.h" + +extern WrenVM *resolver; +void initResolverVM(); +char* wrenResolveModule(const char* importer, const char* module); +char* wrenLoadModule(const char* module); +void freeResolver(); + +#endif \ No newline at end of file diff --git a/src/cli/resolver.wren b/src/cli/resolver.wren new file mode 100644 index 00000000..b2275e49 --- /dev/null +++ b/src/cli/resolver.wren @@ -0,0 +1,129 @@ +class Resolver { + // this is called at the end of this script when the CLI starts up + // and the Resolver VM is fired up + static boot() { + __modules = {} + } + static DEBUG { false } + static debug(s) { + if (this.DEBUG) System.print(s) + } + // load a dynamic library + static loadLibrary(name, file, root) { + var libPath + var moduleDirectories = findModulesDirectories(root) + if (moduleDirectories.isEmpty) { + Fiber.abort("dynamic libraries require a wren_modules folder") + } + for (moduleDirectory in moduleDirectories ) { + libPath = Path.new(moduleDirectory).join(file).toString + if (!File.existsSync(libPath)) { + Fiber.abort("library not found -- %(libPath)") + } + } + // System.print(libPath) + File.loadDynamicLibrary(name, libPath) + } + static isLibrary(module) { module.contains(":") } + // Applies the CLI's import resolution policy. The rules are: + // + // * If [module] starts with "./" or "../", it is a relative import, relative + // to [importer]. The resolved path is [name] concatenated onto the directory + // containing [importer] and then normalized. + // + // For example, importing "./a/./b/../c" from "./d/e/f" gives you "./d/e/a/c". + static resolveModule(importer, module, rootDir) { + if (isLibrary(module)) { + var pieces = module.split(":") + module = pieces[1] + var libraryName = pieces[0] + // TODO: linux, windows, etc. + var libraryFile = "lib%(pieces[0]).dylib" + loadLibrary(libraryName, libraryFile, rootDir) + return module + } + // System.print("importer: %(importer) module: %(module)") + if (PathType.resolve(module) == PathType.SIMPLE) return module + + var path = Path.new(importer).dirname.join(module) + debug("resolved: %(path.toString)") + return path.toString + } + + // walks the tree starting with current root and attemps to find + // `wren_modules` which will be used to resolve modules in addition + // to built-in modules + static findModulesDirectories(root) { + if (__modules[root]) return __modules[root] + var moduleCollections = [] + + var path = Path.new(root + "/") + while(true) { + var modules = path.join("wren_modules/").toString + debug(" ? checking for existance: %(modules)") + if (File.existsSync(modules)) { + debug("- found modules in %(modules)") + // return modules + moduleCollections.add(modules) + } + if (path.isRoot) break + path = path.up() + } + __modules[root] = moduleCollections + return moduleCollections + } + + // searches for a module inside `wren_modules` + // + // If the module is a single bare name, treat it as a module with the same + // name inside the package. So "foo" means "foo/foo". + // + // returns the path to the .wren file that needs to be loaded + static findModule(root, module) { + var segment + if (module.contains("/")) { + segment = "%(module).wren" + } else { + segment = "%(module)/%(module).wren" + } + var moduleDirectory = Path.new(root).join(segment).toString + debug(moduleDirectory) + if (File.existsSync(moduleDirectory)) return moduleDirectory + } + + // Attempts to find the source for [module] relative to the current root + // directory. + // + // Returns the filename to load if found, or `:%(module)` if not which + // is the pattern C uses to attempt a built-in module load, ie: + // returning `:os` will instruct C to use the internal `os` module. + static loadModule(module, rootDir) { + var type = PathType.resolve(module) + if (type == PathType.ABSOLUTE || type == PathType.RELATIVE) { + var path = "%(module).wren" + return path + } + + var root = File.realPathSync(rootDir) + debug("root: %(root)") + for (wren_modules in findModulesDirectories(root)) { + var loc = findModule(wren_modules, module) + if (loc!=null) { + debug("found %(module) in %(wren_modules)") + return loc + } + } + // must be built-in + return ":%(module)" + } +} + +class File { + foreign static loadDynamicLibrary(name, path) + foreign static existsSync(s) + foreign static realPathSync(s) +} + +Resolver.boot() + + diff --git a/src/cli/stat.h b/src/cli/stat.h index b333bce5..0f27a818 100644 --- a/src/cli/stat.h +++ b/src/cli/stat.h @@ -17,6 +17,10 @@ #define S_IWUSR _S_IWRITE #endif + #ifndef S_IRWXU + #define S_IRWXU _S_IREAD | _S_IWRITE + #endif + #ifndef S_ISREG #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif diff --git a/src/cli/vm.c b/src/cli/vm.c index 48d2b1ee..b41e1953 100644 --- a/src/cli/vm.c +++ b/src/cli/vm.c @@ -3,10 +3,10 @@ #include "io.h" #include "modules.h" -#include "path.h" #include "scheduler.h" #include "stat.h" #include "vm.h" +#include "resolver.h" // The single VM instance that the CLI uses. static WrenVM* vm; @@ -17,10 +17,9 @@ static WrenForeignMethodFn afterLoadFn = NULL; static uv_loop_t* loop; -// TODO: This isn't currently used, but probably will be when package imports -// are supported. If not then, then delete this. -static char* rootDirectory = NULL; -static Path* wrenModulesDirectory = NULL; +// the directory of the original script - used as an offset when searching +// for wren_modules, etc. +char* rootDirectory = NULL; // The exit code to use unless some other error overrides it. int defaultExitCode = 0; @@ -63,75 +62,6 @@ static char* readFile(const char* path) return buffer; } -static bool isDirectory(Path* path) -{ - uv_fs_t request; - uv_fs_stat(loop, &request, path->chars, NULL); - // TODO: Check request.result value? - - bool result = request.result == 0 && - (request.statbuf.st_mode & S_IFDIR); - - uv_fs_req_cleanup(&request); - return result; -} - -static Path* realPath(Path* path) -{ - uv_fs_t request; - uv_fs_realpath(loop, &request, path->chars, NULL); - - Path* result = pathNew((char*)request.ptr); - - uv_fs_req_cleanup(&request); - return result; -} - -// Starting at [rootDirectory], walks up containing directories looking for a -// nearby "wren_modules" directory. If found, stores it in -// [wrenModulesDirectory]. -// -// If [wrenModulesDirectory] has already been found, does nothing. -static void findModulesDirectory() -{ - if (wrenModulesDirectory != NULL) return; - - Path* searchDirectory = pathNew(rootDirectory); - Path* lastPath = realPath(searchDirectory); - - // Keep walking up directories as long as we find them. - for (;;) - { - Path* modulesDirectory = pathNew(searchDirectory->chars); - pathJoin(modulesDirectory, "wren_modules"); - - if (isDirectory(modulesDirectory)) - { - pathNormalize(modulesDirectory); - wrenModulesDirectory = modulesDirectory; - break; - } - - pathFree(modulesDirectory); - - // Walk up directories until we hit the root. We can tell that because - // adding ".." yields the same real path. - pathJoin(searchDirectory, ".."); - Path* thisPath = realPath(searchDirectory); - if (strcmp(lastPath->chars, thisPath->chars) == 0) - { - pathFree(thisPath); - break; - } - - pathFree(lastPath); - lastPath = thisPath; - } - - pathFree(lastPath); - pathFree(searchDirectory); -} - // Applies the CLI's import resolution policy. The rules are: // // * If [module] starts with "./" or "../", it is a relative import, relative @@ -142,21 +72,7 @@ static void findModulesDirectory() static const char* resolveModule(WrenVM* vm, const char* importer, const char* module) { - // Logical import strings are used as-is and need no resolution. - if (pathType(module) == PATH_TYPE_SIMPLE) return module; - - // Get the directory containing the importing module. - Path* path = pathNew(importer); - pathDirName(path); - - // Add the relative import path. - pathJoin(path, module); - - pathNormalize(path); - char* resolved = pathToString(path); - - pathFree(path); - return resolved; + return wrenResolveModule(importer, module); } // Attempts to read the source for [module] relative to the current root @@ -167,44 +83,19 @@ static const char* resolveModule(WrenVM* vm, const char* importer, static WrenLoadModuleResult loadModule(WrenVM* vm, const char* module) { WrenLoadModuleResult result = {0}; - Path* filePath; - if (pathType(module) == PATH_TYPE_SIMPLE) - { - // If there is no "wren_modules" directory, then the only logical imports - // we can handle are built-in ones. Let the VM try to handle it. - findModulesDirectory(); - if (wrenModulesDirectory == NULL) return loadBuiltInModule(module); - - // TODO: Should we explicitly check for the existence of the module's base - // directory inside "wren_modules" here? - - // Look up the module in "wren_modules". - filePath = pathNew(wrenModulesDirectory->chars); - pathJoin(filePath, module); - - // If the module is a single bare name, treat it as a module with the same - // name inside the package. So "foo" means "foo/foo". - if (strchr(module, '/') == NULL) pathJoin(filePath, module); + char *moduleLoc = wrenLoadModule(module); + + if (moduleLoc[0] == ':') { + // fprintf(stderr, "%s\n", moduleLoc+1); + result = loadBuiltInModule(moduleLoc+1); + } else { + result.onComplete = loadModuleComplete; + // fprintf(stderr, "found: %s\n", moduleLoc); + result.source = readFile(moduleLoc); + // if (result.source != NULL) return result; } - else - { - // The module path is already a file path. - filePath = pathNew(module); - } - - // Add a ".wren" file extension. - pathAppendString(filePath, ".wren"); - - result.onComplete = loadModuleComplete; - result.source = readFile(filePath->chars); - pathFree(filePath); - - // If we didn't find it, it may be a module built into the CLI or VM, so keep - // going. - if (result.source != NULL) return result; - - // Otherwise, see if it's a built-in module. - return loadBuiltInModule(module); + free(moduleLoc); + return result; } // Binds foreign methods declared in either built in modules, or the injected @@ -246,7 +137,7 @@ static void write(WrenVM* vm, const char* text) printf("%s", text); } -static void reportError(WrenVM* vm, WrenErrorType type, +void reportError(WrenVM* vm, WrenErrorType type, const char* module, int line, const char* message) { switch (type) @@ -286,87 +177,56 @@ static void initVM() uv_loop_init(loop); } +void on_uvClose(uv_handle_t* handle) +{ + if (handle != NULL) + { + free(handle); + } +} + +void on_uvWalkForShutdown(uv_handle_t* handle, void* arg) +{ + if (!uv_is_closing(handle)) + uv_close(handle, on_uvClose); +} + +static void uvShutdown() { + uv_loop_t *loop = getLoop(); + int result = uv_loop_close(loop); + if (result != UV_EBUSY) return; + + // walk open handles and shut them down + uv_walk(loop, on_uvWalkForShutdown, NULL); + uv_run(loop, UV_RUN_ONCE); + result = uv_loop_close(loop); + if (result != 0) { + fprintf(stderr, "could not close UV event loop completely"); + } +} + static void freeVM() { ioShutdown(); schedulerShutdown(); - - uv_loop_close(loop); + uvShutdown(); free(loop); wrenFreeVM(vm); uv_tty_reset_mode(); - - if (wrenModulesDirectory != NULL) pathFree(wrenModulesDirectory); } -WrenInterpretResult runFile(const char* path) +WrenInterpretResult runCLI() { - char* source = readFile(path); - if (source == NULL) - { - fprintf(stderr, "Could not find file \"%s\".\n", path); - exit(66); - } - - // If it looks like a relative path, make it explicitly relative so that we - // can distinguish it from logical paths. - // TODO: It might be nice to be able to run scripts from within a surrounding - // "wren_modules" directory by passing in a simple path like "foo/bar". In - // that case, here, we could check to see whether the give path exists inside - // "wren_modules" or as a relative path and choose to add "./" or not based - // on that. - Path* module = pathNew(path); - if (pathType(module->chars) == PATH_TYPE_SIMPLE) - { - Path* relative = pathNew("."); - pathJoin(relative, path); - - pathFree(module); - module = relative; - } - - pathRemoveExtension(module); + initResolverVM(); - // Use the directory where the file is as the root to resolve imports - // relative to. - Path* directory = pathNew(module->chars); - - pathDirName(directory); - rootDirectory = pathToString(directory); - pathFree(directory); - - initVM(); - - WrenInterpretResult result = wrenInterpret(vm, module->chars, source); - - if (afterLoadFn != NULL) afterLoadFn(vm); - - if (result == WREN_RESULT_SUCCESS) - { - uv_run(loop, UV_RUN_DEFAULT); - } - - freeVM(); - - free(source); - free(rootDirectory); - pathFree(module); - - return result; -} - -WrenInterpretResult runRepl() -{ // This cast is safe since we don't try to free the string later. rootDirectory = (char*)"."; initVM(); - printf("\\\\/\"-\n"); - printf(" \\_/ wren v%s\n", WREN_VERSION_STRING); - - WrenInterpretResult result = wrenInterpret(vm, "", "import \"repl\"\n"); + WrenInterpretResult result = wrenInterpret(vm, "", "import \"cli\" for CLI\n"); + if (result == WREN_RESULT_SUCCESS) { result = wrenInterpret(vm, "", "CLI.start()"); } if (result == WREN_RESULT_SUCCESS) { @@ -374,6 +234,7 @@ WrenInterpretResult runRepl() } freeVM(); + freeResolver(); return result; } diff --git a/src/cli/vm.h b/src/cli/vm.h index cb5f8d15..b674edd4 100644 --- a/src/cli/vm.h +++ b/src/cli/vm.h @@ -10,12 +10,21 @@ WrenInterpretResult runFile(const char* path); // Runs the Wren interactive REPL. WrenInterpretResult runRepl(); +// run the wren CLI +WrenInterpretResult runCLI(); + +extern char* rootDirectory; + // Gets the currently running VM. WrenVM* getVM(); // Gets the event loop the VM is using. uv_loop_t* getLoop(); +// error reporting +void reportError(WrenVM* vm, WrenErrorType type, + const char* module, int line, const char* message); + // Get the exit code the CLI should exit with when done. int getExitCode(); diff --git a/src/module/io.c b/src/module/io.c index ad025a14..e75a1ca2 100644 --- a/src/module/io.c +++ b/src/module/io.c @@ -41,7 +41,9 @@ static void shutdownStdin() { uv_tty_reset_mode(); uv_close((uv_handle_t*)stdinStream, NULL); - free(stdinStream); + // This is premature (needs to be done in the after close callback), so + // we'll let uvShutdown handle this instead. + // free(stdinStream); stdinStream = NULL; } @@ -156,7 +158,9 @@ void directoryCreate(WrenVM* vm) { const char* path = wrenGetSlotString(vm, 1); uv_fs_t* request = createRequest(wrenGetSlotHandle(vm, 2)); - uv_fs_mkdir(getLoop(), request, path, 0, fileDirectoryCallback); + // TODO: Allow controlling access. + // TODO: correct default permissions here? should it include group/world? + uv_fs_mkdir(getLoop(), request, path, S_IRWXU, fileDirectoryCallback); } void directoryDelete(WrenVM* vm) @@ -548,12 +552,19 @@ void stdinIsRawSet(WrenVM* vm) void stdinIsTerminal(WrenVM* vm) { + wrenEnsureSlots(vm,1); initStdin(); wrenSetSlotBool(vm, 0, uv_guess_handle(stdinDescriptor) == UV_TTY); } +void stderrWrite(WrenVM* vm) { + const char* s = wrenGetSlotString(vm,1); + fprintf(stderr, "%s",s); +} + void stdoutFlush(WrenVM* vm) { + wrenEnsureSlots(vm,1); fflush(stdout); wrenSetSlotNull(vm, 0); } diff --git a/src/module/io.wren b/src/module/io.wren index afe161f4..c8374a52 100644 --- a/src/module/io.wren +++ b/src/module/io.wren @@ -220,12 +220,14 @@ class Stdin { foreign static isRaw foreign static isRaw=(value) foreign static isTerminal + static isClosed { __isClosed } static readByte() { return read_ { // Peel off the first byte. + // TODO: this doing a huge amount of effort, but likely fast enough var byte = __buffered.bytes[0] - __buffered = __buffered[1..-1] + __buffered = __buffered.bytes.skip(1).map { |x| String.fromByte(x) }.join() return byte } } @@ -243,6 +245,14 @@ class Stdin { } } + static read() { + return read_ { + var data = __buffered + __buffered = "" + return data + } + } + static read_(handleData) { // See if we're already buffered enough to immediately produce a result. if (__buffered != null && !__buffered.isEmpty) { @@ -300,6 +310,11 @@ class Stdin { foreign static readStop_() } +class Stderr { + static print(str) { write("%(str)\n") } + foreign static write(str) +} + class Stdout { foreign static flush() } diff --git a/src/module/io.wren.inc b/src/module/io.wren.inc index 22b27355..1fe271a9 100644 --- a/src/module/io.wren.inc +++ b/src/module/io.wren.inc @@ -224,12 +224,14 @@ static const char* ioModuleSource = " foreign static isRaw\n" " foreign static isRaw=(value)\n" " foreign static isTerminal\n" +" static isClosed { __isClosed }\n" "\n" " static readByte() {\n" " return read_ {\n" " // Peel off the first byte.\n" +" // TODO: this doing a huge amount of effort, but likely fast enough\n" " var byte = __buffered.bytes[0]\n" -" __buffered = __buffered[1..-1]\n" +" __buffered = __buffered.bytes.skip(1).map { |x| String.fromByte(x) }.join() \n" " return byte\n" " }\n" " }\n" @@ -237,7 +239,7 @@ static const char* ioModuleSource = " static readLine() {\n" " return read_ {\n" " // TODO: Handle Windows line separators.\n" -" var lineSeparator = __buffered.indexOf(\"\n\")\n" +" var lineSeparator = __buffered.indexOf(\"\\n\")\n" " if (lineSeparator == -1) return null\n" "\n" " // Split the line at the separator.\n" @@ -247,6 +249,14 @@ static const char* ioModuleSource = " }\n" " }\n" "\n" +" static read() {\n" +" return read_ {\n" +" var data = __buffered\n" +" __buffered = \"\"\n" +" return data\n" +" }\n" +" }\n" +"\n" " static read_(handleData) {\n" " // See if we're already buffered enough to immediately produce a result.\n" " if (__buffered != null && !__buffered.isEmpty) {\n" @@ -304,6 +314,11 @@ static const char* ioModuleSource = " foreign static readStop_()\n" "}\n" "\n" +"class Stderr {\n" +" static print(str) { write(\"%(str)\\n\") }\n" +" foreign static write(str)\n" +"}\n" +"\n" "class Stdout {\n" " foreign static flush()\n" "}\n"; diff --git a/src/module/os.c b/src/module/os.c index c13cd33f..a1336ef5 100644 --- a/src/module/os.c +++ b/src/module/os.c @@ -1,6 +1,11 @@ #include "os.h" #include "uv.h" #include "wren.h" +#include "vm.h" +#include "scheduler.h" +#include "cli_common.h" + +#include #if __APPLE__ #include "TargetConditionals.h" @@ -98,6 +103,12 @@ void processAllArguments(WrenVM* vm) } } +void processExit(WrenVM* vm) { + int code = (int)wrenGetSlotDouble(vm, 1); + setExitCode(code); + uv_stop(getLoop()); +} + void processCwd(WrenVM* vm) { wrenEnsureSlots(vm, 1); @@ -128,3 +139,136 @@ void processVersion(WrenVM* vm) { wrenEnsureSlots(vm, 1); wrenSetSlotString(vm, 0, WREN_VERSION_STRING); } + +// Called when the UV handle for a process is done, so we can free it +static void processOnClose(uv_handle_t* req) +{ + free((void*)req); +} + +// Called when a process is finished running +static void processOnExit(uv_process_t* req, int64_t exit_status, int term_signal) +{ + ProcessData* data = (ProcessData*)req->data; + WrenHandle* fiber = data->fiber; + + uv_close((uv_handle_t*)req, processOnClose); + + int index = 0; + char* arg = data->options.args[index]; + while (arg != NULL) + { + free(arg); + index += 1; + arg = data->options.args[index]; + } + + index = 0; + if (data->options.env) { + char* env = data->options.env[index]; + while (env != NULL) + { + free(env); + index += 1; + env = data->options.env[index]; + } + } + + free(data->options.stdio); + free((void*)data); + + schedulerResume(fiber, true); + wrenSetSlotDouble(getVM(), 2, (double)exit_status); + schedulerFinishResume(); +} + +// 1 2 3 4 5 +// exec_(cmd, args, cwd, env, fiber) +void processExec(WrenVM* vm) +{ + ProcessData* data = (ProcessData*)malloc(sizeof(ProcessData)); + memset(data, 0, sizeof(ProcessData)); + + //:todo: add env + cwd + flags args + + char* cmd = cli_strdup(wrenGetSlotString(vm, 1)); + + if (wrenGetSlotType(vm, 3) != WREN_TYPE_NULL) { + const char* cwd = wrenGetSlotString(vm, 3); + data->options.cwd = cwd; + } + + // input/output: for now we'll hookup STDOUT/STDERR as inherit/passthru so + // we'll see output just like you would in a shell script, by default + data->options.stdio_count = 3; + // TODO: make more flexible + uv_stdio_container_t *child_stdio = malloc(sizeof(uv_stdio_container_t) * 3); + memset(child_stdio, 0, sizeof(uv_stdio_container_t) * 3); + child_stdio[0].flags = UV_IGNORE; + child_stdio[1].flags = UV_INHERIT_FD; + child_stdio[2].flags = UV_INHERIT_FD; + child_stdio[1].data.fd = 1; + child_stdio[2].data.fd = 2; + data->options.stdio = child_stdio; + + data->options.file = cmd; + data->options.exit_cb = processOnExit; + data->fiber = wrenGetSlotHandle(vm, 5); + + wrenEnsureSlots(vm, 7); + + if (wrenGetSlotType(vm, 4) == WREN_TYPE_NULL) { + // no environment specified + } else if (wrenGetSlotType(vm, 4) == WREN_TYPE_LIST) { + int envCount = wrenGetListCount(vm, 4); + int envSize = sizeof(char*) * (envCount + 1); + + data->options.env = (char**)malloc(envSize); + data->options.env[envCount] = NULL; + + for (int i = 0; i < envCount ; i++) + { + wrenGetListElement(vm, 4, i, 6); + if (wrenGetSlotType(vm, 6) != WREN_TYPE_STRING) { + wrenSetSlotString(vm, 0, "arguments to env are supposed to be strings"); + wrenAbortFiber(vm, 0); + } + char* envKeyPlusValue = cli_strdup(wrenGetSlotString(vm, 6)); + data->options.env[i] = envKeyPlusValue; + } + } + + int argCount = wrenGetListCount(vm, 2); + int argsSize = sizeof(char*) * (argCount + 2); + + // First argument is the cmd, last+1 is NULL + data->options.args = (char**)malloc(argsSize); + data->options.args[0] = cmd; + data->options.args[argCount + 1] = NULL; + + for (int i = 0; i < argCount; i++) + { + wrenGetListElement(vm, 2, i, 3); + if (wrenGetSlotType(vm, 3) != WREN_TYPE_STRING) { + wrenSetSlotString(vm, 0, "arguments to args are supposed to be strings"); + wrenAbortFiber(vm, 0); + } + char* arg = cli_strdup(wrenGetSlotString(vm, 3)); + data->options.args[i + 1] = arg; + } + + uv_process_t* child_req = (uv_process_t*)malloc(sizeof(uv_process_t)); + memset(child_req, 0, sizeof(uv_process_t)); + + child_req->data = data; + + int r; + if ((r = uv_spawn(getLoop(), child_req, &data->options))) + { + // should be stderr??? but no idea how to make tests work/pass with that + fprintf(stdout, "Could not launch %s, reason: %s\n", cmd, uv_strerror(r)); + wrenSetSlotString(vm, 0, "Could not spawn process."); + wrenReleaseHandle(vm, data->fiber); + wrenAbortFiber(vm, 0); + } +} diff --git a/src/module/os.h b/src/module/os.h index b9988f80..55c8beed 100644 --- a/src/module/os.h +++ b/src/module/os.h @@ -1,10 +1,16 @@ #ifndef process_h #define process_h +#include "uv.h" #include "wren.h" #define WREN_PATH_MAX 4096 +typedef struct { + WrenHandle* fiber; + uv_process_options_t options; +} ProcessData; + // Stores the command line arguments passed to the CLI. void osSetArguments(int argc, const char* argv[]); diff --git a/src/module/os.wren b/src/module/os.wren index 4d9ec25a..e8145b91 100644 --- a/src/module/os.wren +++ b/src/module/os.wren @@ -1,3 +1,5 @@ +import "scheduler" for Scheduler + class Platform { foreign static homePath foreign static isPosix @@ -9,10 +11,47 @@ class Platform { class Process { // TODO: This will need to be smarter when wren supports CLI options. static arguments { allArguments.count >= 2 ? allArguments[2..-1] : [] } + static exit() { exit(0) } + static exit(code) { + // sets the exit code on the C side and stops the UV loop + exit_(code) + // suspends our Fiber and with UV loop stopped, no futher Fibers should get + // resumed so we should immediately stop and exit + Fiber.suspend() + } + + static exec(cmd) { + return exec(cmd, null, null, null) + } + + static exec(cmd, args) { + return exec(cmd, args, null, null) + } + + static exec(cmd, args, cwd) { + return exec(cmd, args, cwd, null) + } + + static exec(cmd, args, cwd, envMap) { + var env = [] + args = args || [] + if (envMap is Map) { + for (entry in envMap) { + env.add([entry.key, entry.value].join("=")) + } + } else if (envMap == null) { + env = null + } else { + Fiber.abort("environment vars must be passed as a Map") + } + return Scheduler.await_ { exec_(cmd, args, cwd, env, Fiber.current) } + } + foreign static exec_(cmd, args, cwd, env, fiber) foreign static allArguments foreign static cwd foreign static pid foreign static ppid foreign static version + foreign static exit_(code) } diff --git a/src/module/os.wren.inc b/src/module/os.wren.inc index 8c7c8522..8ae10737 100644 --- a/src/module/os.wren.inc +++ b/src/module/os.wren.inc @@ -2,6 +2,8 @@ // from `src/module/os.wren` using `util/wren_to_c_string.py` static const char* osModuleSource = +"import \"scheduler\" for Scheduler\n" +"\n" "class Platform {\n" " foreign static homePath\n" " foreign static isPosix\n" @@ -13,10 +15,47 @@ static const char* osModuleSource = "class Process {\n" " // TODO: This will need to be smarter when wren supports CLI options.\n" " static arguments { allArguments.count >= 2 ? allArguments[2..-1] : [] }\n" +" static exit() { exit(0) }\n" +" static exit(code) {\n" +" // sets the exit code on the C side and stops the UV loop\n" +" exit_(code)\n" +" // suspends our Fiber and with UV loop stopped, no futher Fibers should get\n" +" // resumed so we should immediately stop and exit\n" +" Fiber.suspend()\n" +" }\n" +"\n" +" static exec(cmd) {\n" +" return exec(cmd, null, null, null)\n" +" }\n" +"\n" +" static exec(cmd, args) {\n" +" return exec(cmd, args, null, null)\n" +" }\n" +"\n" +" static exec(cmd, args, cwd) { \n" +" return exec(cmd, args, cwd, null) \n" +" }\n" +" \n" +" static exec(cmd, args, cwd, envMap) { \n" +" var env = []\n" +" args = args || []\n" +" if (envMap is Map) {\n" +" for (entry in envMap) {\n" +" env.add([entry.key, entry.value].join(\"=\"))\n" +" }\n" +" } else if (envMap == null) {\n" +" env = null\n" +" } else {\n" +" Fiber.abort(\"environment vars must be passed as a Map\")\n" +" }\n" +" return Scheduler.await_ { exec_(cmd, args, cwd, env, Fiber.current) }\n" +" }\n" "\n" +" foreign static exec_(cmd, args, cwd, env, fiber)\n" " foreign static allArguments\n" " foreign static cwd\n" " foreign static pid\n" " foreign static ppid\n" " foreign static version\n" +" foreign static exit_(code)\n" "}\n"; diff --git a/src/module/repl.wren b/src/module/repl.wren index 81d34187..6c09adb2 100644 --- a/src/module/repl.wren +++ b/src/module/repl.wren @@ -8,11 +8,23 @@ class Repl { construct new() { _cursor = 0 _line = "" - _history = [] _historyIndex = 0 } + static start() { + // convenience + Meta.eval("import \"runtime\" for Runtime") + + // Fire up the REPL. We use ANSI when talking to a POSIX TTY. + if (Platform.isPosix && Stdin.isTerminal) { + AnsiRepl.new().run() + } else { + // ANSI escape sequences probably aren't supported, so degrade. + SimpleRepl.new().run() + } + } + cursor { _cursor } cursor=(value) { _cursor = value } line { _line } @@ -945,10 +957,3 @@ class Lexer { makeToken(type) { Token.new(_source, type, _start, _current - _start) } } -// Fire up the REPL. We use ANSI when talking to a POSIX TTY. -if (Platform.isPosix && Stdin.isTerminal) { - AnsiRepl.new().run() -} else { - // ANSI escape sequences probably aren't supported, so degrade. - SimpleRepl.new().run() -} diff --git a/src/module/repl.wren.inc b/src/module/repl.wren.inc index 0e74ac93..942c8069 100644 --- a/src/module/repl.wren.inc +++ b/src/module/repl.wren.inc @@ -12,11 +12,23 @@ static const char* replModuleSource = " construct new() {\n" " _cursor = 0\n" " _line = \"\"\n" -"\n" " _history = []\n" " _historyIndex = 0\n" " }\n" "\n" +" static start() {\n" +" // convenience\n" +" Meta.eval(\"import \\\"runtime\\\" for Runtime\")\n" +"\n" +" // Fire up the REPL. We use ANSI when talking to a POSIX TTY.\n" +" if (Platform.isPosix && Stdin.isTerminal) {\n" +" AnsiRepl.new().run()\n" +" } else {\n" +" // ANSI escape sequences probably aren't supported, so degrade.\n" +" SimpleRepl.new().run()\n" +" }\n" +" }\n" +"\n" " cursor { _cursor }\n" " cursor=(value) { _cursor = value }\n" " line { _line }\n" @@ -272,10 +284,10 @@ static const char* replModuleSource = " // don't know how wide the terminal is, erase the longest line we've seen\n" " // so far.\n" " if (line.count > _erase.count) _erase = \" \" * line.count\n" -" System.write(\"\r %(_erase)\")\n" +" System.write(\"\\r %(_erase)\")\n" "\n" " // Show the prompt at the beginning of the line.\n" -" System.write(\"\r> \")\n" +" System.write(\"\\r> \")\n" "\n" " // Write the line.\n" " System.write(line)\n" @@ -313,9 +325,9 @@ static const char* replModuleSource = " line = line[0...cursor]\n" " } else if (byte == Chars.ctrlL) {\n" " // Clear the screen.\n" -" System.write(\"\x1b[2J\")\n" +" System.write(\"\\x1b[2J\")\n" " // Move cursor to top left.\n" -" System.write(\"\x1b[H\")\n" +" System.write(\"\\x1b[H\")\n" " } else {\n" " // TODO: Ctrl-T to swap chars.\n" " // TODO: ESC H and F to move to beginning and end of line. (Both ESC\n" @@ -350,11 +362,11 @@ static const char* replModuleSource = "\n" " refreshLine(showCompletion) {\n" " // Erase the whole line.\n" -" System.write(\"\x1b[2K\")\n" +" System.write(\"\\x1b[2K\")\n" "\n" " // Show the prompt at the beginning of the line.\n" " System.write(Color.gray)\n" -" System.write(\"\r> \")\n" +" System.write(\"\\r> \")\n" " System.write(Color.none)\n" "\n" " // Syntax highlight the line.\n" @@ -374,7 +386,7 @@ static const char* replModuleSource = " }\n" "\n" " // Position the cursor.\n" -" System.write(\"\r\x1b[%(2 + cursor)C\")\n" +" System.write(\"\\r\\x1b[%(2 + cursor)C\")\n" " Stdout.flush()\n" " }\n" "\n" @@ -393,19 +405,19 @@ static const char* replModuleSource = "\n" "/// ANSI color escape sequences.\n" "class Color {\n" -" static none { \"\x1b[0m\" }\n" -" static black { \"\x1b[30m\" }\n" -" static red { \"\x1b[31m\" }\n" -" static green { \"\x1b[32m\" }\n" -" static yellow { \"\x1b[33m\" }\n" -" static blue { \"\x1b[34m\" }\n" -" static magenta { \"\x1b[35m\" }\n" -" static cyan { \"\x1b[36m\" }\n" -" static white { \"\x1b[37m\" }\n" -"\n" -" static gray { \"\x1b[30;1m\" }\n" -" static pink { \"\x1b[31;1m\" }\n" -" static brightWhite { \"\x1b[37;1m\" }\n" +" static none { \"\\x1b[0m\" }\n" +" static black { \"\\x1b[30m\" }\n" +" static red { \"\\x1b[31m\" }\n" +" static green { \"\\x1b[32m\" }\n" +" static yellow { \"\\x1b[33m\" }\n" +" static blue { \"\\x1b[34m\" }\n" +" static magenta { \"\\x1b[35m\" }\n" +" static cyan { \"\\x1b[36m\" }\n" +" static white { \"\\x1b[37m\" }\n" +"\n" +" static gray { \"\\x1b[30;1m\" }\n" +" static pink { \"\\x1b[31;1m\" }\n" +" static brightWhite { \"\\x1b[37;1m\" }\n" "}\n" "\n" "/// Utilities for working with characters.\n" @@ -948,11 +960,4 @@ static const char* replModuleSource = " // Creates a token of [type] from the current character range.\n" " makeToken(type) { Token.new(_source, type, _start, _current - _start) }\n" "}\n" -"\n" -"// Fire up the REPL. We use ANSI when talking to a POSIX TTY.\n" -"if (Platform.isPosix && Stdin.isTerminal) {\n" -" AnsiRepl.new().run()\n" -"} else {\n" -" // ANSI escape sequences probably aren't supported, so degrade.\n" -" SimpleRepl.new().run()\n" -"}\n"; +"\n"; diff --git a/src/module/runtime.wren b/src/module/runtime.wren new file mode 100644 index 00000000..b05a0dfe --- /dev/null +++ b/src/module/runtime.wren @@ -0,0 +1,26 @@ +class Capability { + construct new(name) { + _name = name + _version = 0 + } + ==(x) { x == _name } + toString { _name } +} + +class Runtime { + static NAME { "wren-console" } + static WREN_VERSION { "0.4.0" } + static VERSION { "0.1.99" } + static details { + return { + "name": Runtime.NAME, + "wrenVersion": Runtime.WREN_VERSION, + "version": Runtime.VERSION, + "capabilities": [ + Capability.new("essentials"), + Capability.new("mirror") + ] + } + } +} + diff --git a/src/module/runtime.wren.inc b/src/module/runtime.wren.inc new file mode 100644 index 00000000..2b7e960f --- /dev/null +++ b/src/module/runtime.wren.inc @@ -0,0 +1,30 @@ +// Please do not edit this file. It has been generated automatically +// from `src/module/runtime.wren` using `util/wren_to_c_string.py` + +static const char* runtimeModuleSource = +"class Capability {\n" +" construct new(name) {\n" +" _name = name\n" +" _version = 0\n" +" }\n" +" ==(x) { x == _name }\n" +" toString { _name }\n" +"}\n" +"\n" +"class Runtime {\n" +" static NAME { \"wren-console\" }\n" +" static WREN_VERSION { \"0.4.0\" }\n" +" static VERSION { \"0.1.99\" }\n" +" static details {\n" +" return {\n" +" \"name\": Runtime.NAME,\n" +" \"wrenVersion\": Runtime.WREN_VERSION,\n" +" \"version\": Runtime.VERSION,\n" +" \"capabilities\": [\n" +" Capability.new(\"essentials\"),\n" +" Capability.new(\"mirror\")\n" +" ]\n" +" }\n" +" }\n" +"}\n" +"\n"; diff --git a/test/io/directory/create_delete.wren b/test/io/directory/create_delete.wren index 59741edb..32f7c47a 100644 --- a/test/io/directory/create_delete.wren +++ b/test/io/directory/create_delete.wren @@ -14,6 +14,9 @@ if (Platform.isPosix) { var stat = Stat.path("tmp") // 511 is 0755 System.print(stat.mode && 0x1ff) // expect: 511 +} else { + // TODO: should we just remove this test entirely + System.print(511) // dummy for non-posix systems } Directory.delete("tmp") diff --git a/test/io/stdin/read_eof.wren b/test/io/stdin/read_eof.wren new file mode 100644 index 00000000..10817383 --- /dev/null +++ b/test/io/stdin/read_eof.wren @@ -0,0 +1,19 @@ +import "io" for Stdin +import "timer" for Timer + +// stdin: one line +// stdin: two line +// stdin: three line +var read = Stdin.read() +System.print(Stdin.isClosed) // expect: null + +// we have to try reading a second time to give the EOF +// a chance to register +Stdin.read() + +System.print(read) +// expect: one line +// expect: two line +// expect: three line + +System.print(Stdin.isClosed) // expect: true diff --git a/test/module/use_first_matching_modules_dir/a/b/use_first_matching_modules_dir.wren b/test/module/use_first_matching_modules_dir/a/b/use_first_matching_modules_dir.wren new file mode 100644 index 00000000..d334ad07 --- /dev/null +++ b/test/module/use_first_matching_modules_dir/a/b/use_first_matching_modules_dir.wren @@ -0,0 +1,2 @@ +// Searchs for foo in every upstream `wren_modules` folder +import "foo" // expect: ran foo module diff --git a/test/module/use_nearest_modules_dir/a/wren_modules/empty.txt b/test/module/use_first_matching_modules_dir/a/wren_modules/empty.txt similarity index 100% rename from test/module/use_nearest_modules_dir/a/wren_modules/empty.txt rename to test/module/use_first_matching_modules_dir/a/wren_modules/empty.txt diff --git a/test/module/use_nearest_modules_dir/wren_modules/foo/foo.wren b/test/module/use_first_matching_modules_dir/wren_modules/foo/foo.wren similarity index 100% rename from test/module/use_nearest_modules_dir/wren_modules/foo/foo.wren rename to test/module/use_first_matching_modules_dir/wren_modules/foo/foo.wren diff --git a/test/module/use_nearest_modules_dir/a/b/use_nearest_modules_dir.wren b/test/module/use_nearest_modules_dir/a/b/use_nearest_modules_dir.wren deleted file mode 100644 index b9208661..00000000 --- a/test/module/use_nearest_modules_dir/a/b/use_nearest_modules_dir.wren +++ /dev/null @@ -1,3 +0,0 @@ -// Stops as soon as it finds a wren_modules directory, regardless of whether or -// not it contains the desired module. -import "foo" // expect runtime error: Could not load module 'foo'. diff --git a/test/os/process/cwd.wren b/test/os/process/cwd.wren index 4f604afb..7d358489 100644 --- a/test/os/process/cwd.wren +++ b/test/os/process/cwd.wren @@ -1,8 +1,15 @@ import "io" for File, Directory -import "os" for Process +import "os" for Process, Platform System.print(Process.cwd is String) // expect: true System.print(!Process.cwd.isEmpty) // expect: true -System.print(Process.cwd.startsWith("/")) // expect: true + +if (Platform.isWindows) { + System.print(Process.cwd[1..-1].startsWith(":\\")) +} else { + System.print(Process.cwd.startsWith("/")) +} +// expect: true + System.print(File.realPath(Process.cwd) == Process.cwd) // expect: true System.print(Directory.exists(Process.cwd)) // expect: true diff --git a/test/os/process/exec_unix.wren b/test/os/process/exec_unix.wren new file mode 100644 index 00000000..595fb93b --- /dev/null +++ b/test/os/process/exec_unix.wren @@ -0,0 +1,52 @@ +// platform: Unix +import "os" for Platform, Process +import "io" for Stdout + +var TRY = Fn.new { |fn| + var fiber = Fiber.new { + fn.call() + } + return fiber.try() +} + +var result +if(Platform.isPosix) { + result = Process.exec("true") + System.print(result) // expect: 0 + + // basics + + // known output of success/fail based on only command name + System.print(Process.exec("true")) // expect: 0 + System.print(Process.exec("false")) // expect: 1 + // these test that our arguments are being passed as it proves + // they effect the result code returned + System.print(Process.exec("test", ["2", "-eq", "2"])) // expect: 0 + System.print(Process.exec("test", ["2", "-eq", "3"])) // expect: 1 + + // cwd + + // tests exists in our project folder + Stdout.flush() + System.print(Process.exec("ls", ["test/README.md"])) + // expect: test/README.md + // expect: 0 + + // but does not in our `src` folder + // TODO: python needs a way to expect exactly stderr output + // other than errors + // System.print(Process.exec("ls", ["test"], "./src/")) + // noexpect: 1 + + // env + + System.print(Process.exec("true",[],null,{})) // expect: 0 + var result = TRY.call { + Process.exec("ls",[],null,{"PATH": "/whereiscarmen/"}) + } + System.print(result) + // TODO: should be on stderr + // expect: Could not launch ls, reason: no such file or directory + // TODO: should this be a runtime error????? + // expect: Could not spawn process. +} \ No newline at end of file diff --git a/test/os/process/exec_windows.wren b/test/os/process/exec_windows.wren new file mode 100644 index 00000000..8fa16a3a --- /dev/null +++ b/test/os/process/exec_windows.wren @@ -0,0 +1,21 @@ +// platform: Windows +import "os" for Platform, Process +import "io" for Stdout + +var TRY = Fn.new { |fn| + var fiber = Fiber.new { + fn.call() + } + return fiber.try() +} + +// TODO: flesh out as much as exec_unix.wrenn + +var result +if(Platform.name == "Windows") { + result = Process.exec("cmd",["/c","echo hi"]) + // expect: hi + System.print(result) // expect: 0 +} + + diff --git a/test/os/process/pid_and_ppid.wren b/test/os/process/pid_and_ppid.wren index 59b32fda..c68b7906 100644 --- a/test/os/process/pid_and_ppid.wren +++ b/test/os/process/pid_and_ppid.wren @@ -8,4 +8,5 @@ System.print(Process.ppid is Num) // expect: true System.print(Process.ppid.isInteger) // expect: true System.print(Process.ppid > 0) // expect: true -System.print(Process.pid > Process.ppid) // expect: true +// on Windows it seems process IDs are perhaps randomized? +System.print(Process.pid != Process.ppid) // expect: true diff --git a/test/unit/path_test.wren b/test/unit/path_test.wren new file mode 100644 index 00000000..c2eeea66 --- /dev/null +++ b/test/unit/path_test.wren @@ -0,0 +1,131 @@ +// nontest +import "wren-assert/Assert" for Assert +import "wren-testie/testie" for Testie +import "../../src/cli/path" for Path + +class TestNormalize { + construct new() {} + expectNormalize(a,b) { + var normalized = Path.new(a).normalize.toString + var error = "`%(a)` should normalize to `%(b)`\n Got `%(normalized)` instead." + Assert.equal(normalized, b, error) + } + run() { + // Simple cases. + expectNormalize("", ".") + expectNormalize(".", ".") + expectNormalize("..", "..") + expectNormalize("a", "a") + expectNormalize("/", "/") + + // Collapses redundant separators. + expectNormalize("a/b/c", "a/b/c") + expectNormalize("a//b///c////d", "a/b/c/d") + + // Eliminates "." parts, except one at the beginning. + expectNormalize("./", ".") + expectNormalize("/.", "/") + expectNormalize("/./", "/") + expectNormalize("./.", ".") + expectNormalize("a/./b", "a/b") + expectNormalize("a/.b/c", "a/.b/c") + expectNormalize("a/././b/./c", "a/b/c") + expectNormalize("././a", "./a") + expectNormalize("a/./.", "a") + + // Eliminates ".." parts. + expectNormalize("..", "..") + expectNormalize("../", "..") + expectNormalize("../../..", "../../..") + expectNormalize("../../../", "../../..") + expectNormalize("/..", "/") + expectNormalize("/../../..", "/") + expectNormalize("/../../../a", "/a") + expectNormalize("a/..", ".") + expectNormalize("a/b/..", "a") + expectNormalize("a/../b", "b") + expectNormalize("a/./../b", "b") + expectNormalize("a/b/c/../../d/e/..", "a/d") + expectNormalize("a/b/../../../../c", "../../c") + + // Does not walk before root on absolute paths. + expectNormalize("..", "..") + expectNormalize("../", "..") + expectNormalize("/..", "/") + expectNormalize("a/..", ".") + expectNormalize("../a", "../a") + expectNormalize("/../a", "/a") + expectNormalize("/../a", "/a") + expectNormalize("a/b/..", "a") + expectNormalize("../a/b/..", "../a") + expectNormalize("a/../b", "b") + expectNormalize("a/./../b", "b") + expectNormalize("a/b/c/../../d/e/..", "a/d") + expectNormalize("a/b/../../../../c", "../../c") + expectNormalize("a/b/c/../../..d/./.e/f././", "a/..d/.e/f.") + + // Removes trailing separators. + expectNormalize("./", ".") + expectNormalize(".//", ".") + expectNormalize("a/", "a") + expectNormalize("a/b/", "a/b") + expectNormalize("a/b///", "a/b") + + expectNormalize("foo/bar/baz", "foo/bar/baz") + expectNormalize("foo", "foo") + expectNormalize("foo/bar/", "foo/bar") + expectNormalize("./foo/././bar/././", "./foo/bar") + } +} + + +Testie.new("Path") { |it, skip| + + it.should("should normalize") { + TestNormalize.new().run() + } + it.should("detect root") { + Assert.ok(Path.new("/").isRoot) + Assert.ok(Path.new("C:\\").isRoot) + Assert.ok(Path.new("E:").isRoot) + Assert.ok(Path.new("Z:\\").isRoot) + Assert.ok(!Path.new("Z::").isRoot) + Assert.ok(!Path.new("/bob").isRoot) + } + it.should("navigate paths") { + Assert.equal(Path.new("/").up().toString, "/") + Assert.equal(Path.new("/bob").up().toString, "/") + Assert.equal(Path.new("/bob/").up().toString, "/") + Assert.equal(Path.new("/bob/smith").up().toString, "/bob") + } + it.should("join") { + Assert.equal(Path.new("/").join("bob").toString, "/bob") + Assert.equal(Path.new("a/b/c").join("d").toString, "a/b/c/d") + Assert.equal(Path.new("a/b/c").join("./d").toString, "a/b/c/d") + Assert.equal(Path.new("a/b/c").join("../d").toString, "a/b/d") + Assert.equal(Path.new("a/b/c").join("../../d").toString, "a/d") + Assert.equal(Path.new("a/b/c").join("../../../d").toString, "d") + } + it.should("dirname") { + Assert.equal(Path.new("/a/b/c").dirname.toString, "/a/b") + Assert.equal(Path.new("/a/b/c/").dirname.toString, "/a/b/c") + Assert.equal(Path.new("/").dirname.toString, "/") + Assert.equal(Path.new("a").dirname.toString, ".") + Assert.equal(Path.new("/a").dirname.toString, "/") + } + it.should("split") { + Assert.deepEqual(Path.split("c:"),["c:"]) + Assert.deepEqual(Path.split("c:\\"),["c:",""]) + Assert.deepEqual(Path.split("c:\\bob\\smith"),["c:","bob","smith"]) + Assert.deepEqual(Path.split("c:\\bob\\smith\\"),["c:","bob","smith",""]) + } + it.should("windows") { + Assert.equal(Path.new("c:\\bob\\smith").up().toString, "c:\\bob") + Assert.equal(Path.new("c:\\bob\\smith").dirname.toString, "c:\\bob") + Assert.equal(Path.new("c:\\").dirname.toString, "c:") + Assert.equal(Path.new("c:\\bob\\ellis").join("./smith").toString, "c:\\bob\\ellis\\smith") + Assert.equal(Path.new("c:\\bob\\ellis").join("../smith").toString, "c:\\bob\\smith") + Assert.equal(Path.new("c:\\bob\\ellis").join("../..").toString, "c:") + Assert.equal(Path.new("c:").join("a/b").toString, "c:\\a\\b") + } +}.run() diff --git a/util/cli_to_c_string.py b/util/cli_to_c_string.py new file mode 100755 index 00000000..5fb029d0 --- /dev/null +++ b/util/cli_to_c_string.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# coding: utf-8 + +import argparse +import glob +import os.path +import re + +# The source for the Wren modules that are built into the VM or CLI are turned +# include C string literals. This way they can be compiled directly into the +# code so that file IO is not needed to find and read them. +# +# These string literals are stored in files with a ".wren.inc" extension and +# #included directly by other source files. This generates a ".wren.inc" file +# given a ".wren" module. + +PREAMBLE = """// Generated automatically from {0}. Do not edit. +static const char* {1}ModuleSource = +{2}; +""" + +def wren_to_c_string(input_path, wren_source_lines, module): + wren_source = "" + # cut off blank lines at the bottom + while (wren_source_lines[-1].strip()==""): + wren_source_lines.pop() + for line in wren_source_lines: + line = line.replace('\\','\\\\') + line = line.replace('"', "\\\"") + line = line.replace("\n", "\\n") + wren_source += '"' + line + '"\n' + + wren_source = wren_source.strip() + + return PREAMBLE.format("src/cli/*.wren", module, wren_source) + +def process_file(path, modules): + infile = os.path.basename(path) + outfile = path + ".inc" + # print("{} => {}").format(path.replace("src/",""), outfile) + + with open(path, "r") as f: + wren_source_lines = f.readlines() + ["\n\n"] + + first = wren_source_lines[0] + m = re.search(r'//module=(.*)',first) + if (m): + moduleNames = m.group(1).split(",") + else: + moduleNames = [os.path.splitext(infile)[0]] + + for module in moduleNames: + module = module.replace("opt_", "") + module = module.replace("wren_", "") + modules[module] = modules.get(module,[]) + modules[module].extend(wren_source_lines) + # return wren_to_c_string(infile, wren_source_lines, module) + + +module_files = {} + +def main(): + files = glob.glob("src/cli/*.wren") + with open("src/cli/_wren.inc", "w") as f: + modules = {} + for file in files: + process_file(file, modules) + for (module,lines) in modules.items(): + source = wren_to_c_string("", lines, module) + f.write(source + "\n") + +main() diff --git a/util/test.py b/util/test.py index 58db4e4c..d1b58a39 100755 --- a/util/test.py +++ b/util/test.py @@ -9,6 +9,8 @@ import re from subprocess import Popen, PIPE import sys +import os +import platform from threading import Timer # Runs the tests. @@ -24,7 +26,7 @@ config_dir = ("debug" if is_debug else "release") + config WREN_DIR = dirname(dirname(realpath(__file__))) -WREN_APP = join(WREN_DIR, 'bin', 'wren_cli' + args.suffix) +WREN_APP = join(WREN_DIR, 'bin', 'wrenc' + args.suffix) # print("Wren Test Directory - " + WREN_DIR) # print("Wren Test App - " + WREN_APP) @@ -34,9 +36,11 @@ EXPECT_ERROR_LINE_PATTERN = re.compile(r'// expect error line (\d+)') EXPECT_RUNTIME_ERROR_PATTERN = re.compile(r'// expect (handled )?runtime error: (.+)') ERROR_PATTERN = re.compile(r'\[.* line (\d+)\] Error') -STACK_TRACE_PATTERN = re.compile(r'(?:\[\./)?test/.* line (\d+)\] in') +# Wren Console purposely has different stack traces +STACK_TRACE_PATTERN = re.compile(r'at .*\((?:\./)?test/.*line (\d+)\)') STDIN_PATTERN = re.compile(r'// stdin: (.*)') SKIP_PATTERN = re.compile(r'// skip: (.*)') +PLATFORM_PATTERN = re.compile(r'// platform: (.*)') NONTEST_PATTERN = re.compile(r'// nontest') passed = 0 @@ -122,6 +126,16 @@ def parse(self): skipped[match.group(1)] += 1 return False + match = PLATFORM_PATTERN.search(line) + if match: + sys = platform.system() + desires = match.group(1) + if ((desires=="Windows" and not sys=="Windows") or + (desires=="Unix" and not (sys=="Darwin" or sys=="Linux"))): + num_skipped += 1 + skipped[match.group(1)] += 1 + return False + # Not a test file at all, so ignore it. match = NONTEST_PATTERN.search(line) if match: @@ -391,9 +405,22 @@ def run_example(path): run_script(WREN_APP, path, "example") +def run_unit(path): + global passed + global failed + + if (splitext(path)[1] != '.wren'): + return + + err = os.system(f"{WREN_APP} {path}") + if (err!=0): + failed += 1 + else: + passed += 1 walk(join(WREN_DIR, 'test'), run_test) walk(join(WREN_DIR, 'example'), run_example) +walk(join(WREN_DIR, 'test/unit'), run_unit) print_line() if failed == 0: @@ -405,5 +432,7 @@ def run_example(path): for key in sorted(skipped.keys()): print('Skipped ' + yellow(skipped[key]) + ' tests: ' + key) + + if failed != 0: sys.exit(1) diff --git a/util/wren_to_c_string.py b/util/wren_to_c_string.py index ddcc540f..213a69d4 100755 --- a/util/wren_to_c_string.py +++ b/util/wren_to_c_string.py @@ -24,6 +24,7 @@ def wren_to_c_string(input_path, wren_source_lines, module): wren_source = "" for line in wren_source_lines: + line = line.replace('\\','\\\\') line = line.replace('"', "\\\"") line = line.replace("\n", "\\n\"") if wren_source: wren_source += "\n"