Skip to content

Commit

Permalink
Use of Flatpak resources to populate flathub
Browse files Browse the repository at this point in the history
  • Loading branch information
hbitteur committed Jun 17, 2024
1 parent e16a1ca commit 00361a4
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 222 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "flathub"]
path = dev/flathub
[submodule "flatpak/flathub"]
path = flatpak/flathub
url = https://github.com/flathub/org.audiveris.Audiveris
3 changes: 2 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ allprojects {

// Run default configuration.
// Heap size (and other stuff) can be modified via a 'jvmLineArgs' on gradle command line
// Application arguments can be provided via a 'cmdLineArgs' on gradle command line
run {
minHeapSize = '512m'
maxHeapSize = '1g'
Expand Down Expand Up @@ -361,7 +362,7 @@ def depsFile = file('build/dependencies.json')
tasks.flatpakGradleGenerator {
description("Collect all dependencies for Flatpak")
outputFile = depsFile
downloadDirectory = '../app/build/dependencies'
downloadDirectory = 'dependencies'

outputs.file(depsFile)
doFirst { println "app. Generating dependencies" }
Expand Down
1 change: 0 additions & 1 deletion dev/flathub
Submodule flathub deleted from a7cdb3
16 changes: 11 additions & 5 deletions flatpak/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Below is a simplified tree view, focused on the main source files.
.
├── app
│   ├── build.gradle
│   ├── build
│   │   └── ... dependencies.json
│   ├── dev
│   │   ├── icons
│   │   │   └── ... // many .png icon images
Expand All @@ -36,7 +38,7 @@ Below is a simplified tree view, focused on the main source files.
│   └── src
│   └── ... // a whole tree of main and test .java files
├── dev // this folder could be removed?
│   ├── flathub // a Git submodule
│   ├── flathub // the old Git submodule
│   │   └── ...
│   ├── flatpak // no longer used
│   │   ├── ...
Expand All @@ -45,13 +47,17 @@ Below is a simplified tree view, focused on the main source files.
│   │   └── create-flatpak-dependencies.py
│   └── icon-50.gif
├── flatpak
│   ├── README.md // this file!
│   ├── build.gradle
│   ├── dev
│   │   ├── add-tessdata-prefix.sed
│   │   └── org.audiveris.audiveris.template.yml
│   ├── org.audiveris.audiveris.desktop
│   ├── org.audiveris.audiveris.metainfo.xml
│   └── README.md // this file!
│   └── flathub // the new Git submodule
│      ├── add-tessdata-prefix.sed
│      ├── org.audiveris.audiveris.desktop
│      ├── org.audiveris.audiveris.metainfo.xml
│      ├── ... lang_sources.yml // generated by task genLanguages
│      ├── ... org.audiveris.audiveris.yml // generated by task genManifest
│      └── ... dependencies.json // generated by task genDependencies
├── gradle
│   └── wrapper
│   ├── gradle-wrapper.jar
Expand Down
65 changes: 45 additions & 20 deletions flatpak/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ plugins {
id 'base'
}

def app = project(':app')
def appDir = app.projectDir
def app = project(':app')
def appDir = app.projectDir
def flathubDir = new File(project.projectDir.getAbsolutePath() + "/flathub")

// SHA1 computation
// Stolen from https://gist.github.com/dagezi/9594839#file-calcsha1-gradle
Expand All @@ -37,14 +38,13 @@ task genLanguages {
description("Generate languages sources")

doLast {
println "Generating language sources"
def outputDir = layout.buildDirectory.get().asFile
outputDir.exists() || outputDir.mkdirs()
def langFile = new File(outputDir, "lang_sources.yml")

project.delete(
fileTree(langFile)
)
///flathubDir.exists() || flathubDir.mkdirs()
def langFile = new File(flathubDir, "lang_sources.yml")
println "Generating language sources into ${langFile}"

project.delete(
fileTree(langFile)
)

fileTree("$appDir/dev/tessdata").include('*.traineddata').each { f ->
def relPath = relativePath(f).replace("\\","/")
Expand Down Expand Up @@ -72,6 +72,14 @@ task genDependencies {

FileCollection sharedFiles = configurations.getByName("sharedConfiguration")
inputs.files(sharedFiles)

doLast {
println "Copying dependencies.json"
copy {
from('../app/build/dependencies.json')
into(flathubDir)
}
}
}

// Generate the Flatpak manifest by expanding key variables
Expand All @@ -97,30 +105,47 @@ task genManifest {
binding.TAG = '5.4-alpha-2'
expand(binding)
}
into('build')
into(flathubDir)
rename '.template', ''
}
}
}

// Initialize flatpak/flathub content before build
task initFlathub {
description("Populate flathub submodule")
dependsOn('genLanguages')
dependsOn('genDependencies')
dependsOn('genManifest')

doLast {
println "Copying resources to flathub"
copy {
from('res')
into(flathubDir)
}
}
}

// Build flatpak on manifest
task buildFlatpak (type: Exec) {
description("Run flatpak-builder on manifest")
dependsOn('genLanguages')
dependsOn('genManifest')
dependsOn('genDependencies')
dependsOn('initFlathub')

onlyIf { app.ext.hostOSName == "linux" }

doFirst {
println "Running flatpak-builder in folder $projectDir"
println "Running flatpak-builder in folder flatpak/flathub"
}

// flatpak-builder is run from the subproject directory
// flatpak-builder is run from the flathub directory
workingDir 'flathub'

// All outputs are located under the 'build' directory for an easier cleanup
commandLine('flatpak-builder',
'--verbose',
'--state-dir=build/.flatpak-builder', // option to define the state-storing directory
// '--verbose',
// '--state-dir=build/.flatpak-builder', // option to define the state-storing directory
'--force-clean', // option to empty the output directory
'build/output', // relative path to the output directory to write
'build/org.audiveris.audiveris.yml') // relative path to the manifest file to read
'build', // relative path to the output directory to write
'org.audiveris.audiveris.yml') // relative path to the manifest file to read
}
184 changes: 0 additions & 184 deletions flatpak/dev/languages.sh

This file was deleted.

Loading

0 comments on commit 00361a4

Please sign in to comment.