Skip to content

Vendor libarchive and use SwiftPM to build #154

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

Closed
wants to merge 5 commits into from
Closed
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
72 changes: 39 additions & 33 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
// swift-tools-version:5.10

import Foundation
import PackageDescription

let swiftlyTarget: Target = .executableTarget(
name: "Swiftly",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.target(name: "SwiftlyCore"),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
]
)

let ghApiCacheResources = (1...16).map { Resource.embedInCode("gh-api-cache/swift-tags-page\($0).json") }
let ghApiCacheExcludedResources = (17...27).map { "gh-api-cache/swift-tags-page\($0).json" }

Expand All @@ -26,16 +36,7 @@ let package = Package(
.package(url: "https://github.com/nicklockwood/SwiftFormat", exact: "0.49.18"),
],
targets: [
.executableTarget(
name: "Swiftly",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.target(name: "SwiftlyCore"),
.target(name: "LinuxPlatform", condition: .when(platforms: [.linux])),
.target(name: "MacOSPlatform", condition: .when(platforms: [.macOS])),
.product(name: "SwiftToolsSupport-auto", package: "swift-tools-support-core"),
]
),
swiftlyTarget,
.target(
name: "SwiftlyCore",
dependencies: [
Expand Down Expand Up @@ -67,29 +68,6 @@ let package = Package(
],
path: "Tools/generate-docs-reference"
),
.target(
name: "LinuxPlatform",
dependencies: [
"SwiftlyCore",
"CLibArchive",
],
linkerSettings: [
.linkedLibrary("z"),
]
),
.target(
name: "MacOSPlatform",
dependencies: [
"SwiftlyCore",
]
),
.systemLibrary(
name: "CLibArchive",
pkgConfig: "libarchive",
providers: [
.apt(["libarchive-dev"]),
]
),
.testTarget(
name: "SwiftlyTests",
dependencies: ["Swiftly"],
Expand All @@ -100,3 +78,31 @@ let package = Package(
),
]
)

#if os(Linux)

package.dependencies.append(.package(path: "libarchive"))
package.targets.append(
.target(
name: "LinuxPlatform",
dependencies: [
.target(name: "SwiftlyCore"),
.product(name: "archive-devel", package: "libarchive"),
]
)
)
swiftlyTarget.dependencies.append(.target(name: "LinuxPlatform"))

#elseif os(macOS)

package.targets.append(
.target(
name: "MacOSPlatform",
dependencies: [
"SwiftlyCore",
]
)
)
swiftlyTarget.dependencies.append(.target(name: "MacOSPlatform"))

#endif
5 changes: 0 additions & 5 deletions Sources/CLibArchive/module.modulemap

This file was deleted.

2 changes: 0 additions & 2 deletions Sources/CLibArchive/shim.h

This file was deleted.

2 changes: 1 addition & 1 deletion Sources/LinuxPlatform/Extract.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CLibArchive
import CArchive
import Foundation

// The code in this file consists mainly of a Swift port of the "Complete Extractor" example included in the libarchive
Expand Down
2 changes: 1 addition & 1 deletion docker/install-test-ubi9.dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG base_image=redhat/ubi9:latest
FROM $base_image

RUN yum install --allowerasing -y curl gcc-c++ gpg
RUN yum install --allowerasing -y curl gpg
RUN echo 'export PATH="$HOME/.local/bin:$PATH"' >> $HOME/.profile
5 changes: 0 additions & 5 deletions docker/test-amazonlinux2.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ ARG ubuntu_version
# dependencies
RUN yum install -y \
curl \
gcc \
gcc-c++ \
make \
gpg
COPY ./scripts/install-libarchive.sh /
RUN /install-libarchive.sh

RUN curl -L https://swift.org/keys/all-keys.asc | gpg --import
5 changes: 0 additions & 5 deletions docker/test-ubi9.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ ARG ubuntu_version
# dependencies
RUN yum install -y --allowerasing \
curl \
gcc \
gcc-c++ \
make \
gpg
COPY ./scripts/install-libarchive.sh /
RUN /install-libarchive.sh

RUN curl -L https://swift.org/keys/all-keys.asc | gpg --import
4 changes: 1 addition & 3 deletions docker/test.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8

# dependencies
RUN apt-get update --fix-missing && apt-get install -y curl build-essential gpg
COPY ./scripts/install-libarchive.sh /
RUN /install-libarchive.sh
RUN apt-get update --fix-missing && apt-get install -y gpg curl

RUN curl -L https://swift.org/keys/all-keys.asc | gpg --import
44 changes: 44 additions & 0 deletions libarchive/.cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
env:
CIRRUS_CLONE_DEPTH: 1
ARCH: amd64

FreeBSD_task:
matrix:
env:
BS: autotools
env:
BS: cmake
matrix:
freebsd_instance:
image_family: freebsd-14-0
freebsd_instance:
image_family: freebsd-13-2
prepare_script:
- ./build/ci/cirrus_ci/ci.sh prepare
configure_script:
- env CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./build/ci/build.sh -a autogen
- env CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./build/ci/build.sh -a configure
build_script:
- env MAKE_ARGS="-j 2" ./build/ci/build.sh -a build
test_script:
- env SKIP_TEST_RESTORE_ATIME=1 MAKE_ARGS="-j 2" ./build/ci/build.sh -a test
- ./build/ci/cirrus_ci/ci.sh test
install_script:
- env MAKE_ARGS="-j 2" ./build/ci/build.sh -a install

Windows_Cygwin_task:
windows_container:
image: cirrusci/windowsservercore:2019
os_version: 2019
env:
BE: cygwin-gcc
prepare_script:
- build\ci\cirrus_ci\ci.cmd prepare
configure_script:
- build\ci\cirrus_ci\ci.cmd configure
build_script:
- build\ci\cirrus_ci\ci.cmd build
test_script:
- build\ci\cirrus_ci\ci.cmd test
install_script:
- build\ci\cirrus_ci\ci.cmd install
18 changes: 18 additions & 0 deletions libarchive/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# To use this config on you editor, follow the instructions at:
# http://editorconfig.org

root = true

[*]
charset = utf-8
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true

[*.sh]
indent_style = space
indent_size = 4

[CMakeLists.txt]
indent_style = space
indent_size = 2
4 changes: 4 additions & 0 deletions libarchive/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git* export-ignore

*.sh crlf=input
config.rpath crlf=input
17 changes: 17 additions & 0 deletions libarchive/.github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
commit-message:
prefix: "CI"
groups:
all-actions:
patterns:
- "*"
Loading