aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2018-10-04 00:47:48 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-06 07:39:33 +0200
commit48ad8c87fd6cc901a4616f3ef02e7f163459a4c5 (patch)
tree9a56cea822d74e4d0772482e48bb561272de706c /src/main.cpp
parent3374901c0392a561bc107287bbf5ad54f52c9d71 (diff)
Add --bundle-install option to reduce distributable package size
* Downloads libraries from internet if they are missing from the system * Libraries are shared among all sibs projects as long as they use same library versions
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 6a807f0..e55014e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -184,12 +184,14 @@ static void usageInit()
static void usagePackage()
{
- printf("Usage: sibs package [project_path] <--static|--bundle>\n\n");
+ printf("Usage: sibs package [project_path] <--static|--bundle|--bundle-install>\n\n");
printf("Create a redistributable package from a sibs project. Note: Redistributable packages can't use system packages to build if packaging using --static\n\n");
printf("Options:\n");
printf(" project_path\t\tThe directory containiung a project.conf file - Optional (default: current directory)\n");
printf(" --static\t\tPackage project by building everything statically. Note: can't use system packages when using this option (meaning no pkg-config support)\n\n");
printf(" --bundle\t\tPackage project by copying all dynamic libraries into one location and creating an archive of all files. The executable is patched to use the dynamic libraries in the same directory. Note: if your project loads dynamic libraries at runtime (for example using dlopen) then you need to manually copy those libraries to the archive\n\n");
+ printf(" --bundle-install\t\tPackage project by copying all dynamic libraries into one location, except libraries that can automatically be downloaded online by the user. Then create an archive of all files - Use this option if you want to reduce the size of the distributed package and also if user already has some of the libraries installed/downloaded on their system, then they are used."
+ "Note: if your project loads dynamic libraries at runtime (for example using dlopen) then you need to manually copy those libraries to the archive");
printf("Examples:\n");
printf(" sibs package --static\n");
printf(" sibs package dirA/dirB --bundle\n");
@@ -937,7 +939,8 @@ enum class PackagingType
{
NONE,
STATIC,
- BUNDLE
+ BUNDLE,
+ BUNDLE_INSTALL
};
static const char* asString(PackagingType packagingType)
@@ -1025,6 +1028,15 @@ static int packageProject(int argc, const _tinydir_char_t **argv)
}
packagingType = PackagingType::BUNDLE;
}
+ else if(_tinydir_strcmp(arg, TINYDIR_STRING("--bundle-install")) == 0)
+ {
+ if(packagingType != PackagingType::NONE)
+ {
+ ferr << "Error: Project packaging type was defined more than once. First as " << asString(packagingType) << " then as " << "bundle-install" << endl;
+ usagePackage();
+ }
+ packagingType = PackagingType::BUNDLE_INSTALL;
+ }
else
{
if(!projectPath.empty())
@@ -1073,7 +1085,7 @@ static int packageProject(int argc, const _tinydir_char_t **argv)
SibsConfig sibsConfig(compiler, projectPath, OPT_LEV_RELEASE, false);
sibsConfig.showWarnings = true;
sibsConfig.packaging = packagingType == PackagingType::STATIC;
- sibsConfig.bundling = packagingType == PackagingType::BUNDLE;
+ sibsConfig.bundling = (packagingType == PackagingType::BUNDLE) || (packagingType == PackagingType::BUNDLE_INSTALL);
int result = buildProject(projectPath, projectConfFilePath, sibsConfig);
if(result != 0)
return result;
@@ -1087,11 +1099,24 @@ static int packageProject(int argc, const _tinydir_char_t **argv)
break;
}
case PackagingType::BUNDLE:
+ case PackagingType::BUNDLE_INSTALL:
{
+ const char *bundleType = nullptr;
+ switch(packagingType)
+ {
+ case PackagingType::BUNDLE:
+ bundleType = "--bundle";
+ break;
+ case PackagingType::BUNDLE_INSTALL:
+ bundleType = "--bundle-install";
+ break;
+ }
+
string packagePath = toUtf8(projectPath + TINYDIR_STRING("/sibs-build/package"));
string executablePath = toUtf8(projectPath + TINYDIR_STRING("/sibs-build/release/") + sibsConfig.getPackageName());
printf("Creating a package from project and dependencies...\n");
- FileString cmd = "python3 \"" + packageScriptPath + "\" \"" + executablePath + "\" \"" + packagePath + "\"";
+ // args: executable_path program_version destination_path <--bundle|--bundle-install>
+ FileString cmd = "python3 \"" + packageScriptPath + "\" \"" + executablePath + "\" \"" + sibsConfig.version + "\" \"" + packagePath + "\" " + bundleType;
Result<ExecResult> bundleResult = exec(cmd.c_str(), true);
if(!bundleResult)
{