Class: Libpng::OHOS::NDK
- Inherits:
-
Object
- Object
- Libpng::OHOS::NDK
- Defined in:
- lib/libpng/ohos/ndk.rb
Overview
Pure-data handle to an extracted OHOS NDK installation. Discovers the four critical paths the build needs (toolchain cmake, clang, sysroot, binary-sign-tool), exposes them as Pathnames, and can invoke ext/ohos/setup-ndk.sh to populate the directory if missing.
Does NOT run any NDK binary itself -- that's the caller's job. This keeps the class testable without qemu/binfmt setup: specs just touch empty files at the expected paths and assert accessors.
Constant Summary collapse
- ROOT_RELATIVE =
Pathname.new('ext/ohos/ndk').freeze
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
- #clang_path ⇒ Object
- #clangxx_path ⇒ Object
- #cmake_path ⇒ Object
-
#download ⇒ Object
Downloads + extracts the NDK via ext/ohos/setup-ndk.sh.
- #exist? ⇒ Boolean
-
#initialize(root: default_root) ⇒ NDK
constructor
A new instance of NDK.
- #sign_tool_path ⇒ Object
- #sysroot_path ⇒ Object
- #toolchain_path ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
53 54 55 |
# File 'lib/libpng/ohos/ndk.rb', line 53 def root @root end |
Instance Method Details
#clang_path ⇒ Object
33 34 35 |
# File 'lib/libpng/ohos/ndk.rb', line 33 def clang_path llvm_dir.join('bin/aarch64-unknown-linux-ohos-clang') end |
#clangxx_path ⇒ Object
37 38 39 |
# File 'lib/libpng/ohos/ndk.rb', line 37 def clangxx_path llvm_dir.join('bin/aarch64-unknown-linux-ohos-clang++') end |
#cmake_path ⇒ Object
49 50 51 |
# File 'lib/libpng/ohos/ndk.rb', line 49 def cmake_path sdk_dir.join('native/build-tools/cmake/bin/cmake') end |
#download ⇒ Object
Downloads + extracts the NDK via ext/ohos/setup-ndk.sh. No-op if #exist?. Returns true on success, false otherwise.
57 58 59 60 61 62 |
# File 'lib/libpng/ohos/ndk.rb', line 57 def download return true if exist? script = recipe_root.join('ext/ohos/setup-ndk.sh') system(script.to_s, '--prefix', @root.to_s) end |
#exist? ⇒ Boolean
22 23 24 25 26 27 |
# File 'lib/libpng/ohos/ndk.rb', line 22 def exist? toolchain_path.exist? && clang_path.exist? && sysroot_path.exist? && sign_tool_path.exist? end |
#sign_tool_path ⇒ Object
45 46 47 |
# File 'lib/libpng/ohos/ndk.rb', line 45 def sign_tool_path sdk_dir.join('toolchains/lib/binary-sign-tool') end |
#sysroot_path ⇒ Object
41 42 43 |
# File 'lib/libpng/ohos/ndk.rb', line 41 def sysroot_path root.join('llvm-19/sysroot') end |
#toolchain_path ⇒ Object
29 30 31 |
# File 'lib/libpng/ohos/ndk.rb', line 29 def toolchain_path sdk_dir.join('native/build/cmake/ohos.toolchain.cmake') end |