Skip to content

Commit

Permalink
Merge branch 'appveyor'
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Jan 5, 2018
2 parents 7e65fe7 + 2c35e24 commit e08a4ea
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 17 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Expand Up @@ -570,6 +570,14 @@ set(ZIG_C_HEADER_FILES
"xtestintrin.h"
)

if(MSVC)
set(MSVC_DIA_SDK_DIR "$ENV{VSINSTALLDIR}DIA SDK")
if (IS_DIRECTORY ${MSVC_DIA_SDK_DIR})
set(ZIG_DIA_GUIDS_LIB "${MSVC_DIA_SDK_DIR}/lib/amd64/diaguids.lib")
string(REGEX REPLACE "\\\\" "\\\\\\\\" ZIG_DIA_GUIDS_LIB_ESCAPED "${ZIG_DIA_GUIDS_LIB}")
endif()
endif()

set(ZIG_LIB_DIR "lib/zig")
set(C_HEADERS_DEST "${ZIG_LIB_DIR}/include")
set(ZIG_STD_DEST "${ZIG_LIB_DIR}/std")
Expand Down Expand Up @@ -631,6 +639,10 @@ target_link_libraries(zig LINK_PUBLIC
${LLVM_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
)
if(ZIG_DIA_GUIDS_LIB)
target_link_libraries(zig LINK_PUBLIC ${ZIG_DIA_GUIDS_LIB})
endif()

if(MSVC OR MINGW)
target_link_libraries(zig LINK_PUBLIC version)
endif()
Expand Down
13 changes: 12 additions & 1 deletion build.zig
Expand Up @@ -45,6 +45,7 @@ pub fn build(b: &Builder) {
const lld_libraries = nextValue(&index, build_info);
const std_files = nextValue(&index, build_info);
const c_header_files = nextValue(&index, build_info);
const dia_guids_lib = nextValue(&index, build_info);

const llvm = findLLVM(b, llvm_config_exe);

Expand Down Expand Up @@ -76,11 +77,21 @@ pub fn build(b: &Builder) {
exe.linkSystemLibrary("c++");
}

if (dia_guids_lib.len != 0) {
exe.addObjectFile(dia_guids_lib);
}

exe.linkSystemLibrary("c");

b.default_step.dependOn(&exe.step);
b.default_step.dependOn(docs_step);
test_step.dependOn(&exe.step);

const skip_self_hosted = b.option(bool, "skip-self-hosted", "Main test suite skips building self hosted compiler") ?? false;
if (!skip_self_hosted) {
test_step.dependOn(&exe.step);
}
const verbose_link_exe = b.option(bool, "verbose-link", "Print link command for self hosted compiler") ?? false;
exe.setVerboseLink(verbose_link_exe);

b.installArtifact(exe);
installStdLib(b, std_files);
Expand Down
2 changes: 1 addition & 1 deletion ci/appveyor/appveyor.yml
Expand Up @@ -6,4 +6,4 @@ build_script:
after_build:
- '%APPVEYOR_BUILD_FOLDER%\ci\appveyor\after_build.bat'
cache:
- 'llvm+clang-5.0.0-win64-msvc-release.tar.xz'
- 'llvm+clang-5.0.1-win64-msvc-release.tar.xz'
9 changes: 6 additions & 3 deletions ci/appveyor/build_script.bat
Expand Up @@ -7,20 +7,23 @@ SET "PATH=C:\msys64\mingw64\bin;C:\msys64\usr\bin;%PATH%"
SET "MSYSTEM=MINGW64"
SET "APPVEYOR_CACHE_ENTRY_ZIP_ARGS=-m0=Copy"

bash -lc "cd ${APPVEYOR_BUILD_FOLDER} && if [ -s ""llvm+clang-5.0.0-win64-msvc-release.tar.xz"" ]; then echo 'skipping LLVM download'; else wget 'https://s3.amazonaws.com/superjoe/temp/llvm%%2bclang-5.0.0-win64-msvc-release.tar.xz'; fi && tar xf llvm+clang-5.0.0-win64-msvc-release.tar.xz" || exit /b
bash -lc "cd ${APPVEYOR_BUILD_FOLDER} && if [ -s ""llvm+clang-5.0.1-win64-msvc-release.tar.xz"" ]; then echo 'skipping LLVM download'; else wget 'https://s3.amazonaws.com/ziglang.org/deps/llvm%%2bclang-5.0.1-win64-msvc-release.tar.xz'; fi && tar xf llvm+clang-5.0.1-win64-msvc-release.tar.xz" || exit /b


SET "PATH=%PREVPATH%"
SET "MSYSTEM=%PREVMSYSTEM%"
SET "ZIGBUILDDIR=%APPVEYOR_BUILD_FOLDER%\build-msvc-release"
SET "ZIGPREFIXPATH=%APPVEYOR_BUILD_FOLDER%\llvm+clang-5.0.0-win64-msvc-release"
SET "ZIGPREFIXPATH=%APPVEYOR_BUILD_FOLDER%\llvm+clang-5.0.1-win64-msvc-release"

call "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64

mkdir %ZIGBUILDDIR%
cd %ZIGBUILDDIR%
cmake.exe .. -Thost=x64 -G"Visual Studio 14 2015 Win64" "-DCMAKE_INSTALL_PREFIX=%ZIGBUILDDIR%" "-DCMAKE_PREFIX_PATH=%ZIGPREFIXPATH%" -DCMAKE_BUILD_TYPE=Release "-DZIG_LIBC_INCLUDE_DIR=C:\Program Files (x86)\Windows Kits\10\Include\10.0.10240.0\ucrt" "-DZIG_LIBC_LIB_DIR=C:\Program Files (x86)\Windows Kits\10\bin\x64\ucrt" "-DZIG_LIBC_STATIC_LIB_DIR=C:\Program Files (x86)\Windows Kits\10\Lib\10.0.10240.0\ucrt\x64" || exit /b
msbuild /p:Configuration=Release INSTALL.vcxproj || exit /b

bin\zig.exe build --build-file ..\build.zig test || exit /b
bin\zig.exe build --build-file ..\build.zig test -Dverbose-link || exit /b

@echo "MSVC build succeeded, proceeding with MinGW build"
cd %APPVEYOR_BUILD_FOLDER%
Expand Down
1 change: 1 addition & 0 deletions src/config.h.in
Expand Up @@ -32,5 +32,6 @@
#define ZIG_LLVM_CONFIG_EXE "@LLVM_CONFIG_EXE@"
#define ZIG_STD_FILES "@ZIG_STD_FILES@"
#define ZIG_C_HEADER_FILES "@ZIG_C_HEADER_FILES@"
#define ZIG_DIA_GUIDS_LIB "@ZIG_DIA_GUIDS_LIB_ESCAPED@"

#endif
5 changes: 3 additions & 2 deletions src/main.cpp
Expand Up @@ -267,14 +267,15 @@ static void add_package(CodeGen *g, CliPkg *cli_pkg, PackageTableEntry *pkg) {

int main(int argc, char **argv) {
if (argc == 2 && strcmp(argv[1], "BUILD_INFO") == 0) {
printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
printf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
ZIG_CMAKE_BINARY_DIR,
ZIG_CXX_COMPILER,
ZIG_LLVM_CONFIG_EXE,
ZIG_LLD_INCLUDE_PATH,
ZIG_LLD_LIBRARIES,
ZIG_STD_FILES,
ZIG_C_HEADER_FILES);
ZIG_C_HEADER_FILES,
ZIG_DIA_GUIDS_LIB);
return 0;
}

Expand Down
5 changes: 5 additions & 0 deletions src/os.cpp
Expand Up @@ -1055,6 +1055,11 @@ int os_find_windows_sdk(ZigWindowsSDK **out_sdk) {
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
sscanf(ffd.cFileName, "%d.%d.%d.%d", &c0, &c1, &c2, &c3);
if (c0 == 10 && c1 == 0 && c2 == 10240 && c3 == 0) {
// Microsoft released 26624 as 10240 accidentally.
// https://developer.microsoft.com/en-us/windows/downloads/sdk-archive
c2 = 26624;
}
if ((c0 > v0) || (c1 > v1) || (c2 > v2) || (c3 > v3)) {
v0 = c0, v1 = c1, v2 = c2, v3 = c3;
buf_init_from_str(&result_sdk->version10, ffd.cFileName);
Expand Down
15 changes: 6 additions & 9 deletions std/build.zig
Expand Up @@ -842,10 +842,10 @@ pub const LibExeObjStep = struct {
lib_paths: ArrayList([]const u8),
disable_libc: bool,
frameworks: BufSet,
verbose_link: bool,

// zig only stuff
root_src: ?[]const u8,
verbose: bool,
output_h_path: ?[]const u8,
out_h_filename: []const u8,
assembly_files: ArrayList([]const u8),
Expand Down Expand Up @@ -923,7 +923,7 @@ pub const LibExeObjStep = struct {
var self = LibExeObjStep {
.strip = false,
.builder = builder,
.verbose = false,
.verbose_link = false,
.build_mode = builtin.Mode.Debug,
.static = static,
.kind = kind,
Expand Down Expand Up @@ -988,7 +988,7 @@ pub const LibExeObjStep = struct {
.linker_script = null,

.root_src = undefined,
.verbose = undefined,
.verbose_link = false,
.output_h_path = undefined,
.out_h_filename = undefined,
.assembly_files = undefined,
Expand Down Expand Up @@ -1087,8 +1087,8 @@ pub const LibExeObjStep = struct {
%%self.source_files.append(file);
}

pub fn setVerbose(self: &LibExeObjStep, value: bool) {
self.verbose = value;
pub fn setVerboseLink(self: &LibExeObjStep, value: bool) {
self.verbose_link = value;
}

pub fn setBuildMode(self: &LibExeObjStep, mode: builtin.Mode) {
Expand Down Expand Up @@ -1223,15 +1223,12 @@ pub const LibExeObjStep = struct {
%%zig_args.append(builder.pathFromRoot(asm_file));
}

if (self.verbose) {
%%zig_args.append("--verbose");
}
if (builder.verbose_tokenize) %%zig_args.append("--verbose-tokenize");
if (builder.verbose_ast) %%zig_args.append("--verbose-ast");
if (builder.verbose_cimport) %%zig_args.append("--verbose-cimport");
if (builder.verbose_ir) %%zig_args.append("--verbose-ir");
if (builder.verbose_llvm_ir) %%zig_args.append("--verbose-llvm-ir");
if (builder.verbose_link) %%zig_args.append("--verbose-link");
if (builder.verbose_link or self.verbose_link) %%zig_args.append("--verbose-link");

if (self.strip) {
%%zig_args.append("--strip");
Expand Down
2 changes: 1 addition & 1 deletion std/special/build_runner.zig
Expand Up @@ -14,7 +14,7 @@ pub fn main() -> %void {
var arg_it = os.args();

// TODO use a more general purpose allocator here
var inc_allocator = %%std.heap.IncrementingAllocator.init(30 * 1024 * 1024);
var inc_allocator = %%std.heap.IncrementingAllocator.init(40 * 1024 * 1024);
defer inc_allocator.deinit();

const allocator = &inc_allocator.allocator;
Expand Down

0 comments on commit e08a4ea

Please sign in to comment.