mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Various fixes for CMake (#13928)
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.24)
|
cmake_minimum_required(VERSION 3.24)
|
||||||
message(STATUS "Configuring Bun")
|
message(STATUS "Configuring Bun")
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH
|
list(APPEND CMAKE_MODULE_PATH
|
||||||
${CMAKE_SOURCE_DIR}/cmake
|
${CMAKE_SOURCE_DIR}/cmake
|
||||||
@@ -11,16 +10,7 @@ list(APPEND CMAKE_MODULE_PATH
|
|||||||
)
|
)
|
||||||
|
|
||||||
include(Policies)
|
include(Policies)
|
||||||
include(Macros)
|
include(Globals)
|
||||||
|
|
||||||
# --- Globals ---
|
|
||||||
|
|
||||||
setx(CWD ${CMAKE_SOURCE_DIR})
|
|
||||||
setx(BUILD_PATH ${CMAKE_BINARY_DIR})
|
|
||||||
optionx(CACHE_PATH STRING "The path to the cache directory" DEFAULT ${BUILD_PATH}/cache)
|
|
||||||
optionx(CACHE_STRATEGY "read-write|read-only|write-only|none" "The strategy to use for caching" DEFAULT "read-write")
|
|
||||||
optionx(TMP_PATH STRING "The path to the temporary directory" DEFAULT ${BUILD_PATH}/tmp)
|
|
||||||
optionx(FRESH BOOL "Set when --fresh is used" DEFAULT OFF)
|
|
||||||
|
|
||||||
# --- Compilers ---
|
# --- Compilers ---
|
||||||
|
|
||||||
@@ -36,6 +26,7 @@ parse_package_json(VERSION_VARIABLE DEFAULT_VERSION)
|
|||||||
optionx(VERSION STRING "The version of Bun" DEFAULT ${DEFAULT_VERSION})
|
optionx(VERSION STRING "The version of Bun" DEFAULT ${DEFAULT_VERSION})
|
||||||
project(Bun VERSION ${VERSION})
|
project(Bun VERSION ${VERSION})
|
||||||
include(Options)
|
include(Options)
|
||||||
|
include(CompilerFlags)
|
||||||
|
|
||||||
# --- Tools ---
|
# --- Tools ---
|
||||||
|
|
||||||
@@ -43,11 +34,8 @@ include(SetupBuildkite)
|
|||||||
include(SetupBun)
|
include(SetupBun)
|
||||||
include(SetupEsbuild)
|
include(SetupEsbuild)
|
||||||
include(SetupZig)
|
include(SetupZig)
|
||||||
|
include(SetupRust)
|
||||||
|
|
||||||
# --- Targets ---
|
# --- Targets ---
|
||||||
|
|
||||||
include(BuildBun)
|
include(BuildBun)
|
||||||
|
|
||||||
# --- Flags ---
|
|
||||||
|
|
||||||
include(CompilerFlags)
|
|
||||||
|
|||||||
@@ -1,57 +1,97 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
# clang: https://clang.llvm.org/docs/CommandGuide/clang.html
|
# clang: https://clang.llvm.org/docs/CommandGuide/clang.html
|
||||||
# clang-cl: https://clang.llvm.org/docs/UsersManual.html#id11
|
# clang-cl: https://clang.llvm.org/docs/UsersManual.html#id11
|
||||||
|
|
||||||
|
# --- Macros ---
|
||||||
|
|
||||||
|
macro(setb variable)
|
||||||
|
if(${variable})
|
||||||
|
set(${variable} ON)
|
||||||
|
else()
|
||||||
|
set(${variable} OFF)
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
set(targets WIN32 APPLE UNIX LINUX)
|
||||||
|
foreach(target ${targets})
|
||||||
|
setb(${target})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# --- CPU target ---
|
||||||
|
|
||||||
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM|arm64|ARM64|aarch64|AARCH64")
|
||||||
|
if(APPLE)
|
||||||
|
register_compiler_flags(-mcpu=apple-m1)
|
||||||
|
else()
|
||||||
|
register_compiler_flags(-march=armv8-a+crc -mtune=ampere1)
|
||||||
|
endif()
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|X86_64|x64|X64|amd64|AMD64")
|
||||||
|
if(ENABLE_BASELINE)
|
||||||
|
register_compiler_flags(-march=nehalem)
|
||||||
|
else()
|
||||||
|
register_compiler_flags(-march=haswell)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
unsupported(CMAKE_SYSTEM_PROCESSOR)
|
||||||
|
endif()
|
||||||
|
|
||||||
# --- MSVC runtime ---
|
# --- MSVC runtime ---
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
if(DEBUG)
|
register_compiler_flags(
|
||||||
add_compile_options(/MTd) # Use static debug run-time
|
DESCRIPTION "Use static MSVC runtime"
|
||||||
else()
|
/MTd ${DEBUG}
|
||||||
add_compile_options(/MT) # Use static run-time
|
/MT ${RELEASE}
|
||||||
endif()
|
/U_DLL
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- Optimization level ---
|
# --- Optimization level ---
|
||||||
|
|
||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
if(WIN32)
|
register_compiler_flags(
|
||||||
add_compile_options(/O0)
|
DESCRIPTION "Disable optimization"
|
||||||
else()
|
/O0 ${WIN32}
|
||||||
add_compile_options(-O0)
|
-O0 ${UNIX}
|
||||||
endif()
|
)
|
||||||
elseif(ENABLE_SMOL)
|
elseif(ENABLE_SMOL)
|
||||||
if(WIN32)
|
register_compiler_flags(
|
||||||
add_compile_options(/Os)
|
DESCRIPTION "Optimize for size"
|
||||||
else()
|
/Os ${WIN32}
|
||||||
add_compile_options(-Os)
|
-Os ${UNIX}
|
||||||
endif()
|
)
|
||||||
else()
|
else()
|
||||||
if(WIN32)
|
register_compiler_flags(
|
||||||
# TODO: change to /0t (same as -O3) to match macOS and Linux?
|
DESCRIPTION "Optimize for speed"
|
||||||
add_compile_options(/O2)
|
/O2 ${WIN32} # TODO: change to /0t (same as -O3) to match macOS and Linux?
|
||||||
else()
|
-O3 ${UNIX}
|
||||||
add_compile_options(-O3)
|
)
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- Debug symbols ---
|
# --- Debug level ---
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_compile_options(
|
register_compiler_flags(
|
||||||
/Z7 # Produce a .pdb file
|
DESCRIPTION "Enable debug symbols (.pdb)"
|
||||||
|
/Z7
|
||||||
)
|
)
|
||||||
else()
|
elseif(APPLE)
|
||||||
add_compile_options(
|
register_compiler_flags(
|
||||||
-ggdb # Produce a format that is compatable with GDB
|
DESCRIPTION "Enable debug symbols (.dSYM)"
|
||||||
-gdwarf-4 # Produce DWARF v4 debug info
|
-gdwarf-4
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Enable debug symbols"
|
||||||
|
-g3 ${DEBUG}
|
||||||
|
-g1 ${RELEASE}
|
||||||
|
)
|
||||||
|
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Optimize debug symbols for LLDB"
|
||||||
|
-glldb
|
||||||
)
|
)
|
||||||
if(DEBUG)
|
|
||||||
add_compile_options(-g3)
|
|
||||||
else()
|
|
||||||
add_compile_options(-g1)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# TODO: consider other debug options
|
# TODO: consider other debug options
|
||||||
@@ -59,44 +99,184 @@ endif()
|
|||||||
# -fstandalone-debug # Emit debug info for non-system libraries
|
# -fstandalone-debug # Emit debug info for non-system libraries
|
||||||
# -fno-eliminate-unused-debug-types # Don't eliminate unused debug symbols
|
# -fno-eliminate-unused-debug-types # Don't eliminate unused debug symbols
|
||||||
|
|
||||||
# --- RTTI ---
|
# --- C/C++ flags ---
|
||||||
|
|
||||||
if(WIN32)
|
register_compiler_flags(
|
||||||
add_compile_options(/GR-)
|
DESCRIPTION "Disable C/C++ exceptions"
|
||||||
else()
|
-fno-exceptions ${UNIX}
|
||||||
add_compile_options(-fno-rtti)
|
/EHsc ${WIN32} # (s- disables C++, c- disables C)
|
||||||
|
)
|
||||||
|
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Disable C++ static destructors"
|
||||||
|
LANGUAGES CXX
|
||||||
|
-Xclang ${WIN32}
|
||||||
|
-fno-c++-static-destructors
|
||||||
|
)
|
||||||
|
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Disable runtime type information (RTTI)"
|
||||||
|
/GR- ${WIN32}
|
||||||
|
-fno-rtti ${UNIX}
|
||||||
|
)
|
||||||
|
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Keep frame pointers"
|
||||||
|
/Oy- ${WIN32}
|
||||||
|
-fno-omit-frame-pointer ${UNIX}
|
||||||
|
-mno-omit-leaf-frame-pointer ${UNIX}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Set C/C++ visibility to hidden"
|
||||||
|
-fvisibility=hidden
|
||||||
|
-fvisibility-inlines-hidden
|
||||||
|
)
|
||||||
|
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Disable unwind tables"
|
||||||
|
-fno-unwind-tables
|
||||||
|
-fno-asynchronous-unwind-tables
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- CPU target (-march, -mtune, -mcpu) ---
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Place each function in its own section"
|
||||||
|
-ffunction-sections ${UNIX}
|
||||||
|
/Gy ${WIN32}
|
||||||
|
)
|
||||||
|
|
||||||
# Using -march=native can break older systems, instead use a specific CPU
|
register_compiler_flags(
|
||||||
if(CPU STREQUAL "native")
|
DESCRIPTION "Place each data item in its own section"
|
||||||
if(ARCH STREQUAL "aarch64")
|
-fdata-sections ${UNIX}
|
||||||
if(APPLE)
|
/Gw ${WIN32}
|
||||||
add_compile_options(-mcpu=apple-m1)
|
)
|
||||||
else()
|
|
||||||
add_compile_options(-march=armv8-a+crc -mtune=ampere1)
|
if(UNIX)
|
||||||
endif()
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Emit an address-significance table"
|
||||||
|
-faddrsig
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Enable string pooling"
|
||||||
|
/GF
|
||||||
|
)
|
||||||
|
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Assume thread-local variables are defined in the executable"
|
||||||
|
/GA
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# --- Linker flags ---
|
||||||
|
|
||||||
|
if(LINUX)
|
||||||
|
register_linker_flags(
|
||||||
|
DESCRIPTION "Disable relocation read-only (RELRO)"
|
||||||
|
-Wl,-z,norelro
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# --- Assertions ---
|
||||||
|
|
||||||
|
# Note: This is a helpful guide about assertions:
|
||||||
|
# https://best.openssf.org/Compiler-Hardening-Guides/Compiler-Options-Hardening-Guide-for-C-and-C++
|
||||||
|
|
||||||
|
if(ENABLE_ASSERTIONS)
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Do not eliminate null-pointer checks"
|
||||||
|
-fno-delete-null-pointer-checks
|
||||||
|
)
|
||||||
|
|
||||||
|
register_compiler_definitions(
|
||||||
|
DESCRIPTION "Enable libc++ assertions"
|
||||||
|
_LIBCPP_ENABLE_ASSERTIONS=1
|
||||||
|
_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE ${RELEASE}
|
||||||
|
_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG ${DEBUG}
|
||||||
|
)
|
||||||
|
|
||||||
|
register_compiler_definitions(
|
||||||
|
DESCRIPTION "Enable fortified sources"
|
||||||
|
_FORTIFY_SOURCE=3
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LINUX)
|
||||||
|
register_compiler_definitions(
|
||||||
|
DESCRIPTION "Enable glibc++ assertions"
|
||||||
|
_GLIBCXX_ASSERTIONS=1
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
elseif(CPU)
|
|
||||||
add_compile_options(-march=${CPU} -mtune=${CPU})
|
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "No CPU specified, please set -DCPU=<string>")
|
register_compiler_definitions(
|
||||||
|
DESCRIPTION "Disable debug assertions"
|
||||||
|
NDEBUG=1
|
||||||
|
)
|
||||||
|
|
||||||
|
register_compiler_definitions(
|
||||||
|
DESCRIPTION "Disable libc++ assertions"
|
||||||
|
_LIBCPP_ENABLE_ASSERTIONS=0
|
||||||
|
_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LINUX)
|
||||||
|
register_compiler_definitions(
|
||||||
|
DESCRIPTION "Disable glibc++ assertions"
|
||||||
|
_GLIBCXX_ASSERTIONS=0
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- Diagnostics ---
|
# --- Diagnostics ---
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(UNIX)
|
||||||
add_compile_options(-fdiagnostics-color=always)
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Enable color diagnostics"
|
||||||
|
-fdiagnostics-color=always
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_compile_options(-ferror-limit=${ERROR_LIMIT})
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Set C/C++ error limit"
|
||||||
|
-ferror-limit=${ERROR_LIMIT}
|
||||||
|
)
|
||||||
|
|
||||||
|
# --- LTO ---
|
||||||
|
|
||||||
|
if(ENABLE_LTO)
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Enable link-time optimization (LTO)"
|
||||||
|
-flto=full ${UNIX}
|
||||||
|
-flto ${WIN32}
|
||||||
|
)
|
||||||
|
|
||||||
|
if(UNIX)
|
||||||
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Enable virtual tables"
|
||||||
|
LANGUAGES CXX
|
||||||
|
-fforce-emit-vtables
|
||||||
|
-fwhole-program-vtables
|
||||||
|
)
|
||||||
|
|
||||||
|
register_linker_flags(
|
||||||
|
DESCRIPTION "Enable link-time optimization (LTO)"
|
||||||
|
-flto=full
|
||||||
|
-fwhole-program-vtables
|
||||||
|
-fforce-emit-vtables
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
# --- Remapping ---
|
# --- Remapping ---
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(UNIX)
|
||||||
add_compile_options(
|
register_compiler_flags(
|
||||||
|
DESCRIPTION "Remap source files"
|
||||||
-ffile-prefix-map=${CWD}=.
|
-ffile-prefix-map=${CWD}=.
|
||||||
|
-ffile-prefix-map=${VENDOR_PATH}=vendor
|
||||||
-ffile-prefix-map=${BUILD_PATH}=build
|
-ffile-prefix-map=${BUILD_PATH}=build
|
||||||
-ffile-prefix-map=${CACHE_PATH}=cache
|
-ffile-prefix-map=${CACHE_PATH}=cache
|
||||||
)
|
)
|
||||||
@@ -107,7 +287,7 @@ endif()
|
|||||||
# Valgrind cannot handle SSE4.2 instructions
|
# Valgrind cannot handle SSE4.2 instructions
|
||||||
# This is needed for picohttpparser
|
# This is needed for picohttpparser
|
||||||
if(ENABLE_VALGRIND AND ARCH STREQUAL "x64")
|
if(ENABLE_VALGRIND AND ARCH STREQUAL "x64")
|
||||||
add_compile_definitions("__SSE4_2__=0")
|
register_compiler_definitions(__SSE4_2__=0)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- Other ---
|
# --- Other ---
|
||||||
@@ -118,28 +298,9 @@ if(WIN32 AND NOT CMAKE_CL_SHOWINCLUDES_PREFIX)
|
|||||||
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file:")
|
set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file:")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ENABLE_ASSERTIONS)
|
|
||||||
if(APPLE)
|
|
||||||
# add_compile_definitions("_LIBCXX_ENABLE_ASSERTIONS=1")
|
|
||||||
# add_compile_definitions("_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG")
|
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
|
||||||
add_compile_definitions("_GLIBCXX_ASSERTIONS=1")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_compile_definitions("ASSERT_ENABLED=1")
|
|
||||||
else()
|
|
||||||
if(APPLE)
|
|
||||||
# add_compile_definitions("_LIBCXX_ENABLE_ASSERTIONS=0")
|
|
||||||
# add_compile_definitions("_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_compile_definitions("NDEBUG=1")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# WebKit uses -std=gnu++20 on non-macOS non-Windows.
|
# WebKit uses -std=gnu++20 on non-macOS non-Windows.
|
||||||
# If we do not set this, it will crash at startup on the first memory allocation.
|
# If we do not set this, it will crash at startup on the first memory allocation.
|
||||||
if(NOT WIN32 AND NOT APPLE)
|
if(NOT WIN32 AND NOT APPLE)
|
||||||
set(CMAKE_CXX_EXTENSIONS ON)
|
set(CMAKE_CXX_EXTENSIONS ON)
|
||||||
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,142 @@
|
|||||||
include(CMakeParseArguments)
|
include(CMakeParseArguments)
|
||||||
|
|
||||||
|
# --- Global macros ---
|
||||||
|
|
||||||
|
# setx()
|
||||||
|
# Description:
|
||||||
|
# Sets a variable, similar to `set()`, but also prints the value.
|
||||||
|
# Arguments:
|
||||||
|
# variable string - The variable to set
|
||||||
|
# value string - The value to set the variable to
|
||||||
|
macro(setx)
|
||||||
|
set(${ARGV})
|
||||||
|
message(STATUS "Set ${ARGV0}: ${${ARGV0}}")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# optionx()
|
||||||
|
# Description:
|
||||||
|
# Defines an option, similar to `option()`, but allows for bool, string, and regex types.
|
||||||
|
# Arguments:
|
||||||
|
# variable string - The variable to set
|
||||||
|
# type string - The type of the variable
|
||||||
|
# description string - The description of the variable
|
||||||
|
# DEFAULT string - The default value of the variable
|
||||||
|
# PREVIEW string - The preview value of the variable
|
||||||
|
# REGEX string - The regex to match the value
|
||||||
|
# REQUIRED bool - Whether the variable is required
|
||||||
|
macro(optionx variable type description)
|
||||||
|
set(options REQUIRED)
|
||||||
|
set(oneValueArgs DEFAULT PREVIEW REGEX)
|
||||||
|
set(multiValueArgs)
|
||||||
|
cmake_parse_arguments(${variable} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT ${type} MATCHES "^(BOOL|STRING|FILEPATH|PATH|INTERNAL)$")
|
||||||
|
set(${variable}_REGEX ${type})
|
||||||
|
set(${variable}_TYPE STRING)
|
||||||
|
else()
|
||||||
|
set(${variable}_TYPE ${type})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${variable} ${${variable}_DEFAULT} CACHE ${${variable}_TYPE} ${description})
|
||||||
|
set(${variable}_SOURCE "argument")
|
||||||
|
set(${variable}_PREVIEW -D${variable})
|
||||||
|
|
||||||
|
if(DEFINED ENV{${variable}})
|
||||||
|
set(${variable} $ENV{${variable}} CACHE ${${variable}_TYPE} ${description} FORCE)
|
||||||
|
set(${variable}_SOURCE "environment variable")
|
||||||
|
set(${variable}_PREVIEW ${variable})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ${variable} AND ${${variable}_REQUIRED})
|
||||||
|
message(FATAL_ERROR "Required ${${variable}_SOURCE} is missing: please set, ${${variable}_PREVIEW}=<${${variable}_REGEX}>")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${type} STREQUAL "BOOL")
|
||||||
|
if("${${variable}}" MATCHES "^(TRUE|true|ON|on|YES|yes|1)$")
|
||||||
|
set(${variable} ON)
|
||||||
|
elseif("${${variable}}" MATCHES "^(FALSE|false|OFF|off|NO|no|0)$")
|
||||||
|
set(${variable} OFF)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Invalid ${${variable}_SOURCE}: ${${variable}_PREVIEW}=\"${${variable}}\", please use ${${variable}_PREVIEW}=<ON|OFF>")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED ${variable}_REGEX AND NOT "^(${${variable}_REGEX})$" MATCHES "${${variable}}")
|
||||||
|
message(FATAL_ERROR "Invalid ${${variable}_SOURCE}: ${${variable}_PREVIEW}=\"${${variable}}\", please use ${${variable}_PREVIEW}=<${${variable}_REGEX}>")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Set ${variable}: ${${variable}}")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# unsupported()
|
||||||
|
# Description:
|
||||||
|
# Prints a message that the feature is not supported.
|
||||||
|
# Arguments:
|
||||||
|
# variable string - The variable that is not supported
|
||||||
|
macro(unsupported variable)
|
||||||
|
message(FATAL_ERROR "Unsupported ${variable}: \"${${variable}}\"")
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# --- CMake variables ---
|
||||||
|
|
||||||
|
setx(CMAKE_VERSION ${CMAKE_VERSION})
|
||||||
|
setx(CMAKE_COMMAND ${CMAKE_COMMAND})
|
||||||
|
setx(CMAKE_HOST_SYSTEM_NAME ${CMAKE_HOST_SYSTEM_NAME})
|
||||||
|
|
||||||
|
# In script mode, using -P, this variable is not set
|
||||||
|
if(NOT DEFINED CMAKE_HOST_SYSTEM_PROCESSOR)
|
||||||
|
cmake_host_system_information(RESULT CMAKE_HOST_SYSTEM_PROCESSOR QUERY OS_PLATFORM)
|
||||||
|
endif()
|
||||||
|
setx(CMAKE_HOST_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR})
|
||||||
|
|
||||||
|
if(CMAKE_HOST_APPLE)
|
||||||
|
set(HOST_OS "darwin")
|
||||||
|
elseif(CMAKE_HOST_WIN32)
|
||||||
|
set(HOST_OS "windows")
|
||||||
|
elseif(CMAKE_HOST_LINUX)
|
||||||
|
set(HOST_OS "linux")
|
||||||
|
else()
|
||||||
|
unsupported(CMAKE_HOST_SYSTEM_NAME)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64|ARM64|aarch64|AARCH64")
|
||||||
|
set(HOST_OS "aarch64")
|
||||||
|
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64|X86_64|x64|X64|amd64|AMD64")
|
||||||
|
set(HOST_OS "x64")
|
||||||
|
else()
|
||||||
|
unsupported(CMAKE_HOST_SYSTEM_PROCESSOR)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
setx(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
setx(CMAKE_COLOR_DIAGNOSTICS ON)
|
||||||
|
|
||||||
|
cmake_host_system_information(RESULT CORE_COUNT QUERY NUMBER_OF_LOGICAL_CORES)
|
||||||
|
optionx(CMAKE_BUILD_PARALLEL_LEVEL STRING "The number of parallel build jobs" DEFAULT ${CORE_COUNT})
|
||||||
|
|
||||||
|
# --- Global variables ---
|
||||||
|
|
||||||
|
setx(CWD ${CMAKE_SOURCE_DIR})
|
||||||
|
setx(BUILD_PATH ${CMAKE_BINARY_DIR})
|
||||||
|
|
||||||
|
optionx(CACHE_PATH FILEPATH "The path to the cache directory" DEFAULT ${BUILD_PATH}/cache)
|
||||||
|
optionx(CACHE_STRATEGY "read-write|read-only|write-only|none" "The strategy to use for caching" DEFAULT "read-write")
|
||||||
|
|
||||||
|
optionx(CI BOOL "If CI is enabled" DEFAULT OFF)
|
||||||
|
|
||||||
|
if(CI)
|
||||||
|
set(DEFAULT_VENDOR_PATH ${CACHE_PATH}/vendor)
|
||||||
|
else()
|
||||||
|
set(DEFAULT_VENDOR_PATH ${CWD}/vendor)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
optionx(VENDOR_PATH FILEPATH "The path to the vendor directory" DEFAULT ${DEFAULT_VENDOR_PATH})
|
||||||
|
optionx(TMP_PATH FILEPATH "The path to the temporary directory" DEFAULT ${BUILD_PATH}/tmp)
|
||||||
|
|
||||||
|
optionx(FRESH BOOL "Set when --fresh is used" DEFAULT OFF)
|
||||||
|
optionx(CLEAN BOOL "Set when --clean is used" DEFAULT OFF)
|
||||||
|
|
||||||
|
# --- Helper functions ---
|
||||||
|
|
||||||
function(parse_semver value variable)
|
function(parse_semver value variable)
|
||||||
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" match "${value}")
|
string(REGEX MATCH "([0-9]+)\\.([0-9]+)\\.([0-9]+)" match "${value}")
|
||||||
|
|
||||||
@@ -13,17 +150,6 @@ function(parse_semver value variable)
|
|||||||
set(${variable}_VERSION_PATCH "${CMAKE_MATCH_3}" PARENT_SCOPE)
|
set(${variable}_VERSION_PATCH "${CMAKE_MATCH_3}" PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# setx()
|
|
||||||
# Description:
|
|
||||||
# Sets a variable, similar to `set()`, but also prints the value.
|
|
||||||
# Arguments:
|
|
||||||
# variable string - The variable to set
|
|
||||||
# value string - The value to set the variable to
|
|
||||||
macro(setx)
|
|
||||||
set(${ARGV})
|
|
||||||
message(STATUS "Set ${ARGV0}: ${${ARGV0}}")
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# setenv()
|
# setenv()
|
||||||
# Description:
|
# Description:
|
||||||
# Sets an environment variable during the build step, and writes it to a .env file.
|
# Sets an environment variable during the build step, and writes it to a .env file.
|
||||||
@@ -61,65 +187,6 @@ function(setenv variable value)
|
|||||||
message(STATUS "Set ENV ${variable}: ${value}")
|
message(STATUS "Set ENV ${variable}: ${value}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# optionx()
|
|
||||||
# Description:
|
|
||||||
# Defines an option, similar to `option()`, but allows for bool, string, and regex types.
|
|
||||||
# Arguments:
|
|
||||||
# variable string - The variable to set
|
|
||||||
# type string - The type of the variable
|
|
||||||
# description string - The description of the variable
|
|
||||||
# DEFAULT string - The default value of the variable
|
|
||||||
# PREVIEW string - The preview value of the variable
|
|
||||||
# REGEX string - The regex to match the value
|
|
||||||
# REQUIRED bool - Whether the variable is required
|
|
||||||
macro(optionx variable type description)
|
|
||||||
set(options REQUIRED)
|
|
||||||
set(oneValueArgs DEFAULT PREVIEW REGEX)
|
|
||||||
set(multiValueArgs)
|
|
||||||
cmake_parse_arguments(${variable} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
||||||
|
|
||||||
if(NOT ${type} MATCHES "^(BOOL|STRING|FILEPATH|PATH|INTERNAL)$")
|
|
||||||
set(${variable}_REGEX ${type})
|
|
||||||
set(${variable}_TYPE STRING)
|
|
||||||
else()
|
|
||||||
set(${variable}_TYPE ${type})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(${variable} ${${variable}_DEFAULT} CACHE ${${variable}_TYPE} ${description})
|
|
||||||
set(${variable}_SOURCE "argument")
|
|
||||||
set(${variable}_PREVIEW -D${variable})
|
|
||||||
|
|
||||||
if(DEFINED ENV{${variable}})
|
|
||||||
# if(DEFINED ${variable} AND NOT ${variable} STREQUAL $ENV{${variable}})
|
|
||||||
# message(FATAL_ERROR "Invalid ${${variable}_SOURCE}: ${${variable}_PREVIEW}=\"${${variable}}\" conflicts with environment variable ${variable}=\"$ENV{${variable}}\"")
|
|
||||||
# endif()
|
|
||||||
|
|
||||||
set(${variable} $ENV{${variable}} CACHE ${${variable}_TYPE} ${description} FORCE)
|
|
||||||
set(${variable}_SOURCE "environment variable")
|
|
||||||
set(${variable}_PREVIEW ${variable})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT ${variable} AND ${${variable}_REQUIRED})
|
|
||||||
message(FATAL_ERROR "Required ${${variable}_SOURCE} is missing: please set, ${${variable}_PREVIEW}=<${${variable}_REGEX}>")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${type} STREQUAL "BOOL")
|
|
||||||
if("${${variable}}" MATCHES "^(TRUE|true|ON|on|YES|yes|1)$")
|
|
||||||
set(${variable} ON)
|
|
||||||
elseif("${${variable}}" MATCHES "^(FALSE|false|OFF|off|NO|no|0)$")
|
|
||||||
set(${variable} OFF)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Invalid ${${variable}_SOURCE}: ${${variable}_PREVIEW}=\"${${variable}}\", please use ${${variable}_PREVIEW}=<ON|OFF>")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(DEFINED ${variable}_REGEX AND NOT "^(${${variable}_REGEX})$" MATCHES "${${variable}}")
|
|
||||||
message(FATAL_ERROR "Invalid ${${variable}_SOURCE}: ${${variable}_PREVIEW}=\"${${variable}}\", please use ${${variable}_PREVIEW}=<${${variable}_REGEX}>")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
message(STATUS "Set ${variable}: ${${variable}}")
|
|
||||||
endmacro()
|
|
||||||
|
|
||||||
# check_command()
|
# check_command()
|
||||||
# Description:
|
# Description:
|
||||||
# Checks if a command is available, used by `find_command()` as a validator.
|
# Checks if a command is available, used by `find_command()` as a validator.
|
||||||
@@ -142,7 +209,7 @@ function(check_command FOUND CMD)
|
|||||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT RESULT EQUAL 0)
|
if(NOT RESULT EQUAL 0 OR NOT OUTPUT)
|
||||||
message(DEBUG "${CHECK_COMMAND}, exited with code ${RESULT}")
|
message(DEBUG "${CHECK_COMMAND}, exited with code ${RESULT}")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
@@ -212,7 +279,11 @@ function(find_command)
|
|||||||
message(FATAL_ERROR "Command not found: \"${CMD_COMMAND}\"")
|
message(FATAL_ERROR "Command not found: \"${CMD_COMMAND}\"")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
setx(${CMD_VARIABLE} ${${CMD_VARIABLE}})
|
if(${CMD_VARIABLE} MATCHES "NOTFOUND")
|
||||||
|
unset(${CMD_VARIABLE} PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
setx(${CMD_VARIABLE} ${${CMD_VARIABLE}} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# register_command()
|
# register_command()
|
||||||
@@ -272,7 +343,7 @@ function(register_command)
|
|||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(source ${CMD_SOURCES})
|
foreach(source ${CMD_SOURCES})
|
||||||
if(NOT source MATCHES "^(${CWD}|${BUILD_PATH})")
|
if(NOT source MATCHES "^(${CWD}|${BUILD_PATH}|${CACHE_PATH}|${VENDOR_PATH})")
|
||||||
message(FATAL_ERROR "register_command: SOURCES contains \"${source}\", if it's a path, make it absolute, otherwise add it to TARGETS instead")
|
message(FATAL_ERROR "register_command: SOURCES contains \"${source}\", if it's a path, make it absolute, otherwise add it to TARGETS instead")
|
||||||
endif()
|
endif()
|
||||||
list(APPEND CMD_EFFECTIVE_DEPENDS ${source})
|
list(APPEND CMD_EFFECTIVE_DEPENDS ${source})
|
||||||
@@ -285,14 +356,14 @@ function(register_command)
|
|||||||
set(CMD_EFFECTIVE_OUTPUTS)
|
set(CMD_EFFECTIVE_OUTPUTS)
|
||||||
|
|
||||||
foreach(output ${CMD_OUTPUTS})
|
foreach(output ${CMD_OUTPUTS})
|
||||||
if(NOT output MATCHES "^(${CWD}|${BUILD_PATH})")
|
if(NOT output MATCHES "^(${CWD}|${BUILD_PATH}|${CACHE_PATH}|${VENDOR_PATH})")
|
||||||
message(FATAL_ERROR "register_command: OUTPUTS contains \"${output}\", if it's a path, make it absolute")
|
message(FATAL_ERROR "register_command: OUTPUTS contains \"${output}\", if it's a path, make it absolute")
|
||||||
endif()
|
endif()
|
||||||
list(APPEND CMD_EFFECTIVE_OUTPUTS ${output})
|
list(APPEND CMD_EFFECTIVE_OUTPUTS ${output})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
foreach(artifact ${CMD_ARTIFACTS})
|
foreach(artifact ${CMD_ARTIFACTS})
|
||||||
if(NOT artifact MATCHES "^(${CWD}|${BUILD_PATH})")
|
if(NOT artifact MATCHES "^(${CWD}|${BUILD_PATH}|${CACHE_PATH}|${VENDOR_PATH})")
|
||||||
message(FATAL_ERROR "register_command: ARTIFACTS contains \"${artifact}\", if it's a path, make it absolute")
|
message(FATAL_ERROR "register_command: ARTIFACTS contains \"${artifact}\", if it's a path, make it absolute")
|
||||||
endif()
|
endif()
|
||||||
list(APPEND CMD_EFFECTIVE_OUTPUTS ${artifact})
|
list(APPEND CMD_EFFECTIVE_OUTPUTS ${artifact})
|
||||||
@@ -501,7 +572,7 @@ function(register_repository)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT GIT_PATH)
|
if(NOT GIT_PATH)
|
||||||
set(GIT_PATH ${CWD}/vendor/${GIT_NAME})
|
set(GIT_PATH ${VENDOR_PATH}/${GIT_NAME})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(GIT_COMMIT)
|
if(GIT_COMMIT)
|
||||||
@@ -562,7 +633,7 @@ function(register_cmake_command)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT MAKE_CWD)
|
if(NOT MAKE_CWD)
|
||||||
set(MAKE_CWD ${CWD}/vendor/${MAKE_TARGET})
|
set(MAKE_CWD ${VENDOR_PATH}/${MAKE_TARGET})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT MAKE_BUILD_PATH)
|
if(NOT MAKE_BUILD_PATH)
|
||||||
@@ -621,7 +692,7 @@ function(register_cmake_command)
|
|||||||
|
|
||||||
set(effectiveFlags ${setFlags} ${appendFlags})
|
set(effectiveFlags ${setFlags} ${appendFlags})
|
||||||
foreach(flag ${effectiveFlags})
|
foreach(flag ${effectiveFlags})
|
||||||
list(APPEND MAKE_EFFECTIVE_ARGS -DCMAKE_${flag}=${MAKE_${flag}})
|
list(APPEND MAKE_EFFECTIVE_ARGS "-DCMAKE_${flag}=${MAKE_${flag}}")
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
if(DEFINED FRESH)
|
if(DEFINED FRESH)
|
||||||
@@ -706,3 +777,116 @@ function(register_cmake_command)
|
|||||||
target_sources(${bun} PRIVATE ${MAKE_ARTIFACTS})
|
target_sources(${bun} PRIVATE ${MAKE_ARTIFACTS})
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# register_compiler_flag()
|
||||||
|
# Description:
|
||||||
|
# Registers a compiler flag, similar to `add_compile_options()`, but has more validation and features.
|
||||||
|
# Arguments:
|
||||||
|
# flags string[] - The flags to register
|
||||||
|
# DESCRIPTION string - The description of the flag
|
||||||
|
# LANGUAGES string[] - The languages to register the flag (default: C, CXX)
|
||||||
|
# TARGETS string[] - The targets to register the flag (default: all)
|
||||||
|
function(register_compiler_flags)
|
||||||
|
set(args DESCRIPTION)
|
||||||
|
set(multiArgs LANGUAGES TARGETS)
|
||||||
|
cmake_parse_arguments(COMPILER "" "${args}" "${multiArgs}" ${ARGN})
|
||||||
|
|
||||||
|
if(NOT COMPILER_LANGUAGES)
|
||||||
|
set(COMPILER_LANGUAGES C CXX)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(COMPILER_FLAGS)
|
||||||
|
foreach(flag ${COMPILER_UNPARSED_ARGUMENTS})
|
||||||
|
if(flag STREQUAL "ON")
|
||||||
|
continue()
|
||||||
|
elseif(flag STREQUAL "OFF")
|
||||||
|
list(POP_BACK COMPILER_FLAGS)
|
||||||
|
elseif(flag MATCHES "^(-|/)")
|
||||||
|
list(APPEND COMPILER_FLAGS ${flag})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "register_compiler_flags: Invalid flag: \"${flag}\"")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(target ${COMPILER_TARGETS})
|
||||||
|
if(NOT TARGET ${target})
|
||||||
|
message(FATAL_ERROR "register_compiler_flags: \"${target}\" is not a target")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(lang ${COMPILER_LANGUAGES})
|
||||||
|
list(JOIN COMPILER_FLAGS " " COMPILER_FLAGS_STRING)
|
||||||
|
|
||||||
|
if(NOT COMPILER_TARGETS)
|
||||||
|
set(CMAKE_${lang}_FLAGS "${CMAKE_${lang}_FLAGS} ${COMPILER_FLAGS_STRING}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(target ${COMPILER_TARGETS})
|
||||||
|
set(${target}_CMAKE_${lang}_FLAGS "${${target}_CMAKE_${lang}_FLAGS} ${COMPILER_FLAGS_STRING}" PARENT_SCOPE)
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(lang ${COMPILER_LANGUAGES})
|
||||||
|
foreach(flag ${COMPILER_FLAGS})
|
||||||
|
if(NOT COMPILER_TARGETS)
|
||||||
|
add_compile_options($<$<COMPILE_LANGUAGE:${lang}>:${flag}>)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(target ${COMPILER_TARGETS})
|
||||||
|
get_target_property(type ${target} TYPE)
|
||||||
|
if(type MATCHES "EXECUTABLE|LIBRARY")
|
||||||
|
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:${lang}>:${flag}>)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(register_compiler_definitions)
|
||||||
|
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# register_linker_flags()
|
||||||
|
# Description:
|
||||||
|
# Registers a linker flag, similar to `add_link_options()`.
|
||||||
|
# Arguments:
|
||||||
|
# flags string[] - The flags to register
|
||||||
|
# DESCRIPTION string - The description of the flag
|
||||||
|
function(register_linker_flags)
|
||||||
|
set(args DESCRIPTION)
|
||||||
|
cmake_parse_arguments(LINKER "" "${args}" "" ${ARGN})
|
||||||
|
|
||||||
|
foreach(flag ${LINKER_UNPARSED_ARGUMENTS})
|
||||||
|
if(flag STREQUAL "ON")
|
||||||
|
continue()
|
||||||
|
elseif(flag STREQUAL "OFF")
|
||||||
|
list(POP_FRONT LINKER_FLAGS)
|
||||||
|
elseif(flag MATCHES "^(-|/)")
|
||||||
|
list(APPEND LINKER_FLAGS ${flag})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "register_linker_flags: Invalid flag: \"${flag}\"")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_link_options(${LINKER_FLAGS})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(print_compiler_flags)
|
||||||
|
get_property(targets DIRECTORY PROPERTY BUILDSYSTEM_TARGETS)
|
||||||
|
set(languages C CXX)
|
||||||
|
foreach(target ${targets})
|
||||||
|
get_target_property(type ${target} TYPE)
|
||||||
|
message(STATUS "Target: ${target}")
|
||||||
|
foreach(lang ${languages})
|
||||||
|
if(${target}_CMAKE_${lang}_FLAGS)
|
||||||
|
message(STATUS " ${lang} Flags: ${${target}_CMAKE_${lang}_FLAGS}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endforeach()
|
||||||
|
foreach(lang ${languages})
|
||||||
|
message(STATUS "Language: ${lang}")
|
||||||
|
if(CMAKE_${lang}_FLAGS)
|
||||||
|
message(STATUS " Flags: ${CMAKE_${lang}_FLAGS}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endfunction()
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
if(NOT CMAKE_SYSTEM_NAME OR NOT CMAKE_SYSTEM_PROCESSOR)
|
if(NOT CMAKE_SYSTEM_NAME OR NOT CMAKE_SYSTEM_PROCESSOR)
|
||||||
message(FATAL_ERROR "CMake included this file before project() was called")
|
message(FATAL_ERROR "CMake included this file before project() was called")
|
||||||
endif()
|
endif()
|
||||||
@@ -7,7 +5,6 @@ endif()
|
|||||||
optionx(BUN_LINK_ONLY BOOL "If only the linking step should be built" DEFAULT OFF)
|
optionx(BUN_LINK_ONLY BOOL "If only the linking step should be built" DEFAULT OFF)
|
||||||
optionx(BUN_CPP_ONLY BOOL "If only the C++ part of Bun should be built" DEFAULT OFF)
|
optionx(BUN_CPP_ONLY BOOL "If only the C++ part of Bun should be built" DEFAULT OFF)
|
||||||
|
|
||||||
optionx(CI BOOL "If CI is enabled" DEFAULT OFF)
|
|
||||||
optionx(BUILDKITE BOOL "If Buildkite is enabled" DEFAULT OFF)
|
optionx(BUILDKITE BOOL "If Buildkite is enabled" DEFAULT OFF)
|
||||||
optionx(GITHUB_ACTIONS BOOL "If GitHub Actions is enabled" DEFAULT OFF)
|
optionx(GITHUB_ACTIONS BOOL "If GitHub Actions is enabled" DEFAULT OFF)
|
||||||
|
|
||||||
@@ -34,10 +31,6 @@ if(CMAKE_BUILD_TYPE MATCHES "MinSizeRel")
|
|||||||
setx(ENABLE_SMOL ON)
|
setx(ENABLE_SMOL ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_host_system_information(RESULT CORE_COUNT QUERY NUMBER_OF_LOGICAL_CORES)
|
|
||||||
|
|
||||||
optionx(CMAKE_BUILD_PARALLEL_LEVEL STRING "The number of parallel build jobs" DEFAULT ${CORE_COUNT})
|
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
setx(OS "darwin")
|
setx(OS "darwin")
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
@@ -60,16 +53,6 @@ if(ARCH STREQUAL "x64")
|
|||||||
optionx(ENABLE_BASELINE BOOL "If baseline features should be used for older CPUs (e.g. disables AVX, AVX2)" DEFAULT OFF)
|
optionx(ENABLE_BASELINE BOOL "If baseline features should be used for older CPUs (e.g. disables AVX, AVX2)" DEFAULT OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ARCH STREQUAL "aarch64")
|
|
||||||
set(DEFAULT_CPU "native")
|
|
||||||
elseif(ENABLE_BASELINE)
|
|
||||||
set(DEFAULT_CPU "nehalem")
|
|
||||||
else()
|
|
||||||
set(DEFAULT_CPU "haswell")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
optionx(CPU STRING "The CPU to use for the compiler" DEFAULT ${DEFAULT_CPU})
|
|
||||||
|
|
||||||
optionx(ENABLE_LOGS BOOL "If debug logs should be enabled" DEFAULT ${DEBUG})
|
optionx(ENABLE_LOGS BOOL "If debug logs should be enabled" DEFAULT ${DEBUG})
|
||||||
optionx(ENABLE_ASSERTIONS BOOL "If debug assertions should be enabled" DEFAULT ${DEBUG})
|
optionx(ENABLE_ASSERTIONS BOOL "If debug assertions should be enabled" DEFAULT ${DEBUG})
|
||||||
|
|
||||||
@@ -170,51 +153,5 @@ optionx(USE_WEBKIT_ICU BOOL "Use the ICU libraries from WebKit" DEFAULT ${DEFAUL
|
|||||||
|
|
||||||
optionx(ERROR_LIMIT STRING "Maximum number of errors to show when compiling C++ code" DEFAULT "100")
|
optionx(ERROR_LIMIT STRING "Maximum number of errors to show when compiling C++ code" DEFAULT "100")
|
||||||
|
|
||||||
# Set the CMAKE_C_FLAGS and CMAKE_CXX_FLAGS for building dependencies.
|
|
||||||
# This is a mess, since it doesn't use the CMake add_compile_options or target_compile_options commands.
|
|
||||||
# In the future, make some macros so we can set this automatically.
|
|
||||||
# e.g.
|
|
||||||
# add_c_flags(-mtune=native) - applies to all dependencies
|
|
||||||
# add_c_flags({target} -fno-rtti) - applies to a specific target
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|arm64|arm|ARM64")
|
|
||||||
if(APPLE)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=apple-m1")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=apple-m1")
|
|
||||||
else()
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=armv8-a+crc -mtune=ampere1")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=armv8-a+crc -mtune=ampere1")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mtune=${CPU}")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mtune=${CPU}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
list(APPEND CMAKE_ARGS -DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
|
list(APPEND CMAKE_ARGS -DCMAKE_EXPORT_COMPILE_COMMANDS=ON)
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
list(APPEND CMAKE_ARGS -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Z7 /MT /Ob2 /DNDEBUG /U_DLL")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Z7 /MT /Ob2 /DNDEBUG /U_DLL -Xclang -fno-c++-static-destructors")
|
|
||||||
if(ENABLE_LTO)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fuse-ld=lld -flto -Xclang -emit-llvm-bc")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fuse-ld=lld -flto -Xclang -emit-llvm-bc")
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidden -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-asynchronous-unwind-tables -fno-unwind-tables")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -fno-asynchronous-unwind-tables -fno-unwind-tables -fno-c++-static-destructors")
|
|
||||||
if(ENABLE_LTO)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto=full")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto=full -fwhole-program-vtables -fforce-emit-vtables")
|
|
||||||
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -flto=full -fwhole-program-vtables -fforce-emit-vtables")
|
|
||||||
endif()
|
|
||||||
if(LINUX)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections -faddrsig")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffunction-sections -fdata-sections -faddrsig")
|
|
||||||
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -Wl,-z,norelro")
|
|
||||||
endif()
|
|
||||||
if(APPLE)
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_LIBCXX_ENABLE_ASSERTIONS=0 -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
# https://clang.llvm.org/extra/clang-tidy/
|
# https://clang.llvm.org/extra/clang-tidy/
|
||||||
|
|
||||||
include(Macros)
|
|
||||||
|
|
||||||
find_command(
|
find_command(
|
||||||
VARIABLE
|
VARIABLE
|
||||||
CLANG_TIDY_PROGRAM
|
CLANG_TIDY_PROGRAM
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
# https://cppcheck.sourceforge.io/
|
# https://cppcheck.sourceforge.io/
|
||||||
|
|
||||||
include(Macros)
|
|
||||||
|
|
||||||
find_command(
|
find_command(
|
||||||
VARIABLE
|
VARIABLE
|
||||||
CPPCHECK_EXECUTABLE
|
CPPCHECK_EXECUTABLE
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
find_command(
|
find_command(
|
||||||
VARIABLE
|
VARIABLE
|
||||||
CPPLINT_PROGRAM
|
CPPLINT_PROGRAM
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
# IWYU = "Include What You Use"
|
# IWYU = "Include What You Use"
|
||||||
# https://include-what-you-use.org/
|
# https://include-what-you-use.org/
|
||||||
|
|
||||||
include(Macros)
|
|
||||||
|
|
||||||
setx(IWYU_SOURCE_PATH ${CACHE_PATH}/iwyu-${LLVM_VERSION_MAJOR})
|
setx(IWYU_SOURCE_PATH ${CACHE_PATH}/iwyu-${LLVM_VERSION_MAJOR})
|
||||||
setx(IWYU_BUILD_PATH ${IWYU_SOURCE_PATH}/build)
|
setx(IWYU_BUILD_PATH ${IWYU_SOURCE_PATH}/build)
|
||||||
setx(IWYU_PROGRAM ${IWYU_BUILD_PATH}/bin/include-what-you-use)
|
setx(IWYU_PROGRAM ${IWYU_BUILD_PATH}/bin/include-what-you-use)
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include(cmake/Macros.cmake)
|
include(cmake/Globals.cmake)
|
||||||
|
|
||||||
if(NOT GIT_PATH OR NOT GIT_REPOSITORY OR NOT GIT_REF)
|
if(NOT GIT_PATH OR NOT GIT_REPOSITORY OR NOT GIT_REF)
|
||||||
message(FATAL_ERROR "git_clone: GIT_PATH, GIT_REPOSITORY, and GIT_REF are required")
|
message(FATAL_ERROR "git_clone: GIT_PATH, GIT_REPOSITORY, and GIT_REF are required")
|
||||||
@@ -33,6 +33,7 @@ foreach(i RANGE 10)
|
|||||||
${GIT_DOWNLOAD_TMP_PATH}
|
${GIT_DOWNLOAD_TMP_PATH}
|
||||||
TIMEOUT 120
|
TIMEOUT 120
|
||||||
STATUS GIT_DOWNLOAD_STATUS
|
STATUS GIT_DOWNLOAD_STATUS
|
||||||
|
SHOW_PROGRESS
|
||||||
)
|
)
|
||||||
if(GIT_DOWNLOAD_STATUS MATCHES "^0")
|
if(GIT_DOWNLOAD_STATUS MATCHES "^0")
|
||||||
file(RENAME ${GIT_DOWNLOAD_TMP_PATH} ${GIT_DOWNLOAD_PATH})
|
file(RENAME ${GIT_DOWNLOAD_TMP_PATH} ${GIT_DOWNLOAD_PATH})
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
boringssl
|
boringssl
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
brotli
|
brotli
|
||||||
@@ -9,6 +7,12 @@ register_repository(
|
|||||||
v1.1.0
|
v1.1.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Tests fail with "BrotliDecompressionError" when LTO is enabled
|
||||||
|
# only on Linux x64 (non-baseline). It's a mystery.
|
||||||
|
if(LINUX AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|X86_64|x64|X64|amd64|AMD64" AND NOT ENABLE_BASELINE)
|
||||||
|
set(BROTLI_CMAKE_ARGS "-DCMAKE_C_FLAGS=-fno-lto")
|
||||||
|
endif()
|
||||||
|
|
||||||
register_cmake_command(
|
register_cmake_command(
|
||||||
TARGET
|
TARGET
|
||||||
brotli
|
brotli
|
||||||
@@ -21,6 +25,7 @@ register_cmake_command(
|
|||||||
-DBROTLI_BUILD_TOOLS=OFF
|
-DBROTLI_BUILD_TOOLS=OFF
|
||||||
-DBROTLI_EMSCRIPTEN=OFF
|
-DBROTLI_EMSCRIPTEN=OFF
|
||||||
-DBROTLI_DISABLE_TESTS=ON
|
-DBROTLI_DISABLE_TESTS=ON
|
||||||
|
${BROTLI_CMAKE_ARGS}
|
||||||
INCLUDES
|
INCLUDES
|
||||||
c/include
|
c/include
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
set(bun bun-debug)
|
set(bun bun-debug)
|
||||||
elseif(ENABLE_SMOL)
|
elseif(ENABLE_SMOL)
|
||||||
@@ -496,8 +494,8 @@ list(APPEND BUN_ZIG_SOURCES
|
|||||||
${BUN_JAVASCRIPT_OUTPUTS}
|
${BUN_JAVASCRIPT_OUTPUTS}
|
||||||
)
|
)
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
# In debug builds, these are not embedded, but rather referenced at runtime.
|
||||||
# in a debug build, these are not embedded, but rather referenced at runtime.
|
if (DEBUG)
|
||||||
list(APPEND BUN_ZIG_SOURCES ${CODEGEN_PATH}/kit_empty_file)
|
list(APPEND BUN_ZIG_SOURCES ${CODEGEN_PATH}/kit_empty_file)
|
||||||
else()
|
else()
|
||||||
list(APPEND BUN_ZIG_SOURCES ${BUN_KIT_RUNTIME_OUTPUTS})
|
list(APPEND BUN_ZIG_SOURCES ${BUN_KIT_RUNTIME_OUTPUTS})
|
||||||
@@ -505,9 +503,27 @@ endif()
|
|||||||
|
|
||||||
set(BUN_ZIG_OUTPUT ${BUILD_PATH}/bun-zig.o)
|
set(BUN_ZIG_OUTPUT ${BUILD_PATH}/bun-zig.o)
|
||||||
|
|
||||||
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM|arm64|ARM64|aarch64|AARCH64")
|
||||||
|
if(APPLE)
|
||||||
|
set(ZIG_CPU "apple_m1")
|
||||||
|
else()
|
||||||
|
set(ZIG_CPU "native")
|
||||||
|
endif()
|
||||||
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64|X86_64|x64|X64|amd64|AMD64")
|
||||||
|
if(ENABLE_BASELINE)
|
||||||
|
set(ZIG_CPU "nehalem")
|
||||||
|
else()
|
||||||
|
set(ZIG_CPU "haswell")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
unsupported(CMAKE_SYSTEM_PROCESSOR)
|
||||||
|
endif()
|
||||||
|
|
||||||
register_command(
|
register_command(
|
||||||
TARGET
|
TARGET
|
||||||
bun-zig
|
bun-zig
|
||||||
|
GROUP
|
||||||
|
console
|
||||||
COMMENT
|
COMMENT
|
||||||
"Building src/*.zig for ${ZIG_TARGET}"
|
"Building src/*.zig for ${ZIG_TARGET}"
|
||||||
COMMAND
|
COMMAND
|
||||||
@@ -518,7 +534,7 @@ register_command(
|
|||||||
-Dobj_format=${ZIG_OBJECT_FORMAT}
|
-Dobj_format=${ZIG_OBJECT_FORMAT}
|
||||||
-Dtarget=${ZIG_TARGET}
|
-Dtarget=${ZIG_TARGET}
|
||||||
-Doptimize=${ZIG_OPTIMIZE}
|
-Doptimize=${ZIG_OPTIMIZE}
|
||||||
-Dcpu=${CPU}
|
-Dcpu=${ZIG_CPU}
|
||||||
-Denable_logs=$<IF:$<BOOL:${ENABLE_LOGS}>,true,false>
|
-Denable_logs=$<IF:$<BOOL:${ENABLE_LOGS}>,true,false>
|
||||||
-Dversion=${VERSION}
|
-Dversion=${VERSION}
|
||||||
-Dsha=${REVISION}
|
-Dsha=${REVISION}
|
||||||
@@ -572,7 +588,7 @@ register_repository(
|
|||||||
picohttpparser.c
|
picohttpparser.c
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND BUN_C_SOURCES ${CWD}/vendor/picohttpparser/picohttpparser.c)
|
list(APPEND BUN_C_SOURCES ${VENDOR_PATH}/picohttpparser/picohttpparser.c)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
list(APPEND BUN_C_SOURCES ${CWD}/src/bun.js/bindings/windows/musl-memmem.c)
|
list(APPEND BUN_C_SOURCES ${CWD}/src/bun.js/bindings/windows/musl-memmem.c)
|
||||||
@@ -662,13 +678,17 @@ target_include_directories(${bun} PRIVATE
|
|||||||
${CWD}/src/js/builtins
|
${CWD}/src/js/builtins
|
||||||
${CWD}/src/napi
|
${CWD}/src/napi
|
||||||
${CWD}/src/deps
|
${CWD}/src/deps
|
||||||
${CWD}/vendor
|
|
||||||
${CWD}/vendor/picohttpparser
|
|
||||||
${CODEGEN_PATH}
|
${CODEGEN_PATH}
|
||||||
|
${VENDOR_PATH}
|
||||||
|
${VENDOR_PATH}/picohttpparser
|
||||||
)
|
)
|
||||||
|
|
||||||
# --- C/C++ Definitions ---
|
# --- C/C++ Definitions ---
|
||||||
|
|
||||||
|
if(ENABLE_ASSERTIONS)
|
||||||
|
target_compile_definitions(${bun} PRIVATE ASSERT_ENABLED=1)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
target_compile_definitions(${bun} PRIVATE BUN_DEBUG=1)
|
target_compile_definitions(${bun} PRIVATE BUN_DEBUG=1)
|
||||||
endif()
|
endif()
|
||||||
@@ -714,31 +734,10 @@ endif()
|
|||||||
|
|
||||||
# --- Compiler options ---
|
# --- Compiler options ---
|
||||||
|
|
||||||
if(WIN32)
|
if(NOT WIN32)
|
||||||
target_compile_options(${bun} PUBLIC
|
|
||||||
/EHsc
|
|
||||||
-Xclang -fno-c++-static-destructors
|
|
||||||
)
|
|
||||||
if(RELEASE)
|
|
||||||
target_compile_options(${bun} PUBLIC
|
|
||||||
/Gy
|
|
||||||
/Gw
|
|
||||||
/GF
|
|
||||||
/GA
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
target_compile_options(${bun} PUBLIC
|
target_compile_options(${bun} PUBLIC
|
||||||
-fconstexpr-steps=2542484
|
-fconstexpr-steps=2542484
|
||||||
-fconstexpr-depth=54
|
-fconstexpr-depth=54
|
||||||
-fno-exceptions
|
|
||||||
-fno-asynchronous-unwind-tables
|
|
||||||
-fno-unwind-tables
|
|
||||||
-fno-c++-static-destructors
|
|
||||||
-fvisibility=hidden
|
|
||||||
-fvisibility-inlines-hidden
|
|
||||||
-fno-omit-frame-pointer
|
|
||||||
-mno-omit-leaf-frame-pointer
|
|
||||||
-fno-pic
|
-fno-pic
|
||||||
-fno-pie
|
-fno-pie
|
||||||
-faddrsig
|
-faddrsig
|
||||||
@@ -798,7 +797,6 @@ if(WIN32)
|
|||||||
)
|
)
|
||||||
if(RELEASE)
|
if(RELEASE)
|
||||||
target_link_options(${bun} PUBLIC
|
target_link_options(${bun} PUBLIC
|
||||||
-flto=full
|
|
||||||
/LTCG
|
/LTCG
|
||||||
/OPT:REF
|
/OPT:REF
|
||||||
/OPT:NOICF
|
/OPT:NOICF
|
||||||
@@ -858,22 +856,6 @@ else()
|
|||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- LTO options ---
|
|
||||||
|
|
||||||
if(ENABLE_LTO)
|
|
||||||
if(WIN32)
|
|
||||||
target_link_options(${bun} PUBLIC -flto)
|
|
||||||
target_compile_options(${bun} PUBLIC -flto -Xclang -emit-llvm-bc)
|
|
||||||
else()
|
|
||||||
target_compile_options(${bun} PUBLIC
|
|
||||||
-flto=full
|
|
||||||
-emit-llvm
|
|
||||||
-fwhole-program-vtables
|
|
||||||
-fforce-emit-vtables
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# --- Symbols list ---
|
# --- Symbols list ---
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
cares
|
cares
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
libarchive
|
libarchive
|
||||||
@@ -40,7 +38,7 @@ register_cmake_command(
|
|||||||
# spawn a processes to compress instead of using the library.
|
# spawn a processes to compress instead of using the library.
|
||||||
-DENABLE_ZLIB=OFF
|
-DENABLE_ZLIB=OFF
|
||||||
-DHAVE_ZLIB_H=ON
|
-DHAVE_ZLIB_H=ON
|
||||||
-DCMAKE_C_FLAGS="-I${CWD}/vendor/zlib"
|
-DCMAKE_C_FLAGS="-I${VENDOR_PATH}/zlib"
|
||||||
LIB_PATH
|
LIB_PATH
|
||||||
libarchive
|
libarchive
|
||||||
LIBRARIES
|
LIBRARIES
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
libdeflate
|
libdeflate
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
libuv
|
libuv
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
include(SetupRust)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
lolhtml
|
lolhtml
|
||||||
@@ -10,7 +7,7 @@ register_repository(
|
|||||||
8d4c273ded322193d017042d1f48df2766b0f88b
|
8d4c273ded322193d017042d1f48df2766b0f88b
|
||||||
)
|
)
|
||||||
|
|
||||||
set(LOLHTML_CWD ${CWD}/vendor/lolhtml/c-api)
|
set(LOLHTML_CWD ${VENDOR_PATH}/lolhtml/c-api)
|
||||||
set(LOLHTML_BUILD_PATH ${BUILD_PATH}/lolhtml)
|
set(LOLHTML_BUILD_PATH ${BUILD_PATH}/lolhtml)
|
||||||
|
|
||||||
if(DEBUG)
|
if(DEBUG)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
lshpack
|
lshpack
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
mimalloc
|
mimalloc
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_cmake_command(
|
register_cmake_command(
|
||||||
TARGET
|
TARGET
|
||||||
sqlite
|
sqlite
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
tinycc
|
tinycc
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
zlib
|
zlib
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
zstd
|
zstd
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
optionx(BUILDKITE_CACHE BOOL "If the build can use Buildkite caches, even if not running in Buildkite" DEFAULT ${BUILDKITE})
|
optionx(BUILDKITE_CACHE BOOL "If the build can use Buildkite caches, even if not running in Buildkite" DEFAULT ${BUILDKITE})
|
||||||
|
|
||||||
if(NOT BUILDKITE_CACHE OR NOT BUN_LINK_ONLY)
|
if(NOT BUILDKITE_CACHE OR NOT BUN_LINK_ONLY)
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
find_command(
|
find_command(
|
||||||
VARIABLE
|
VARIABLE
|
||||||
BUN_EXECUTABLE
|
BUN_EXECUTABLE
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
optionx(ENABLE_CCACHE BOOL "If ccache should be enabled" DEFAULT ON)
|
optionx(ENABLE_CCACHE BOOL "If ccache should be enabled" DEFAULT ON)
|
||||||
|
|
||||||
if(NOT ENABLE_CCACHE OR CACHE_STRATEGY STREQUAL "none")
|
if(NOT ENABLE_CCACHE OR CACHE_STRATEGY STREQUAL "none")
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
if(CMAKE_HOST_WIN32)
|
if(CMAKE_HOST_WIN32)
|
||||||
setx(ESBUILD_EXECUTABLE ${CWD}/node_modules/.bin/esbuild.exe)
|
setx(ESBUILD_EXECUTABLE ${CWD}/node_modules/.bin/esbuild.exe)
|
||||||
else()
|
else()
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
if(CMAKE_HOST_WIN32 OR CMAKE_HOST_APPLE)
|
if(CMAKE_HOST_WIN32 OR CMAKE_HOST_APPLE)
|
||||||
set(DEFAULT_LLVM_VERSION "18.1.8")
|
set(DEFAULT_LLVM_VERSION "18.1.8")
|
||||||
else()
|
else()
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
set(MIN_OSX_DEPLOYMENT_TARGET "13.0")
|
set(MIN_OSX_DEPLOYMENT_TARGET "13.0")
|
||||||
|
|
||||||
if(DEFINED ENV{CI})
|
if(DEFINED ENV{CI})
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
find_command(
|
find_command(
|
||||||
VARIABLE
|
VARIABLE
|
||||||
CARGO_EXECUTABLE
|
CARGO_EXECUTABLE
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
optionx(WEBKIT_VERSION STRING "The version of WebKit to use" DEFAULT "147ed53838e21525677492c27099567a6cd19c6b")
|
optionx(WEBKIT_VERSION STRING "The version of WebKit to use" DEFAULT "147ed53838e21525677492c27099567a6cd19c6b")
|
||||||
optionx(WEBKIT_PREBUILT BOOL "If a pre-built version of WebKit should be used" DEFAULT ON)
|
optionx(WEBKIT_PREBUILT BOOL "If a pre-built version of WebKit should be used" DEFAULT ON)
|
||||||
|
|
||||||
@@ -69,8 +67,8 @@ set(WEBKIT_NAME bun-webkit-${WEBKIT_OS}-${WEBKIT_ARCH}${WEBKIT_SUFFIX})
|
|||||||
set(WEBKIT_FILENAME ${WEBKIT_NAME}.tar.gz)
|
set(WEBKIT_FILENAME ${WEBKIT_NAME}.tar.gz)
|
||||||
setx(WEBKIT_DOWNLOAD_URL https://github.com/oven-sh/WebKit/releases/download/autobuild-${WEBKIT_VERSION}/${WEBKIT_FILENAME})
|
setx(WEBKIT_DOWNLOAD_URL https://github.com/oven-sh/WebKit/releases/download/autobuild-${WEBKIT_VERSION}/${WEBKIT_FILENAME})
|
||||||
|
|
||||||
file(DOWNLOAD ${WEBKIT_DOWNLOAD_URL} ${CACHE_PATH}/${WEBKIT_FILENAME})
|
file(DOWNLOAD ${WEBKIT_DOWNLOAD_URL} ${CACHE_PATH}/${WEBKIT_FILENAME} SHOW_PROGRESS)
|
||||||
file(ARCHIVE_EXTRACT INPUT ${CACHE_PATH}/${WEBKIT_FILENAME} DESTINATION ${CACHE_PATH})
|
file(ARCHIVE_EXTRACT INPUT ${CACHE_PATH}/${WEBKIT_FILENAME} DESTINATION ${CACHE_PATH} TOUCH)
|
||||||
file(REMOVE ${CACHE_PATH}/${WEBKIT_FILENAME})
|
file(REMOVE ${CACHE_PATH}/${WEBKIT_FILENAME})
|
||||||
file(REMOVE_RECURSE ${WEBKIT_PATH})
|
file(REMOVE_RECURSE ${WEBKIT_PATH})
|
||||||
file(RENAME ${CACHE_PATH}/bun-webkit ${WEBKIT_PATH})
|
file(RENAME ${CACHE_PATH}/bun-webkit ${WEBKIT_PATH})
|
||||||
@@ -78,57 +76,3 @@ file(RENAME ${CACHE_PATH}/bun-webkit ${WEBKIT_PATH})
|
|||||||
if(APPLE)
|
if(APPLE)
|
||||||
file(REMOVE_RECURSE ${WEBKIT_INCLUDE_PATH}/unicode)
|
file(REMOVE_RECURSE ${WEBKIT_INCLUDE_PATH}/unicode)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# --- WebKit ---
|
|
||||||
# WebKit is either prebuilt and distributed via NPM, or you can pass WEBKIT_PATH to use a local build.
|
|
||||||
# We cannot include their CMake build files (TODO: explain why, for now ask @paperdave why)
|
|
||||||
#
|
|
||||||
# On Unix, this will pull from NPM the single package that is needed and use that
|
|
||||||
# if(WIN32)
|
|
||||||
# set(STATIC_LIB_EXT "lib")
|
|
||||||
# set(libJavaScriptCore "JavaScriptCore")
|
|
||||||
# set(libWTF "WTF")
|
|
||||||
# else()
|
|
||||||
# set(STATIC_LIB_EXT "a")
|
|
||||||
# set(libJavaScriptCore "libJavaScriptCore")
|
|
||||||
# set(libWTF "libWTF")
|
|
||||||
# endif()
|
|
||||||
|
|
||||||
# if(WEBKIT_PREBUILT)
|
|
||||||
|
|
||||||
# elseif(WEBKIT_PATH STREQUAL "omit")
|
|
||||||
|
|
||||||
# else()
|
|
||||||
# # Expected to be WebKit/WebKitBuild/${CMAKE_BUILD_TYPE}
|
|
||||||
# if(EXISTS "${WEBKIT_PATH}/cmakeconfig.h")
|
|
||||||
# # You may need to run:
|
|
||||||
# # make jsc-compile-debug jsc-copy-headers
|
|
||||||
# include_directories(
|
|
||||||
# "${WEBKIT_PATH}/"
|
|
||||||
# "${WEBKIT_PATH}/JavaScriptCore/Headers/JavaScriptCore"
|
|
||||||
# "${WEBKIT_PATH}/JavaScriptCore/PrivateHeaders"
|
|
||||||
# "${WEBKIT_PATH}/bmalloc/Headers"
|
|
||||||
# "${WEBKIT_PATH}/WTF/Headers"
|
|
||||||
# )
|
|
||||||
# set(WEBKIT_LIB_DIR "${WEBKIT_PATH}/lib")
|
|
||||||
|
|
||||||
# if(ENABLE_ASSERTIONS)
|
|
||||||
# add_compile_definitions("BUN_DEBUG=1")
|
|
||||||
# endif()
|
|
||||||
|
|
||||||
# message(STATUS "Using WebKit from ${WEBKIT_PATH}")
|
|
||||||
# else()
|
|
||||||
# if(NOT EXISTS "${WEBKIT_PATH}/lib/${libWTF}.${STATIC_LIB_EXT}" OR NOT EXISTS "${WEBKIT_PATH}/lib/${libJavaScriptCore}.${STATIC_LIB_EXT}")
|
|
||||||
# if(WEBKIT_PATH MATCHES "src/bun.js/WebKit$")
|
|
||||||
# message(FATAL_ERROR "WebKit directory ${WEBKIT_PATH} does not contain all the required files for Bun. Did you forget to init submodules?")
|
|
||||||
# endif()
|
|
||||||
|
|
||||||
# message(FATAL_ERROR "WebKit directory ${WEBKIT_PATH} does not contain all the required files for Bun. Expected a path to the oven-sh/WebKit repository, or a path to a folder containing `include` and `lib`.")
|
|
||||||
# endif()
|
|
||||||
|
|
||||||
# set(WEBKIT_LIB_DIR "${WEBKIT_PATH}/lib")
|
|
||||||
|
|
||||||
# message(STATUS "Using specified WebKit directory: ${WEBKIT_PATH}")
|
|
||||||
# message(STATUS "WebKit assertions: OFF")
|
|
||||||
# endif()
|
|
||||||
# endif()
|
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
include(Macros)
|
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
||||||
set(DEFAULT_ZIG_ARCH "aarch64")
|
set(DEFAULT_ZIG_ARCH "aarch64")
|
||||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|x64|AMD64")
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|x64|AMD64")
|
||||||
set(DEFAULT_ZIG_ARCH "x86_64")
|
set(DEFAULT_ZIG_ARCH "x86_64")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_SYSTEM_PROCESSOR}")
|
unsupported(CMAKE_SYSTEM_PROCESSOR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
@@ -15,7 +13,7 @@ elseif(WIN32)
|
|||||||
elseif(LINUX)
|
elseif(LINUX)
|
||||||
set(DEFAULT_ZIG_TARGET ${DEFAULT_ZIG_ARCH}-linux-gnu)
|
set(DEFAULT_ZIG_TARGET ${DEFAULT_ZIG_ARCH}-linux-gnu)
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unsupported operating system: ${CMAKE_SYSTEM_NAME}")
|
unsupported(CMAKE_SYSTEM_NAME)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
optionx(ZIG_TARGET STRING "The zig target to use" DEFAULT ${DEFAULT_ZIG_TARGET})
|
optionx(ZIG_TARGET STRING "The zig target to use" DEFAULT ${DEFAULT_ZIG_TARGET})
|
||||||
@@ -28,6 +26,8 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")
|
|||||||
set(DEFAULT_ZIG_OPTIMIZE "ReleaseSmall")
|
set(DEFAULT_ZIG_OPTIMIZE "ReleaseSmall")
|
||||||
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
set(DEFAULT_ZIG_OPTIMIZE "Debug")
|
set(DEFAULT_ZIG_OPTIMIZE "Debug")
|
||||||
|
else()
|
||||||
|
unsupported(CMAKE_BUILD_TYPE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Since Bun 1.1, Windows has been built using ReleaseSafe.
|
# Since Bun 1.1, Windows has been built using ReleaseSafe.
|
||||||
@@ -46,8 +46,9 @@ optionx(ZIG_OBJECT_FORMAT "obj|bc" "Output file format for Zig object files" DEF
|
|||||||
optionx(ZIG_VERSION STRING "The version of zig to use" DEFAULT "0.13.0")
|
optionx(ZIG_VERSION STRING "The version of zig to use" DEFAULT "0.13.0")
|
||||||
optionx(ZIG_LOCAL_CACHE_DIR FILEPATH "The path to local the zig cache directory" DEFAULT ${CACHE_PATH}/zig/local)
|
optionx(ZIG_LOCAL_CACHE_DIR FILEPATH "The path to local the zig cache directory" DEFAULT ${CACHE_PATH}/zig/local)
|
||||||
optionx(ZIG_GLOBAL_CACHE_DIR FILEPATH "The path to the global zig cache directory" DEFAULT ${CACHE_PATH}/zig/global)
|
optionx(ZIG_GLOBAL_CACHE_DIR FILEPATH "The path to the global zig cache directory" DEFAULT ${CACHE_PATH}/zig/global)
|
||||||
optionx(ZIG_BIN_CACHE_DIR FILEPATH "The path to the zig binary cache directory" DEFAULT ${CACHE_PATH}/zig/bin)
|
|
||||||
optionx(ZIG_REPOSITORY_PATH FILEPATH "The path to the Zig repository" DEFAULT ${CWD}/vendor/zig)
|
setx(ZIG_REPOSITORY_PATH ${VENDOR_PATH}/zig)
|
||||||
|
setx(ZIG_PATH ${CACHE_PATH}/zig/bin)
|
||||||
|
|
||||||
register_repository(
|
register_repository(
|
||||||
NAME
|
NAME
|
||||||
@@ -76,14 +77,14 @@ find_command(
|
|||||||
zig
|
zig
|
||||||
zig.exe
|
zig.exe
|
||||||
PATHS
|
PATHS
|
||||||
${ZIG_BIN_CACHE_DIR}
|
${ZIG_PATH}
|
||||||
VERSION
|
VERSION
|
||||||
${ZIG_VERSION}
|
${ZIG_VERSION}
|
||||||
REQUIRED
|
REQUIRED
|
||||||
OFF
|
OFF
|
||||||
)
|
)
|
||||||
|
|
||||||
if(NOT CMAKE_ZIG_COMPILER MATCHES "NOTFOUND")
|
if(CMAKE_ZIG_COMPILER)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -92,7 +93,7 @@ if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
|||||||
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|x64|AMD64")
|
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|x64|AMD64")
|
||||||
set(ZIG_HOST_ARCH "x86_64")
|
set(ZIG_HOST_ARCH "x86_64")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unsupported architecture: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
|
unsupported(CMAKE_HOST_SYSTEM_PROCESSOR)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_HOST_APPLE)
|
if(CMAKE_HOST_APPLE)
|
||||||
@@ -102,7 +103,7 @@ elseif(CMAKE_HOST_WIN32)
|
|||||||
elseif(CMAKE_HOST_UNIX)
|
elseif(CMAKE_HOST_UNIX)
|
||||||
set(ZIG_HOST_OS "linux")
|
set(ZIG_HOST_OS "linux")
|
||||||
else()
|
else()
|
||||||
message(FATAL_ERROR "Unsupported operating system: ${CMAKE_HOST_SYSTEM_NAME}")
|
unsupported(CMAKE_HOST_SYSTEM_NAME)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(ZIG_NAME zig-${ZIG_HOST_OS}-${ZIG_HOST_ARCH}-${ZIG_VERSION})
|
set(ZIG_NAME zig-${ZIG_HOST_OS}-${ZIG_HOST_ARCH}-${ZIG_VERSION})
|
||||||
@@ -116,14 +117,27 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
setx(ZIG_DOWNLOAD_URL https://ziglang.org/download/${ZIG_VERSION}/${ZIG_FILENAME})
|
setx(ZIG_DOWNLOAD_URL https://ziglang.org/download/${ZIG_VERSION}/${ZIG_FILENAME})
|
||||||
file(DOWNLOAD ${ZIG_DOWNLOAD_URL} ${ZIG_BIN_CACHE_DIR}/${ZIG_FILENAME})
|
file(DOWNLOAD ${ZIG_DOWNLOAD_URL} ${TMP_PATH}/${ZIG_FILENAME} SHOW_PROGRESS)
|
||||||
file(ARCHIVE_EXTRACT INPUT ${ZIG_BIN_CACHE_DIR}/${ZIG_FILENAME} DESTINATION ${ZIG_BIN_CACHE_DIR})
|
file(ARCHIVE_EXTRACT INPUT ${TMP_PATH}/${ZIG_FILENAME} DESTINATION ${TMP_PATH} TOUCH)
|
||||||
file(REMOVE ${ZIG_BIN_CACHE_DIR}/${ZIG_FILENAME})
|
file(REMOVE ${TMP_PATH}/${ZIG_FILENAME})
|
||||||
file(COPY ${ZIG_BIN_CACHE_DIR}/${ZIG_NAME}/${ZIG_EXE} DESTINATION ${ZIG_BIN_CACHE_DIR})
|
file(COPY ${TMP_PATH}/${ZIG_NAME}/${ZIG_EXE} DESTINATION ${ZIG_PATH})
|
||||||
file(REMOVE_RECURSE ${ZIG_BIN_CACHE_DIR}/${ZIG_NAME})
|
file(CHMOD ${ZIG_PATH}/${ZIG_EXE} PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)
|
||||||
file(CHMOD ${ZIG_BIN_CACHE_DIR}/${ZIG_EXE} PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE)
|
setx(CMAKE_ZIG_COMPILER ${ZIG_PATH}/${ZIG_EXE})
|
||||||
setx(CMAKE_ZIG_COMPILER ${ZIG_BIN_CACHE_DIR}/${ZIG_EXE})
|
|
||||||
|
|
||||||
if(NOT WIN32)
|
if(NOT WIN32)
|
||||||
file(CREATE_LINK ${ZIG_BIN_CACHE_DIR}/${ZIG_EXE} ${ZIG_BIN_CACHE_DIR}/zig.exe SYMBOLIC)
|
file(CREATE_LINK ${ZIG_PATH}/${ZIG_EXE} ${ZIG_PATH}/zig.exe SYMBOLIC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Some zig commands need the executable to be in the same directory as the zig repository
|
||||||
|
register_command(
|
||||||
|
COMMENT
|
||||||
|
"Creating symlink for zig"
|
||||||
|
COMMAND
|
||||||
|
${CMAKE_COMMAND} -E copy ${ZIG_PATH}/${ZIG_EXE} ${ZIG_REPOSITORY_PATH}/${ZIG_EXE}
|
||||||
|
&& ${CMAKE_COMMAND} -E create_symlink ${ZIG_REPOSITORY_PATH}/${ZIG_EXE} ${ZIG_REPOSITORY_PATH}/zig.exe
|
||||||
|
OUTPUTS
|
||||||
|
${ZIG_REPOSITORY_PATH}/${ZIG_EXE}
|
||||||
|
${ZIG_REPOSITORY_PATH}/zig.exe
|
||||||
|
TARGETS
|
||||||
|
clone-zig
|
||||||
|
)
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
"build:debug": "bun run build",
|
"build:debug": "bun run build",
|
||||||
"build:valgrind": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_BASELINE=ON -ENABLE_VALGRIND=ON -B build/debug-valgrind",
|
"build:valgrind": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Debug -DENABLE_BASELINE=ON -ENABLE_VALGRIND=ON -B build/debug-valgrind",
|
||||||
"build:release": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -B build/release",
|
"build:release": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -B build/release",
|
||||||
"build:ci": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCI=true -B build/release-ci --verbose",
|
"build:ci": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DCI=true -B build/release-ci --verbose --fresh",
|
||||||
"build:assert": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_ASSERTIONS=ON -DENABLE_LOGS=ON -B build/release-assert",
|
"build:assert": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_ASSERTIONS=ON -DENABLE_LOGS=ON -B build/release-assert",
|
||||||
"build:logs": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DENABLE_LOGS=ON -B build/release-logs",
|
"build:logs": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DENABLE_LOGS=ON -B build/release-logs",
|
||||||
"build:safe": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=ReleaseSafe -B build/release-safe",
|
"build:safe": "bun ./scripts/build.mjs -GNinja -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=ReleaseSafe -B build/release-safe",
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
"test": "node scripts/runner.node.mjs ./build/bun-debug",
|
"test": "node scripts/runner.node.mjs ./build/bun-debug",
|
||||||
"test:release": "node scripts/runner.node.mjs ./build-release/bun",
|
"test:release": "node scripts/runner.node.mjs ./build-release/bun",
|
||||||
"banned": "bun packages/bun-internal-test/src/linter.ts",
|
"banned": "bun packages/bun-internal-test/src/linter.ts",
|
||||||
"zig": "build/debug/cache/zig/bin/zig.exe",
|
"zig": "vendor/zig/zig.exe",
|
||||||
"zig:fmt": "bun run zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig",
|
"zig:fmt": "bun run zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig",
|
||||||
"zig:check": "bun run zig build check --summary new",
|
"zig:check": "bun run zig build check --summary new",
|
||||||
"zig:check-all": "bun run zig build check-all --summary new",
|
"zig:check-all": "bun run zig build check-all --summary new",
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const buildFlags = [
|
|||||||
|
|
||||||
async function build(args) {
|
async function build(args) {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
if (process.platform === "win32" && !process.env["VSINSTALLDIR"]) {
|
if (process.platform === "win32" && !process.env["VSINSTALLDIR"]) {
|
||||||
const shellPath = join(import.meta.dirname, "vs-shell.ps1");
|
const shellPath = join(import.meta.dirname, "vs-shell.ps1");
|
||||||
const scriptPath = import.meta.filename;
|
const scriptPath = import.meta.filename;
|
||||||
@@ -138,7 +138,7 @@ async function build(args) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
printDuration('total', Date.now() - startTime);
|
printDuration("total", Date.now() - startTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
function cmakePath(path) {
|
function cmakePath(path) {
|
||||||
@@ -209,8 +209,9 @@ async function spawn(command, args, options, label) {
|
|||||||
|
|
||||||
label ??= basename(command);
|
label ??= basename(command);
|
||||||
|
|
||||||
|
const pipe = process.env.CI === "true";
|
||||||
const subprocess = nodeSpawn(command, effectiveArgs, {
|
const subprocess = nodeSpawn(command, effectiveArgs, {
|
||||||
stdio: "pipe",
|
stdio: pipe ? "pipe" : "inherit",
|
||||||
...options,
|
...options,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -219,24 +220,29 @@ async function spawn(command, args, options, label) {
|
|||||||
timestamp = Date.now();
|
timestamp = Date.now();
|
||||||
});
|
});
|
||||||
|
|
||||||
const stdout = new Promise(resolve => {
|
let done;
|
||||||
subprocess.stdout.on("end", resolve);
|
if (pipe) {
|
||||||
subprocess.stdout.on("data", data => process.stdout.write(data));
|
const stdout = new Promise(resolve => {
|
||||||
});
|
subprocess.stdout.on("end", resolve);
|
||||||
|
subprocess.stdout.on("data", data => process.stdout.write(data));
|
||||||
|
});
|
||||||
|
|
||||||
const stderr = new Promise(resolve => {
|
const stderr = new Promise(resolve => {
|
||||||
subprocess.stderr.on("end", resolve);
|
subprocess.stderr.on("end", resolve);
|
||||||
subprocess.stderr.on("data", data => process.stderr.write(data));
|
subprocess.stderr.on("data", data => process.stderr.write(data));
|
||||||
});
|
});
|
||||||
|
|
||||||
const done = Promise.all([stdout, stderr]);
|
done = Promise.all([stdout, stderr]);
|
||||||
|
}
|
||||||
|
|
||||||
const { error, exitCode, signalCode } = await new Promise(resolve => {
|
const { error, exitCode, signalCode } = await new Promise(resolve => {
|
||||||
subprocess.on("error", error => resolve({ error }));
|
subprocess.on("error", error => resolve({ error }));
|
||||||
subprocess.on("exit", (exitCode, signalCode) => resolve({ exitCode, signalCode }));
|
subprocess.on("exit", (exitCode, signalCode) => resolve({ exitCode, signalCode }));
|
||||||
});
|
});
|
||||||
|
|
||||||
await done;
|
if (done) {
|
||||||
|
await done;
|
||||||
|
}
|
||||||
|
|
||||||
printDuration(label, Date.now() - timestamp);
|
printDuration(label, Date.now() - timestamp);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user