### Install SWBQNXPlatform Library Source: https://github.com/tuist/argus/blob/main/Sources/SWBQNXPlatform/CMakeLists.txt Installs the SWBQNXPlatform library to the appropriate destination within the installation directory structure. This command ensures the built library is placed where it can be accessed after installation. ```cmake install(TARGETS SWBQNXPlatform ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Install SWBGenericUnixPlatform Target Source: https://github.com/tuist/argus/blob/main/Sources/SWBGenericUnixPlatform/CMakeLists.txt This snippet defines the installation rules for the SWBGenericUnixPlatform target. It specifies that the target's archive (static library) should be installed into the SwiftBuild library directory. ```cmake install(TARGETS SWBGenericUnixPlatform ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Install Swift Library (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBProjectModel/CMakeLists.txt This snippet installs the SWBProjectModel target as an archive library to the specified destination path within the Swift build installation directory. This makes the compiled library available for use in other projects or installations. ```cmake install(TARGETS SWBProjectModel ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Install SwiftBuild Target Source: https://github.com/tuist/argus/blob/main/Sources/SwiftBuild/CMakeLists.txt Installs the `SwiftBuild` target as an archive to the specified library directory (`${SwiftBuild_INSTALL_LIBDIR}`). This ensures the built library is placed in the correct location for system-wide or project-specific use. ```cmake install(TARGETS SwiftBuild ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}" ) ``` -------------------------------- ### Install SWBAndroidPlatform Library (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBAndroidPlatform/CMakeLists.txt This CMake snippet defines how the SWBAndroidPlatform library should be installed, specifying the destination for the archive files. This is crucial for making the library available for use in other projects. ```cmake install(TARGETS SWBAndroidPlatform ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Swift Test Project Setup with Temporary Directory Source: https://github.com/tuist/argus/blob/main/SwiftBuild.docc/Development/test-development-project-tests.md Demonstrates how to set up a test project within a temporary directory using Swift. This approach is common for both task construction and build operation tests, ensuring that any generated files are automatically cleaned up after the test execution. ```swift func testProject() throws { try withTemporaryDirectory { tmpDir in let project = TestProject( "aProject", sourceRoot: tmpDir, groupTree: TestGroup( "SomeFiles", children: [ TestFile("Assets.xcassets"), TestFile("Class.swift"), ]), buildConfigurations: [ TestBuildConfiguration( "Debug", buildSettings: [ "PRODUCT_NAME": "$(TARGET_NAME)", "PRODUCT_BUNDLE_IDENTIFIER": "com.apple.project", "SWIFT_VERSION": "5.0", ]), ], targets: [ TestStandardTarget( "SomeLibrary", type: .framework, buildConfigurations: [ TestBuildConfiguration("Debug"), ], buildPhases: [ TestSourcesBuildPhase([ "Class.swift" ]), TestResourcesBuildPhase([ TestBuildFile("Assets.xcassets"), ]), ] ), ]) } } ``` -------------------------------- ### Install SWBCore Target Source: https://github.com/tuist/argus/blob/main/Sources/SWBCore/CMakeLists.txt Installs the SWBCore target to the specified library destination within the SwiftBuild installation directory. This step ensures the compiled module is placed correctly for use. ```cmake install(TARGETS SWBCore ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Install SWBTaskConstruction Library (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBTaskConstruction/CMakeLists.txt This CMake install command specifies that the SWBTaskConstruction target should be installed as an archive to the Swift build library directory. ```cmake install(TARGETS SWBTaskConstruction ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Install SWBApplePlatform Target Source: https://github.com/tuist/argus/blob/main/Sources/SWBApplePlatform/CMakeLists.txt Installs the SWBApplePlatform target to the specified library destination within the SwiftBuild installation directory. This makes the compiled library accessible after installation. ```cmake install(TARGETS SWBApplePlatform ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Install SWBWindowsPlatform Target Source: https://github.com/tuist/argus/blob/main/Sources/SWBWindowsPlatform/CMakeLists.txt Installs the SWBWindowsPlatform target as an archive to the library directory of the Swift build system. This makes the compiled library available for use in other projects or installations. ```cmake install(TARGETS SWBWindowsPlatform ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Install SWBCLibc Library (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBCLibc/CMakeLists.txt This CMake snippet configures the installation of the SWBCLibc library. It specifies that the library's archive should be installed to the SwiftBuild library directory. ```cmake install(TARGETS SWBCLibc ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Install and Export Executable (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBBuildServiceBundle/CMakeLists.txt This CMake snippet handles the installation of the SWBBuildServiceBundle executable and sets a global property to export it as part of SWIFTBUILD_EXPORTS. This ensures the executable is available for use after the build process. ```cmake install(TARGETS SWBBuildServiceBundle) set_property(GLOBAL APPEND PROPERTY SWIFTBUILD_EXPORTS SWBBuildServiceBundle) ``` -------------------------------- ### Install SWBLLBuild Library (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBLLBuild/CMakeLists.txt Installs the SWBLLBuild target as an archive to the specified library directory within the Swift build installation path. This makes the compiled library available for use after installation. ```cmake install(TARGETS SWBLLBuild ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### List Projects Source: https://context7.com/tuist/argus/llms.txt List all projects managed by Argus, including their build history, success rates, and last build times. This command helps in getting an overview of the project landscape. ```bash argus trace projects ``` -------------------------------- ### Install Argus with mise Source: https://github.com/tuist/argus/blob/main/README.md Installs Argus globally using the mise package manager. It's recommended to use the `github:` backend to ensure all necessary resource bundles are correctly extracted. ```bash mise use -g github:tuist/argus ``` -------------------------------- ### Install SWBBuildService Target (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBBuildService/CMakeLists.txt Installs the SWBBuildService target as an archive to the specified library directory within the installation path. ```cmake install(TARGETS SWBBuildService ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### CMake Project and Language Configuration Source: https://github.com/tuist/argus/blob/main/CMakeLists.txt Initializes the CMake project named SwiftBuild, specifying C, C++, and Swift as supported languages. It sets up output directories for libraries and executables, and configures installation paths and runtime paths. ```cmake cmake_minimum_required(VERSION 3.26...3.29) project(SwiftBuild LANGUAGES C CXX Swift) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_INSTALL_RPATH "$,@loader_path/..,$ORIGIN>") set(CMAKE_INSTALL_REMOVE_ENVIRONMENT_RPATH YES) set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL) set(CMAKE_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift) option(BUILD_SHARED_LIBS "Build shared libraries by default" YES) set(CMAKE_C_VISIBILITY hidden) set(CMAKE_CXX_VISIBILITY hidden) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED YES) set(CMAKE_CXX_EXTENSIONS NO) set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) option(SwiftBuild_USE_LLBUILD_FRAMEWORK "Use LLBuild Framework" NO) ``` -------------------------------- ### Initialize BuildTraceDatabase Connection (Swift) Source: https://context7.com/tuist/argus/llms.txt Initialize a connection to a build trace database using the SWBServiceCore library. This can be used to open the default database location or a custom path. Operations should be flushed before closing. ```swift import SWBServiceCore // Open the default database location let defaultPath = "(NSHomeDirectory())/Library/Developer/Xcode/BuildTraces/traces.db" let database = try BuildTraceDatabase(path: defaultPath) // Or use a custom path let customDatabase = try BuildTraceDatabase(path: "/tmp/my-builds.db") // Flush pending operations before closing database.flush() ``` -------------------------------- ### Configure SWBBuildSystem Library with CMake Source: https://github.com/tuist/argus/blob/main/Sources/SWBBuildSystem/CMakeLists.txt This snippet configures the SWBBuildSystem as a static library using CMake. It specifies the Swift source files, sets the Swift language version to 5, and links against other necessary libraries (SWBCore, SWBTaskConstruction, SWBTaskExecution). It also defines interface include directories and makes the library available for export. ```cmake add_library(SWBBuildSystem \ BuildManager.swift \ BuildOperation.swift \ BuildOperationExtension.swift \ BuildSystemCache.swift \ CleanOperation.swift \ DependencyCycleFormatter.swift \ SandboxViolations.swift) set_target_properties(SWBBuildSystem PROPERTIES Swift_LANGUAGE_VERSION 5) target_link_libraries(SWBBuildSystem PUBLIC SWBCore SWBTaskConstruction SWBTaskExecution) set_target_properties(SWBBuildSystem PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) set_property(GLOBAL APPEND PROPERTY SWIFTBUILD_EXPORTS SWBBuildSystem) install(TARGETS SWBBuildSystem ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Enable Swift Build Additional Debugging and Tracing Source: https://github.com/tuist/argus/blob/main/SwiftBuild.docc/Development/build-debugging.md This command enables llbuild's tracing feature and creates a copy of the build database for post-mortem analysis. The database can be inspected with llbuild's UI, and the trace file provides low-level build engine activity. ```shell defaults write org.swift.swift-build EnableBuildDebugging -bool YES ``` -------------------------------- ### Bundle Resources for SWBQNXPlatform Source: https://github.com/tuist/argus/blob/main/Sources/SWBQNXPlatform/CMakeLists.txt Bundles spec files for the SWBQNXPlatform module, which are essential for Swift build system to correctly compile and link the library. These specs define compilation and linking options. ```cmake SwiftBuild_Bundle(MODULE SWBQNXPlatform FILES Specs/QNX.xcspec Specs/QNXCompile.xcspec Specs/QNXLd.xcspec Specs/QNXLibtool.xcspec) ``` -------------------------------- ### Trace Build Bottlenecks (JSON) Source: https://context7.com/tuist/argus/llms.txt Trace build bottlenecks and output the results in JSON format for programmatic analysis. This command requires a build to be specified. ```bash argus trace bottlenecks --build latest --json ``` -------------------------------- ### Define SWBQNXPlatform Library Source: https://github.com/tuist/argus/blob/main/Sources/SWBQNXPlatform/CMakeLists.txt Defines the SWBQNXPlatform library with its Swift source files. This is a fundamental step in configuring the library within the build system. ```cmake add_library(SWBQNXPlatform Plugin.swift QNXSDP.swift) ``` -------------------------------- ### Swift Library Build Configuration (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBLibc/CMakeLists.txt Configures the SWBLibc library with Swift 6 language version, links it to SWBCLibc, and sets up include directories. It also specifies the installation destination for the library archives. ```cmake add_library(SWBLibc libc.swift) set_target_properties(SWBLibc PROPERTIES Swift_LANGUAGE_VERSION 6) target_link_libraries(SWBLibc PUBLIC SWBCLibc) # FIXME: why is this needed? We should be wiring up the Swift_MODULE_DIRECTORY # without this explicit configuration. target_include_directories(SWBLibc PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) set_target_properties(SWBLibc PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) set_property(GLOBAL APPEND PROPERTY SWIFTBUILD_EXPORTS SWBLibc) install(TARGETS SWBLibc ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Query Build Data using Swift Source: https://context7.com/tuist/argus/llms.txt Retrieves structured build information, including build summaries, errors, slowest targets, and bottlenecks. Assumes a 'database' object is available for querying. ```swift // Get summary for the latest build if let summary = database.queryBuildSummary(buildId: "latest") { print("Duration: (summary.durationSeconds ?? 0)s") print("Targets: (summary.targetCount)") print("Errors: (summary.errorCount)") print("Cache hit rate: (summary.cacheHitCount)/(summary.cacheMissCount)") } // Query errors for a specific build let errors = database.queryErrors(buildId: buildId) for error in errors { if let path = error.filePath, let line = error.line { print("(path):(line): (error.message)") } } // Get slowest targets with limit let slowestTargets = database.querySlowestTargets( buildId: "latest", limit: 10 ) for target in slowestTargets { print("(target.name): (target.durationSeconds)s ((target.taskCount) tasks)") } // Analyze build bottlenecks let bottlenecks = database.queryBottlenecks(buildId: "latest") for bottleneck in bottlenecks { print("(bottleneck.targetName): (bottleneck.durationSeconds)s") print("Blocked (bottleneck.blockedCount) targets") print("Blocked targets: (bottleneck.blockedTargets.joined(separator: ", "))") } ``` -------------------------------- ### Run Xcode Builds with Argus and Query Results Source: https://github.com/tuist/argus/blob/main/README.md This snippet demonstrates how to run Xcode builds instrumented by Argus and subsequently query the collected build data. It involves setting a trace ID, running the build with Argus as the build service, and then using the `argus trace` command to retrieve summaries, errors, slowest targets, or bottlenecks using the session ID. The `--json` flag is available for programmatic access. ```bash SWB_BUILD_TRACE_ID=$(uuidgen) XCBBUILDSERVICE_PATH=$(which argus) SWB_BUILD_TRACE_ID=$SWB_BUILD_TRACE_ID xcodebuild build -scheme MyScheme argus trace summary --build $SWB_BUILD_TRACE_ID argus trace errors --build $SWB_BUILD_TRACE_ID argus trace slowest-targets --build $SWB_BUILD_TRACE_ID --limit 5 argus trace bottlenecks --build $SWB_BUILD_TRACE_ID # Or use "latest" to query the most recent build: argus trace summary --build latest # Use --json flag for programmatic access: argus trace summary --build $SWB_BUILD_TRACE_ID --json ``` -------------------------------- ### Analyze Slowest Targets with Argus CLI Source: https://context7.com/tuist/argus/llms.txt Identify targets that take the most time to build using `argus trace slowest-targets`. This command helps pinpoint performance bottlenecks by listing targets based on their execution time and the number of tasks they involve. You can specify a limit for the number of slowest targets and get detailed JSON output. ```bash # Show the 5 slowest targets argus trace slowest-targets --build latest --limit 5 # Get detailed JSON output argus trace slowest-targets --build latest --limit 10 --json ``` -------------------------------- ### Define SWBWindowsPlatform Library Source: https://github.com/tuist/argus/blob/main/Sources/SWBWindowsPlatform/CMakeLists.txt Defines the SWBWindowsPlatform library and lists its Swift source files. This is a core step in building the library. ```cmake add_library(SWBWindowsPlatform KnownFolders.swift Plugin.swift VSInstallation.swift) ``` -------------------------------- ### List Build Errors and Warnings with Argus CLI Source: https://context7.com/tuist/argus/llms.txt Get structured diagnostic information for build errors and warnings using `argus trace errors` and `argus trace warnings`. You can list all errors or warnings from the latest build, or retrieve detailed JSON output containing file paths, line numbers, messages, and kinds. ```bash # Show all errors from the latest build argus trace errors --build latest # Show warnings argus trace warnings --build latest # Get JSON output with full diagnostic details argus trace errors --build latest --json ``` -------------------------------- ### Link Libraries for SWBQNXPlatform Source: https://github.com/tuist/argus/blob/main/Sources/SWBQNXPlatform/CMakeLists.txt Specifies the libraries that SWBQNXPlatform depends on. These are typically other internal libraries within the project that provide necessary functionalities. The PUBLIC keyword indicates that these dependencies are exposed to targets that link against SWBQNXPlatform. ```cmake target_link_libraries(SWBQNXPlatform PUBLIC SWBCore SWBMacro SWBUtil) ``` -------------------------------- ### Set Target Properties for SWBQNXPlatform Source: https://github.com/tuist/argus/blob/main/Sources/SWBQNXPlatform/CMakeLists.txt Sets interface include directories for the SWBQNXPlatform target. This ensures that the compiler can find header files or other necessary include paths when compiling code that uses this library. ```cmake set_target_properties(SWBQNXPlatform PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) ``` -------------------------------- ### Configure SWBWindowsPlatform Bundle Source: https://github.com/tuist/argus/blob/main/Sources/SWBWindowsPlatform/CMakeLists.txt Configures the bundle for the SWBWindowsPlatform module, specifying the resource files used for its specifications. This ensures proper packaging of platform-specific build settings. ```cmake SwiftBuild_Bundle(MODULE SWBWindowsPlatform FILES Specs/Windows.xcspec Specs/WindowsCompile.xcspec Specs/WindowsLd.xcspec Specs/WindowsLibtool.xcspec) ``` -------------------------------- ### View Builds for Project (JSON) Source: https://context7.com/tuist/argus/llms.txt View a list of builds for a specific project, with options to limit the number of results and filter by workspace path. JSON output is supported for programmatic access. ```bash argus trace builds --project my-mobile-app --limit 10 ``` ```bash argus trace builds --workspace /Users/dev/MyApp --limit 5 --json ``` -------------------------------- ### Record Build Events using Swift Source: https://context7.com/tuist/argus/llms.txt Captures build operations and messages using the BuildTraceRecorder. Requires SWBProtocol and SWBServiceCore. Records various build stages and diagnostics, flushing asynchronously. ```swift import SWBProtocol import SWBServiceCore // Initialize the build trace recorder let recorder = try BuildTraceRecorder(databasePath: defaultPath) // Set environment variables for build correlation // SWB_BUILD_TRACE_ID: Custom build identifier // SWB_BUILD_PROJECT_ID: Project grouping identifier // SWB_BUILD_WORKSPACE_PATH: Workspace path for filtering // Record messages from the build service recorder.record(buildStartedMessage) recorder.record(targetStartedMessage) recorder.record(taskStartedMessage) recorder.record(taskEndedMessage) recorder.record(diagnosticMessage) recorder.record(buildEndedMessage) // Ensure all async operations complete recorder.flush() ``` -------------------------------- ### Build Option Value Definitions Source: https://github.com/tuist/argus/blob/main/SwiftBuild.docc/Core/xcspecs.md Defines the structure and supported keys for build option value definitions, used for Boolean and Enumeration build options. ```APIDOC ## Build Option Value Definitions Each build option value definition is a property dictionary defining information about a particular possible value for a *Boolean* or *Enumeration* build option. The following keys are supported: ### Parameters #### Request Body - **Value** (String) - Required - The string identifying the value. For boolean types, only the values `"YES"` and `"NO"` are allowed. - **DisplayName** (String) - Optional - The human readable string used to describe this value. - **CommandLine** (String) - Optional - If present, defines a "shell"-escaped string to use when translating this option to command line arguments (if the containing option's dynamic value matches this one). The string will be broken into separate individual arguments following the shell rules, and will be subject to macro expression evaluation. The macro expression may make use of `$(value)` to refer to the dynamic value of the option. - **CommandLineArgs** (StringList) - Optional - If present, defines a list of "shell"-escaped strings to use when translating this option to command line arguments (if the containing option's dynamic value matches this one). Each item in the string list will be broken into separate individual arguments following the shell rules, and will be subject to macro expression evaluation. The macro expression may make use of `$(value)` to refer to the dynamic value of the option. - **CommandLineFlag** (String) - Optional - If present, defines a single command line flag to pass on the command line when this dynamic value is present for the containing option. ### Request Example ```json { "Value": "YES", "DisplayName": "Enable Feature", "CommandLine": "--enable-feature $(value)" } ``` ### Response #### Success Response (200) - **Value** (String) - The string identifying the value. - **DisplayName** (String) - The human readable string used to describe this value. - **CommandLine** (String) - A "shell"-escaped string for command line arguments. - **CommandLineArgs** (StringList) - A list of "shell"-escaped strings for command line arguments. - **CommandLineFlag** (String) - A single command line flag. #### Response Example ```json { "Value": "YES", "DisplayName": "Enable Feature", "CommandLine": "--enable-feature $(value)" } ``` ``` -------------------------------- ### List Projects and Builds Source: https://context7.com/tuist/argus/llms.txt Manage projects and view build history. Allows listing all projects with their build statistics and viewing detailed build information for specific projects or workspaces. ```APIDOC ## List Projects and Builds ### Description Manage multiple projects and view build history. ### Method GET ### Endpoint /tuist/argus ### Commands 1. **List Projects**: ```bash argus trace projects ``` 2. **List Builds for a Project**: ```bash argus trace builds --project [--limit ] [--json] ``` 3. **List Builds for a Workspace**: ```bash argus trace builds --workspace [--limit ] [--json] ``` ### Query Parameters - **project** (string) - Optional - Filters builds for a specific project ID. - **workspace** (string) - Optional - Filters builds for a specific workspace path. - **limit** (integer) - Optional - Limits the number of builds returned. - **json** (boolean) - Optional - If true, outputs the result in JSON format. ### Response Example (Projects - Human-readable) ```text Projects ========= project-a Project ID: my-mobile-app Workspace: /Users/dev/MyApp Builds: 47 (89% success) Last build: 2025-12-11 14:32:18 project-b Workspace: /Users/dev/OtherApp Builds: 23 (96% success) Last build: 2025-12-10 09:15:42 ``` ### Response Example (Builds - Human-readable) ```text Builds for my-mobile-app ======================================== 8F9C4D2E-1A3B-4C5D-9E7F-2B8A6D4C9E1F Status: succeeded Duration: 127.45s Started: 2025-12-11 14:32:18 Targets: 24, Tasks: 1847 7E8B3C1D-2A9F-4B6E-8D3A-1C7F5E9B2D4A Status: failed Duration: 89.23s Started: 2025-12-11 13:15:09 Targets: 24, Tasks: 1456 Errors: 3 ``` ### Response Example (Builds - JSON) ```json { "projects": [ { "name": "project-a", "projectId": "my-mobile-app", "workspace": "/Users/dev/MyApp", "builds": 47, "successRate": "89%", "lastBuild": "2025-12-11 14:32:18" } ], "builds": [ { "id": "8F9C4D2E-1A3B-4C5D-9E7F-2B8A6D4C9E1F", "status": "succeeded", "duration": "127.45s", "started": "2025-12-11 14:32:18", "targets": 24, "tasks": 1847 } ] } ``` ``` -------------------------------- ### Add Library and Bundle Files Source: https://github.com/tuist/argus/blob/main/Sources/SWBGenericUnixPlatform/CMakeLists.txt This snippet defines the addition of a library named SWBGenericUnixPlatform and bundles associated specification files. It uses the 'add_library' command for the Swift source file and 'SwiftBuild_Bundle' for the XCSpec files. ```cmake add_library(SWBGenericUnixPlatform Plugin.swift) SwiftBuild_Bundle(MODULE SWBGenericUnixPlatform FILES Specs/Unix.xcspec Specs/UnixCompile.xcspec Specs/UnixLd.xcspec Specs/UnixLibtool.xcspec) ``` -------------------------------- ### Export SWBQNXPlatform for Swift Build Source: https://github.com/tuist/argus/blob/main/Sources/SWBQNXPlatform/CMakeLists.txt Exports the SWBQNXPlatform target for use by the Swift build system. This makes the library available for other modules or targets that depend on it. ```cmake set_property(GLOBAL APPEND PROPERTY SWIFTBUILD_EXPORTS SWBQNXPlatform) ``` -------------------------------- ### Check Build with Error and No Diagnostics Source: https://github.com/tuist/argus/blob/main/SwiftBuild.docc/Development/test-development-project-tests.md Demonstrates a build check scenario where an error is expected and verified using `results.checkError`, followed by confirming no other diagnostics exist using `results.checkNoDiagnostics()`. ```swift await tester.checkBuild(BuildParameters(configuration: "Debug")) { results in results.checkError(.equal("The build encountered an error.")) results.checkNoDiagnostics() } ``` -------------------------------- ### Link SwiftBuild Libraries Source: https://github.com/tuist/argus/blob/main/Sources/SwiftBuild/CMakeLists.txt Links essential libraries required by the `SwiftBuild` target. This includes core components like `SWBCSupport`, `SWBCore`, `SWBProtocol`, `SWBUtil`, and `SWBProjectModel` for the library's functionality. ```cmake target_link_libraries(SwiftBuild PUBLIC SWBCSupport SWBCore SWBProtocol SWBUtil SWBProjectModel ) ``` -------------------------------- ### Launch Swift Build in Process for Debugging Source: https://github.com/tuist/argus/blob/main/SwiftBuild.docc/Development/build-debugging.md This environment variable forces the Swift Build service to run entirely within the client-side framework, simplifying multi-process debugging scenarios. This is a fallback when direct testing of the service fails. ```shell export XCBUILD_LAUNCH_IN_PROCESS=1 ``` -------------------------------- ### Initialize Build Operation Tester Source: https://github.com/tuist/argus/blob/main/SwiftBuild.docc/Development/test-development-project-tests.md Initializes a `BuildOperationTester` for testing build operations on a project. Similar to `TaskConstructionTester`, it requires a `Core` object and the `testProject`. A `Core` instance can be obtained via the `CoreBasedTests` protocol. ```swift let tester = try BuildOperationTester(core, testProject) ``` -------------------------------- ### Enable Swift Build Debug Activity Logs Source: https://github.com/tuist/argus/blob/main/SwiftBuild.docc/Development/build-debugging.md This command enables detailed diagnostic logs for Swift Build, which can be verbose for normal use. It's useful for in-depth analysis of build processes. ```shell defaults write org.swift.swift-build EnableDebugActivityLogs -bool YES ``` -------------------------------- ### Define SWBUniversalPlatform Library (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBUniversalPlatform/CMakeLists.txt This snippet defines the SWBUniversalPlatform library using CMake. It lists the source files that constitute the library and specifies the build rules and compiler specifications to be used. It also sets target properties related to include directories and exports the target for Swift build. ```cmake add_library(SWBUniversalPlatform BareMetal.swift CopyPlistFile.swift CopyStringsFile.swift CppTool.swift DiffTool.swift LexCompiler.swift TestEntryPointGenerationTaskAction.swift TestEntryPointGenerationTool.swift TestEntryPointTaskProducer.swift YaccCompiler.swift Plugin.swift) SwiftBuild_Bundle(MODULE SWBUniversalPlatform FILES Specs/BuiltInBuildRules.xcbuildrules Specs/BuiltInCompilers.xcspec Specs/BuiltInFileTypes.xcspec Specs/Clang.xcspec Specs/ClangModuleVerifierInputGenerator.xcspec Specs/ClangStatCache.xcspec Specs/ClangSymbolExtractor.xcspec Specs/ClangVerifier.xcspec Specs/CodeSign.xcspec Specs/CopyPlistFile.xcspec Specs/CopyStringsFile.xcspec Specs/Cpp.xcspec Specs/DefaultCompiler.xcspec Specs/Documentation.xcspec Specs/Ld.xcspec Specs/Lex.xcspec Specs/Libtool.xcspec Specs/ObjectLibraryAssembler.xcspec Specs/PackageTypes.xcspec Specs/PBXCp.xcspec Specs/ProductTypes.xcspec Specs/ProductTypeValidationTool.xcspec Specs/StandardFileTypes.xcspec Specs/StripSymbols.xcspec Specs/swift-stdlib-tool.xcspec Specs/Swift.xcspec Specs/SwiftBuildSettings.xcspec Specs/TAPI.xcspec Specs/TestEntryPointGenerator.xcspec Specs/Unifdef.xcspec Specs/Yacc.xcspec) target_link_libraries(SWBUniversalPlatform PUBLIC SWBCore SWBMacro SWBUtil SWBTaskConstruction SWBTaskExecution ArgumentParser) set_target_properties(SWBUniversalPlatform PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) set_property(GLOBAL APPEND PROPERTY SWIFTBUILD_EXPORTS SWBUniversalPlatform) install(TARGETS SWBUniversalPlatform ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Check Specific Task Execution Details Source: https://github.com/tuist/argus/blob/main/SwiftBuild.docc/Development/test-development-project-tests.md Verifies the execution of a specific build task, identified by its rule type ('Ld' in this case). It checks the command line arguments, input files, and output files of the task using detailed assertions. ```swift await tester.checkBuild(BuildParameters(configuration: "Debug")) { results in results.checkTask(.matchRuleType("Ld")) { task in task.checkCommandLine(["ld", "-o", "/tmp/file.dylib", "/tmp/input1.o", "/tmp/input2.o"]) task.checkInputs([.path("/tmp/input1.o"), .path("/tmp/input2.o")]) task.checkOutputs([.path("/tmp/file.dylib")]) } } ``` -------------------------------- ### Set Interface Include Directories Source: https://github.com/tuist/argus/blob/main/Sources/SWBApplePlatform/CMakeLists.txt Configures the interface include directories for the SWBApplePlatform target, setting it to the Swift module directory. This is crucial for header visibility during compilation. ```cmake set_target_properties(SWBApplePlatform PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) ``` -------------------------------- ### Configure SWBCSupport Library Build Source: https://github.com/tuist/argus/blob/main/Sources/SWBCSupport/CMakeLists.txt Configures the SWBCSupport library using CMake. It specifies source files (C++, C, Swift), sets Swift as the linker language, enables C++ interop, and defines platform-specific compile options and include directories. It also handles linking the BlocksRuntime library on non-Darwin platforms. ```cmake add_library(SWBCSupport CLibclang.cpp CLibRemarksHelper.c empty.swift) # Use swiftc as the linker so we pick up search paths for the blocks runtime, # and enable C++ interop so it delegates to clang++. set_target_properties(SWBCSupport PROPERTIES LINKER_LANGUAGE Swift) set_target_properties(SWBCSupport PROPERTIES Swift_MODULE_NAME __SWBCSupport_Empty) target_link_options(SWBCSupport PRIVATE -cxx-interoperability-mode=default) target_compile_definitions(SWBCSupport PRIVATE $<$:_CRT_SECURE_NO_WARNINGS> $<$:_CRT_NONSTDC_NO_WARNINGS>) target_compile_options(SWBCSupport PRIVATE "$<$:SHELL:-fblocks>") target_include_directories(SWBCSupport PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) # TODO(compnerd) wire this up with `find_package` target_link_libraries(SWBCSupport PRIVATE $<$>:BlocksRuntime>) set_property(GLOBAL APPEND PROPERTY SWIFTBUILD_EXPORTS SWBCSupport) install(TARGETS SWBCSupport ARCHIVE DESTINATION "${SwiftBuild_INSTALL_LIBDIR}") ``` -------------------------------- ### Initialize Task Construction Tester Source: https://github.com/tuist/argus/blob/main/SwiftBuild.docc/Development/test-development-project-tests.md Initializes a `TaskConstructionTester` for performing tests on a project's task construction. It requires a `Core` object and the `testProject` to operate on. The `CoreBasedTests` protocol provides access to a `Core` instance. ```swift let tester = try TaskConstructionTester(core, testProject) ``` -------------------------------- ### Query Build Summary with Argus CLI Source: https://context7.com/tuist/argus/llms.txt Retrieve high-level build metrics and status using the `argus trace summary` command. You can query the latest build, a specific build by ID, or obtain JSON output for programmatic parsing. This provides insights into build duration, targets, tasks, errors, warnings, and cache hits. ```bash # Query the most recent build argus trace summary --build latest # Query a specific build by ID argus trace summary --build 8F9C4D2E-1A3B-4C5D-9E7F-2B8A6D4C9E1F # Get JSON output for programmatic parsing argus trace summary --build latest --json ``` -------------------------------- ### SwiftBuild Bundle Configuration Source: https://github.com/tuist/argus/blob/main/Sources/SWBCore/CMakeLists.txt Defines a bundle for SWBCore, specifying the source files for different build systems. This configuration is essential for structuring the project's build process. ```swift SwiftBuild_Bundle(MODULE SWBCoreFILES Specs/CoreBuildSystem.xcspec Specs/ExternalBuildSystem.xcspec Specs/NativeBuildSystem.xcspec) ``` -------------------------------- ### Query Project History using Swift Source: https://context7.com/tuist/argus/llms.txt Retrieves build history across projects and workspaces. Allows listing all projects with their build statistics and filtering builds for a specific project by ID or workspace path. ```swift // List all projects with build history let projects = database.queryProjects() for project in projects { print("Project: (project.identifier)") if let projectId = project.projectId { print(" ID: (projectId)") } print(" Builds: (project.buildCount)") print(" Success rate: (project.successCount)/(project.buildCount)") print(" Last build: (project.lastBuildAt)") } // Get builds for a specific project let builds = database.queryBuildsForProject( projectId: "my-mobile-app", workspacePath: nil, limit: 20 ) for build in builds { print("(build.id): (build.status ?? "in progress")") print(" Duration: (build.durationSeconds ?? 0)s") print(" Errors: (build.errorCount), Warnings: (build.warningCount)") } // Filter by workspace path let workspaceBuilds = database.queryBuildsForProject( projectId: nil, workspacePath: "/Users/dev/MyApp", limit: 10 ) ``` -------------------------------- ### Link Libraries and Set Include Directories (CMake) Source: https://github.com/tuist/argus/blob/main/Sources/SWBProjectModel/CMakeLists.txt This snippet links the SWBProjectModel library with the SWBProtocol library and sets the interface include directories for the Swift module. This ensures proper dependency resolution and header access during compilation. ```cmake target_link_libraries(SWBProjectModel PUBLIC SWBProtocol) set_target_properties(SWBProjectModel PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) ``` -------------------------------- ### BuildTraceDatabase API Source: https://context7.com/tuist/argus/llms.txt API for interacting with the build trace database, allowing initialization and management of trace data. ```APIDOC ## BuildTraceDatabase API ### Initialize Database Connection Open or create a build trace database. ### Language Swift ### Code Example ```swift import SWBServiceCore // Open the default database location let defaultPath = "\(NSHomeDirectory())\/Library\/Developer\/Xcode\/BuildTraces\/traces.db" let database = try BuildTraceDatabase(path: defaultPath) // Or use a custom path let customDatabase = try BuildTraceDatabase(path: "\/tmp\/my-builds.db") // Flush pending operations before closing database.flush() ``` ### Parameters - **path** (string) - Required - The file path for the database. If it doesn't exist, it will be created. ```