Skip to content

Commit

Permalink
Added library support
Browse files Browse the repository at this point in the history
Added ARM support to Xcode. Added archs override to xcode. Added support to libraries
  • Loading branch information
burgerbecky committed Jul 15, 2024
1 parent 8fdd01c commit fea248a
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 59 deletions.
2 changes: 1 addition & 1 deletion makeprojects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
########################################

# Current version of the library as a numeric tuple
__numversion__ = (0, 15, 0)
__numversion__ = (0, 15, 1)

# Current version of the library
__version__ = ".".join([str(num) for num in __numversion__])
Expand Down
37 changes: 34 additions & 3 deletions makeprojects/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
from .core import Solution, Project, Configuration
from .config import BUILD_RULES_PY
from .__init__ import __version__
from .defaults import get_project_name, get_platform, get_ide,\
from .defaults import get_project_name, get_platform, get_ide, \
get_project_type, get_configuration_list
from .util import get_build_rules
from .util import get_build_rules, load_build_rules

########################################

Expand Down Expand Up @@ -242,10 +242,41 @@ def get_project_list(args, build_rules_list, working_directory):
platform_item, ide):

# Set the platform
configuration = Configuration(name=config_item, platform=platform_item)
configuration = Configuration(
name=config_item, platform=platform_item)
project.add_configuration(configuration)
configuration.parse_attributes(build_rules_list)

# Add in any smart libraries
for configuration in project.configuration_list:
for library_rules in configuration.get_unique_chained_list(
"library_rules_list"):

# Is it a directory? Append build_rules.py
if os.path.isdir(library_rules):
library_rules = os.path.join(library_rules, BUILD_RULES_PY)

build_rules = load_build_rules(library_rules)
if not build_rules:
print(
"Error: {} doesn't contain a build_rules file".format(
library_rules))
continue

# Rules found

function_ref = getattr(build_rules, "library_settings", None)
if not callable(function_ref):
print(
"Error: Function library_settings() not found in {}".format(
library_rules))
continue

# Call the function
error = function_ref(configuration)
if error is not None:
break

# Perform the generation
solution.generate(ide)
return 0
Expand Down
21 changes: 21 additions & 0 deletions makeprojects/build_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,27 @@ def configuration_settings(configuration):
return None


########################################

def library_settings(configuration):
"""
Add settings when using this project at a library
When configuration.add_library[] is set to a list of directories,
if the directory has a build_rules.py file, it will run this
function on every configuration to add the library this rules
file describes.
Args:
configuration: Configuration class instance to update.
Returns:
None, to continue processing, zero is no error and stop processing,
any other number is an error code.
"""
return None


# If called as a command line, replace 0 with a call the function
# for the default action. Return a numeric error code, or zero.
if __name__ == "__main__":
Expand Down
8 changes: 6 additions & 2 deletions makeprojects/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Attributes(object):
include_folders_list: List of folders to add to compiler include list
library_folders_list: List of folders to add to linker include list
libraries_list: List of libraries to link
library_rules_list: List of build_rules.py with libraries
frameworks_list: Darwin frameworks list
env_variable_list: List of required environment variables
exclude_from_build_list: List of patterns to exclude from this config
Expand Down Expand Up @@ -82,6 +83,7 @@ class Attributes(object):
include_folders_list = StringListProperty("_include_folders_list")
library_folders_list = StringListProperty("_library_folders_list")
libraries_list = StringListProperty("_libraries_list")
library_rules_list = StringListProperty("_library_rules_list")
frameworks_list = StringListProperty("_frameworks_list")
env_variable_list = StringListProperty("_env_variable_list")
exclude_from_build_list = StringListProperty("_exclude_from_build_list")
Expand All @@ -98,6 +100,7 @@ def __init__(self):
self.include_folders_list = []
self.library_folders_list = []
self.libraries_list = []
self.library_rules_list = []
self.frameworks_list = []
self.env_variable_list = []
self.exclude_from_build_list = []
Expand Down Expand Up @@ -605,6 +608,7 @@ class Configuration(Attributes):
- ``include_folders_list`` List of directories for headers
- ``library_folders_list`` List of directories for libraries
- ``libraries_list`` List of libraries to include
- ``library_rules_list`` List of build_rules.py with libraries
- ``frameworks_list`` List of frameworks to include (macOS/iOS)
- ``env_variable_list`` List of required environment variables
- ``define_list`` List of defines for compilation
Expand Down Expand Up @@ -716,7 +720,7 @@ def parse_attributes(self, build_rules_list):
settings = getattr(build_rules, "configuration_settings", None)
if callable(settings):
result = settings(configuration=self)
# Must test for zero, since None is a break.
# Must test for zero, since None is continue.
if result is not None:
break

Expand Down Expand Up @@ -1028,7 +1032,7 @@ def parse_attributes(self, build_rules_list):
settings = getattr(build_rules, "project_settings", None)
if callable(settings):
result = settings(project=self)
# Must test for zero, since None is a break.
# Must test for zero, since None is continue.
if result is not None:
break
return result
Expand Down
1 change: 1 addition & 0 deletions makeprojects/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

# pylint: disable=consider-using-f-string
# pylint: disable=unused-argument

from __future__ import absolute_import, print_function, unicode_literals

Expand Down
18 changes: 13 additions & 5 deletions makeprojects/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ class FileTypes(IntEnum):
a65: 6502/65812 assembly source
ppc: PowerPC assembly source
a68: 680x0 assembly source
arm: ARM 32 assembly source
arm64: ARM 64 assembly source
image: Image files
ico: Windows icon files
icns: MacOSX icon files
Expand Down Expand Up @@ -175,11 +177,13 @@ class FileTypes(IntEnum):
a65 = 21
ppc = 22
a68 = 23
s = 24
image = 25
ico = 26
icns = 27
appxmanifest = 28
arm = 24
arm64 = 25
s = 26
image = 27
ico = 28
icns = 29
appxmanifest = 30

@staticmethod
def lookup(test_name):
Expand Down Expand Up @@ -264,6 +268,8 @@ def __str__(self):
"a65": FileTypes.a65, # 6502/65816 source code
"ppc": FileTypes.ppc, # PowerPC source code
"a68": FileTypes.a68, # 680x0 source code
"arm": FileTypes.arm, # ARM 32 source code
"arm64": FileTypes.arm64, # ARM 64 source code
"s": FileTypes.s, # Generic assembly code
"ico": FileTypes.ico, # Windows icon file
"icns": FileTypes.icns, # Mac OSX Icon file
Expand Down Expand Up @@ -306,6 +312,8 @@ def __str__(self):
FileTypes.a65: "6502/65816 assembly file",
FileTypes.ppc: "PowerPC assembly file",
FileTypes.a68: "680x0 assembly file",
FileTypes.arm: "ARM 32 assembly file",
FileTypes.arm64: "ARM 64 assembly file",
FileTypes.s: "Generic assembly file",
FileTypes.image: "Image file",
FileTypes.ico: "Windows Icon file",
Expand Down
20 changes: 16 additions & 4 deletions makeprojects/visual_studio_2010.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,8 @@ def __init__(self, configuration):
platform = configuration.platform

# Xbox ONE XDK is Windows RT
if platform is PlatformTypes.xboxone:
if platform is PlatformTypes.xboxone and \
not configuration.project_type.is_library():
self.add_tag("CompileAsWinRT", "true")

# Get the optimization setting
Expand Down Expand Up @@ -1219,7 +1220,11 @@ def __init__(self, configuration):
self.add_tag("BufferSecurityCheck", "false")

# Inline functions
if configuration.debug:
# This is a hack, it appears that VS2022 for Windows ARM64
# generates bad code on AnySuitable
if configuration.debug or (
configuration.ide >= IDETypes.vs2022 and \
platform is PlatformTypes.winarm64):
item = "OnlyExplicitInline"
else:
item = "AnySuitable"
Expand Down Expand Up @@ -1697,6 +1702,7 @@ def __init__(self, project):
self.addfiles(FileTypes.h, "ClInclude")
self.addfiles((FileTypes.cpp, FileTypes.c), "ClCompile")
self.addfiles((FileTypes.x86, FileTypes.x64), "MASM")
self.addfiles((FileTypes.arm, FileTypes.arm64), "MARMASM")

# Resource files
self.addfiles(FileTypes.rc, "ResourceCompile")
Expand Down Expand Up @@ -1850,7 +1856,7 @@ def addfiles(self, file_types, xml_name):
self.add_element(new_xml)

# Check if needs to be marked as "Not part of build"
if xml_name == "MASM":
if xml_name in ("MASM", "MARMASM"):

# Required for Visual Studio 2015 and higher, but present in all
# versions
Expand All @@ -1869,7 +1875,9 @@ def addfiles(self, file_types, xml_name):
FileTypes.x64: ("x64",
"Durango",
"Gaming.Xbox.XboxOne.x64",
"Gaming.Xbox.Scarlett.x64")
"Gaming.Xbox.Scarlett.x64"),
FileTypes.arm: ("ARM",),
FileTypes.arm64: ("ARM64",)
}.get(item.type, [])

# For early out
Expand Down Expand Up @@ -2045,6 +2053,8 @@ def __init__(self, project):
groups, "ClCompile")
self.write_filter_group((FileTypes.x86, FileTypes.x64),
groups, "MASM")
self.write_filter_group((FileTypes.arm, FileTypes.arm64),
groups, "MARMASM")

# Generic assembly is assumed to be PowerPC for PS3
if project.platform_code in ("ps3", "ps4", "ps5", "vit", "swi"):
Expand Down Expand Up @@ -2236,6 +2246,8 @@ def generate(solution):
FileTypes.x86,
FileTypes.x64,
FileTypes.ppc,
FileTypes.arm,
FileTypes.arm64,
FileTypes.s,
FileTypes.rc,
FileTypes.ico,
Expand Down
10 changes: 10 additions & 0 deletions makeprojects/visual_studio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,13 @@ def add_masm_support(project):
"$(VCTargetsPath)\\BuildCustomizations\\masm.props")
project.vs_targets.append(
"$(VCTargetsPath)\\BuildCustomizations\\masm.targets")

# Add props for ARM assembly (Only supported by VS 2017 or higher)
if project.ide >= IDETypes.vs2017:
if source_file_detect(
project.codefiles, (FileTypes.arm, FileTypes.arm64)):
# Add support for masm on VS 2010 and beyond
project.vs_props.append(
"$(VCTargetsPath)\\BuildCustomizations\\marmasm.props")
project.vs_targets.append(
"$(VCTargetsPath)\\BuildCustomizations\\marmasm.targets")
Loading

0 comments on commit fea248a

Please sign in to comment.