Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
WORKDIR /build

# Copy source files
COPY System_Programming_Projects/ System_Programming_Projects/
COPY src/ src/
COPY include/ include/
COPY tests/ tests/
COPY Makefile .

# Build the project (supports both legacy and new structure)
# Build the project
RUN make clean && make all

# Run tests during build to ensure correctness
Expand All @@ -46,9 +45,8 @@ RUN useradd -m -s /bin/bash sysuser

WORKDIR /app

# Copy only the built binaries (handles both structures)
COPY --from=builder /build/bin/* /app/ 2>/dev/null || \
(cp /build/myshell /app/ && cp /build/queue_test /app/)
# Copy the built binaries
COPY --from=builder /build/bin/* /app/

# Set ownership
RUN chown -R sysuser:sysuser /app
Expand Down
45 changes: 4 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,23 @@ TEST_DIR := tests
BUILD_DIR := build
BIN_DIR := bin

# Legacy support
LEGACY_DIR := System_Programming_Projects

# Source files
SHELL_SRCS := $(SRC_DIR)/shell/myshell.c $(SRC_DIR)/shell/shell_main.c
QUEUE_SRCS := $(SRC_DIR)/queue/queue.c
QUEUE_TEST := $(TEST_DIR)/queue_test.c

# Fallback to legacy structure if new structure doesn't exist
ifeq ($(wildcard $(SRC_DIR)/shell/myshell.c),)
SHELL_SRCS := $(LEGACY_DIR)/shell/myshell.c $(LEGACY_DIR)/shell/shell_main.c
QUEUE_SRCS := $(LEGACY_DIR)/queue/queue.c
QUEUE_TEST := $(LEGACY_DIR)/queue/queue_test.c
INC_DIR := $(LEGACY_DIR)/queue
endif

# Build targets
MYSHELL := $(BIN_DIR)/myshell
QUEUE_TEST_BIN := $(BIN_DIR)/queue_test

# Legacy targets (for backward compatibility)
MYSHELL_LEGACY := myshell
QUEUE_TEST_LEGACY := queue_test

# ============================================================================
# Phony targets
# ============================================================================
.PHONY: all clean test check debug help install \
legacy legacy-test legacy-clean format
.PHONY: all clean test check debug help install format

# Default target
all: $(BIN_DIR) $(MYSHELL) $(QUEUE_TEST_BIN)

# Legacy build (backward compatible)
legacy: $(MYSHELL_LEGACY) $(QUEUE_TEST_LEGACY)

# ============================================================================
# Build rules
# ============================================================================
Expand All @@ -60,25 +41,18 @@ legacy: $(MYSHELL_LEGACY) $(QUEUE_TEST_LEGACY)
$(BIN_DIR):
@mkdir -p $(BIN_DIR)

# Build shell (new structure)
# Build shell
$(MYSHELL): $(SHELL_SRCS) | $(BIN_DIR)
@echo "Building myshell..."
$(CC) $(CFLAGS) -I$(INC_DIR) -o $@ $^ $(LDFLAGS)
@echo "✓ myshell built successfully"

# Build queue test (new structure)
# Build queue test
$(QUEUE_TEST_BIN): $(QUEUE_SRCS) $(QUEUE_TEST) | $(BIN_DIR)
@echo "Building queue_test..."
$(CC) $(CFLAGS) $(THREADS) -I$(INC_DIR) -o $@ $^ $(LDFLAGS)
@echo "✓ queue_test built successfully"

# Legacy targets (backward compatible)
$(MYSHELL_LEGACY): $(SHELL_SRCS)
$(CC) $(CFLAGS) -o $@ $^

$(QUEUE_TEST_LEGACY): $(LEGACY_DIR)/queue/queue.c $(LEGACY_DIR)/queue/queue_test.c
$(CC) $(CFLAGS) $(THREADS) -o $@ $^

# ============================================================================
# Test and validation
# ============================================================================
Expand All @@ -89,10 +63,6 @@ test: $(QUEUE_TEST_BIN)
@$(QUEUE_TEST_BIN)
@echo "✓ All tests passed"

# Legacy test
legacy-test: $(QUEUE_TEST_LEGACY)
@./$(QUEUE_TEST_LEGACY)

# Code quality check (runs tests and validates build)
check: all test
@echo "✓ All checks passed"
Expand Down Expand Up @@ -126,12 +96,9 @@ format:
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(BIN_DIR) $(BUILD_DIR)
@rm -f $(MYSHELL_LEGACY) $(QUEUE_TEST_LEGACY) *.o
@rm -f *.o
@echo "✓ Clean complete"

legacy-clean:
@rm -f $(MYSHELL_LEGACY) $(QUEUE_TEST_LEGACY) *.o

# ============================================================================
# Installation (local)
# ============================================================================
Expand Down Expand Up @@ -160,10 +127,6 @@ help:
@echo " install - Install to PREFIX (default: /usr/local)"
@echo " help - Show this help message"
@echo ""
@echo "Legacy targets (backward compatibility):"
@echo " legacy - Build in legacy mode"
@echo " legacy-test - Run tests in legacy mode"
@echo ""
@echo "Examples:"
@echo " make # Build all"
@echo " make test # Run tests"
Expand Down
139 changes: 0 additions & 139 deletions System_Programming_Projects/queue/queue.c

This file was deleted.

17 changes: 0 additions & 17 deletions System_Programming_Projects/queue/queue.h

This file was deleted.

94 changes: 0 additions & 94 deletions System_Programming_Projects/queue/queue_test.c

This file was deleted.

Loading
Loading