Skip to content

Commit

Permalink
Merge pull request #28 from dinkelk/asm-support-s
Browse files Browse the repository at this point in the history
Assembly Compilation Support
  • Loading branch information
dinkelk authored Feb 28, 2024
2 parents e072276 + 7373bbe commit 388b552
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions redo/database/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ def _is_ada_source_file(filename):
return ext in [".adb", ".ads"]


# Determine if a filename is c/c++ source file by its extension.
# Determine if a filename is c/c++ or asm source file by its extension.
def _is_c_source_file(filename):
_, ext = os.path.splitext(filename)
return ext in [".c", ".cpp", ".h", ".hpp"]
return ext in [".c", ".cpp", ".h", ".hpp", ".s"]


# Determine if a filename is python source file by its extension.
Expand Down Expand Up @@ -348,7 +348,7 @@ def create(build_path):
ada_source_regex = re.compile(r".*\.ad[sb]$")
do_file_regex = re.compile(r".*\.do$")
yaml_file_regex = re.compile(r".*\.yaml$")
c_source_regex = re.compile(r".*\.[ch]p?p?$")
c_source_regex = re.compile(r".*\.(h|hpp|c|cpp|s)$")

# Search first for model files, and create the model database. This
# may be needed by generators, so we need to build it first.
Expand Down
17 changes: 11 additions & 6 deletions redo/rules/build_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,15 @@ def _extract_from_deps_file(dependency_file, object_file):
includes = "-I" + " -I".join(db.get_all_source_dirs())

# Run g++ -MM to generate dependencies for a source file in a .d output:
if source_file.endswith(".cpp"):
compiler = "g++"
else:
compiler = "gcc"
obj_file = redo_arg.src_file_to_obj_file(source_file, build_target_instance.name)
dep_output_file = os.path.join(os.path.dirname(obj_file), os.path.basename(source_file)) + ".d"
filesystem.safe_makedir(os.path.dirname(dep_output_file))
compiler_prefix, _ = build_target_instance.gnatmetric_info()
gcc_m_command = compiler_prefix + "g++ " + source_file + " -MM -MG -MF " + dep_output_file + " " + includes
gcc_m_command = compiler_prefix + compiler + " " + source_file + " -MM -MG -MF " + dep_output_file + " " + includes
shell.run_command(gcc_m_command)

# Open the dependency file and parse it to get out the dependencies:
Expand All @@ -230,8 +234,9 @@ def _build_all_c_dependencies(
def _get_immediate_dependencies(source_files):
all_deps = []
for source_file in source_files:
# Get dependencies for this source files:
all_deps.extend(get_c_source_dependencies(source_file, build_target_instance, c_source_db))
# Get dependencies for this source file. Ignore assembly files.
if not source_file.endswith(".s"):
all_deps.extend(get_c_source_dependencies(source_file, build_target_instance, c_source_db))
return list(set(all_deps))

def _get_all_dependencies(source_files):
Expand Down Expand Up @@ -347,7 +352,7 @@ def _get_object_sources(object_file):
source_to_compile_extension = None
for source_file in source_files:
_, source_to_compile_extension = os.path.splitext(source_file)
if source_to_compile_extension in [".c", ".cpp"]:
if source_to_compile_extension in [".c", ".cpp", ".s"]:
source_to_compile = source_file
break

Expand Down Expand Up @@ -555,7 +560,7 @@ def _compile_c_object(redo_1, redo_2, redo_3, source_files, db):
source_to_compile_extension = None
for source_file in source_files:
_, source_to_compile_extension = os.path.splitext(source_file)
if source_to_compile_extension in [".c", ".cpp"]:
if source_to_compile_extension in [".c", ".cpp", ".s"]:
source_to_compile = source_file
break

Expand Down Expand Up @@ -656,7 +661,7 @@ def _build(self, redo_1, redo_2, redo_3):
# an object. In C/C++ only the .c or .cpp files produce object
# code, so ignore header files.
def input_file_regex(self):
return [r"^((?!template/).)*\.ad[sb]$", r"^((?!template/).)*\.cp?p?$"]
return [r"^((?!template/).)*\.ad[sb]$", r"^((?!template/).)*\.(h|hpp|c|cpp|s)$"]

# Output object files will always be stored with the same name
# as their source package, and in the build/obj directory.
Expand Down

0 comments on commit 388b552

Please sign in to comment.