| author | |
| committer | |
| log | d53e8a5751c3d3a65db775598cc1db88c4d92ba9 |
| tree | 1e14fcb22dc0957dda325fbc058989609c48b5a0 |
| parent | 9348609e6a409d688ae4899b6e3b8347e1c1353e |
This reverts commit cd062b08d01cf2c92b05ef3e96b2ff3715f29fd5.2 files changed, 27 insertions(+), 43 deletions(-)
CMakeLists.txt+12-23| ... | ... | @@ -45,6 +45,7 @@ message("Configuring zig version ${ZIG_VERSION}") |
| 45 | 45 | |
| 46 | 46 | set(ZIG_STATIC off CACHE BOOL "Attempt to build a static zig executable (not compatible with glibc)") |
| 47 | 47 | set(ZIG_STATIC_LLVM off CACHE BOOL "Prefer linking against static LLVM libraries") |
| 48 | set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Disable copying lib/ files to install prefix") | |
| 48 | 49 | set(ZIG_ENABLE_MEM_PROFILE off CACHE BOOL "Activate memory usage instrumentation") |
| 49 | 50 | |
| 50 | 51 | if(ZIG_STATIC) |
| ... | ... | @@ -607,26 +608,19 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") |
| 607 | 608 | else() |
| 608 | 609 | set(LIBUSERLAND_RELEASE_MODE "true") |
| 609 | 610 | endif() |
| 610 | ||
| 611 | set(BUILD_LIBUSERLAND_COMMAND zig0 build | |
| 612 | --override-lib-dir "${CMAKE_SOURCE_DIR}/lib" | |
| 613 | "-Doutput-dir=${CMAKE_BINARY_DIR}" | |
| 614 | "-Drelease=${LIBUSERLAND_RELEASE_MODE}" | |
| 615 | "-Dlib-files-only" | |
| 616 | --prefix "${CMAKE_INSTALL_PREFIX}" | |
| 617 | libuserland | |
| 618 | ) | |
| 619 | ||
| 620 | # When using Visual Studio build system generator we default to libuserland install. | |
| 621 | if(MSVC) | |
| 622 | set(ZIG_SKIP_INSTALL_LIB_FILES off CACHE BOOL "Disable copying lib/ files to install prefix") | |
| 623 | if(NOT ZIG_SKIP_INSTALL_LIB_FILES) | |
| 624 | set(BUILD_LIBUSERLAND_COMMAND ${BUILD_LIBUSERLAND_COMMAND} install) | |
| 625 | endif() | |
| 611 | if(ZIG_SKIP_INSTALL_LIB_FILES) | |
| 612 | set(ZIG_BUILD_INSTALL_STEP "") | |
| 613 | else() | |
| 614 | set(ZIG_BUILD_INSTALL_STEP "install") | |
| 626 | 615 | endif() |
| 627 | ||
| 628 | 616 | add_custom_target(zig_build_libuserland ALL |
| 629 | COMMAND ${BUILD_LIBUSERLAND_COMMAND} | |
| 617 | COMMAND zig0 build | |
| 618 | --override-lib-dir "${CMAKE_SOURCE_DIR}/lib" | |
| 619 | libuserland ${ZIG_BUILD_INSTALL_STEP} | |
| 620 | "-Doutput-dir=${CMAKE_BINARY_DIR}" | |
| 621 | "-Drelease=${LIBUSERLAND_RELEASE_MODE}" | |
| 622 | "-Dlib-files-only" | |
| 623 | --prefix "${CMAKE_INSTALL_PREFIX}" | |
| 630 | 624 | DEPENDS zig0 |
| 631 | 625 | BYPRODUCTS "${LIBUSERLAND}" |
| 632 | 626 | WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" |
| ... | ... | @@ -644,9 +638,4 @@ elseif(MINGW) |
| 644 | 638 | target_link_libraries(zig ntdll) |
| 645 | 639 | endif() |
| 646 | 640 | add_dependencies(zig zig_build_libuserland) |
| 647 | ||
| 648 | 641 | install(TARGETS zig DESTINATION bin) |
| 649 | ||
| 650 | # CODE has no effect with Visual Studio build system generator. | |
| 651 | install(CODE "message(\"-- Installing: ${CMAKE_INSTALL_PREFIX}/lib\")") | |
| 652 | install(CODE "execute_process(COMMAND ${BUILD_LIBUSERLAND_COMMAND} install)") |
CONTRIBUTING.md+15-20| ... | ... | @@ -51,28 +51,23 @@ knowledge of Zig internals.** |
| 51 | 51 | |
| 52 | 52 | ### Editing Source Code |
| 53 | 53 | |
| 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`. | |
| 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. | |
| 69 | 65 | |
| 70 | 66 | To test changes, do the following from the build directory: |
| 71 | 67 | |
| 72 | 1. Run `make` (on POSIX) or | |
| 68 | 1. Run `make install` (on POSIX) or | |
| 73 | 69 | `msbuild -p:Configuration=Release INSTALL.vcxproj` (on Windows). |
| 74 | 2. `$BUILD_DIR/zig build test` (on POSIX) or | |
| 75 | `$BUILD_DIR/Release\zig.exe build test` (on Windows). | |
| 70 | 2. `bin/zig build test` (on POSIX) or `bin\zig.exe build test` (on Windows). | |
| 76 | 71 | |
| 77 | 72 | That runs the whole test suite, which does a lot of extra testing that you |
| 78 | 73 | likely won't always need, and can take upwards of 1 hour. This is what the |
| ... | ... | @@ -90,8 +85,8 @@ Another example is choosing a different set of things to test. For example, |
| 90 | 85 | not the other ones. Combining this suggestion with the previous one, you could |
| 91 | 86 | do this: |
| 92 | 87 | |
| 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). | |
| 88 | `bin/zig build test-std -Dskip-release` (on POSIX) or | |
| 89 | `bin\zig.exe build test-std -Dskip-release` (on Windows). | |
| 95 | 90 | |
| 96 | 91 | This will run only the standard library tests, in debug mode only, for all |
| 97 | 92 | targets (it will cross-compile the tests for non-native targets but not run |