Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional debug configuration for a better debugging experience + CI update #1893

Merged
merged 12 commits into from
Jan 30, 2025
Merged
67 changes: 41 additions & 26 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,34 @@ name: CI

on: [push, pull_request]

# Cancel any previous workflows if the pull request was updated
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true

jobs:
build:
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
strategy:
fail-fast: false
matrix:
config:
- { os: ubuntu-22.04, platform: x64, cxx: g++-11, cc: gcc-11 }
- { os: macos-12, platform: x64, cxx: clang++, cc: clang }
- { os: windows-2022, platform: x64, vs: "Program Files/Microsoft Visual Studio/2022" }
os: [ubuntu-22.04, macos-12, windows-2022]
platform: [x64]
build-cfg: [DebugOpt, Release]
#build-cfg: [Debug, DebugOpt, Release] # our local copy of clang isn't build for debug on linux/macos currently
include:
- os: windows-2022
platform: x64
build-cfg: Debug

runs-on: ${{ matrix.config.os }}
runs-on: ${{ matrix.os }}

env:
CC: ${{ matrix.config.cc }}
CXX: ${{ matrix.config.cxx }}
VS_VERSION: ${{ matrix.config.vs }}
PLATFORM: ${{ matrix.config.platform }}
CC: ${{ startsWith(matrix.os, 'ubuntu') && 'gcc-11' || 'clang' }}
CXX: ${{ startsWith(matrix.os, 'ubuntu') && 'g++-11' || 'clang++' }}
VS_VERSION: "Program Files/Microsoft Visual Studio/2022"
PLATFORM: ${{ matrix.platform }}
BUILD_CONFIGURATION: ${{ matrix.build-cfg }}
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
EMSCRIPTEN_VERSION: 3.1.65
Expand All @@ -41,59 +51,63 @@ jobs:
cmake-version: '3.30.x'

- name: Install nbgv
if: startsWith(matrix.config.os, 'macos')
if: startsWith(matrix.os, 'macos')
run: |
dotnet tool install -g nbgv

- name: Set version
run: nbgv cloud --all-vars

- name: Environment
if: matrix.config.vs
if: startsWith(matrix.os, 'windows')
shell: bash
run: echo "/c/$VS_VERSION/Enterprise/MSBuild/Current/Bin" >> $GITHUB_PATH

- name: Setup
shell: bash
run: |
build/build.sh generate -platform $PLATFORM
build/build.sh download_llvm -platform $PLATFORM
build/build.sh generate -platform $PLATFORM -configuration $BUILD_CONFIGURATION
build/build.sh download_llvm -platform $PLATFORM -configuration $BUILD_CONFIGURATION

- name: Restore
shell: bash
run: build/build.sh restore -platform $PLATFORM
run: build/build.sh restore -platform $PLATFORM -configuration $BUILD_CONFIGURATION

- name: Build
shell: bash
run: build/build.sh -platform $PLATFORM -build_only
run: build/build.sh -platform $PLATFORM -build_only -configuration $BUILD_CONFIGURATION

- name: Test (.NET)
# Disable test for debug configs, since they take over 6 hours to complete
if: matrix.build-cfg != 'Debug'
shell: bash
run: build/test.sh -platform $PLATFORM
run: build/test.sh -platform $PLATFORM -configuration $BUILD_CONFIGURATION

- name: Build (QuickJS runtime)
if: runner.os != 'Windows'
shell: bash
run: tests/quickjs/bootstrap.sh
if: runner.os != 'Windows'

- name: Test (QuickJS)
shell: bash
run: tests/quickjs/test.sh
if: runner.os != 'Windows'
shell: bash
run: tests/quickjs/test.sh -dotnet_configuration $BUILD_CONFIGURATION

- name: Test (Emscripten)
shell: bash
run: tests/emscripten/test.sh
if: runner.os != 'Windows'
shell: bash
run: tests/emscripten/test.sh -dotnet_configuration $BUILD_CONFIGURATION

- name: Pack
shell: bash
run: build/build.sh prepack -platform $PLATFORM
run: build/build.sh prepack -platform $PLATFORM -configuration $BUILD_CONFIGURATION

- name: Upload Artifacts
# We only need a release version of this in the create_package job
if: matrix.build-cfg == 'Release'
uses: actions/upload-artifact@v4
with:
name: intermediate
name: intermediate-${{ matrix.build-cfg }}-${{ matrix.platform }}
retention-days: 7
overwrite: true
path: |
Expand All @@ -110,6 +124,7 @@ jobs:
env:
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
BUILD_CONFIGURATION: Release

steps:
- uses: actions/checkout@v4
Expand All @@ -121,15 +136,15 @@ jobs:

- uses: actions/download-artifact@v4
with:
name: intermediate
name: intermediate-Release-x64

- name: Setup
shell: bash
run: build/build.sh generate_config
run: build/build.sh generate_config -configuration $BUILD_CONFIGURATION

- name: Create package
shell: bash
run: build/build.sh pack
run: build/build.sh pack -configuration $BUILD_CONFIGURATION

- name: Upload package
uses: actions/upload-artifact@v4
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<PropertyGroup>
<RootDir>$(MSBuildThisFileDirectory)</RootDir>
<Platforms>x86;x64</Platforms>
<Configurations>Debug;DebugOpt;Release</Configurations>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
19 changes: 16 additions & 3 deletions build/Helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ newoption {
allowed = {
{ "Release", "Release" },
{ "Debug", "Debug" },
{ "DebugOpt", "DebugOpt" },
}
}

Expand Down Expand Up @@ -104,13 +105,21 @@ function SetupNativeProject()

filter { "configurations:Debug" }
defines { "DEBUG" }

filter { "configurations:DebugOpt" }
defines { "DEBUG" }
optimize "Debug"
runtime "Release"

filter { "configurations:Release" }
defines { "NDEBUG" }
optimize "On"
optimize "Full"

-- Compiler-specific options

filter { "toolset:msc*", "configurations:DebugOpt" }
defines { "_ITERATOR_DEBUG_LEVEL=0" }

filter { "toolset:msc*" }
buildoptions { msvc_buildflags }
defines { msvc_cpp_defines }
Expand Down Expand Up @@ -247,9 +256,13 @@ end
function AddPlatformSpecificFiles(folder, filename)

if os.istarget("windows") then
filter { "toolset:msc*", "architecture:x86_64" }
filter { "toolset:msc*", "architecture:x86_64", "configurations:Debug" }
files { path.join(folder, "x86_64-pc-win32-msvc-d", filename) }
filter { "toolset:msc*", "architecture:x86", "configurations:Debug" }
files { path.join(folder, "i686-pc-win32-msvc-d", filename) }
filter { "toolset:msc*", "architecture:x86_64", "configurations:not Debug" }
files { path.join(folder, "x86_64-pc-win32-msvc", filename) }
filter { "toolset:msc*", "architecture:x86" }
filter { "toolset:msc*", "architecture:x86", "configurations:not Debug" }
files { path.join(folder, "i686-pc-win32-msvc", filename) }
elseif os.istarget("macosx") then
filter { "architecture:arm64" }
Expand Down
18 changes: 18 additions & 0 deletions build/LLVM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,18 @@ function SetupLLVMIncludes()
local c = filter()

if LLVMDirPerConfiguration then
filter { "configurations:DebugOpt" }
includedirs
{
path.join(LLVMRootDirRelease, "include"),
path.join(LLVMRootDirRelease, "llvm/include"),
path.join(LLVMRootDirRelease, "lld/include"),
path.join(LLVMRootDirRelease, "clang/include"),
path.join(LLVMRootDirRelease, "clang/lib"),
path.join(LLVMRootDirRelease, "build/include"),
path.join(LLVMRootDirRelease, "build/clang/include"),
}

filter { "configurations:Debug" }
includedirs
{
Expand Down Expand Up @@ -121,6 +133,9 @@ function SetupLLVMLibs()
filter {}

if LLVMDirPerConfiguration then
filter { "configurations:DebugOpt" }
libdirs { path.join(LLVMRootDirRelease, "build/lib") }

filter { "configurations:Debug" }
libdirs { path.join(LLVMRootDirDebug, "build/lib") }

Expand All @@ -129,6 +144,9 @@ function SetupLLVMLibs()
else
local LLVMBuildDir = get_llvm_build_dir()
libdirs { path.join(LLVMBuildDir, "lib") }

filter { "configurations:DebugOpt", "toolset:msc*" }
libdirs { path.join(LLVMBuildDir, "RelWithDebInfo/lib") }

filter { "configurations:Debug", "toolset:msc*" }
libdirs { path.join(LLVMBuildDir, "Debug/lib") }
Expand Down
2 changes: 1 addition & 1 deletion build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
builddir=$(cd "$(dirname "$0")"; pwd)
platform=x64
vs=vs2022
configuration=Release
configuration=DebugOpt
build_only=false
ci=false
target_framework=
Expand Down
3 changes: 3 additions & 0 deletions build/llvm/LLVM.lua
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ function get_llvm_package_name(rev, conf, arch)
end

function get_llvm_configuration_name(debug)
if string.find(_OPTIONS["configuration"], "DebugOpt") then
return os.istarget("windows") and "RelWithDebInfo" or "Release"
end
if string.find(_OPTIONS["configuration"], "Debug") then
return "Debug"
end
Expand Down
Loading
Loading