diff --git a/cli/build_remote.go b/cli/build_remote.go index 21d2f15..054b007 100644 --- a/cli/build_remote.go +++ b/cli/build_remote.go @@ -58,7 +58,9 @@ func buildRemote(bParams *build.BuildParams) error { buildDir := moscommon.GetBuildDir(projectDir) - os.RemoveAll(buildDir) + if !*flags.KeepBuildDir { + os.RemoveAll(buildDir) + } if err := os.MkdirAll(buildDir, 0755); err != nil { return errors.Annotatef(err, "failed to create build directory") } diff --git a/cli/flags/flags.go b/cli/flags/flags.go index 5a602bc..43bea88 100644 --- a/cli/flags/flags.go +++ b/cli/flags/flags.go @@ -129,6 +129,7 @@ var ( LibsExtra = flag.StringArray("lib-extra", []string{}, "Extra libs to add to the app being built. Value should be a YAML string. Can be used multiple times.") SaveBuildStat = flag.Bool("save-build-stat", true, "save build statistics") PreferPrebuiltLibs = flag.Bool("prefer-prebuilt-libs", false, "if both sources and prebuilt binary of a lib exists, use the binary") + KeepBuildDir = flag.Bool("keep-build-dir", false, "do not remove build dir before build, enables incremental remote builds") DepsVersions = flag.String("deps-versions", "", "If specified, this file will be consulted for all libs and modules versions") StrictDepsVersions = flag.Bool("strict-deps-versions", true, "If set, then --deps-versions will be in strict mode: missing deps will be disallowed")