Skip to content

Commit f18164d

Browse files
committed
[Static Linux] Add build scripts.
Add the build scripts for the fully static Linux SDK. rdar://129171568
1 parent 987156a commit f18164d

21 files changed

+4242
-0
lines changed

swift-ci/sdks/static-linux/Dockerfile

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# ===----------------------------------------------------------------------===
2+
#
3+
# Swift Static SDK for Linux: Docker-based build
4+
#
5+
# This source file is part of the Swift.org open source project
6+
#
7+
# Copyright (c) 2024 Apple Inc. and the Swift project authors
8+
# Licensed under Apache License v2.0 with Runtime Library Exception
9+
#
10+
# See https://swift.org/LICENSE.txt for license information
11+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
12+
#
13+
# ===----------------------------------------------------------------------===
14+
15+
FROM ubuntu:22.04
16+
17+
# Versions to fetch
18+
19+
ARG SWIFT_VERSION=scheme:release/6.0
20+
ARG MUSL_VERSION=1.2.5
21+
ARG LIBXML2_VERSION=2.12.7
22+
ARG CURL_VERSION=8.7.1
23+
ARG BORINGSSL_VERSION=fips-20220613
24+
ARG ICU_VERSION=maint/maint-69
25+
ARG ZLIB_VERSION=1.3.1
26+
27+
# ............................................................................
28+
29+
# Install development tools
30+
RUN apt-get -q update \
31+
&& DEBIAN_FRONTEND=noninteractive apt-get -q install -y \
32+
build-essential \
33+
cmake \
34+
ninja-build \
35+
python3 \
36+
golang \
37+
git \
38+
gnupg2 \
39+
libsqlite3-dev \
40+
libcurl4-openssl-dev \
41+
libedit-dev \
42+
libicu-dev \
43+
libncurses5-dev \
44+
libpython3-dev \
45+
libsqlite3-dev \
46+
libxml2-dev \
47+
uuid-dev \
48+
uuid-runtime \
49+
tzdata \
50+
curl \
51+
&& rm -rf /var/lib/apt-lists/*
52+
53+
# Install Swift
54+
ARG SWIFT_SIGNING_KEY=E813C892820A6FA13755B268F167DF1ACF9CE069
55+
ARG SWIFT_PLATFORM=ubuntu
56+
ARG OS_MAJOR_VER=22
57+
ARG OS_MINOR_VER=04
58+
ARG SWIFT_WEBROOT=https://download.swift.org/swift-6.0-branch
59+
60+
ENV SWIFT_SIGNING_KEY=$SWIFT_SIGNING_KEY \
61+
SWIFT_PLATFORM=$SWIFT_PLATFORM \
62+
OS_MAJOR_VER=$OS_MAJOR_VER \
63+
OS_MINOR_VER=$OS_MINOR_VER \
64+
OS_VER=$SWIFT_PLATFORM$OS_MAJOR_VER.$OS_MINOR_VER \
65+
SWIFT_WEBROOT="$SWIFT_WEBROOT/$SWIFT_PLATFORM$OS_MAJOR_VER$OS_MINOR_VER"
66+
67+
COPY scripts/install-swift.sh /scripts/install-swift.sh
68+
RUN chmod ugo+x /scripts/install-swift.sh
69+
70+
RUN /scripts/install-swift.sh
71+
72+
ENV PATH="/usr/local/swift/bin:${PATH}"
73+
74+
ENV SWIFT_VERSION=$SWIFT_VERSION \
75+
MUSL_VERSION=$MUSL_VERSION \
76+
LIBXML2_VERSION=$LIBXML2_VERSION \
77+
CURL_VERSION=$CURL_VERSION \
78+
BORINGSSL_VERSION=$BORINGSSL_VERSION \
79+
ICU_VERSION=$ICU_VERSION \
80+
ZLIB_VERSION=$ZLIB_VERSION
81+
82+
COPY scripts /scripts
83+
RUN chmod ugo+x /scripts/*
84+
85+
COPY resources /resources
86+
87+
# Create a user
88+
RUN groupadd -g 998 build-user && \
89+
useradd -m -r -u 998 -g build-user build-user
90+
91+
USER build-user
92+
93+
WORKDIR /home/build-user
94+
95+
96+
97+

swift-ci/sdks/static-linux/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Dockerfile-based build for Swift Static Linux SDK
2+
3+
## What is this?
4+
5+
This is a Dockerfile-based build set-up for the Swift Static Linux SDK.
6+
7+
To use it, you need to build the Docker image with
8+
9+
```shell
10+
$ docker build -t static-swift-linux .
11+
```
12+
13+
then you can check-out the sources somewhere using
14+
15+
```shell
16+
$ scripts/fetch-source.sh --clone-with-ssh --source-dir /path/to/source
17+
```
18+
19+
and finally use the Docker image to do your build
20+
21+
```shell
22+
$ mkdir /path/to/products
23+
$ docker run -it --rm \
24+
-v /path/to/source:/source \
25+
-v /path/to/products:/products \
26+
static-swift-linux \
27+
/scripts/build.sh --source-dir /source --products-dir /products
28+
```
29+
30+
The artifact bundle should appear at `/path/to/products`.
31+
32+
The `scripts/build.sh` script has a number of options you may wish to
33+
investigate. Similarly with the `scripts/fetch-source.sh` script.

swift-ci/sdks/static-linux/build

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
#
3+
# ===----------------------------------------------------------------------===
4+
#
5+
# Swift Static SDK for Linux: Top-level Build Script
6+
#
7+
# This source file is part of the Swift.org open source project
8+
#
9+
# Copyright (c) 2024 Apple Inc. and the Swift project authors
10+
# Licensed under Apache License v2.0 with Runtime Library Exception
11+
#
12+
# See https://swift.org/LICENSE.txt for license information
13+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
14+
#
15+
# ===----------------------------------------------------------------------===
16+
17+
DOCKER=docker
18+
19+
# Build the Docker image
20+
$(DOCKER) build -t static-swift-linux .
21+
22+
# Check-out the sources
23+
scripts/fetch-source.sh --clone-with-ssh --source-dir source
24+
25+
mkdir -p products
26+
27+
# Run the build
28+
$(DOCKER) run -it --rm \
29+
-v ./source:/source \
30+
-v ./products:/products \
31+
static-swift-linux \
32+
/scripts/build.sh --source-dir /source --products-dir /products
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# ===----------------------------------------------------------------------===
2+
#
3+
# Swift Static SDK for Linux: Build libfts
4+
#
5+
# This source file is part of the Swift.org open source project
6+
#
7+
# Copyright (c) 2024 Apple Inc. and the Swift project authors
8+
# Licensed under Apache License v2.0 with Runtime Library Exception
9+
#
10+
# See https://swift.org/LICENSE.txt for license information
11+
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
12+
#
13+
# ===----------------------------------------------------------------------===
14+
15+
cmake_minimum_required(VERSION 3.22.1)
16+
17+
project(fts)
18+
19+
add_library(fts STATIC fts.c)
20+
set_target_properties(fts PROPERTIES PUBLIC_HEADER fts.h)
21+
target_include_directories(fts PRIVATE SYSTEM ${CMAKE_CURRENT_SOURCE_DIR})
22+
23+
install(TARGETS fts
24+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
25+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
What is this?
2+
=============
3+
4+
Musl doesn't have fts in its libc. Alpine and other Musl-based
5+
distributions typically provide an fts implementation separately,
6+
using a derivative of NetBSD's fts, which is what you'll find in this
7+
directory.
8+
9+
Typically they use the one from https://github.com/void-linux/musl-fts
10+
but that uses GNU autotools and annoyingly they haven't checked in the
11+
generated configure script. Not that it actually *needs* a configure
12+
script, because they know what C library they're using already.
13+
14+
Anyway, I grabbed the fts sources from there and chucked them in this
15+
directory along with a CMakeLists.txt that lets us build them with
16+
CMake.
17+
18+
What's the license?
19+
===================
20+
21+
Being from NetBSD, it's the BSD license:
22+
23+
Copyright (c) 1990, 1993, 1994
24+
The Regents of the University of California. All rights reserved.
25+
26+
Redistribution and use in source and binary forms, with or without
27+
modification, are permitted provided that the following conditions
28+
are met:
29+
1. Redistributions of source code must retain the above copyright
30+
notice, this list of conditions and the following disclaimer.
31+
2. Redistributions in binary form must reproduce the above copyright
32+
notice, this list of conditions and the following disclaimer in the
33+
documentation and/or other materials provided with the distribution.
34+
3. Neither the name of the University nor the names of its contributors
35+
may be used to endorse or promote products derived from this software
36+
without specific prior written permission.
37+
38+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
39+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
41+
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
42+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
44+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
45+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
48+
SUCH DAMAGE.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.2.7
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* Configure definitions for Musl */
2+
3+
#ifndef FTS_CONFIG_H_
4+
#define FTS_CONFIG_H_
5+
6+
// We have dirfd(), in <dirent.h>
7+
#define HAVE_DIRFD 1
8+
9+
// MAX is defined in <sys/param.h>
10+
#define HAVE_DECL_MAX 1
11+
12+
// UINTMAX_MAX is in <stdint.h>
13+
#define HAVE_DECL_UINTMAX_MAX 1
14+
15+
// We don't have d_namlen
16+
//#undef HAVE_STRUCT_DIRENT_D_NAMLEN
17+
18+
// DIR is opaque
19+
//#undef HAVE_DIR_DD_FD
20+
//#undef HAVE_DIR_D_FD
21+
22+
#endif /* FTS_CONFIG_H_ */

0 commit comments

Comments
 (0)