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 CMakeLists.txt for building with CMake. #145

Merged
merged 10 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ on:
- main

jobs:
build:
build-spm:
name: Build & Test (SPM)
runs-on: windows-2022
timeout-minutes: 20

steps:
- uses: actions/checkout@v3
- name: Checkout Swift-WebBrowser
uses: actions/[email protected]

- name: Setup Visual Studio Development Environment
uses: compnerd/gha-setup-vsdevenv@main
Expand All @@ -29,3 +31,30 @@ jobs:

- name: Test
run: swift test --verbose --skip-build

build-cmake:
name: Build (CMake)
runs-on: windows-2022
timeout-minutes: 20

steps:
- name: Checkout Swift-WebBrowser
uses: actions/[email protected]

- name: Setup Visual Studio Development Environment
uses: compnerd/gha-setup-vsdevenv@main

- name: Install Swift
# TODO: Use mainline version once linker issue is fixed.
uses: compnerd/gha-setup-swift@8f43ccc3e8bac89829862af09de9567c807c1c12
with:
branch: swift-5.8-release
tag: 5.8-RELEASE

- name: CMake Configure
shell: pwsh
run: cmake -S . -B build -G Ninja

- name: CMake Build
shell: pwsh
run: cmake --build .\build
15 changes: 8 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
.DS_Store
/.build
/Packages
xcuserdata/
DerivedData/
.swiftpm/
.netrc
.DS_Store
/.build
/build
/Packages
xcuserdata/
DerivedData/
.swiftpm/
.netrc
17 changes: 17 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cmake_minimum_required(VERSION 3.25)

project(SwiftWebDriver
LANGUAGES 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_Swift_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/swift)

option(SWIFT_WEBDRIVER_BUILD_WINAPPDRIVER "Build WinAppDriver functionality." TRUE)

add_subdirectory(Sources/WebDriver)

if(SWIFT_WEBDRIVER_BUILD_WINAPPDRIVER)
add_subdirectory(Sources/WinAppDriver)
endif()
jeffdav marked this conversation as resolved.
Show resolved Hide resolved
13 changes: 10 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ All UI tests are located in the `Tests` directory. Build and run tests using `sw

For additional examples, refer to the `Tests\WebDriverTests` directory.

## Code Submissions
Fork the repository and create a feature branch for your work. When
ready, send a pull request. Make sure that the CI workflows that
build and test the code pass. If you add files or dependencies, make
sure you update both `Package.swift` and the appropriate `CMakeLists.txt`
files. If you forget about CMake, your CI jobs will fail. `:-)`

## Bug Submissions
If you've found a bug in the project feel free to open an issue [here](https://github.com/thebrowsercompany/swift-webdriver/issues/new). Please follow the issues template provided.

## Enhancement Requests
To submit an enhancement open a new issue with the `enhancements` tag with details for what you think would be good to add.

## Style Guide
For branch names please follow the naming convention of `<name>/<desciption-of-change>` e.g. squid/docs-update. When opening a pr use the most relevant tag to your request.

For branch names please follow the naming convention of `<name>/<desciption-of-change>` e.g. squid/docs-update. When opening a pr use the most relevant tag to your request.

Thank you for helping expand the swift environment and we look forward to working with you!
##
Thank you for helping expand the swift environment and we look forward to working with you!
8 changes: 8 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ Build and run tests using `swift build` and `swift test`, or use the [Swift exte

For additional examples, refer to the `Tests\WebDriverTests` directory.

### CMake

To build with CMake, use the Ninja generator:
```powershell
cmake -S . -B build -G Ninja
cmake --build .\build\
```

## Architecture

The library has two logical layers:
Expand Down
19 changes: 19 additions & 0 deletions Sources/WebDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
add_library(WebDriver
jeffdav marked this conversation as resolved.
Show resolved Hide resolved
Capabilities.swift
Element.swift
ErrorResponse.swift
HTTPWebDriver.swift
Keys.swift
Location.swift
MouseButton.swift
Poll.swift
Request.swift
Requests.swift
ScreenOrientation.swift
Session.swift
TimeoutType.swift
TouchClickKind.swift
URLRequestExtensions.swift
WebDriver.swift
WebDriverStatus.swift
Window.swift)
12 changes: 12 additions & 0 deletions Sources/WinAppDriver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
add_library(WinAppDriver
CommandLine.swift
ErrorResponse+WinAppDriver.swift
ReexportWebDriver.swift
Win32Error.swift
Win32ProcessTree.swift
WinAppDriver+Attributes.swift
WinAppDriver+Capabilities.swift
WinAppDriver.swift
WindowsSystemPaths.swift)
target_link_libraries(WinAppDriver PRIVATE
WebDriver)
Loading