| ... | ... | @@ -51,23 +51,28 @@ knowledge of Zig internals.** |
| 51 | 51 | |
| 52 | 52 | ### Editing Source Code |
| 53 | 53 | |
| 54 | | First, build the Stage 1 compiler as described in [the Building section](#building). |
| 55 | | |
| 56 | | One modification you may want to make is adding `-DZIG_SKIP_INSTALL_LIB_FILES=ON` |
| 57 | | to the cmake line. If you use the build directory as a working directory to run |
| 58 | | tests with, zig will find the lib files in the source directory, and they will not |
| 59 | | be "installed" every time you run `make`. This will allow you to make modifications |
| 60 | | directly to the standard library, for example, and have them effective immediately. |
| 61 | | Note that if you already ran `make` or `make install` with the default cmake |
| 62 | | settings, there will already be a `lib/` directory in your build directory. When |
| 63 | | executed from the build directory, zig will find this instead of the source lib/ |
| 64 | | directory. Remove the unwanted directory so that the desired one can be found. |
| 54 | First, build the Stage 1 compiler as described in [Building from Source](README.md#Building-from-Source). |
| 55 | |
| 56 | Zig locates lib files relative to executable path by searching up the |
| 57 | filesystem tree for a sub-path of `lib/zig/std/std.zig` or `lib/std/std.zig`. |
| 58 | Typically the former is an install and the latter a git working tree which |
| 59 | contains the build directory. |
| 60 | |
| 61 | During development it is not necessary to perform installs when modifying |
| 62 | stage1 or userland sources and in fact it is faster and simpler to run, |
| 63 | test and debug from a git working tree. |
| 64 | |
| 65 | - `make` is typically sufficient to build zig during development iterations. |
| 66 | - `make install` performs a build __and__ install. |
| 67 | - `msbuild -p:Configuration=Release INSTALL.vcxproj` on Windows performs a |
| 68 | build and install. To avoid install, pass cmake option `-DZIG_SKIP_INSTALL_LIB_FILES=ON`. |
| 65 | 69 | |
| 66 | 70 | To test changes, do the following from the build directory: |
| 67 | 71 | |
| 68 | | 1. Run `make install` (on POSIX) or |
| 72 | 1. Run `make` (on POSIX) or |
| 69 | 73 | `msbuild -p:Configuration=Release INSTALL.vcxproj` (on Windows). |
| 70 | | 2. `bin/zig build test` (on POSIX) or `bin\zig.exe build test` (on Windows). |
| 74 | 2. `$BUILD_DIR/zig build test` (on POSIX) or |
| 75 | `$BUILD_DIR/Release\zig.exe build test` (on Windows). |
| 71 | 76 | |
| 72 | 77 | That runs the whole test suite, which does a lot of extra testing that you |
| 73 | 78 | likely won't always need, and can take upwards of 1 hour. This is what the |
| ... | ... | @@ -85,8 +90,8 @@ Another example is choosing a different set of things to test. For example, |
| 85 | 90 | not the other ones. Combining this suggestion with the previous one, you could |
| 86 | 91 | do this: |
| 87 | 92 | |
| 88 | | `bin/zig build test-std -Dskip-release` (on POSIX) or |
| 89 | | `bin\zig.exe build test-std -Dskip-release` (on Windows). |
| 93 | `$BUILD_DIR/bin/zig build test-std -Dskip-release` (on POSIX) or |
| 94 | `$BUILD_DIR/Release\zig.exe build test-std -Dskip-release` (on Windows). |
| 90 | 95 | |
| 91 | 96 | This will run only the standard library tests, in debug mode only, for all |
| 92 | 97 | targets (it will cross-compile the tests for non-native targets but not run |