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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ add_library(runcpp2 STATIC
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/StageInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/ProfilesDefines.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/FilesToCopyInfo.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/Data/BuildTypeHelper.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/ProfileHelper.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/CompilingLinking.cpp"
"${CMAKE_CURRENT_LIST_DIR}/Src/runcpp2/ConfigParsing.cpp"
Expand Down
109 changes: 64 additions & 45 deletions DefaultYAMLs/DefaultScriptInfo.yaml
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
# NOTE: All command substitutions are passed directly to the shell.
# Be cautious when using user-provided input in your build commands to avoid potential security risks.

# NOTE: All the options here are defaulted to empty.
# You can uncomment different sections to set what you want.

# (Optional) Whether to pass the script path as the second parameter when running
# This is the template for specifying build settings.
# Many of the settings are passed directly to the shell.
# Be cautious when using user-provided input in your build commands to avoid potential security risks.
# Output from commands such as Setup or Cleanup won't be shown unless log level is set to info.
# If the default is not mentioned for a setting, it will be empty.

# Each of the platform dependent settings can be listed under
# - DefaultPlatform
# - Windows
# - Linux
# - MacOS
# - Unix

# You can find all the profiles in your config folder.
# This can be found by running `runcpp2 --show-config-path`.
# Specifying "DefaultProfile" in the profile name will allow any profiles
# and use the user's preferred one.

# (Optional) Whether to pass the script path as the second parameter when running. Default is false
PassScriptPath: false

# # (Optional) Language of the script
# (Optional) Language of the script. Default is determined by file extension
Language: "c++"

# (Optional) Preferred profiles for the script for each platform.
# Profiles are listed in user config file,
# which can be retreived by running `runcpp2 --show-config-path`
# Each of the platform dependent settings can be listed under
# - Default
# - Windows
# - Linux
# - MacOS
# - Unix
# (Optional) The type of output to build. Default is Executable
# Supported types:
# - Executable: Build as executable that can be run
# - Static: Build as static library (.lib/.a)
# - Shared: Build as shared library (.dll/.so)
# - Objects: Only compile to object files without linking
BuildType: Executable

# TODO: Rename this
# (Optional) Allowed profiles for the script for each platform.
# Any profiles will be used if none is specified for the platform.
RequiredProfiles:
Windows: ["g++"]
Linux: ["g++"]
Expand All @@ -28,7 +42,7 @@ RequiredProfiles:
OverrideCompileFlags:
# Target Platform
DefaultPlatform:
# Profile with the respective flags to override. ("DefaultProfile" for any profile)
# Profile with the respective flags to override
"g++":
# (Optional) Flags to be removed from the default compile flags, separated by space
Remove: ""
Expand All @@ -40,7 +54,7 @@ OverrideCompileFlags:
OverrideLinkFlags:
# Target Platform
DefaultPlatform:
# Profile with the respective flags to override ("DefaultProfile" for any profile)
# Profile with the respective flags to override
"g++":
# (Optional) Flags to be removed from the default link flags, separated by space
Remove: ""
Expand All @@ -59,35 +73,35 @@ OtherFilesToBeCompiled:

# (Optional) Include paths (relative to script file path) for each platform and profile
IncludePaths:
# Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix)
# Target Platform
DefaultPlatform:
# Target Profile (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile)
# Target Profile
DefaultProfile:
- "./include"
- "./src/include"

# (Optional) Define cross-compiler defines for each platform and profile.
# Defines can be specified as just a name or as a name-value pair.
# Defines can be specified as just a name or as a name-value pair.
Defines:
# Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix)
# Target Platform
DefaultPlatform:
# Profile name (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile)
# Profile name
DefaultProfile:
- "EXAMPLE_DEFINE" # Define without a value
- "VERSION_MAJOR=1" # Define with a value

# (Optional) Setup commands are run once before the script is first built.
# These commands are run at the script's location when no build directory exists.
# These commands are run at the script's location when no build directory exists.
Setup:
# Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix)
# Target Platform
DefaultPlatform:
# Profile name (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile)
# Profile name
DefaultProfile:
# List of setup commands
- "echo Setting up script..."

# (Optional) PreBuild commands are run before each build.
# These commands are run in the build directory before compilation starts.
# These commands are run in the build directory before compilation starts.
PreBuild:
# Target Platform
DefaultPlatform:
Expand All @@ -96,7 +110,7 @@ PreBuild:
- "echo Starting build..."

# (Optional) PostBuild commands are run after each successful build.
# These commands are run in the output directory where binaries are located.
# These commands are run in the output directory where binaries are located.
PostBuild:
# Target Platform
DefaultPlatform:
Expand All @@ -105,7 +119,7 @@ PostBuild:
- "echo Build completed..."

# (Optional) Cleanup commands are run when using the --cleanup option.
# These commands are run at the script's location before the build directory is removed.
# These commands are run at the script's location before the build directory is removed.
Cleanup:
# Target Platform
DefaultPlatform:
Expand All @@ -121,23 +135,26 @@ Dependencies:
# Supported platforms of the dependency
Platforms: [Windows, Linux, MacOS]

# The source of getting the dependency (Git, Local)
# Where to get and copy the dependency (Git, Local)
# Either Git or Local can exist, not both
Source:
# (Optional) Import dependency configuration from a YAML file
# For Git source: Path is relative to the git repository root
# For Local source: Path is relative to the script directory.
# If neither source exists, local source with root script directory is assumed.
# ImportPath: "config/dependency.yaml"
# (Optional) Import dependency configuration from a YAML file if this field exists
# All other fields (Name, Platforms, etc...) are not needed if this field exists
# For Git source: Path is relative to the git repository root
# For Local source: Path is relative to the script directory.
# If neither source exists, local source with root script directory is assumed.
ImportPath: "config/dependency.yaml"

# Git: Dependency or import YAML file exists in a git server, and needs to be cloned.
# Dependency or import YAML file exists in a git server, and needs to be cloned to build directory
Git:
# Git repository URL
URL: "https://github.com/MyUser/MyLibrary.git"

# Local: Dependency or import YAML file exists in local filesystem
# Local:
# # Path to the library directory
# Path: "./libs/LocalLibrary"
# Dependency or import YAML file exists in local filesystem directory,
# and needs to be copied to build directory
Local:
# Path to the library directory
Path: "./libs/LocalLibrary"


# Library Type (Static, Object, Shared, Header)
Expand All @@ -158,7 +175,7 @@ Dependencies:
SearchLibraryNames: ["MyLibrary"]

# (Optional) The library names to be excluded from being searched.
# Works the same as SearchLibraryNames but will NOT be linked instead
# Works the same as SearchLibraryNames but will NOT be linked instead
ExcludeLibraryNames: []

# The path (relative to the dependency folder) to be searched for the dependency binaries
Expand All @@ -182,23 +199,25 @@ Dependencies:
Build:
# Target Platform
DefaultPlatform:
# Target Profile ("DefaultProfile" for any profile)
# Target Profile
"g++":
- "cd build && cmake .."
- "cd build && cmake --build ."

# (Optional) Cleanup commands are run when the reset option is present. Normally nothing needs
# to be done since the dependency folder will be removed automatically.
Cleanup:
# Target Platform
Linux:
# Target Profile
"g++":
- "sudo apt purge MyLibrary"

# (Optional) Files to be copied to next to output binary for each platform and profile
FilesToCopy:
# Target Platform (DefaultPlatform, Windows, Linux, MacOS, or Unix)
# Target Platform
DefaultPlatform:
# Profile name (e.g., "g++", "clang++", "msvc", or "DefaultProfile" for any profile)
# Profile name
DefaultProfile:
# List of files to copy (relative to the dependency folder)
- "assets/textures/sprite.png"
Expand Down
49 changes: 32 additions & 17 deletions DefaultYAMLs/DefaultUserConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,13 @@ Profiles:
# (Optional) The commands to run in **shell** AFTER compiling
# This is run inside the .runcpp2 directory where the build happens.
# Cleanup: []
ExecutableShared:
DefaultPlatform:
Flags: "-std=c++17 -Wall -g -fpic"
Executable: "g++"
RunParts: *g++_CompileRunParts
# Setup: []
# Cleanup: []
Static:
DefaultPlatform:
Flags: "-std=c++17 -Wall -g"
Expand Down Expand Up @@ -227,14 +234,15 @@ Profiles:
# {OutputFilePath}: (Similar to previous)
LinkTypes:
Executable:
Unix:
DefaultPlatform:
Flags: "-Wl,-rpath,\\$ORIGIN"
Executable: "g++"
RunParts: *g++_LinkRunParts
# Setup: []
# Cleanup: []
Windows:
Flags: "-Wl,-rpath,\\$ORIGIN"
ExecutableShared:
DefaultPlatform:
Flags: "-shared -Wl,-rpath,\\$ORIGIN"
Executable: "g++"
RunParts: *g++_LinkRunParts
# Setup: []
Expand All @@ -247,13 +255,7 @@ Profiles:
# Setup: []
# Cleanup: []
Shared:
Unix:
Flags: "-shared -Wl,-rpath,\\$ORIGIN"
Executable: "g++"
RunParts: *g++_LinkRunParts
# Setup: []
# Cleanup: []
Windows:
DefaultPlatform:
Flags: "-shared -Wl,-rpath,\\$ORIGIN"
Executable: "g++"
RunParts: *g++_LinkRunParts
Expand Down Expand Up @@ -286,6 +288,11 @@ Profiles:
<<: *MSVC_CompileFlags
Executable: "CL.exe"
RunParts: *vs2022_v17+_CompileRunParts
ExecutableShared:
Windows:
<<: *MSVC_CompileFlags
Executable: "CL.exe"
RunParts: *vs2022_v17+_CompileRunParts
Static:
Windows:
<<: *MSVC_CompileFlags
Expand All @@ -296,7 +303,6 @@ Profiles:
<<: *MSVC_CompileFlags
Executable: "CL.exe"
RunParts: *vs2022_v17+_CompileRunParts
# Specify the linker settings
Linker:
PreRun:
Windows: ".\\prerun.bat"
Expand All @@ -310,12 +316,7 @@ Profiles:
oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /manifest:embed /SUBSYSTEM:CONSOLE
Executable: "link.exe"
RunParts: *vs2022_v17+_LinkRunParts
Static:
Windows:
Flags: "/NOLOGO"
Executable: "lib.exe"
RunParts: *vs2022_v17+_LinkRunParts
Shared:
ExecutableShared:
Windows:
Flags: >-
/NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib
Expand All @@ -329,3 +330,17 @@ Profiles:
CommandPart: " \"{LinkFilePath}\""
Setup: [ "echo EXPORTS > .\\temp.def", "echo. main @1 >> .\\temp.def" ]
Cleanup: [ "del .\\temp.def" ]
Static:
Windows:
Flags: "/NOLOGO"
Executable: "lib.exe"
RunParts: *vs2022_v17+_LinkRunParts
Shared:
Windows:
Flags: >-
/NOLOGO kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib
oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /manifest:embed /SUBSYSTEM:CONSOLE
/DLL
Executable: "link.exe"
RunParts: *vs2022_v17+_LinkRunParts

Loading