-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Tizen] Create TPK flashbundle with Tizen GN SDK (#18298)
- Loading branch information
Showing
6 changed files
with
216 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/env python | ||
|
||
# Copyright (c) 2022 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import argparse | ||
import json | ||
from xml.etree import ElementTree as ET | ||
|
||
|
||
class TizenManifest: | ||
|
||
def __init__(self, manifest): | ||
self.manifest = ET.parse(manifest).getroot() | ||
|
||
def _get_application(self, apptype): | ||
return self.manifest.find("{*}" + apptype) | ||
|
||
def get_package_name(self): | ||
return self.manifest.get("package") | ||
|
||
def get_package_version(self): | ||
return self.manifest.get("version") | ||
|
||
def get_service_exec(self): | ||
app = self._get_application("service-application") | ||
return app.get("exec", "") if app else "" | ||
|
||
def get_ui_exec(self): | ||
app = self._get_application("ui-application") | ||
return app.get("exec", "") if app else "" | ||
|
||
def get_watch_exec(self): | ||
app = self._get_application("watch-application") | ||
return app.get("exec", "") if app else "" | ||
|
||
def get_widget_exec(self): | ||
app = self._get_application("widget-application") | ||
return app.get("exec", "") if app else "" | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
parser = argparse.ArgumentParser( | ||
description="Tool for extracting data from Tizen XML manifest file") | ||
parser.add_argument('MANIFEST', help="Tizen manifest XML file") | ||
|
||
args = parser.parse_args() | ||
manifest = TizenManifest(args.MANIFEST) | ||
|
||
print(json.dumps({ | ||
'package': { | ||
'name': manifest.get_package_name(), | ||
'version': manifest.get_package_version(), | ||
}, | ||
'apps': { | ||
'service': manifest.get_service_exec(), | ||
'ui': manifest.get_ui_exec(), | ||
'watch': manifest.get_watch_exec(), | ||
'widget': manifest.get_widget_exec(), | ||
} | ||
})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# Copyright (c) 2020 Project CHIP Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import("//build_overrides/build.gni") | ||
import("//build_overrides/chip.gni") | ||
import("//build_overrides/tizen.gni") | ||
|
||
import("${build_root}/config/tizen/config.gni") | ||
|
||
tizen_manifest_parser = rebase_path("tizen_manifest_parser.py") | ||
|
||
template("tizen_sdk") { | ||
forward_variables_from(invoker, | ||
[ | ||
"project_build_dir", | ||
"project_app_name", | ||
]) | ||
|
||
if (!defined(project_app_name)) { | ||
project_app_name = "tizen-app" | ||
} | ||
|
||
# Create a dummy project definition file, so the Tizen Studio CLI | ||
# will recognize our build directory as a Tizen project. | ||
write_file("${project_build_dir}/project_def.prop", | ||
[ | ||
"# Generated by the GN script. DO NOT EDIT!", | ||
"APPNAME = " + project_app_name, | ||
"type = app", | ||
]) | ||
|
||
# Create a dummy project file, so the Tizen Studio CLI will not | ||
# complain about invalid XPath (this file is not used anyway...) | ||
write_file("${project_build_dir}/.project", | ||
[ | ||
"<!-- Generated by the build script. DO NOT EDIT! -->", | ||
"<projectDescription></projectDescription>", | ||
]) | ||
|
||
action(target_name) { | ||
forward_variables_from(invoker, | ||
[ | ||
"deps", | ||
"outputs", | ||
]) | ||
script = "${build_root}/gn_run_binary.py" | ||
args = [ "${tizen_sdk_root}/tools/ide/bin/tizen" ] + invoker.args | ||
} | ||
} | ||
|
||
template("tizen_sdk_package") { | ||
# Output directory where packaging will occur. We need a separate directory | ||
# for this, because Tizen Studio CLI scans "res" (resources), "shared" and | ||
# "lib" directories for items to pack. In our case it could include in the | ||
# TPK package libraries available in ${root_build_dir}/lib directory. | ||
tizen_package_dir = "${root_build_dir}/package" | ||
tizen_package_out_dir = "${tizen_package_dir}/out" | ||
|
||
assert(defined(invoker.manifest), | ||
"It is required to specify Tizen `manifest` XML file.") | ||
assert(defined(invoker.sign_security_profile), | ||
"It is required to specify a `sign_security_profile` which " + | ||
"should be used for signing TPK package.") | ||
|
||
# Extract data from Tizen XML manifest. | ||
manifest = exec_script(tizen_manifest_parser, [ invoker.manifest ], "json") | ||
manifest_package = manifest["package"] | ||
manifest_apps = manifest["apps"] | ||
|
||
# Copy Tizen manifest from the source directory. | ||
copy("${target_name}:manifest") { | ||
sources = [ invoker.manifest ] | ||
outputs = [ "${tizen_package_dir}/{{source_file_part}}" ] | ||
deps = invoker.deps | ||
} | ||
|
||
# List of dependencies for Tizen Studio CLI packager. | ||
dependencies = [ ":${target_name}:manifest" ] | ||
|
||
# Copy executable(s) to temporary output directory. This action is required, | ||
# because Tizen Studio CLI expects particular directory layout - it is not | ||
# possible to specify input files manually. | ||
if (manifest_apps["service"] != "") { | ||
dependencies += [ ":${target_name}:app:service" ] | ||
copy("${target_name}:app:service") { | ||
sources = [ root_build_dir + "/" + manifest_apps["service"] ] | ||
outputs = [ "${tizen_package_out_dir}/{{source_file_part}}" ] | ||
deps = invoker.deps | ||
} | ||
} | ||
|
||
tpk = manifest_package["name"] + "-" + manifest_package["version"] + ".tpk" | ||
tizen_sdk(target_name) { | ||
deps = invoker.deps + dependencies | ||
outputs = [ "${tizen_package_out_dir}/" + tpk ] | ||
project_build_dir = tizen_package_dir | ||
args = [ | ||
"package", | ||
"--type", | ||
"tpk", | ||
"--sign", | ||
invoker.sign_security_profile, | ||
"--", | ||
tizen_package_out_dir, | ||
] | ||
} | ||
} |