11

だから私はここで階層ビルドに関する質問を読みました: SCons を使用した階層ビルドの作成

Mercurial を使用してサブリポジトリとして設定した scons を両方とも使用する 2 つのスタンドアロンリポジトリの実際の階層構造を作成したいと考えています。以下は、私がやりたいことを示すファイルレイアウトです。

希望するレイアウト:

project_root/  (new project that builds bar app using the libfoo built from source)

    libfoo_subrepo/  (standalone project repo from bitbucket)
        src/
            SConscript
            libfoo.c
            libfoo.h
        test/
            SConscript
            test_foo.c
        SConstruct

    barapp_subrepo/  (standalone project repo from bitbucket that uses libfoo)
        src/
            SConscript
            bar.c
            bar.h
        test/
            SConscript
            test_bar.c
        SConstruct

    test/
        SConscript
        test_bar_with_foo.c
    SConstruct

したがって、両方とも scons を使用する 2 つの個別のリポジトリがあります。最初の libfoo は、スタンドアロンでクローンを作成し、scons を使用してビルドできます。libfoo ルート ディレクトリで scons を実行すると、src/ に libfoo の静的ライブラリが構築され、src/ の静的ライブラリにリンクする単体テスト実行可能ファイルが test/ に構築されます。

2 番目のリポジトリには、libfoo に依存する bar アプリがあります。これもスタンドアロンで複製でき、ビルド システムに libfoo がインストールされている場合は、scons を使用してビルドできます。

私がやりたいことは、mercurial を使用してサブリポジトリとして設定された libfoo と bar アプリ リポジトリの両方を持つ新しいリポジトリ (project_root) をセットアップすることです。したがって、この新しいレポを複製すると、bar app が自動的にプルダウンされ、依存関係のある libfoo になります。次に、この新しいリポジトリのルートで scons を実行し、libfoo_subrepo/ ルートで scons を実行して libfoo をビルドし、ユニット テストを実行できるようにしたいと考えています。次に、barapp_subrepo/ ルートで scons を実行して bar を構築し、libfoo_subrepo/src/ の libfoo 静的ライブラリにリンクするように指示します。最後に、libfoo スタティック ライブラリと bar app のソース ファイルの両方を使用して bar app と libfoo を組み合わせてテストする新しい単体テストを tests/ に作成します。

scons のドキュメントを読んでわかる限りでは、サブシェルで scons を実行する「subrepo」用のカスタム Builder を作成する必要があります。次に、libfoo.subrepo と barapp.subrepo を project_root/ ディレクトリに追加し、ビルダーがコマンドを実行して libfoo.subrepo をビルドするときに、ソース名を scons を実行するパスに変換するように、何らかの方法でリグすることができます。 .

building 'libfoo.subrepo' translates into executing 'cd libfoo_subrepo; scons'

私には、scons がスタンドアロンの scons プロジェクトを再帰的にビルドできないように見えます。私が読んだことはすべて、サブフォルダーに SConscript ファイルを作成し、ルート SConstruct ファイルを SConscript ファイルに依存させることができることを前提としています。私がsconsでやりたいことをする方法があると教えてください。作りに戻りたくない。

ありがとう。

4

2 に答える 2

9

カスタム ビルダーを作成する必要がある理由がわかりません。あなたのことを正しく理解していれば、SCons とそのビルトイン ビルダーを使用して、必要なことはすべて実行できると思います。

あなたが説明したことを行うには、3つの個別のビルドを実行できるようにするには、実際に3つの個別のSConsctructファイルが必要です。また、3 つの SConscript ファイルを追加し、それらすべてを次のように作成します。

編集:この例では、SConstruct スクリプトで Environment() を作成することをお勧めします

project_root/SConstruct

# This SConstruct orchestrates building 3 subdirs

import os

subdirs = ['libfoo_subrepo', 'barapp_subrepo', 'test']
env = Environment()

for subdir in subdirs:
    SConscript(os.path.join(subdir, 'SConscript'), exports = ['env'])

libfoo_subrepo/SConstruct

# This SConstruct does nothing more than load the SConscript in this dir
# The Environment() is created in the SConstruct script
# This dir can be built standalone by executing scons here, or together
# by executing scons in the parent directory
env = Environment()
SConscript('SConscript', exports = ['env'])

libfoo_subrepo/SConscript

# This SConstruct orchestrates building 2 subdirs
import os

Import('env')
subdirs = ['src', 'test']

for subdir in subdirs:
    SConscript(os.path.join(subdir, 'SConscript'), exports = ['env'])

barapp_subrepo/SConstruct

# This SConstruct does nothing more than load the SConscript in this dir
# The Environment() is created in the SConstruct script
# This dir can be build standalone by executing scons here, or together
# by executing scons in the parent directory
env = Environment()
SConscript('SConscript', exports = ['env'])

barapp_subrepo/SConscript

# This SConstruct orchestrates building 2 subdirs
import os

Import('env')
subdirs = ['src', 'test']

for subdir in subdirs:
    SConscript(os.path.join(subdir, 'SConscript'), exports = ['env'])

各ファイルのコメントがその目的を説明していることを願っています。

お役に立てれば。

于 2012-03-31T12:08:37.413 に答える