Refactor build and topdata path resolution through project config
This commit is contained in:
@@ -22,41 +22,31 @@ const (
|
||||
)
|
||||
|
||||
func compiled2DAOutputDir(p *project.Project) string {
|
||||
return filepath.Join(p.TopDataBuildDir(), "2da")
|
||||
}
|
||||
|
||||
func defaultTopDataCacheDir(p *project.Project) string {
|
||||
return filepath.Join(p.Root, ".cache")
|
||||
return p.TopDataCompiled2DADir()
|
||||
}
|
||||
|
||||
func topDataBuildUsesRepoCache(p *project.Project) bool {
|
||||
return samePath(p.TopDataBuildDir(), defaultTopDataCacheDir(p))
|
||||
return p.TopDataUsesRepoCache()
|
||||
}
|
||||
|
||||
func compiledTLKOutputPath(p *project.Project) string {
|
||||
if topDataBuildUsesRepoCache(p) {
|
||||
return filepath.Join(p.BuildDir(), defaultTLKName)
|
||||
}
|
||||
return filepath.Join(p.TopDataBuildDir(), defaultTLKName)
|
||||
return p.TopDataCompiledTLKPath()
|
||||
}
|
||||
|
||||
func compiledTLKOutputDir(p *project.Project) string {
|
||||
return filepath.Dir(compiledTLKOutputPath(p))
|
||||
return p.TopDataCompiledTLKDir()
|
||||
}
|
||||
|
||||
func wikiOutputRootDir(p *project.Project) string {
|
||||
if topDataBuildUsesRepoCache(p) {
|
||||
return filepath.Join(defaultTopDataCacheDir(p), wikiRootDirName)
|
||||
}
|
||||
return filepath.Join(p.TopDataBuildDir(), wikiRootDirName)
|
||||
return p.TopDataWikiRootDir()
|
||||
}
|
||||
|
||||
func wikiOutputPagesDir(p *project.Project) string {
|
||||
return filepath.Join(wikiOutputRootDir(p), wikiPagesDirName)
|
||||
return p.TopDataWikiPagesDir()
|
||||
}
|
||||
|
||||
func wikiOutputStatePath(p *project.Project) string {
|
||||
return filepath.Join(wikiOutputRootDir(p), wikiStateFileName)
|
||||
return p.TopDataWikiStatePath()
|
||||
}
|
||||
|
||||
func legacyCompiled2DAOutputDir(p *project.Project) string {
|
||||
@@ -106,7 +96,7 @@ func BuildAndPackageWithOptions(p *project.Project, opts BuildAndPackageOptions,
|
||||
return PackageResult{}, err
|
||||
}
|
||||
if ok {
|
||||
progress("Compiled topdata outputs are current; refreshing sow_top.hak and sow_tlk.tlk only.")
|
||||
progress(fmt.Sprintf("Compiled topdata outputs are current; refreshing %s and %s only.", p.TopDataPackageHAKName(), p.TopDataPackageTLKName()))
|
||||
return packageBuiltTopData(p, nativeResult, progress)
|
||||
}
|
||||
}
|
||||
@@ -133,11 +123,10 @@ func packageBuiltTopData(p *project.Project, nativeResult BuildResult, progress
|
||||
if progress == nil {
|
||||
progress = func(string) {}
|
||||
}
|
||||
buildDir := p.BuildDir()
|
||||
outputHAK := filepath.Join(buildDir, PackageHAKFileName)
|
||||
outputTLK := filepath.Join(buildDir, PackageTLKFileName)
|
||||
outputHAK := p.TopDataPackageHAKPath()
|
||||
outputTLK := p.TopDataPackageTLKPath()
|
||||
|
||||
progress("Packaging compiled topdata resources into sow_top.hak...")
|
||||
progress(fmt.Sprintf("Packaging compiled topdata resources into %s...", filepath.Base(outputHAK)))
|
||||
resources, assetFiles, err := collectTopPackageResources(p, nativeResult.Output2DADir)
|
||||
if err != nil {
|
||||
return PackageResult{}, err
|
||||
@@ -146,7 +135,7 @@ func packageBuiltTopData(p *project.Project, nativeResult BuildResult, progress
|
||||
return PackageResult{}, err
|
||||
}
|
||||
|
||||
progress("Preparing compiled TLK release output...")
|
||||
progress(fmt.Sprintf("Preparing compiled TLK release output %s...", filepath.Base(outputTLK)))
|
||||
sourceTLK := compiledTLKOutputPath(p)
|
||||
if nativeResult.OutputTLKDir != "" {
|
||||
sourceTLK, err = resolveCompiledTLKPath(nativeResult.OutputTLKDir)
|
||||
@@ -446,8 +435,8 @@ func currentTopPackageResult(p *project.Project) (PackageResult, bool, error) {
|
||||
return PackageResult{}, ok, err
|
||||
}
|
||||
|
||||
outputHAK := filepath.Join(p.BuildDir(), PackageHAKFileName)
|
||||
outputTLK := filepath.Join(p.BuildDir(), PackageTLKFileName)
|
||||
outputHAK := p.TopDataPackageHAKPath()
|
||||
outputTLK := p.TopDataPackageTLKPath()
|
||||
hakInfo, err := os.Stat(outputHAK)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
||||
Reference in New Issue
Block a user