Remove src/ folder and update CMakeLists.txt to reference real interpreter

- Removed src/ directory (accidental commit with minimal runtime)
- Removed include/ and tests/ directories (part of minimal runtime)
- Updated CMakeLists.txt to build Programs/python.c (real CPython entry point)
- Added minimal pyconfig.h stub (NOTE: incomplete, proper build needs configure)

The CMakeLists.txt now references the real Python interpreter source but requires
additional work to properly build the full CPython interpreter with all dependencies.

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-28 21:53:09 +00:00
parent 468f324003
commit d83dd682f5
6 changed files with 89 additions and 122 deletions

View File

@@ -11,51 +11,45 @@ set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/generated/typthon/version.h
@ONLY
)
# NOTE: Building CPython requires proper configuration (./configure)
# This CMakeLists.txt is a work in progress to wire to the real interpreter
add_library(typthon_core STATIC src/runtime.c)
target_include_directories(
typthon_core
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/generated
)
target_compile_features(typthon_core PUBLIC c_std_11)
# Platform detection
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
add_executable(typthon src/main.c)
target_link_libraries(typthon PRIVATE typthon_core)
# TODO: Collect and build Python core source files from:
# - Python/*.c (interpreter core)
# - Objects/*.c (built-in types)
# - Parser/*.c (parser)
# - Modules/*.c (built-in modules)
# TODO: Generate or provide pyconfig.h
# CPython normally generates this via ./configure
# Placeholder: Build Python executable
add_executable(typthon Programs/python.c)
# TODO: Link against Python core library once built
# target_link_libraries(typthon PRIVATE python_core)
if(UNIX)
target_link_libraries(typthon PRIVATE m dl pthread util)
endif()
target_include_directories(typthon
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/Include
)
include(GNUInstallDirs)
install(
TARGETS typthon_core typthon
TARGETS typthon
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/generated/typthon/version.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/typthon
)
include(CTest)
if(BUILD_TESTING)
add_executable(typthon_smoketest tests/smoke.c)
target_include_directories(
typthon_smoketest
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/generated
)
target_link_libraries(typthon_smoketest PRIVATE typthon_core)
add_test(NAME typthon_cli COMMAND typthon --version)
add_test(NAME typthon_runtime_version COMMAND typthon_smoketest)
add_test(NAME typthon_version COMMAND typthon --version)
endif()

58
Include/pyconfig.h Normal file
View File

@@ -0,0 +1,58 @@
/* Minimal pyconfig.h for Typthon CMake build
* NOTE: This is a stub. A proper build requires running ./configure
* to generate a complete pyconfig.h with platform-specific settings.
*/
#ifndef Py_PYCONFIG_H
#define Py_PYCONFIG_H
/* Platform detection */
#if defined(_WIN32) || defined(_WIN64)
#define MS_WINDOWS
#define MS_WIN32
#elif defined(__linux__)
#define __linux__ 1
#elif defined(__APPLE__)
#define __APPLE__ 1
#endif
/* Basic configuration - these are minimal stubs */
#define SIZEOF_INT 4
#define SIZEOF_LONG 8
#define SIZEOF_VOID_P 8
#define SIZEOF_SIZE_T 8
#define SIZEOF_TIME_T 8
#define SIZEOF_WCHAR_T 4
#define SIZEOF_SHORT 2
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
#define SIZEOF_FPOS_T 16
#define SIZEOF_LONG_LONG 8
/* Enable threading */
#ifndef MS_WINDOWS
#define WITH_THREAD 1
#define HAVE_PTHREAD_H 1
#endif
/* Common POSIX features */
#ifndef MS_WINDOWS
#define HAVE_UNISTD_H 1
#define HAVE_FCNTL_H 1
#define HAVE_SYS_TYPES_H 1
#define HAVE_SYS_STAT_H 1
#define HAVE_DIRENT_H 1
#define HAVE_DLFCN_H 1
#endif
/* Standard C features */
#define HAVE_STDINT_H 1
#define HAVE_STDLIB_H 1
#define HAVE_STRING_H 1
#define HAVE_ERRNO_H 1
#define HAVE_STDIO_H 1
/* TODO: Add more platform-specific defines as needed */
/* This stub is incomplete. For a full build, use CPython's configure script */
#endif /* Py_PYCONFIG_H */

View File

@@ -1,15 +0,0 @@
#pragma once
#include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
const char *typthon_version(void);
void typthon_print_banner(FILE *output);
#ifdef __cplusplus
}
#endif

View File

@@ -1,40 +0,0 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "typthon/runtime.h"
#include "typthon/version.h"
static void print_usage(void) {
printf("Typthon %s\n", typthon_version());
printf("usage: typthon [--version] [--help]\n");
printf("This is a lightweight bootstrap for the Typthon runtime.\n");
}
int main(int argc, char **argv) {
bool show_help = false;
bool show_version = false;
for (int i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) {
show_help = true;
} else if (strcmp(argv[i], "--version") == 0 || strcmp(argv[i], "-V") == 0) {
show_version = true;
} else {
fprintf(stderr, "unknown option: %s\n", argv[i]);
return 1;
}
}
if (show_help) {
print_usage();
return 0;
}
if (show_version || argc == 1) {
typthon_print_banner(stdout);
return 0;
}
return 0;
}

View File

@@ -1,14 +0,0 @@
#include "typthon/runtime.h"
#include "typthon/version.h"
const char *typthon_version(void) {
return TYPTHON_VERSION;
}
void typthon_print_banner(FILE *output) {
if (output == NULL) {
return;
}
fprintf(output, "Typthon %s\n", typthon_version());
}

View File

@@ -1,16 +0,0 @@
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "typthon/runtime.h"
#include "typthon/version.h"
int main(void) {
const char *version = typthon_version();
assert(version != NULL);
assert(strlen(version) > 0);
printf("Typthon runtime version: %s\n", version);
typthon_print_banner(stdout);
return 0;
}