Skip to content

Commit

Permalink
Watcom exporter is documented
Browse files Browse the repository at this point in the history
  • Loading branch information
burgerbecky committed Oct 6, 2024
1 parent 51d65a1 commit 2ff66e6
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 42 deletions.
13 changes: 13 additions & 0 deletions docs/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,16 @@ build_objects.BuildObject
^^^^^^^^^^^^^^^^^^^^^^^^^
.. doxygenclass:: makeprojects::build_objects::BuildObject
:members:

Watcom
------

watcom.BuildWatcomFile
^^^^^^^^^^^^^^^^^^^^^^
.. doxygenclass:: makeprojects::watcom::BuildWatcomFile
:members:

watcom.WatcomProject
^^^^^^^^^^^^^^^^^^^^
.. doxygenclass:: makeprojects::watcom::WatcomProject
:members:
33 changes: 27 additions & 6 deletions makeprojects/codewarrior.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ def __init__(self, defines):
index = item.find("=")
if index != -1:
# Only replace the first one
item = item[:index] + " " + item[index+1:]
item = item[:index] + " " + item[index + 1:]

definestring.append("#define " + item)

Expand Down Expand Up @@ -1046,7 +1046,7 @@ class MWLinker_X86(object):
settings: List of setting objects for this generator
"""

def __init__(self):
def __init__(self, configuration):
"""
Initialize
"""
Expand All @@ -1056,8 +1056,19 @@ def __init__(self):
SETTING("MWLinker_X86_linkCV", "1"),
SETTING("MWLinker_X86_symfullpath", "false"),
SETTING("MWLinker_X86_linkdebug", "true"),
SETTING("MWLinker_X86_debuginline", "true"),
SETTING("MWLinker_X86_subsystem", "Unknown"),
SETTING("MWLinker_X86_debuginline", "true")
]

# Get the target subsystem
item = "Unknown"
if configuration.platform.is_windows():
if configuration.project_type is ProjectTypes.tool:
item = "WinCUI"
else:
item = "WinGUI"
self.settings.append(SETTING("MWLinker_X86_subsystem", item))

self.settings.extend([
SETTING("MWLinker_X86_entrypointusage", "Default"),
SETTING("MWLinker_X86_entrypoint", ""),
SETTING("MWLinker_X86_codefolding", "Any"),
Expand All @@ -1071,7 +1082,7 @@ def __init__(self):
SETTING("MWLinker_X86_nowarnings", "false"),
SETTING("MWLinker_X86_verbose", "false"),
SETTING("MWLinker_X86_commandfile", "")
]
])

def generate(self, line_list, level=4):
"""
Expand Down Expand Up @@ -1544,7 +1555,7 @@ def __init__(self, solution, projectname=None,
target.settinglist.append(PDisasmX86())

# x86 Linker
target.settinglist.append(MWLinker_X86())
target.settinglist.append(MWLinker_X86(configuration))

# Create the list of libraries to add to the project if
# it's an application
Expand All @@ -1553,6 +1564,16 @@ def __init__(self, solution, projectname=None,
if not configuration.project_type.is_library():
liblist = configuration.get_unique_chained_list(
"libraries_list")
if configuration.platform.is_windows():
if configuration.use_mfc:
for item in liblist:
temp = item.lower()
if temp in ("mfccw.lib", "mfccw_d.lib"):
break
else:
# Insert the library
item = "MFCcw_D.lib" if configuration.debug else "MFCcw.lib"
liblist.insert(0, item)

# Generate the file and group lists
if alllists or liblist:
Expand Down
23 changes: 18 additions & 5 deletions makeprojects/visual_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -2980,7 +2980,19 @@ def __init__(self, configuration):

# Additional libraries
default = configuration.get_unique_chained_list(
'libraries_list')
"libraries_list")

# Check if the MFC library is already present
if configuration.use_mfc:
for item in default:
temp = item.lower()
if temp in ("nafxcw.lib", "nafxcwd.lib"):
break
else:
# Insert the library
item = "nafxcwd.lib" if configuration.debug else "nafxcw.lib"
default.insert(0, item)

self.add_default(
VSStringListProperty(
'AdditionalDependencies',
Expand Down Expand Up @@ -4136,17 +4148,18 @@ def __init__(self, configuration):
VSStringProperty("UseOfATL", None),
BoolATLMinimizesCRunTimeLibraryUsage(configuration),
VSStringProperty("CharacterSet", None),
VSStringProperty('DeleteExtensionsOnClean', None),
VSStringProperty('ManagedExtensions', None),
VSStringProperty('WholeProgramOptimization',
VSStringProperty("DeleteExtensionsOnClean", None),
VSStringProperty("ManagedExtensions", None),
VSStringProperty("WholeProgramOptimization",
vs_link_time_code_generation),
VSStringProperty('ReferencesPath', None)
VSStringProperty("ReferencesPath", None)
])

if platform.is_windows():
if configuration.use_mfc is not None:
self.set_attribute(
"UseOfMFC", "1" if configuration.use_mfc else "0")

if configuration.use_atl is not None:
self.set_attribute(
"UseOfATL", "1" if configuration.use_atl else "0")
Expand Down
86 changes: 55 additions & 31 deletions makeprojects/watcom.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,18 @@ def __init__(self, file_name, priority, configuration, verbose=False):
Class to handle watcom make files
Args:
file_name: Pathname to the *.wmk to build
file_name: Pathname to the \*.wmk to build
priority: Priority to build this object
configuration: Build configuration
verbose: True if verbose output
"""

super(BuildWatcomFile, self).__init__(
file_name, priority, configuration=configuration)
super(
BuildWatcomFile,
self).__init__(
file_name,
priority,
configuration=configuration)
self.verbose = verbose

def build(self):
Expand All @@ -104,10 +108,10 @@ def build(self):
# Is Watcom installed?
watcom_path = where_is_watcom(verbose=self.verbose)
if watcom_path is None:
return BuildError(
0, self.file_name,
file_name = self.file_name
return BuildError(0, file_name,
msg="{} requires Watcom to be installed to build!".format(
self.file_name))
file_name))

# Watcom requires the path set up so it can access link files
exe_name = where_is_watcom("wmake", verbose=self.verbose)
Expand Down Expand Up @@ -160,6 +164,7 @@ def clean(self):
Returns:
None if not implemented, otherwise an integer error code.
"""

return self.build()

########################################
Expand Down Expand Up @@ -279,6 +284,7 @@ def generate(solution):
if solution.ide not in SUPPORTED_IDES:
return 10

# Perform sanity checks
error = warn_if_invalid(solution)
if error:
return error
Expand Down Expand Up @@ -337,14 +343,17 @@ def __init__(self, solution):
solution: Parent solution.
"""

self.solution = solution
self.platforms = []
self.configuration_list = []
self.configuration_names = []
# Init the platform list
platforms = []

# Init the list of custom rules
custom_list = []

self.solution = solution
self.platforms = platforms
self.configuration_list = []
self.configuration_names = []

# Process all the projects and configurations
for project in solution.project_list:

Expand Down Expand Up @@ -373,8 +382,8 @@ def __init__(self, solution):
self.configuration_names.append(configuration)

# Add platform if not already found
if configuration.platform not in self.platforms:
self.platforms.append(configuration.platform)
if configuration.platform not in platforms:
platforms.append(configuration.platform)

# Get the rule list
rule_list = (configuration.custom_rules,
Expand Down Expand Up @@ -564,7 +573,8 @@ def _write_phony_all(self, line_list):
"""

target_list = []
for item in self.configuration_names:
configuration_names = self.configuration_names
for item in configuration_names:
target_list.append(item.name)

line_all = "all: " + " ".join(target_list) + " .SYMBOLIC"
Expand Down Expand Up @@ -603,9 +613,10 @@ def _write_phony_configurations(self, line_list):
"#"
))

platforms = self.platforms
for configuration in self.configuration_names:
target_list = []
for platform in self.platforms:
for platform in platforms:
target_list.append(
configuration.name +
platform.get_short_code())
Expand Down Expand Up @@ -635,20 +646,22 @@ def _write_phony_platforms(self, line_list):
"""

# Only generate if there are platforms
if self.platforms:
platforms = self.platforms
if platforms:
line_list.extend((
"",
"#",
"# Platforms",
"#"
))

for platform in self.platforms:
configuration_list = self.configuration_list
for platform in platforms:

short_code = platform.get_short_code()

target_list = []
for configuration in self.configuration_list:
for configuration in configuration_list:
target_list.append(
configuration.name +
short_code)
Expand Down Expand Up @@ -676,7 +689,8 @@ def _write_phony_binaries(self, line_list):
line_list: List of lines of text generated.
"""

if self.configuration_list:
configuration_list = self.configuration_list
if configuration_list:

line_list.extend((
"",
Expand All @@ -685,7 +699,7 @@ def _write_phony_binaries(self, line_list):
"#"
))

for configuration in self.configuration_list:
for configuration in configuration_list:
template = get_output_template(
configuration.project_type, configuration.platform)

Expand Down Expand Up @@ -733,13 +747,15 @@ def _write_phony_binaries(self, line_list):
def write_all_targets(self, line_list):
"""
Output all of the .SYMBOLIC targets.
Create all of the targets, starting with all, and then all the
configurations, followed by the clean targets
configurations, followed by the clean targets.
Args:
line_list: List of lines of text generated.
Returns:
Zero
Zero.
"""

# Save the "All" targets
Expand Down Expand Up @@ -806,7 +822,8 @@ def write_configurations(self, line_list):
# Default configuration, assume Release or use
# the one found first.
config = None
for item in self.configuration_list:
configuration_list = self.configuration_list
for item in configuration_list:
if item.name == "Release":
config = "Release"
break
Expand All @@ -830,8 +847,9 @@ def write_configurations(self, line_list):

# Default platform is Dos4GW unless it's not in the list
target = PlatformTypes.msdos4gw.get_short_code()
if self.platforms and PlatformTypes.msdos4gw not in self.platforms:
target = self.platforms[0].get_short_code()
platforms = self.platforms
if platforms and PlatformTypes.msdos4gw not in platforms:
target = platforms[0].get_short_code()

line_list.extend([
"",
Expand All @@ -853,7 +871,7 @@ def write_configurations(self, line_list):

# List all platforms
line_list.append("")
for platform in self.platforms:
for platform in platforms:
line_list.append(
"TARGET_SUFFIX_{0} = {1}".format(
platform.get_short_code(),
Expand Down Expand Up @@ -904,7 +922,8 @@ def write_source_dir(self, line_list):
# Sort them for consistent diffs for source control
include_folders = []
source_folders = []
for configuration in self.configuration_list:
configuration_list = self.configuration_list
for configuration in configuration_list:
for item in configuration.get_unique_chained_list(
"_source_include_list"):
if item not in source_folders:
Expand Down Expand Up @@ -986,7 +1005,8 @@ def _setcppflags(self, line_list):
"#",
""))

for configuration in self.configuration_list:
configuration_list = self.configuration_list
for configuration in configuration_list:
entries = ["CFlags" + configuration.watcommake_name + "="]

if configuration.platform is PlatformTypes.msdos4gw:
Expand Down Expand Up @@ -1052,7 +1072,8 @@ def _setasmflags(self, line_list):
"#",
""))

for configuration in self.configuration_list:
configuration_list = self.configuration_list
for configuration in configuration_list:
entries = ["AFlags" + configuration.watcommake_name + "="]

if configuration.platform.is_windows():
Expand Down Expand Up @@ -1085,7 +1106,8 @@ def _setlinkerflags(self, line_list):
"#",
""))

for configuration in self.configuration_list:
configuration_list = self.configuration_list
for configuration in configuration_list:
entries = ["LFlags" + configuration.watcommake_name + "="]

# Add linker "system nt"
Expand Down Expand Up @@ -1141,7 +1163,8 @@ def _setresourceflags(self, line_list):
"#",
""))

for configuration in self.configuration_list:
configuration_list = self.configuration_list
for configuration in configuration_list:
entries = ["RFlags" + configuration.watcommake_name + "="]

# Use Windows format
Expand Down Expand Up @@ -1376,7 +1399,8 @@ def write_builds(self, line_list, has_rez):
"#"
])

for configuration in self.configuration_list:
configuration_list = self.configuration_list
for configuration in configuration_list:
if configuration.project_type is ProjectTypes.library:
suffix = ".lib"
else:
Expand Down

0 comments on commit 2ff66e6

Please sign in to comment.