Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hxb writer config #11507

Merged
merged 14 commits into from
Feb 1, 2024
Merged

Hxb writer config #11507

merged 14 commits into from
Feb 1, 2024

Conversation

Simn
Copy link
Member

@Simn Simn commented Jan 25, 2024

Allows specifying --hxb some.json and adds haxe.macro.Compiler.getHxbConfiguration and haxe.macro.Compiler.setHxbConfiguration.

All the pertinent information should be in the .hx files. @PXshadow Could you check if this works for your use-case?

Closes #11490

@Simn
Copy link
Member Author

Simn commented Jan 25, 2024

Where would be put one of these fancy JSON schema things for this?

(And is there a tool to generate those from a type definition?)

@kLabz
Copy link
Contributor

kLabz commented Jan 25, 2024

json2object lib can generate them: https://github.com/elnabo/json2object/#using-the-jsonschema-writer
I don't remember where we put it, checking..

Edit:
Haxelib.json schema is there: https://github.com/HaxeFoundation/haxelib/blob/master/schema.json

Guess we could start storing some here in extra/schema or something?
We will also need to publish those on schemastore when ready (example)

@Simn
Copy link
Member Author

Simn commented Jan 25, 2024

We have .vscode/schemas but I vaguely remember that this wasn't the right place either, and it's also gitignored.

Edit: On the bright side, looks like json2object just works:

{
	"definitions": {
		"haxe.hxb.WriterTargetConfig": {
			"additionalProperties": false,
			"properties": {
				"include": {
					"description": "Dot paths of modules or packages to be included in the archive. This takes priority over exclude. By default, all modules that aren't explicitly excluded are included.",
					"items": {
						"type": "string"
					},
					"type": "array"
				},
				"hxbVersion": {
					"description": "The hxb version to target. By default, the version of the Haxe compiler itself is targeted. See https://github.com/HaxeFoundation/haxe/issues/11505",
					"type": "integer"
				},
				"generateDocumentation": {
					"description": "If false, no documentation",
					"type": "boolean"
				},
				"generate": {
					"description": "If `false`, this target is ignored by the writer.",
					"type": "boolean"
				},
				"exclude": {
					"description": "Dot paths of modules or packages to be exluded from the archive.",
					"items": {
						"type": "string"
					},
					"type": "array"
				}
			},
			"type": "object"
		},
		"haxe.hxb.WriterConfig": {
			"additionalProperties": false,
			"properties": {
				"targetConfig": {
					"description": "The configuration for the current target context. If it is `null`, all data for the target context is generated.",
					"$ref": "#/definitions/haxe.hxb.WriterTargetConfig"
				},
				"macroConfig": {
					"description": "The configuration for the macro context. If it is `null`, all data for the macro context is generated.",
					"$ref": "#/definitions/haxe.hxb.WriterTargetConfig"
				},
				"archivePath": {
					"description": "The file path for the archive. Occurrences of `$target` are replaced by the name of the current target (js, hl, etc.).",
					"type": "string"
				}
			},
			"required": [
				"archivePath"
			],
			"type": "object"
		}
	},
	"$ref": "#/definitions/haxe.hxb.WriterConfig",
	"$schema": "http://json-schema.org/draft-07/schema#"
}

@kLabz
Copy link
Contributor

kLabz commented Jan 25, 2024

Those two might work for Haxe repo itself (... on vscode only)
They're likely outdated, and one should be added for warnings..

We could move all those schemas to extra with the generator code there too? So we don't update those manually (and forget to do it)

@Simn
Copy link
Member Author

Simn commented Jan 25, 2024

Ok I see, I shouldn't have brought that up here... made a new issue!

@Simn
Copy link
Member Author

Simn commented Feb 1, 2024

I'll go ahead and merge this. The foundation should be good, and if we need anything else it's easy enough to add thanks to the new internal data API here. The macro side of this isn't very well tested (read: not tested at all) but I'm sure people will get to that.

@Simn Simn merged commit 3280f2f into development Feb 1, 2024
120 of 122 checks passed
@Simn Simn deleted the hxb_writer_config branch February 1, 2024 06:13
@skial skial mentioned this pull request Feb 1, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[hxb] Filter for --hxb output
2 participants