Move curl to tool/curl/ and support it as a builtin in cocmd.

You can now handily use `curl` with popen()/system() with STATIC_YOINK("_curl").
This commit is contained in:
Ronsor 2022-12-20 14:26:55 -07:00
parent aa4a1a4618
commit 4e3978fa4d
7 changed files with 82 additions and 6 deletions

View file

@ -193,6 +193,7 @@ include third_party/python/python.mk
include tool/build/emucrt/emucrt.mk
include tool/build/emubin/emubin.mk
include tool/build/build.mk
include tool/curl/curl.mk
include examples/examples.mk
include examples/pyapp/pyapp.mk
include examples/pylife/pylife.mk

View file

@ -38,7 +38,7 @@
#include "third_party/awk/cmd.h"
#include "third_party/sed/cmd.h"
#include "third_party/tr/cmd.h"
#include "tool/net/curl.h"
#include "tool/curl/cmd.h"
/**
* @fileoverview Cosmopolitan Command Interpreter

View file

@ -1,4 +1,4 @@
#include "curl.inc"
#include "tool/curl/cmd.h"
int main(int argc, char *argv[]) {
return _curl(argc, argv);

View file

@ -1,5 +1,5 @@
#ifndef COSMOPOLITAN_TOOL_NET_CURL_CMD_H_
#define COSMOPOLITAN_TOOL_NET_CURL_CMD_H_
#ifndef COSMOPOLITAN_TOOL_CURL_CMD_H_
#define COSMOPOLITAN_TOOL_CURL_CMD_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
@ -7,4 +7,4 @@ int _curl(int, char *[]);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_TOOL_NET_CURL_CMD_H_ */
#endif /* COSMOPOLITAN_TOOL_CURL_CMD_H_ */

View file

@ -52,7 +52,7 @@
#include "third_party/mbedtls/pk.h"
#include "third_party/mbedtls/ssl.h"
#include "third_party/mbedtls/ssl_ticket.h"
#include "tool/net/curl.h"
#include "tool/curl/cmd.h"
/**
* @fileoverview Downloads HTTP URL to stdout.

74
tool/curl/curl.mk Normal file
View file

@ -0,0 +1,74 @@
#-*-mode:makefile-gmake;indent-tabs-mode:t;tab-width:8;coding:utf-8-*-┐
#───vi: set et ft=make ts=8 tw=8 fenc=utf-8 :vi───────────────────────┘
PKGS += TOOL_CURL
TOOL_CURL_ARTIFACTS += TOOL_CURL_A
TOOL_CURL = $(TOOL_CURL_DEPS) $(TOOL_CURL_A)
TOOL_CURL_A = o/$(MODE)/tool/curl/curl.a
TOOL_CURL_FILES := $(wildcard tool/curl/*)
TOOL_CURL_HDRS = $(filter %.h,$(TOOL_CURL_FILES))
TOOL_CURL_INCS = $(filter %.inc,$(TOOL_CURL_FILES))
TOOL_CURL_SRCS = $(filter %.c,$(TOOL_CURL_FILES))
TOOL_CURL_OBJS = $(TOOL_CURL_SRCS:%.c=o/$(MODE)/%.o)
TOOL_CURL_DIRECTDEPS = \
LIBC_CALLS \
LIBC_DNS \
LIBC_FMT \
LIBC_INTRIN \
LIBC_LOG \
LIBC_MEM \
LIBC_NEXGEN32E \
LIBC_NT_IPHLPAPI \
LIBC_NT_KERNEL32 \
LIBC_RUNTIME \
LIBC_SOCK \
LIBC_STDIO \
LIBC_STR \
LIBC_STUBS \
LIBC_SYSV \
LIBC_SYSV_CALLS \
LIBC_TIME \
LIBC_THREAD \
LIBC_TINYMATH \
LIBC_X \
LIBC_ZIPOS \
NET_HTTP \
NET_HTTPS \
THIRD_PARTY_GETOPT \
THIRD_PARTY_MBEDTLS
TOOL_CURL_DEPS := \
$(call uniq,$(foreach x,$(TOOL_CURL_DIRECTDEPS),$($(x))))
TOOL_CURL_CHECKS = \
$(TOOL_CURL_A).pkg \
$(TOOL_CURL_HDRS:%=o/$(MODE)/%.ok)
$(TOOL_CURL_A): \
tool/curl/ \
$(TOOL_CURL_A).pkg \
$(TOOL_CURL_OBJS)
$(TOOL_CURL_A).pkg: \
$(TOOL_CURL_OBJS) \
$(foreach x,$(TOOL_CURL_DIRECTDEPS),$($(x)_A).pkg)
o/$(MODE)/tool/curl/curl.com.dbg: \
$(TOOL_CURL) \
o/$(MODE)/tool/curl/cmd.o \
o/$(MODE)/tool/curl/curl.o \
$(CRT) \
$(APE_NO_MODIFY_SELF)
@$(APELINK)
TOOL_CURL_LIBS = $(TOOL_CURL_A)
TOOL_CURL_BINS = $(TOOL_CURL_COMS) $(TOOL_CURL_COMS:%=%.dbg)
TOOL_CURL_COMS = o/$(MODE)/tool/curl/curl.com
$(TOOL_CURL_OBJS): $(BUILD_FILES) tool/curl/curl.mk
.PHONY: o/$(MODE)/tool/curl
o/$(MODE)/tool/curl: \
$(TOOL_CURL_BINS) \
$(TOOL_CURL_CHECKS)

View file

@ -5,6 +5,7 @@
o/$(MODE)/tool: \
o/$(MODE)/tool/args \
o/$(MODE)/tool/build \
o/$(MODE)/tool/curl \
o/$(MODE)/tool/decode \
o/$(MODE)/tool/hash \
o/$(MODE)/tool/lambda \