summaryrefslogtreecommitdiff
path: root/misc/codex/Makefile
blob: 720411221f29b1a1c3659949b60f99e66288cbba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
PORTNAME=	codex
DISTVERSIONPREFIX=	rust-v
DISTVERSION=	0.87.0
CATEGORIES=	misc devel

MAINTAINER=	tagattie@FreeBSD.org
COMMENT=	Lightweight coding agent that runs in your terminal
WWW=		https://openai.com/codex \
		https://github.com/openai/codex

LICENSE=	APACHE20
LICENSE_FILE=	${WRKSRC}/LICENSE

LIB_DEPENDS=	libzstd.so:archivers/zstd \
		libdbus-1.so:devel/dbus \
		libonig.so:devel/oniguruma
RUN_DEPENDS=	bash:shells/bash \
		rg:textproc/ripgrep
TEST_DEPENDS=	bash:shells/bash

USES=		cargo python:test shebangfix ssl

USE_GITHUB=	yes
GH_ACCOUNT=	openai

SHEBANG_FILES=	codex-rs/core/src/skills/assets/samples/skill-creator/scripts/init_skill.py \
		codex-rs/core/src/skills/assets/samples/skill-creator/scripts/package_skill.py \
		codex-rs/core/src/skills/assets/samples/skill-creator/scripts/quick_validate.py \
		codex-rs/core/src/skills/assets/samples/skill-installer/scripts/github_utils.py \
		codex-rs/core/src/skills/assets/samples/skill-installer/scripts/install-skill-from-github.py \
		codex-rs/core/src/skills/assets/samples/skill-installer/scripts/list-curated-skills.py \
		codex-rs/mcp-types/check_lib_rs.py \
		codex-rs/mcp-types/generate_mcp_types.py

CARGO_CARGOTOML=	${BUILD_WRKSRC}/Cargo.toml
CARGO_CARGOLOCK=	${BUILD_WRKSRC}/Cargo.lock
CARGO_BUILD_ARGS=	--bin ${PORTNAME}
CARGO_INSTALL_PATH=	codex-rs
CARGO_TEST_ARGS=	--all-features --no-fail-fast
CARGO_ENV=		OPENSSL_NO_VENDOR=1

BUILD_WRKSRC=	${WRKSRC}/codex-rs

PLIST_FILES=	bin/${PORTNAME}
PORTDOCS=	README.md config.md

OPTIONS_DEFINE=		COMPLETIONS DOCS
OPTIONS_DEFAULT=	COMPLETIONS

COMPLETIONS_DESC=	Build and/or install shell completions

COMPLETIONS_PLIST_FILES=etc/bash_completion.d/${PORTNAME} \
			share/fish/completions/${PORTNAME}.fish \
			share/zsh/site-functions/_${PORTNAME}

post-patch:
	@${REINPLACE_CMD} -e 's|0\.0\.0|${DISTVERSION}|' \
		${BUILD_WRKSRC}/app-server/tests/suite/user_agent.rs
	@${REINPLACE_CMD} -e 's|/bin/bash|${LOCALBASE}&|' \
		${BUILD_WRKSRC}/cli/src/debug_sandbox/pid_tracker.rs \
		${BUILD_WRKSRC}/core/src/environment_context.rs \
		${BUILD_WRKSRC}/core/src/exec.rs \
		${BUILD_WRKSRC}/core/src/parse_command.rs \
		${BUILD_WRKSRC}/core/src/shell.rs \
		${BUILD_WRKSRC}/core/src/shell_snapshot.rs \
		${BUILD_WRKSRC}/core/src/tools/handlers/shell.rs \
		${BUILD_WRKSRC}/core/src/tools/handlers/unified_exec.rs \
		${BUILD_WRKSRC}/core/tests/suite/exec.rs \
		${BUILD_WRKSRC}/core/tests/suite/unified_exec.rs \
		${BUILD_WRKSRC}/core/tests/suite/user_notification.rs \
		${BUILD_WRKSRC}/tui/src/exec_command.rs \
		${BUILD_WRKSRC}/tui2/src/exec_command.rs
	@${REINPLACE_CMD} -e 's|python3|${PYTHON_VERSION}|' \
		${BUILD_WRKSRC}/app-server/tests/suite/codex_message_processor_flow.rs \
		${BUILD_WRKSRC}/app-server/tests/suite/v2/turn_start.rs \
		${BUILD_WRKSRC}/core/src/command_safety/is_safe_command.rs \
		${BUILD_WRKSRC}/core/tests/suite/approvals.rs \
		${BUILD_WRKSRC}/core/tests/suite/seatbelt.rs \
		${BUILD_WRKSRC}/core/tests/suite/tools.rs \
		${BUILD_WRKSRC}/core/tests/suite/unified_exec.rs \
		${BUILD_WRKSRC}/exec/tests/suite/sandbox.rs \
		${BUILD_WRKSRC}/mcp-server/tests/suite/codex_tool.rs \
		${BUILD_WRKSRC}/utils/pty/src/tests.rs

post-build-COMPLETIONS-on:
	@${MKDIR} ${WRKSRC}/completions
.for sh in bash fish zsh
	${CARGO_TARGET_DIR}/*/${PORTNAME} completion ${sh} > \
		${WRKSRC}/completions/${PORTNAME}.${sh}
.endfor

do-install:
	${INSTALL_PROGRAM} ${CARGO_TARGET_DIR}/*/${PORTNAME} \
		${STAGEDIR}${PREFIX}/bin

do-install-COMPLETIONS-on:
	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/bash_completion.d \
		${STAGEDIR}${PREFIX}/share/fish/completions \
		${STAGEDIR}${PREFIX}/share/zsh/site-functions
	${INSTALL_DATA} ${WRKSRC}/completions/${PORTNAME}.bash \
		${STAGEDIR}${PREFIX}/etc/bash_completion.d/${PORTNAME}
	${INSTALL_DATA} ${WRKSRC}/completions/${PORTNAME}.fish \
		${STAGEDIR}${PREFIX}/share/fish/completions/${PORTNAME}.fish
	${INSTALL_DATA} ${WRKSRC}/completions/${PORTNAME}.zsh \
		${STAGEDIR}${PREFIX}/share/zsh/site-functions/_${PORTNAME}

do-install-DOCS-on:
	@${MKDIR} ${STAGEDIR}${DOCSDIR}
	${INSTALL_MAN} ${PORTDOCS:S|^|${BUILD_WRKSRC}/|} ${STAGEDIR}${DOCSDIR}

.include <bsd.port.mk>