fstudio/clangbuilder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automated tools help developers on Windows platforms building LLVM and clang.

Clone clangbuilder on

git clone https://.com/fstudio/clangbuilder.git clangbuilder

Click the script/InitializeEnv.bat

The installation script will compile ClangbuilderUI and create a shortcut, download required packages.

Your can modified settings.json to change your clangbuilder run mode. settings.template.json content like here:

{
  "EnterpriseWDK": "D:\\EWDK",
  "LLVMRoot": "D:\\LLVM",
  "LLVMArch": "x64",
  "PwshCoreEnabled": true,
  "UseWindowsTerminal": true,
  "Conhost": "C:\\Path\\To\\OpenConsole.exe",
  "SetWindowCompositionAttribute": false
}
  • EnterpriseWDK Set EWDK root path and enable Enterprise WDK.
  • LLVMRoot Pre-built llvm installation root directory.
  • LLVMArch Pre-built llvm default architecture
  • PwshCoreEnabled Enable Powershell Core, all script run use pwsh (when you install powershell core).
  • UseWindowsTerminal Use Windows Terminal (We need wt support commandline)
  • Conhost If Windows Termianl not exists, your can set OpenConsole path.
  • SetWindowCompositionAttribute Fluent UI features

Clangbuilder Now Only support use Visual C++ build Clang LLVM LLDB.

Best Visual Studio Version:

Visual Studio 2019 16.3 or later

You can click to run ClangbuilderUI, Modified Arch, Configuration and other options. after click Building

ClangbuilderUI Snapshot

clangbuilder

Branch

CMake Custom flags

You can custom cmake build flags Now !!!

Clangbuilder will check $ClangbuilderRoot\out\cmakeflags.$Branch.json and $ClangbuilderRoot\out\cmakeflags.json is exists, if exists parse cmake flags.

The corresponding branch takes effect:

Set cmakeflags.json will take effect in all branches (Mainline, Stable, Release)

Flags configuration format is json:

{
    "CMake":[
        "-DCMAKE_INSTALL_PREFIX=\"D:/LLVM\""
    ]
}

Engine

  • MSbuild use msbuild build llvm MSBuild - MSVC
  • Ninja use ninja build llvm Ninja - MSVC
  • NinjaBootstrap use ninja build and bootstrap llvm Ninja - Bootstrap
  • NinjaIterate use ninja build llvm, but compile is prebuilt clang (config by config\prebuilt.json) Ninja - Clang

LLDB

When you select build LLDB, If not found Python 3 installed. Clangbuilder add flag -DLLDB_DISABLE_PYTHON=1.

LLDB maybe not work.

Libc++

Only NinjaBootstrap and NinjaIterate will compile libc++ ,Because Visual C++ not support include_next now.

clang-cl -std:c++14  -Iinclude\c++\v1 hello.cc c++.lib

after copy c++.dll to your path(or exe self directory).

Use Clean Environment

Clangbuilder support Clean Environment, When use -ClearEnv flag or enable check box Use Clean Environment, Clangbuilder will retset $env:PATH.

Function ReinitializePath {
    if ($PSEdition -eq "Desktop" -or $IsWindows) {
        $env:PATH += "${env:windir};${env:windir}\System32;${env:windir}\System32\Wbem;${env:windir}\System32\WindowsPowerShell\v1.0"
    }
    else {
        $env:PATH = "/usr/local/bin:/usr/bin:/bin"
    }
}

You can modify UseWindowsTerminal to enable or disable the use of Windows Terminal as the default terminal. When UseWindowsTerminal is set to true, you open the Clangbuilder terminal environment, the screenshot is as follows:

termianl

You can modify config/initialize.json , add some directories to PATH. Note that directories have higher priority in PATH. (Insert Front)

  • Best Platform is Windows 10 x64
  • Select Use Clean Environment will reset current process Environment PATH value, Resolve conflict environment variables
  • If your will build lldb, your should install python3.
$env:Path = "${env:windir};${env:windir}\System32;${env:windir}\System32\Wbem;${env:windir}\System32\WindowsPowerShell\v1.0"

$evn:windir is usually C:\Windows

baulk is a better Windows package management tool developed by the author

You can port some tools to clangbuilder, see ports and then double-click script/DevAll.bat to the software you need as part of the Clangbuilder is added to the environment. Clangbuilder 6.0 support devi, You can run devi under Environment Console, use devi install $ToolName to install your need tools.

Usage:

Default installed tools:

{
    "core": [
        "7z",
        "cmake",
        "git",
        "ninja",
        "nsis",
        "nuget",
        "python2",
        "vswhere"
    ]
}

Current ported tools:

Extensions:

We support 4 extensions: exe, zip, msi, 7z. If 7z is not installed, only the first three extensions are supported. If you need to port a 7z extension type of package, you need to understand the decompression format supported by 7z.exe.

7z.exe supported formats(Unpacking): AR, ARJ, CAB, CHM, CPIO, CramFS, DMG, EXT, FAT, GPT, HFS, IHEX, ISO, LZH, LZMA, MBR, MSI, NSIS, NTFS, QCOW2, RAR, RPM, SquashFS, UDF, UEFI, VDI, VHD, VMDK, WIM, XAR and Z

You can add extranl lib, such as z3, download extranl lib, unpack to bin/external , bin/external/include is include dir, bin/external/lib/$arch(x86,x64,arm,arm64), bin/external/bin/$arch(x86,x64,arm,arm64).

Ninja Task Parallel:

Function Parallel() {
    $MemSize = (Get-CimInstance -Class Win32_ComputerSystem).TotalPhysicalMemory
    $ProcessorCount = $env:NUMBER_OF_PROCESSORS
    $MemParallelRaw = $MemSize / 1610612736 #1.5GB
    #[int]$MemParallel = [Math]::Floor($MemParallelRaw)
    [int]$MemParallel = [Math]::Ceiling($MemParallelRaw) ## less 1
    return [Math]::Min($ProcessorCount, $MemParallel)
}

License: MIT
Author: Force.Charlie
Copyright © 2022 Force Charlie. All Rights Reserved.

fstudio: Icons made by Smashicons from www.flaticon.com

About

Building Clang ♡ Utility and Environment

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •