Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 31, 2025

Task: Add create_executable_makefile function to CMake

The issue requests adding a create_executable_makefile function similar to the existing create_library_makefile function. This function should create a Makefile for executable targets based on CMake data.

Completed Implementation:

✅ All tasks completed successfully!

Changes Made:

  1. scripts/Makefile-exe.in - New template file for generating executable Makefiles

    • Follows convention: Defines variables and includes $(DMOD_SYSTEM_TOOL_MK_FILE_PATH) instead of manually defining build targets
    • Mirrors the pattern used by library Makefiles (which include $(DMOD_SLIB_FILE_PATH))
    • Matches the original format of tool Makefiles (todmp, todmfc)
    • Auto-generated comment to prevent manual editing
  2. scripts/CMakeLists.txt - New create_executable_makefile function

    • Simplified to only set necessary variables for the template
    • Extracts target sources, include directories, linked libraries, and compile definitions
    • Recursively processes linked libraries to get all dependencies
    • Special handling for "dmod" INTERFACE library (expands to constituent libraries)
    • Gracefully handles forward references and non-target libraries
    • Integrated into dmod_add_tool function - Automatically generates Makefiles for build tools
    • Conditional generation - Only creates Makefiles for tools in tools/ directory (not for examples)
    • Comprehensive inline documentation with usage example
  3. tools/system/todmp/Makefile & tools/system/todmfc/Makefile - Auto-generated Makefiles

    • Generated automatically by dmod_add_tool function
    • Follow the same pattern as the original manual Makefiles
    • Include $(DMOD_SYSTEM_TOOL_MK_FILE_PATH) which provides all build rules
    • Compatible with existing build system
  4. examples/system/dmod_loader/ - Preserved as manual example

    • Makefile and CMakeLists.txt kept in original state
    • Serves as reference example for manually maintained build files

Key Features:

  • ✅ Follows project conventions (includes main makefile instead of defining targets)
  • ✅ Handles INTERFACE libraries recursively
  • ✅ Expands "dmod" to: dmod_common, dmod_fastlz, dmod_system, pthread
  • ✅ Manages include directories properly
  • ✅ Works with forward references (targets not yet defined)
  • ✅ Generates working Makefiles compatible with existing build system
  • ✅ Automatically generates Makefiles for tools built with dmod_add_tool
  • ✅ Smart conditional generation - only for tools in tools/ directory

Security & Quality:

  • ✅ Code review completed - all feedback addressed
  • ✅ CodeQL security scan - no vulnerabilities found
  • ✅ Function tested and verified working with both CMAKE and MAKE builds

The implementation is complete and ready for use!

Original prompt

This section details on the original issue you should resolve

<issue_title>Dodać funkcję create_executable_makefile do cmake</issue_title>
<issue_description>Aktualnie mamy funkcję create_library_makefile, która tworzy makefile na podstawie danych z cmake. Teraz potrzeba jeszcze stworzyć drugą funkcję, która będzie tworzyła podobny makefile dla sytuacji gdy chcemy zrobić plik wykonywalny</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI self-assigned this Oct 31, 2025
Copilot AI and others added 3 commits October 31, 2025 12:52
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add create_executable_makefile function to CMake Add create_executable_makefile function to CMake build system Oct 31, 2025
Copilot AI requested a review from JohnAmadis October 31, 2025 12:58
@JohnAmadis
Copy link
Contributor

@copilot build CI failuje

…lative path

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Oct 31, 2025

@copilot build CI failuje

Fixed in commit ca5bd8e. The issue was that OUTPUT_DIR was using a hardcoded relative path (../../../build/...) instead of the $(DMOD_BUILD_DIR) variable. This caused problems when the Makefile was called from different contexts. The generated Makefile now properly uses Makefile variables for portability.

Copy link
Contributor

@JohnAmadis JohnAmadis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DEFINITIONS =

# -----------------------------------------------------------------------------
# Initialization of paths
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot makefile'a dla dmod_loadera nie ruszaj. On ma być jak był bo to przykład

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 39b9212. The dmod_loader Makefile and CMakeLists.txt have been reverted to their original state. The example remains as a manually maintained reference.

@@ -0,0 +1,79 @@
# ##############################################################################
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Możesz od razu dodać użycie tej nowej funkcji w narzędziach które się budują aktualnie poprzez add_dmod_tool

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in commit 39b9212. Added create_executable_makefile call to the dmod_add_tool function. Now all tools built with dmod_add_tool in the tools/ directory automatically get Makefiles generated (todmp and todmfc). Example tools in examples/ are excluded to preserve their manual Makefiles.

…tion to dmod_add_tool function

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
@JohnAmadis
Copy link
Contributor

@copilot źle - sprawdz sobie co jest generowane dla statycznych bibliotek - łamiesz konwencję. Nie masz dawać ręcznie targetów tylko w tych generowanych załączać główny makefile. Możesz sobie przejrzeć narzędzia - one dobrze to robią, załączają główny system-tool.mk czy jakoś tak

…nstead of defining targets manually

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Nov 18, 2025

@copilot źle - sprawdz sobie co jest generowane dla statycznych bibliotek - łamiesz konwencję. Nie masz dawać ręcznie targetów tylko w tych generowanych załączać główny makefile. Możesz s...

Fixed in commit 2fa8590. The generated Makefiles now follow the convention - they define variables and include $(DMOD_SYSTEM_TOOL_MK_FILE_PATH) instead of manually defining build targets. This matches the pattern used by library Makefiles (which include $(DMOD_SLIB_FILE_PATH)) and the original tool Makefiles.

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.

Dodać funkcję create_executable_makefile do cmake

2 participants