rbe-tebako 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.clang-format +4 -0
- data/Brewfile +23 -0
- data/CMakeLists.txt +464 -0
- data/CODE_OF_CONDUCT.adoc +128 -0
- data/CONTRIBUTING.adoc +294 -0
- data/Gemfile +31 -0
- data/INSTALLATION.adoc +233 -0
- data/LICENSE.md +33 -0
- data/README.adoc +1363 -0
- data/Rakefile +35 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/cmake/copy_dir.cmake +29 -0
- data/common.env +5 -0
- data/exe/rbe-tebako +32 -0
- data/exe/rbe-tebako-packager +77 -0
- data/include/tebako/tebako-fs.h +43 -0
- data/include/tebako/tebako-main.h +42 -0
- data/include/tebako/tebako-prism.h +51 -0
- data/lib/rbe-tebako.rb +6 -0
- data/lib/tebako/build_helpers.rb +77 -0
- data/lib/tebako/cache_manager.rb +112 -0
- data/lib/tebako/cli.rb +220 -0
- data/lib/tebako/cli_helpers.rb +165 -0
- data/lib/tebako/codegen.rb +252 -0
- data/lib/tebako/deploy_helper.rb +258 -0
- data/lib/tebako/error.rb +70 -0
- data/lib/tebako/options_manager.rb +338 -0
- data/lib/tebako/package_descriptor.rb +143 -0
- data/lib/tebako/packager/pass1_patch.rb +266 -0
- data/lib/tebako/packager/pass1a_patch.rb +55 -0
- data/lib/tebako/packager/pass2_patch.rb +140 -0
- data/lib/tebako/packager/pass2_patch_crt.rb +46 -0
- data/lib/tebako/packager/pass2msys_patch.rb +190 -0
- data/lib/tebako/packager/patch.rb +54 -0
- data/lib/tebako/packager/patch_buildsystem.rb +124 -0
- data/lib/tebako/packager/patch_helpers.rb +109 -0
- data/lib/tebako/packager/patch_libraries.rb +188 -0
- data/lib/tebako/packager/patch_literals.rb +275 -0
- data/lib/tebako/packager/patch_main.rb +93 -0
- data/lib/tebako/packager/rubygems_patch.rb +83 -0
- data/lib/tebako/packager.rb +210 -0
- data/lib/tebako/packager_lite.rb +78 -0
- data/lib/tebako/ruby_builder.rb +71 -0
- data/lib/tebako/ruby_version.rb +206 -0
- data/lib/tebako/scenario_manager.rb +251 -0
- data/lib/tebako/stripper.rb +135 -0
- data/lib/tebako/version.rb +30 -0
- data/lib/tebako.rb +34 -0
- data/src/tebako-main.cpp +168 -0
- data/tools/.gitattributes +4 -0
- data/tools/.github/workflows/build-containers.yml +190 -0
- data/tools/.github/workflows/lint.yml +41 -0
- data/tools/.github/workflows/test.yml +331 -0
- data/tools/.gitignore +1 -0
- data/tools/README.md +49 -0
- data/tools/ci-scripts/arm-brew-install.sh +43 -0
- data/tools/ci-scripts/arm-brew-setup.sh +33 -0
- data/tools/ci-scripts/level-up.sh +35 -0
- data/tools/ci-scripts/patch-fbthrift.sh +94 -0
- data/tools/ci-scripts/patch-folly.sh +551 -0
- data/tools/ci-scripts/patch-glog.sh +57 -0
- data/tools/ci-scripts/patch-zstd.sh +57 -0
- data/tools/ci-scripts/tools.sh +63 -0
- data/tools/ci-scripts/x86-brew-install.sh +43 -0
- data/tools/ci-scripts/x86-brew-setup.sh +33 -0
- data/tools/cmake-scripts/def-external-project.cmake +96 -0
- data/tools/cmake-scripts/macos-environment.cmake +91 -0
- data/tools/cmake-scripts/msys-environment.cmake +78 -0
- data/tools/cmake-scripts/setup-libarchive.cmake +93 -0
- data/tools/cmake-scripts/setup-libfmt.cmake +61 -0
- data/tools/cmake-scripts/setup-libhowardhinnerdate.cmake +55 -0
- data/tools/cmake-scripts/setup-libutfcpp.cmake +56 -0
- data/tools/cmake-scripts/version.cmake +162 -0
- data/tools/docker/alpine-3.17-dev.Dockerfile +49 -0
- data/tools/docker/tools/tools.sh +66 -0
- data/tools/docker/ubuntu-20.04-dev.Dockerfile +51 -0
- data/tools/dwarfs-test-helper/CMakeLists.txt +34 -0
- data/tools/include/pro-statvfs.h +57 -0
- data/tools/tests/cmake/CMakeLists.txt +81 -0
- data/tools/tests/setup-libfmt/CMakeLists.txt +35 -0
- data/tools/tests/setup-libhowardhinnerdate/CMakeLists.txt +35 -0
- data/tools/tests/setup-librachive/CMakeLists.txt +35 -0
- data/tools/tests/setup-libutfcpp/CMakeLists.txt +36 -0
- data/tools/tests/setup-openssl/CMakeLists.txt +36 -0
- metadata +312 -0
data/Rakefile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions
|
|
9
|
+
# are met:
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
|
15
|
+
#
|
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
require "bundler/gem_tasks"
|
|
29
|
+
require "rubocop/rake_task"
|
|
30
|
+
require "rspec/core/rake_task"
|
|
31
|
+
|
|
32
|
+
RuboCop::RakeTask.new
|
|
33
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
34
|
+
|
|
35
|
+
task default: %i[rubocop spec]
|
data/bin/console
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "tebako"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
|
11
|
+
# require "pry"
|
|
12
|
+
# Pry.start
|
|
13
|
+
|
|
14
|
+
require "irb"
|
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Copyright (c) 2021, [Ribose Inc](https://www.ribose.com).
|
|
2
|
+
# All rights reserved.
|
|
3
|
+
# This file is a part of the Tebako project.
|
|
4
|
+
#
|
|
5
|
+
# Redistribution and use in source and binary forms, with or without
|
|
6
|
+
# modification, are permitted provided that the following conditions
|
|
7
|
+
# are met:
|
|
8
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
9
|
+
# notice, this list of conditions and the following disclaimer.
|
|
10
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
12
|
+
# documentation and/or other materials provided with the distribution.
|
|
13
|
+
#
|
|
14
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
15
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
16
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
17
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
18
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
19
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
20
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
21
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
22
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
23
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
24
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
25
|
+
|
|
26
|
+
# https://cmake.org/Bug/view.php?id=13204
|
|
27
|
+
# note the trailing slash after ${SOURCE_DIR}
|
|
28
|
+
|
|
29
|
+
file (COPY "${SOURCE_DIR}/" DESTINATION "${TARGET_DIR}")
|
data/common.env
ADDED
data/exe/rbe-tebako
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
# This file is a part of the Tebako project.
|
|
7
|
+
#
|
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
|
9
|
+
# modification, are permitted provided that the following conditions
|
|
10
|
+
# are met:
|
|
11
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
|
13
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
# documentation and/or other materials provided with the distribution.
|
|
16
|
+
#
|
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
19
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
20
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
21
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
require_relative "../lib/tebako"
|
|
30
|
+
require_relative "../lib/tebako/cli"
|
|
31
|
+
|
|
32
|
+
Tebako::Cli.start
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
|
|
5
|
+
# All rights reserved.
|
|
6
|
+
# This file is a part of the Tebako project.
|
|
7
|
+
#
|
|
8
|
+
# Redistribution and use in source and binary forms, with or without
|
|
9
|
+
# modification, are permitted provided that the following conditions
|
|
10
|
+
# are met:
|
|
11
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
|
13
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
# documentation and/or other materials provided with the distribution.
|
|
16
|
+
#
|
|
17
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
19
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
20
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
21
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
|
|
29
|
+
require_relative "../lib/tebako/packager"
|
|
30
|
+
require_relative "../lib/tebako/ruby_version"
|
|
31
|
+
require_relative "../lib/tebako/stripper"
|
|
32
|
+
require_relative "../lib/tebako/build_helpers"
|
|
33
|
+
|
|
34
|
+
begin
|
|
35
|
+
unless ARGV.length.positive?
|
|
36
|
+
raise Tebako::Error, "tebako-packager needs at least 1 argument (command), none has been provided."
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
case ARGV[0]
|
|
40
|
+
when "pass1"
|
|
41
|
+
# ARGV[0] -- command
|
|
42
|
+
# ARGV[1] -- OSTYPE
|
|
43
|
+
# ARGV[2] -- RUBY_SOURCE_DIR
|
|
44
|
+
# ARGV[3] -- FS_MOUNT_POINT
|
|
45
|
+
# ARGV[4] -- DATA_SRC_DIR
|
|
46
|
+
# ARGV[5] -- RUBY_VER
|
|
47
|
+
unless ARGV.length == 6
|
|
48
|
+
raise Tebako::Error,
|
|
49
|
+
"tebako-packager pass1 command expects 6 arguments, #{ARGV.length} has been provided."
|
|
50
|
+
end
|
|
51
|
+
ruby_ver = Tebako::RubyVersion.new(ARGV[5])
|
|
52
|
+
Tebako::Packager.pass1(ARGV[1], ARGV[2], ARGV[3], ARGV[4], ruby_ver)
|
|
53
|
+
|
|
54
|
+
when "pass2"
|
|
55
|
+
# ARGV[0] -- command
|
|
56
|
+
# ARGV[1] -- OSTYPE
|
|
57
|
+
# ARGV[2] -- RUBY_SOURCE_DIR
|
|
58
|
+
# ARGV[3] -- DEPS_LIB_DIR
|
|
59
|
+
# ARGV[4] -- DATA_SRC_DIR
|
|
60
|
+
# ARGV[5] -- RUBY_STASH_DIR
|
|
61
|
+
# ARGV[6] -- RUBY_VER
|
|
62
|
+
unless ARGV.length == 7
|
|
63
|
+
raise Tebako::Error,
|
|
64
|
+
"tebako-packager pass2 command expects 7 arguments, #{ARGV.length} has been provided."
|
|
65
|
+
end
|
|
66
|
+
ruby_ver = Tebako::RubyVersion.new(ARGV[6])
|
|
67
|
+
Tebako::Packager.pass1a(ARGV[2])
|
|
68
|
+
Tebako::Packager.stash(ARGV[4], ARGV[5], ARGV[2], ruby_ver)
|
|
69
|
+
Tebako::Packager.pass2(ARGV[1], ARGV[2], ARGV[3], ruby_ver)
|
|
70
|
+
else
|
|
71
|
+
raise Tebako::Error, "tebako-packager cannot process #{ARGV[0]} command"
|
|
72
|
+
end
|
|
73
|
+
rescue Tebako::Error => e
|
|
74
|
+
puts "tebako-packager failed: #{e.message} [#{e.error_code}]"
|
|
75
|
+
exit(e.error_code)
|
|
76
|
+
end
|
|
77
|
+
exit(0)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 2021-2025, [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* This file is a part of the Tebako project.
|
|
6
|
+
*
|
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
|
8
|
+
* modification, are permitted provided that the following conditions
|
|
9
|
+
* are met:
|
|
10
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
|
12
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
* documentation and/or other materials provided with the distribution.
|
|
15
|
+
*
|
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#pragma once
|
|
31
|
+
|
|
32
|
+
#include <incbin/incbin.h>
|
|
33
|
+
|
|
34
|
+
INCBIN_EXTERN(fs);
|
|
35
|
+
|
|
36
|
+
namespace tebako {
|
|
37
|
+
extern const char* fs_log_level;
|
|
38
|
+
extern const char* fs_mount_point;
|
|
39
|
+
extern const char* fs_entry_point;
|
|
40
|
+
extern bool needs_cwd;
|
|
41
|
+
extern const char* package_cwd;
|
|
42
|
+
extern char original_cwd[PATH_MAX];
|
|
43
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Copyright (c) 2021-2025, [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
* All rights reserved.
|
|
5
|
+
* This file is a part of the Tebako project.
|
|
6
|
+
*
|
|
7
|
+
* Redistribution and use in source and binary forms, with or without
|
|
8
|
+
* modification, are permitted provided that the following conditions
|
|
9
|
+
* are met:
|
|
10
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
* notice, this list of conditions and the following disclaimer.
|
|
12
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
* documentation and/or other materials provided with the distribution.
|
|
15
|
+
*
|
|
16
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#ifdef __cplusplus
|
|
31
|
+
extern "C" {
|
|
32
|
+
#endif
|
|
33
|
+
int tebako_main(int* argc, char*** argv);
|
|
34
|
+
const char* tebako_mount_point(void);
|
|
35
|
+
int tebako_is_running_miniruby(void);
|
|
36
|
+
const char* tebako_original_pwd(void);
|
|
37
|
+
#ifdef RB_W32
|
|
38
|
+
int tebako_file_load_ok(const char *path);
|
|
39
|
+
#endif
|
|
40
|
+
#ifdef __cplusplus
|
|
41
|
+
}
|
|
42
|
+
#endif
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#include <fcntl.h>
|
|
2
|
+
|
|
3
|
+
static pm_string_init_result_t
|
|
4
|
+
tebako_string_file_init(pm_string_t *string, const char *filepath) {
|
|
5
|
+
|
|
6
|
+
// Open the file for reading
|
|
7
|
+
int fd = open(filepath, O_RDONLY);
|
|
8
|
+
if (fd == -1) {
|
|
9
|
+
return PM_STRING_INIT_ERROR_GENERIC;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Stat the file to get the file size
|
|
13
|
+
struct stat sb;
|
|
14
|
+
if (fstat(fd, &sb) == -1) {
|
|
15
|
+
close(fd);
|
|
16
|
+
return PM_STRING_INIT_ERROR_GENERIC;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Ensure it is a file and not a directory
|
|
20
|
+
if (S_ISDIR(sb.st_mode)) {
|
|
21
|
+
close(fd);
|
|
22
|
+
return PM_STRING_INIT_ERROR_DIRECTORY;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Check the size to see if it's empty
|
|
26
|
+
size_t size = (size_t) sb.st_size;
|
|
27
|
+
if (size == 0) {
|
|
28
|
+
close(fd);
|
|
29
|
+
const uint8_t source[] = "";
|
|
30
|
+
*string = (pm_string_t) { .type = PM_STRING_CONSTANT, .source = source, .length = 0 };
|
|
31
|
+
return PM_STRING_INIT_SUCCESS;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
size_t length = (size_t) size;
|
|
35
|
+
uint8_t *source = xmalloc(length);
|
|
36
|
+
if (source == NULL) {
|
|
37
|
+
close(fd);
|
|
38
|
+
return PM_STRING_INIT_ERROR_GENERIC;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
long bytes_read = (long) read(fd, source, length);
|
|
42
|
+
close(fd);
|
|
43
|
+
|
|
44
|
+
if (bytes_read == -1) {
|
|
45
|
+
xfree(source);
|
|
46
|
+
return PM_STRING_INIT_ERROR_GENERIC;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
*string = (pm_string_t) { .type = PM_STRING_OWNED, .source = source, .length = length };
|
|
50
|
+
return PM_STRING_INIT_SUCCESS;
|
|
51
|
+
}
|
data/lib/rbe-tebako.rb
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2023-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions
|
|
9
|
+
# are met:
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
|
15
|
+
#
|
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
require "open3"
|
|
29
|
+
|
|
30
|
+
# Tebako - an executable packager
|
|
31
|
+
module Tebako
|
|
32
|
+
# Ruby build helpers
|
|
33
|
+
module BuildHelpers
|
|
34
|
+
class << self
|
|
35
|
+
def run_with_capture(args)
|
|
36
|
+
args = args.compact
|
|
37
|
+
puts " ... @ #{args.join(" ")}"
|
|
38
|
+
# Read merged stdout+stderr in the calling thread via IO.popen rather than
|
|
39
|
+
# Open3.capture2e: capture2e spawns a background reader thread that races and
|
|
40
|
+
# raises "stream closed in another thread (IOError)" on large-output builds
|
|
41
|
+
# (e.g. `make ruby`) under Ruby >= 4.0. Reading inline avoids that race.
|
|
42
|
+
out = +""
|
|
43
|
+
IO.popen(args, err: %i[child out]) { |io| io.each_line { |line| out << line } }
|
|
44
|
+
st = $? # rubocop:disable Style/SpecialGlobalVars
|
|
45
|
+
raise Tebako::Error, "Failed to run #{args.join(" ")} (#{st}):\n #{out}" if st.signaled? || !st.exitstatus.zero?
|
|
46
|
+
|
|
47
|
+
out
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def run_with_capture_v(args)
|
|
51
|
+
if @verbose
|
|
52
|
+
args_v = args.dup
|
|
53
|
+
args_v.push("--verbose")
|
|
54
|
+
puts run_with_capture(args_v)
|
|
55
|
+
else
|
|
56
|
+
run_with_capture(args)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Sets up temporary environment variables and yields to the
|
|
61
|
+
# block. When the block exits, the environment variables are set
|
|
62
|
+
# back to their original values.
|
|
63
|
+
def with_env(hash)
|
|
64
|
+
old = {}
|
|
65
|
+
hash.each do |k, v|
|
|
66
|
+
old[k] = ENV.fetch(k, nil)
|
|
67
|
+
ENV[k] = v
|
|
68
|
+
end
|
|
69
|
+
begin
|
|
70
|
+
yield
|
|
71
|
+
ensure
|
|
72
|
+
hash.each_key { |k| ENV[k] = old[k] }
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (c) 2024-2025 [Ribose Inc](https://www.ribose.com).
|
|
4
|
+
# All rights reserved.
|
|
5
|
+
# This file is a part of the Tebako project.
|
|
6
|
+
#
|
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
|
8
|
+
# modification, are permitted provided that the following conditions
|
|
9
|
+
# are met:
|
|
10
|
+
# 1. Redistributions of source code must retain the above copyright
|
|
11
|
+
# notice, this list of conditions and the following disclaimer.
|
|
12
|
+
# 2. Redistributions in binary form must reproduce the above copyright
|
|
13
|
+
# notice, this list of conditions and the following disclaimer in the
|
|
14
|
+
# documentation and/or other materials provided with the distribution.
|
|
15
|
+
#
|
|
16
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
17
|
+
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
18
|
+
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
19
|
+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS
|
|
20
|
+
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
21
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
22
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
23
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
24
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
25
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
26
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
|
|
28
|
+
require "fileutils"
|
|
29
|
+
require_relative "version"
|
|
30
|
+
|
|
31
|
+
# Tebako - an executable packager
|
|
32
|
+
module Tebako
|
|
33
|
+
# Cache management
|
|
34
|
+
class CacheManager
|
|
35
|
+
E_VERSION_FILE = ".environment.version"
|
|
36
|
+
|
|
37
|
+
def initialize(deps, src_dir, out_dir)
|
|
38
|
+
@deps = deps
|
|
39
|
+
@src_dir = src_dir
|
|
40
|
+
@out_dir = out_dir
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def clean_cache
|
|
44
|
+
puts "Cleaning tebako packaging environment"
|
|
45
|
+
# Using File.join(deps, "") to ensure that the slashes are appropriate
|
|
46
|
+
FileUtils.rm_rf([File.join(@deps, ""), File.join(@out_dir, "")], secure: true)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def clean_output
|
|
50
|
+
puts "Cleaning CMake cache and Ruby build files"
|
|
51
|
+
|
|
52
|
+
nmr = "src/_ruby_*"
|
|
53
|
+
nms = "stash_*"
|
|
54
|
+
FileUtils.rm_rf(Dir.glob(File.join(@deps, nmr)), secure: true)
|
|
55
|
+
FileUtils.rm_rf(Dir.glob(File.join(@deps, nms)), secure: true)
|
|
56
|
+
|
|
57
|
+
# Using File.join(output_folder, "") to ensure that the slashes are appropriate
|
|
58
|
+
FileUtils.rm_rf(File.join(@out_dir, ""), secure: true)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def ensure_version_file
|
|
62
|
+
version_file_path = File.join(@deps, E_VERSION_FILE)
|
|
63
|
+
|
|
64
|
+
begin
|
|
65
|
+
File.write(version_file_path, version_key)
|
|
66
|
+
# puts "Set version information for tebako packaging environment to #{Tebako::VERSION}"
|
|
67
|
+
rescue StandardError => e
|
|
68
|
+
puts "#{Tebako::PACKAGING_ERRORS[201]} #{E_VERSION_FILE}: #{e.message}"
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def version_key
|
|
73
|
+
@version_key ||= "#{Tebako::VERSION} at #{@src_dir}"
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def version_cache
|
|
77
|
+
version_file_path = File.join(@deps, E_VERSION_FILE)
|
|
78
|
+
file_version = File.open(version_file_path, &:readline).strip
|
|
79
|
+
file_version.match(/(?<version>.+) at (?<source>.+)/)
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def version_cache_check
|
|
83
|
+
match_data = version_cache
|
|
84
|
+
return version_unknown unless match_data
|
|
85
|
+
|
|
86
|
+
if match_data[:version] != Tebako::VERSION
|
|
87
|
+
version_mismatch(match_data[:version])
|
|
88
|
+
elsif match_data[:source] != @src_dir
|
|
89
|
+
version_source_mismatch(match_data[:source])
|
|
90
|
+
end
|
|
91
|
+
rescue StandardError
|
|
92
|
+
version_unknown
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def version_mismatch(cached_version)
|
|
96
|
+
puts "Tebako cache was created by a gem version #{cached_version} " \
|
|
97
|
+
"and cannot be used for gem version #{Tebako::VERSION}"
|
|
98
|
+
clean_cache
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def version_source_mismatch(cached_source)
|
|
102
|
+
puts "CMake cache was created for a different source directory '#{cached_source}' " \
|
|
103
|
+
"and cannot be used for '#{@src_dir}'"
|
|
104
|
+
clean_output
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def version_unknown
|
|
108
|
+
puts "CMake cache version was not recognized, cleaning up"
|
|
109
|
+
clean_cache
|
|
110
|
+
end
|
|
111
|
+
end
|
|
112
|
+
end
|