From e441b9df9a68595d0dd7b8ed184aecb27c86054b Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Mon, 26 Jan 2015 16:30:13 -0800 Subject: [PATCH] Initial soong This creates the infrastructure that will be used to bootstrap the soong primary builder through blueprint and ninja. Change-Id: Iebed8f369e4db41b207d0b2a48a7a54a4dd7d45d --- Blueprints | 0 bootstrap.bash | 34 +++++++ build.ninja.in | 249 +++++++++++++++++++++++++++++++++++++++++++++++++ root.bp | 4 + soong.in | 24 +++++ 5 files changed, 311 insertions(+) create mode 100644 Blueprints create mode 100755 bootstrap.bash create mode 100644 build.ninja.in create mode 100644 root.bp create mode 100644 soong.in diff --git a/Blueprints b/Blueprints new file mode 100644 index 000000000..e69de29bb diff --git a/bootstrap.bash b/bootstrap.bash new file mode 100755 index 000000000..0aa073cc4 --- /dev/null +++ b/bootstrap.bash @@ -0,0 +1,34 @@ +#!/bin/bash + +export BOOTSTRAP="${BASH_SOURCE[0]}" +export SRCDIR=$(dirname "${BASH_SOURCE[0]}") +export BOOTSTRAP_MANIFEST="${SRCDIR}/build/soong/build.ninja.in" + +case $(uname) in + Linux) + export GOOS="linux" + export PREBUILTOS="linux-x86" + ;; + Darwin) + export GOOS="darwin" + export PREBUILTOS="darwin-x86" + ;; + *) echo "unknown OS:" $(uname) && exit 1;; +esac +export GOROOT="${SRCDIR}/prebuilts/go/$PREBUILTOS/" +export GOARCH="amd64" +export GOCHAR="6" + +if [[ $(find . -maxdepth 1 -name $(basename "${BOOTSTRAP}")) ]]; then + echo "FAILED: Tried to run "$(basename "${BOOTSTRAP}")" from "$(pwd)"" + exit 1 +fi + +if [[ $# -eq 0 ]]; then + sed -e "s|@@SrcDir@@|${SRCDIR}|" \ + -e "s|@@PrebuiltOS@@|${PREBUILTOS}|" \ + ${SRCDIR}/build/soong/soong.in > soong + chmod 0770 soong +fi + +${SRCDIR}/build/blueprint/bootstrap.bash "$@" diff --git a/build.ninja.in b/build.ninja.in new file mode 100644 index 000000000..d5b0a7c31 --- /dev/null +++ b/build.ninja.in @@ -0,0 +1,249 @@ +# ****************************************************************************** +# *** This file is generated and should not be edited *** +# ****************************************************************************** +# +# This file contains variables, rules, and pools with name prefixes indicating +# they were generated by the following Go packages: +# +# bootstrap [from Go package blueprint/bootstrap] +# +ninja_required_version = 1.1.0 + +g.bootstrap.bootstrapCmd = @@Bootstrap@@ + +g.bootstrap.bootstrapManifest = @@BootstrapManifest@@ + +g.bootstrap.goRoot = @@GoRoot@@ + +g.bootstrap.goOS = @@GoOS@@ + +g.bootstrap.goArch = @@GoArch@@ + +g.bootstrap.goToolDir = ${g.bootstrap.goRoot}/pkg/tool/${g.bootstrap.goOS}_${g.bootstrap.goArch} + +g.bootstrap.goChar = @@GoChar@@ + +g.bootstrap.gcCmd = ${g.bootstrap.goToolDir}/${g.bootstrap.goChar}g + +g.bootstrap.linkCmd = ${g.bootstrap.goToolDir}/${g.bootstrap.goChar}l + +g.bootstrap.srcDir = @@SrcDir@@ + +builddir = .bootstrap + +rule g.bootstrap.bootstrap + command = ${g.bootstrap.bootstrapCmd} -i ${in} + description = bootstrap ${in} + generator = true + +rule g.bootstrap.cp + command = cp ${in} ${out} + description = cp ${out} + +rule g.bootstrap.gc + command = GOROOT='${g.bootstrap.goRoot}' ${g.bootstrap.gcCmd} -o ${out} -p ${pkgPath} -complete ${incFlags} -pack ${in} + description = ${g.bootstrap.goChar}g ${out} + +rule g.bootstrap.link + command = GOROOT='${g.bootstrap.goRoot}' ${g.bootstrap.linkCmd} -o ${out} ${libDirFlags} ${in} + description = ${g.bootstrap.goChar}l ${out} + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: blueprint +# Type: bootstrap_go_package +# Factory: blueprint/bootstrap.newGoPackageModule +# Defined: build/blueprint/Blueprints:1:1 + +build .bootstrap/blueprint/pkg/blueprint.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/blueprint/context.go $ + ${g.bootstrap.srcDir}/build/blueprint/live_tracker.go $ + ${g.bootstrap.srcDir}/build/blueprint/mangle.go $ + ${g.bootstrap.srcDir}/build/blueprint/module_ctx.go $ + ${g.bootstrap.srcDir}/build/blueprint/ninja_defs.go $ + ${g.bootstrap.srcDir}/build/blueprint/ninja_strings.go $ + ${g.bootstrap.srcDir}/build/blueprint/ninja_writer.go $ + ${g.bootstrap.srcDir}/build/blueprint/package_ctx.go $ + ${g.bootstrap.srcDir}/build/blueprint/scope.go $ + ${g.bootstrap.srcDir}/build/blueprint/singleton_ctx.go $ + ${g.bootstrap.srcDir}/build/blueprint/unpack.go | ${g.bootstrap.gcCmd} $ + .bootstrap/blueprint-parser/pkg/blueprint/parser.a $ + .bootstrap/blueprint-proptools/pkg/blueprint/proptools.a + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-proptools/pkg + pkgPath = blueprint +default .bootstrap/blueprint/pkg/blueprint.a + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: blueprint-bootstrap +# Type: bootstrap_go_package +# Factory: blueprint/bootstrap.newGoPackageModule +# Defined: build/blueprint/Blueprints:55:1 + +build .bootstrap/blueprint-bootstrap/pkg/blueprint/bootstrap.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/blueprint/bootstrap/bootstrap.go $ + ${g.bootstrap.srcDir}/build/blueprint/bootstrap/cleanup.go $ + ${g.bootstrap.srcDir}/build/blueprint/bootstrap/command.go $ + ${g.bootstrap.srcDir}/build/blueprint/bootstrap/config.go $ + ${g.bootstrap.srcDir}/build/blueprint/bootstrap/doc.go | $ + ${g.bootstrap.gcCmd} $ + .bootstrap/blueprint-parser/pkg/blueprint/parser.a $ + .bootstrap/blueprint-proptools/pkg/blueprint/proptools.a $ + .bootstrap/blueprint/pkg/blueprint.a $ + .bootstrap/blueprint-deptools/pkg/blueprint/deptools.a $ + .bootstrap/blueprint-pathtools/pkg/blueprint/pathtools.a + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-pathtools/pkg + pkgPath = blueprint/bootstrap +default .bootstrap/blueprint-bootstrap/pkg/blueprint/bootstrap.a + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: blueprint-deptools +# Type: bootstrap_go_package +# Factory: blueprint/bootstrap.newGoPackageModule +# Defined: build/blueprint/Blueprints:34:1 + +build .bootstrap/blueprint-deptools/pkg/blueprint/deptools.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/blueprint/deptools/depfile.go | $ + ${g.bootstrap.gcCmd} + pkgPath = blueprint/deptools +default .bootstrap/blueprint-deptools/pkg/blueprint/deptools.a + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: blueprint-parser +# Type: bootstrap_go_package +# Factory: blueprint/bootstrap.newGoPackageModule +# Defined: build/blueprint/Blueprints:23:1 + +build .bootstrap/blueprint-parser/pkg/blueprint/parser.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/blueprint/parser/modify.go $ + ${g.bootstrap.srcDir}/build/blueprint/parser/parser.go $ + ${g.bootstrap.srcDir}/build/blueprint/parser/printer.go $ + ${g.bootstrap.srcDir}/build/blueprint/parser/sort.go | $ + ${g.bootstrap.gcCmd} + pkgPath = blueprint/parser +default .bootstrap/blueprint-parser/pkg/blueprint/parser.a + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: blueprint-pathtools +# Type: bootstrap_go_package +# Factory: blueprint/bootstrap.newGoPackageModule +# Defined: build/blueprint/Blueprints:40:1 + +build .bootstrap/blueprint-pathtools/pkg/blueprint/pathtools.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/blueprint/pathtools/lists.go $ + ${g.bootstrap.srcDir}/build/blueprint/pathtools/glob.go | $ + ${g.bootstrap.gcCmd} + pkgPath = blueprint/pathtools +default .bootstrap/blueprint-pathtools/pkg/blueprint/pathtools.a + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: blueprint-proptools +# Type: bootstrap_go_package +# Factory: blueprint/bootstrap.newGoPackageModule +# Defined: build/blueprint/Blueprints:49:1 + +build .bootstrap/blueprint-proptools/pkg/blueprint/proptools.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/blueprint/proptools/proptools.go | $ + ${g.bootstrap.gcCmd} + pkgPath = blueprint/proptools +default .bootstrap/blueprint-proptools/pkg/blueprint/proptools.a + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: bpfmt +# Type: bootstrap_go_binary +# Factory: blueprint/bootstrap.newGoBinaryModule +# Defined: build/blueprint/Blueprints:81:1 + +build .bootstrap/bpfmt/obj/bpfmt.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/blueprint/bpfmt/bpfmt.go | $ + ${g.bootstrap.gcCmd} $ + .bootstrap/blueprint-parser/pkg/blueprint/parser.a + incFlags = -I .bootstrap/blueprint-parser/pkg + pkgPath = bpfmt +default .bootstrap/bpfmt/obj/bpfmt.a + +build .bootstrap/bpfmt/obj/a.out: g.bootstrap.link $ + .bootstrap/bpfmt/obj/bpfmt.a | ${g.bootstrap.linkCmd} + libDirFlags = -L .bootstrap/blueprint-parser/pkg +default .bootstrap/bpfmt/obj/a.out + +build .bootstrap/bin/bpfmt: g.bootstrap.cp .bootstrap/bpfmt/obj/a.out +default .bootstrap/bin/bpfmt + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: bpmodify +# Type: bootstrap_go_binary +# Factory: blueprint/bootstrap.newGoBinaryModule +# Defined: build/blueprint/Blueprints:87:1 + +build .bootstrap/bpmodify/obj/bpmodify.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/blueprint/bpmodify/bpmodify.go | $ + ${g.bootstrap.gcCmd} $ + .bootstrap/blueprint-parser/pkg/blueprint/parser.a + incFlags = -I .bootstrap/blueprint-parser/pkg + pkgPath = bpmodify +default .bootstrap/bpmodify/obj/bpmodify.a + +build .bootstrap/bpmodify/obj/a.out: g.bootstrap.link $ + .bootstrap/bpmodify/obj/bpmodify.a | ${g.bootstrap.linkCmd} + libDirFlags = -L .bootstrap/blueprint-parser/pkg +default .bootstrap/bpmodify/obj/a.out + +build .bootstrap/bin/bpmodify: g.bootstrap.cp .bootstrap/bpmodify/obj/a.out +default .bootstrap/bin/bpmodify + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Module: minibp +# Type: bootstrap_go_binary +# Factory: blueprint/bootstrap.newGoBinaryModule +# Defined: build/blueprint/Blueprints:72:1 + +build .bootstrap/minibp/obj/minibp.a: g.bootstrap.gc $ + ${g.bootstrap.srcDir}/build/blueprint/bootstrap/minibp/main.go | $ + ${g.bootstrap.gcCmd} $ + .bootstrap/blueprint-parser/pkg/blueprint/parser.a $ + .bootstrap/blueprint-proptools/pkg/blueprint/proptools.a $ + .bootstrap/blueprint/pkg/blueprint.a $ + .bootstrap/blueprint-deptools/pkg/blueprint/deptools.a $ + .bootstrap/blueprint-pathtools/pkg/blueprint/pathtools.a $ + .bootstrap/blueprint-bootstrap/pkg/blueprint/bootstrap.a + incFlags = -I .bootstrap/blueprint-parser/pkg -I .bootstrap/blueprint-proptools/pkg -I .bootstrap/blueprint/pkg -I .bootstrap/blueprint-deptools/pkg -I .bootstrap/blueprint-pathtools/pkg -I .bootstrap/blueprint-bootstrap/pkg + pkgPath = minibp +default .bootstrap/minibp/obj/minibp.a + +build .bootstrap/minibp/obj/a.out: g.bootstrap.link $ + .bootstrap/minibp/obj/minibp.a | ${g.bootstrap.linkCmd} + libDirFlags = -L .bootstrap/blueprint-parser/pkg -L .bootstrap/blueprint-proptools/pkg -L .bootstrap/blueprint/pkg -L .bootstrap/blueprint-deptools/pkg -L .bootstrap/blueprint-pathtools/pkg -L .bootstrap/blueprint-bootstrap/pkg +default .bootstrap/minibp/obj/a.out + +build .bootstrap/bin/minibp: g.bootstrap.cp .bootstrap/minibp/obj/a.out +default .bootstrap/bin/minibp + +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# Singleton: bootstrap +# Factory: blueprint/bootstrap.newSingleton + +rule s.bootstrap.bigbp + command = .bootstrap/bin/minibp -p -d .bootstrap/main.ninja.in.d -m ${g.bootstrap.bootstrapManifest} -o ${out} ${in} + depfile = .bootstrap/main.ninja.in.d + description = minibp ${out} + +rule s.bootstrap.minibp + command = .bootstrap/bin/minibp -c ${checkFile} -m ${g.bootstrap.bootstrapManifest} -d ${out}.d -o ${out} ${in} + depfile = ${out}.d + description = minibp ${out} + generator = true + +build .bootstrap/main.ninja.in: s.bootstrap.bigbp $ + ${g.bootstrap.srcDir}/Blueprints | .bootstrap/bin/bpfmt $ + .bootstrap/bin/bpmodify .bootstrap/bin/minibp +default .bootstrap/main.ninja.in +build .bootstrap/notAFile: phony +default .bootstrap/notAFile +build build.ninja: g.bootstrap.bootstrap .bootstrap/main.ninja.in | $ + ${g.bootstrap.bootstrapCmd} .bootstrap/notAFile $ + .bootstrap/bootstrap.ninja.in +default build.ninja +build .bootstrap/bootstrap.ninja.in: s.bootstrap.minibp $ + ${g.bootstrap.srcDir}/Blueprints | .bootstrap/bin/minibp + checkFile = ${g.bootstrap.bootstrapManifest} +default .bootstrap/bootstrap.ninja.in + diff --git a/root.bp b/root.bp new file mode 100644 index 000000000..2acb742d8 --- /dev/null +++ b/root.bp @@ -0,0 +1,4 @@ +subdirs = [ + "build/blueprint", + "build/soong", +] diff --git a/soong.in b/soong.in new file mode 100644 index 000000000..51882db97 --- /dev/null +++ b/soong.in @@ -0,0 +1,24 @@ +#!/bin/bash + +# Determine the build directory location based on the location of this script. +BPBUILD="${BASH_SOURCE[0]}" +BUILDDIR=`dirname "${BASH_SOURCE[0]}"` + +# The source directory path and operating system will get substituted in by +# the bootstrap script. +SRCDIR_IN=@@SrcDir@@ +if [[ ${SRCDIR_IN:0:1} == '/' ]]; then + # SRCDIR_IN is an absolute path + SRCDIR=${SRCDIR_IN} +else + # SRCDIR_IN is a relative path + SRCDIR=${BUILDDIR}/${SRCDIR_IN} +fi + +PREBUILTOS=@@PrebuiltOS@@ + +# Let Blueprint know that the Ninja we're using performs multiple passes that +# can regenerate the build manifest. +export BLUEPRINT_NINJA_HAS_MULTIPASS=1 + +${SRCDIR}/prebuilts/ninja/${PREBUILTOS}/ninja -C ${BUILDDIR} "$@"