Browse Source

Allow `.asm`, `.s`, and `.S` as valid assembly file extensions

gingerBill 3 years ago
parent
commit
27106dd9ae
3 changed files with 15 additions and 4 deletions
  1. 12 0
      src/build_settings.cpp
  2. 1 2
      src/checker.cpp
  3. 2 2
      src/main.cpp

+ 12 - 0
src/build_settings.cpp

@@ -822,6 +822,18 @@ bool show_error_line(void) {
 	return build_context.show_error_line;
 }
 
+bool has_asm_extension(String const &path) {
+	String ext = path_extension(path);
+	if (ext == ".asm") {
+		return true;
+	} else if (ext == ".s") {
+		return true;
+	} else if (ext == ".S") {
+		return true;
+	}
+	return false;
+}
+
 
 void init_build_context(TargetMetrics *cross_target) {
 	BuildContext *bc = &build_context;

+ 1 - 2
src/checker.cpp

@@ -4121,8 +4121,7 @@ void check_add_foreign_import_decl(CheckerContext *ctx, Ast *decl) {
 		add_entity_use(ctx, nullptr, e);
 	}
 	
-	String ext = path_extension(fullpath);
-	if (ext == ".asm") {
+	if (has_asm_extension(fullpath)) {
 		if (build_context.metrics.arch != TargetArch_amd64 ||
 		    build_context.metrics.os   != TargetOs_windows) {
 			error(decl, "Assembly files are not yet supported on this platform: %.*s_%.*s", 

+ 2 - 2
src/main.cpp

@@ -225,7 +225,7 @@ i32 linker_stage(lbGenerator *gen) {
 			lbModule *m = gen->modules.entries[j].value;
 			for_array(i, m->foreign_library_paths) {
 				String lib = m->foreign_library_paths[i];
-				if (string_ends_with(lib, str_lit(".asm"))) {
+				if (has_asm_extension(lib)) {
 					string_set_add(&asm_files, lib);
 				} else {
 					string_set_add(&libs, lib);
@@ -235,7 +235,7 @@ i32 linker_stage(lbGenerator *gen) {
 
 		for_array(i, gen->default_module.foreign_library_paths) {
 			String lib = gen->default_module.foreign_library_paths[i];
-			if (string_ends_with(lib, str_lit(".asm"))) {
+			if (has_asm_extension(lib)) {
 				string_set_add(&asm_files, lib);
 			} else {
 				string_set_add(&libs, lib);