chalet icon indicating copy to clipboard operation
chalet copied to clipboard

how to compile libraries and build a zipfile

Open dimitre opened this issue 3 years ago • 4 comments

It is really great all that Chalet can do. for now I'm trying to replicate what openFrameworks/apothecary do with scripts and makefiles

it would be great to know how I can compile and bundle the libraries, so I can use github actions to deploy to different platforms.

I see the following tries to make a zip file from "dist" folder but it fails, as there is nothing in there.

{
	"name": "OFLibs",
	"version": "0.11.3",
	"externalDependencies": {
		"assimp": {
			"repository": "https://github.com/assimp/assimp",
			"tag" : "v5.2.5"
		},
		"glfw": {
		   "repository": "https://github.com/glfw/glfw",
		   "tag" : "3.3.8"
		},

		"poco": {
			"repository" : "https://github.com/pocoproject/poco",
			"tag" : "poco-1.12.2-release"
		}
	},

	"targets" : {
		"assimp": {
			"kind": "cmakeProject",
			"location": "${external:assimp}",
			"recheck": false,
			"rebuild": false
		}, 
		"glfw": {
			"kind": "cmakeProject",
			"location": "${external:glfw}",
			"recheck": false,
			"rebuild": false
		},
		"poco": {
			"kind": "cmakeProject",
			"location": "${external:poco}",
			"recheck": false,
			"rebuild": false
		}
	}
	,

	"distribution": {
		"of_libs": {
			"kind": "archive",
			"condition": "[:macos]",
			"format": "zip"
			,
			"include": "*"
		}
	}
}

dimitre avatar Oct 11 '22 01:10 dimitre

Hmmm this is interesting actually. At the moment, "include": "*" means nothing in the context of CMake targets, because you can script anything in a CMakeLists.txt file - any build structure, file types, etc. Chalet doesn't read those to figure out what's in them, it only invokes the build process for them in kind of an expected manner. At some level, you have to inform Chalet where the things in that build are. You could try:

"include": [
  "${external:assimp}/**"
  "${externalBuild:assimp}/**"
]

...but externalBuild would include all intermediate files, so you really should narrow those down to just what you need to include. Once the package management feature is figured out, stuff like this will be easier, because the package file would define things like this.

rewrking avatar Oct 11 '22 02:10 rewrking

I gave a quick try here and it doesn't find the files with this command. it was like the working directory for this part is "dist" folder

▼  Compressing: of_libs.zip

   Compressing files ... make directory: dist/of_libs
/usr/bin/zip -r -X of_libs.zip

zip error: Nothing to do! (of_libs.zip)
remove recursively: dist/of_libs

ERROR: Couldn't create archive 'of_libs.zip' because '/usr/bin/zip' ran into a problem.

I've tried with the previous folder and it find the files but fails for other reason

			"include": [
				"../${external:assimp}/**",
				"../${externalBuild:assimp}/**"
			]

thank you!

dimitre avatar Oct 11 '22 02:10 dimitre

Hmmm, yeah I gotta check out that part of the code again to see what it's doing or not doing. There might be another relative path issue.

rewrking avatar Oct 11 '22 02:10 rewrking

in the case it helps: I've tried this configuration and the error is the following:

	"distribution": {
		"of_libs": {
			"kind": "archive",
			"condition": "[:macos]",
			"format": "zip",
			"include": [
				"${external:assimp}",
				"${externalBuild:assimp}"
			]
		}
	}
Compressing: of_libs.zip

   Compressing files ... make directory: dist/of_libs
copy to path: dist/chalet_external/assimp -> dist/of_libs
libc++abi: terminating with uncaught exception of type std::__1::__fs::filesystem::filesystem_error: filesystem error: in copy: No such file or directory ["dist/chalet_external/assimp"] ["dist/of_libs/assimp"]
zsh: segmentation fault  chalet bundle

dimitre avatar Oct 12 '22 00:10 dimitre

These issues are more or less fixed in v0.5.7 although I would still avoid relative paths if you can.

This is the example distribution target I used during testing:

"distribution": {
  "of_libs": {
    "kind": "archive",
    "condition": "[:macos]",
    "format": "zip",
    "include": [
      "${external:assimp}/{include,Readme.md,LICENSE}",
      "${externalBuild:assimp}/{include,bin}"
    ]
  }
}

You can define includes that are relative to the dist folder and the working directory. Let me know if you run into any more issues!

rewrking avatar Oct 23 '22 22:10 rewrking