From 9c58c4e43b7850cc38dc61352f4548cc0acf14ea Mon Sep 17 00:00:00 2001 From: Arsen Date: Mon, 17 Feb 2020 01:38:47 +0100 Subject: [PATCH] ci: add files needed to build with jenkins --- ci/Jenkinsfile | 33 ++++++++++++++++ ci/bootstrap.yml | 89 ++++++++++++++++++++++++++++++++++++++++++++ ci/docker/Dockerfile | 11 ++++++ ci/docker/gitconfig | 3 ++ 4 files changed, 136 insertions(+) create mode 100644 ci/Jenkinsfile create mode 100644 ci/bootstrap.yml create mode 100644 ci/docker/Dockerfile create mode 100644 ci/docker/gitconfig diff --git a/ci/Jenkinsfile b/ci/Jenkinsfile new file mode 100644 index 00000000..640b2a0c --- /dev/null +++ b/ci/Jenkinsfile @@ -0,0 +1,33 @@ +// vim: sw=4 et : +node { + stage('Fetch sources') { + dir('src') { + dir ('mlibc') { + checkout scm + // don't replace sources + writeFile file: 'checkedout.xbstrap', text: '' + } + sh 'cp mlibc/ci/bootstrap.yml .' + } + } + docker.build('mlibc_cienv', 'src/mlibc/ci/docker').inside { + dir('build') { + stage('Prepare build') { + sh '''#!/bin/sh + set -xe + xbstrap init ../src || true # no cleanWs() step + ''' + } + stage('Build mlibc') { + sh 'xbstrap install --reconfigure mlibc' + } + stage('Install gcc') { + sh 'xbstrap install-tool --recompile gcc' + } + stage('Collect results') { + sh 'tar c system-root | xz - > root.tar.xz' + archiveArtifacts 'root.tar.xz' + } + } + } +} diff --git a/ci/bootstrap.yml b/ci/bootstrap.yml new file mode 100644 index 00000000..2165efb6 --- /dev/null +++ b/ci/bootstrap.yml @@ -0,0 +1,89 @@ +sources: + - name: cxxshim + git: 'https://github.com/managarm/cxxshim.git' + branch: 'master' + + - name: frigg + git: 'https://github.com/managarm/frigg.git' + branch: 'master' + + - name: gcc + git: 'git://gcc.gnu.org/git/gcc.git' + tag: 'releases/gcc-9.2.0' + regenerate: + - args: ['./contrib/download_prerequisites'] + workdir: '@THIS_SOURCE_DIR@' + + - name: mlibc + git: 'https://github.com/managarm/mlibc.git' + branch: 'master' + sources_required: + - cxxshim + - frigg + regenerate: + - args: ['ln', '-sf', '@SOURCE_ROOT@/cxxshim', '@THIS_SOURCE_DIR@/subprojects/cxxshim'] + - args: ['ln', '-sf', '@SOURCE_ROOT@/frigg', '@THIS_SOURCE_DIR@/subprojects/frigg'] + +tools: + - name: gcc + from_source: gcc + configure: + - args: + - '@THIS_SOURCE_DIR@/configure' + - '--prefix=@PREFIX@' + - '--program-prefix=mlibc-' + - '--with-sysroot=@SYSROOT_DIR@' + - '--enable-languages=c,c++' + - '--disable-multilib' + - '--disable-bootstrap' + # -g blows up GCC's binary size. + - 'CFLAGS=-O2' + - 'CXXFLAGS=-O2' + stages: + - name: compiler + pkgs_required: + - mlibc + compile: + # GCC complains if the include directory is non-existant. + - args: ['mkdir', '-p', '@SYSROOT_DIR@/usr/include'] + - args: ['make', '-j@PARALLELISM@', 'all-gcc'] + install: + - args: ['make', 'install-gcc'] + - name: libgcc + tools_required: + - tool: gcc + stage_dependencies: [compiler] + compile: + - args: ['make', '-j@PARALLELISM@', 'all-target-libgcc'] + install: + - args: ['make', 'install-target-libgcc'] + # TODO: to build libstdc++, we need to pass -rpath and --dynamic-linker. +# - name: libstdc++ +# tools_required: +# - tool: gcc +# stage_dependencies: [libgcc] +# compile: +# - args: ['make', '-j@PARALLELISM@', 'all-target-libstdc++-v3'] +# install: +# - args: ['make', 'install-target-libstdc++-v3'] + +packages: + - name: mlibc + from_source: mlibc + configure: + - args: + - 'meson' + - '--prefix=/usr' + - '--libdir=lib' + - '--buildtype=debugoptimized' + - '@THIS_SOURCE_DIR@' + build: + - args: ['ninja'] + - args: ['ninja', 'install'] + environ: + DESTDIR: '@THIS_COLLECT_DIR@' + quiet: true + - args: ['cp', '/usr/lib/x86_64-linux-gnu/crti.o', '@THIS_COLLECT_DIR@/usr/lib'] + quiet: true + - args: ['cp', '/usr/lib/x86_64-linux-gnu/crtn.o', '@THIS_COLLECT_DIR@/usr/lib'] + quiet: true diff --git a/ci/docker/Dockerfile b/ci/docker/Dockerfile new file mode 100644 index 00000000..8e4f9898 --- /dev/null +++ b/ci/docker/Dockerfile @@ -0,0 +1,11 @@ +FROM debian:buster + +RUN apt update +RUN apt -y install build-essential pkg-config autopoint bison curl flex gettext git gperf help2man m4 mercurial ninja-build python3-mako python3-protobuf python3-yaml texinfo unzip wget xsltproc xz-utils libexpat1-dev rsync python3-pip doxygen + +RUN pip3 install meson +RUN pip3 install xbstrap + +ADD gitconfig /etc/gitconfig + +CMD ["bash"] diff --git a/ci/docker/gitconfig b/ci/docker/gitconfig new file mode 100644 index 00000000..7c4ca93a --- /dev/null +++ b/ci/docker/gitconfig @@ -0,0 +1,3 @@ +[user] + email = build@localhost + name = build