From ef1744e2c938517220e8f27370c134efb78cdd0c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 15 Jan 2020 12:54:47 -0500 Subject: [PATCH 01/10] add_c_file: handle adding to the end of a list correctly. Fixes bug 32962. --- scripts/maint/add_c_file.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index 9ec182efcc..6656d0d422 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -99,10 +99,14 @@ class AutomakeChunk: def __init__(self): self.lines = [] self.kind = "" + self.hasBlank = False # true if we end with a blank line. def addLine(self, line): """ Insert a line into this chunk while parsing the automake file. + + Return True if we have just read the last line in the chunk, and + False otherwise. """ m = self.pat.match(line) if m: @@ -110,10 +114,12 @@ class AutomakeChunk: raise ValueError("control line not preceded by a blank line") self.kind = m.group(1) - self.lines.append(line) if line.strip() == "": + self.hasBlank = True return True + self.lines.append(line) + return False def insertMember(self, member): @@ -145,8 +151,8 @@ class AutomakeChunk: "{}{}{}\\\n".format(prespace, member, postspace)) def insert_at_end(self, member, prespace, postspace): - lastline = self.lines[-1] - self.lines[-1] += '{}\\\n'.format(postspace) + lastline = self.lines[-1].strip() + self.lines[-1] = '{}{}{}\\\n'.format(prespace, lastline, postspace) self.lines.append("{}{}\n".format(prespace, member)) def dump(self, f): @@ -156,6 +162,9 @@ class AutomakeChunk: if not line.endswith("\n"): f.write("\n") + if self.hasBlank: + f.write("\n") + class ParsedAutomake: """A sort-of-parsed automake file, with identified chunks into which headers and c files can be inserted. From 4f45ad1394c4744f2c7a3deec45a32e3712e24bc Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Wed, 15 Jan 2020 12:58:52 -0500 Subject: [PATCH 02/10] add_c_file: tolerate ./ in filenames. --- scripts/maint/add_c_file.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index 6656d0d422..66a4fdcd9e 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -216,6 +216,9 @@ def run(fn): add them to include.am. """ + if fn.startswith("./"): + fn = fn[2:] + cf = makeext(fn, "c") hf = makeext(fn, "h") From 207d2625ed1485fd66dd9fd8df936d46252802ec Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 16 Jan 2020 08:36:45 +1000 Subject: [PATCH 03/10] add_c_file: Improve path handling and canonicalisation * distinguish between paths relative to the top-level tor directory, and paths relative to tor's src directory * canonicalise paths before using them * check that the script is run from the top-level tor directory * check that the file is being created in tor's src directory Part of 32962. --- scripts/maint/add_c_file.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index 66a4fdcd9e..f242a8b4e9 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -18,14 +18,20 @@ import os import re import time -def topdir_file(name): - """Strip opening "src" from a filename""" - return os.path.relpath(name, './src') +def tordir_file(name): + """Make name relative to the current directory, which should be the + top-level tor directory. Also performs basic path simplifications.""" + return os.path.normpath(os.path.relpath(name)) + +def srcdir_file(name): + """Make name relative to tor's "src" directory. + Also performs basic path simplifications.""" + return os.path.normpath(os.path.relpath(name, 'src')) def guard_macro(name): """Return the guard macro that should be used for the header file 'name'. """ - td = topdir_file(name).replace(".", "_").replace("/", "_").upper() + td = srcdir_file(name).replace(".", "_").replace("/", "_").upper() return "TOR_{}".format(td) def makeext(name, new_extension): @@ -41,9 +47,9 @@ def instantiate_template(template, output_fname): """ names = { # The relative location of the header file. - 'header_path' : makeext(topdir_file(output_fname), "h"), + 'header_path' : makeext(srcdir_file(output_fname), "h"), # The relative location of the C file file. - 'c_file_path' : makeext(topdir_file(output_fname), "c"), + 'c_file_path' : makeext(srcdir_file(output_fname), "c"), # The truncated name of the file. 'short_name' : os.path.basename(output_fname), # The current year, for the copyright notice @@ -200,7 +206,8 @@ def get_include_am_location(fname): Note that this function is imperfect because our include.am layout is not (yet) consistent. """ - td = topdir_file(fname) + # Strip src for pattern matching, but add it back when returning the path + td = srcdir_file(fname) m = re.match(r'^(lib|core|feature|app)/([a-z0-9_]*)/', td) if m: return "src/{}/{}/include.am".format(m.group(1),m.group(2)) @@ -216,8 +223,15 @@ def run(fn): add them to include.am. """ - if fn.startswith("./"): - fn = fn[2:] + # Make sure we're in the top-level tor directory, + # which contains the src directory + assert(os.path.isdir("src")) + + # Make the file name relative to the top-level tor directory + fn = tordir_file(fn) + # And check that we're adding files to the "src" directory, + # with canonical paths + assert(fn[:4] == "src/") cf = makeext(fn, "c") hf = makeext(fn, "h") From 3d50efcf9812f4d977f83adff9ed23aacc49fb7c Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 16 Jan 2020 08:48:44 +1000 Subject: [PATCH 04/10] add_c_file: Document the paths used by each part of the script Most paths are relative to the top-level tor directory, but the paths in the C and H files are relative to tor's src directory. Part of 32962. --- scripts/maint/add_c_file.py | 42 +++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index f242a8b4e9..3394ff38ee 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -4,6 +4,17 @@ Add a C file with matching header to the Tor codebase. Creates both files from templates, and adds them to the right include.am file. + This script takes paths relative to the top-level tor directory. + It creates files, and inserts them into include.am, also relative to + the top-level tor directory. + + But the template content in those files is relative to tor's src + directory. (This script strips "src" from the paths used to create + templated comments and macros.) + + This script expects posix paths, so it should be run with a python + where os.path is posixpath. (Rather than ntpath.) + Example usage: % add_c_file.py ./src/feature/dirauth/ocelot.c @@ -25,17 +36,24 @@ def tordir_file(name): def srcdir_file(name): """Make name relative to tor's "src" directory. - Also performs basic path simplifications.""" + Also performs basic path simplifications. + (This function takes paths relative to the top-level tor directory, + but outputs a path that is relative to tor's src directory.)""" return os.path.normpath(os.path.relpath(name, 'src')) def guard_macro(name): """Return the guard macro that should be used for the header file 'name'. + This function takes paths relative to the top-level tor directory, + but its output is relative to tor's src directory. """ td = srcdir_file(name).replace(".", "_").replace("/", "_").upper() return "TOR_{}".format(td) def makeext(name, new_extension): """Replace the extension for the file called 'name' with 'new_extension'. + This function takes and returns paths relative to either the top-level + tor directory, or tor's src directory, and returns the same kind + of path. """ base = os.path.splitext(name)[0] return base + "." + new_extension @@ -44,6 +62,10 @@ def instantiate_template(template, output_fname): """ Fill in a template with string using the fields that should be used for 'output_fname'. + + This function takes paths relative to the top-level tor directory, + but the paths in the completed template are relative to tor's src + directory. (Except for one of the fields, which is just a basename). """ names = { # The relative location of the header file. @@ -60,6 +82,7 @@ def instantiate_template(template, output_fname): return template.format(**names) +# This template operates on paths relative to tor's src directory HEADER_TEMPLATE = """\ /* Copyright (c) 2001 Matej Pfajfar. * Copyright (c) 2001-2004, Roger Dingledine. @@ -78,6 +101,7 @@ HEADER_TEMPLATE = """\ #endif /* !defined({guard_macro}) */ """ +# This template operates on paths relative to the tor's src directory C_FILE_TEMPLATE = """\ /* Copyright (c) 2001 Matej Pfajfar. * Copyright (c) 2001-2004, Roger Dingledine. @@ -99,6 +123,8 @@ class AutomakeChunk: Represents part of an automake file. If it is decorated with an ADD_C_FILE comment, it has a "kind" based on what to add to it. Otherwise, it only has a bunch of lines in it. + + This class operates on paths relative to the top-level tor directory. """ pat = re.compile(r'# ADD_C_FILE: INSERT (\S*) HERE', re.I) @@ -139,6 +165,9 @@ class AutomakeChunk: X \ Y \ Z + + This function operates on paths relative to the top-level tor + directory. """ prespace = "\t" postspace = "\t\t" @@ -174,6 +203,8 @@ class AutomakeChunk: class ParsedAutomake: """A sort-of-parsed automake file, with identified chunks into which headers and c files can be inserted. + + This class operates on paths relative to the top-level tor directory. """ def __init__(self): self.chunks = [] @@ -187,6 +218,9 @@ class ParsedAutomake: def add_file(self, fname, kind): """Insert a file of kind 'kind' to the appropriate section of this file. Return True if we added it. + + This function operates on paths relative to the top-level tor + directory. """ if kind.lower() in self.by_type: self.by_type[kind.lower()].insertMember(fname) @@ -205,6 +239,8 @@ def get_include_am_location(fname): Note that this function is imperfect because our include.am layout is not (yet) consistent. + + This function operates on paths relative to the top-level tor directory. """ # Strip src for pattern matching, but add it back when returning the path td = srcdir_file(fname) @@ -220,7 +256,9 @@ def get_include_am_location(fname): def run(fn): """ Create a new C file and H file corresponding to the filename "fn", and - add them to include.am. + add them to the corresponding include.am. + + This function operates on paths relative to the top-level tor directory. """ # Make sure we're in the top-level tor directory, From b82858849930dace7ad4685bb4008ffdface3a5d Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 16 Jan 2020 08:55:20 +1000 Subject: [PATCH 05/10] add_c_file: Simplify some usage of srcdir_file() Part of 32962. --- scripts/maint/add_c_file.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index 3394ff38ee..88a24a1cfb 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -41,12 +41,11 @@ def srcdir_file(name): but outputs a path that is relative to tor's src directory.)""" return os.path.normpath(os.path.relpath(name, 'src')) -def guard_macro(name): - """Return the guard macro that should be used for the header file 'name'. - This function takes paths relative to the top-level tor directory, - but its output is relative to tor's src directory. +def guard_macro(src_fname): + """Return the guard macro that should be used for the header file + 'src_fname'. This function takes paths relative to tor's src directory. """ - td = srcdir_file(name).replace(".", "_").replace("/", "_").upper() + td = src_fname.replace(".", "_").replace("/", "_").upper() return "TOR_{}".format(td) def makeext(name, new_extension): @@ -58,26 +57,27 @@ def makeext(name, new_extension): base = os.path.splitext(name)[0] return base + "." + new_extension -def instantiate_template(template, output_fname): +def instantiate_template(template, tor_fname): """ Fill in a template with string using the fields that should be used - for 'output_fname'. + for 'tor_fname'. This function takes paths relative to the top-level tor directory, but the paths in the completed template are relative to tor's src directory. (Except for one of the fields, which is just a basename). """ + src_fname = srcdir_file(tor_fname) names = { # The relative location of the header file. - 'header_path' : makeext(srcdir_file(output_fname), "h"), + 'header_path' : makeext(src_fname, "h"), # The relative location of the C file file. - 'c_file_path' : makeext(srcdir_file(output_fname), "c"), + 'c_file_path' : makeext(src_fname, "c"), # The truncated name of the file. - 'short_name' : os.path.basename(output_fname), + 'short_name' : os.path.basename(src_fname), # The current year, for the copyright notice 'this_year' : time.localtime().tm_year, # An appropriate guard macro, for the header. - 'guard_macro' : guard_macro(output_fname), + 'guard_macro' : guard_macro(src_fname), } return template.format(**names) From eb336e23a6a0979cf0c8e68f3dcd6a825a4b210d Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 16 Jan 2020 09:15:22 +1000 Subject: [PATCH 06/10] add_c_file: Rename variables based on the type of path * fname for generic file paths * tor_fname for paths relative to the top-level tor directory * src_fname for paths relative to tor's src directory With prefixes as required to disambiguate different paths of the same type. Part of 32962. --- scripts/maint/add_c_file.py | 101 ++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 50 deletions(-) diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index 88a24a1cfb..25a1be5331 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -29,17 +29,17 @@ import os import re import time -def tordir_file(name): - """Make name relative to the current directory, which should be the +def tordir_file(fname): + """Make fname relative to the current directory, which should be the top-level tor directory. Also performs basic path simplifications.""" - return os.path.normpath(os.path.relpath(name)) + return os.path.normpath(os.path.relpath(fname)) -def srcdir_file(name): - """Make name relative to tor's "src" directory. +def srcdir_file(tor_fname): + """Make tor_fname relative to tor's "src" directory. Also performs basic path simplifications. (This function takes paths relative to the top-level tor directory, but outputs a path that is relative to tor's src directory.)""" - return os.path.normpath(os.path.relpath(name, 'src')) + return os.path.normpath(os.path.relpath(tor_fname, 'src')) def guard_macro(src_fname): """Return the guard macro that should be used for the header file @@ -48,13 +48,13 @@ def guard_macro(src_fname): td = src_fname.replace(".", "_").replace("/", "_").upper() return "TOR_{}".format(td) -def makeext(name, new_extension): - """Replace the extension for the file called 'name' with 'new_extension'. +def makeext(fname, new_extension): + """Replace the extension for the file called 'fname' with 'new_extension'. This function takes and returns paths relative to either the top-level tor directory, or tor's src directory, and returns the same kind of path. """ - base = os.path.splitext(name)[0] + base = os.path.splitext(fname)[0] return base + "." + new_extension def instantiate_template(template, tor_fname): @@ -154,11 +154,11 @@ class AutomakeChunk: return False - def insertMember(self, member): + def insertMember(self, new_tor_fname): """ - Add a new member to this chunk. Try to insert it in alphabetical - order with matching indentation, but don't freak out too much if the - source isn't consistent. + Add a new file name new_tor_fname to this chunk. Try to insert it in + alphabetical order with matching indentation, but don't freak out too + much if the source isn't consistent. Assumes that this chunk is of the form: FOOBAR = \ @@ -175,20 +175,21 @@ class AutomakeChunk: m = re.match(r'(\s+)(\S+)(\s+)\\', line) if not m: continue - prespace, fname, postspace = m.groups() - if fname > member: - self.insert_before(lineno, member, prespace, postspace) + prespace, cur_tor_fname, postspace = m.groups() + if cur_tor_fname > new_tor_fname: + self.insert_before(lineno, new_tor_fname, prespace, postspace) return - self.insert_at_end(member, prespace, postspace) + self.insert_at_end(new_tor_fname, prespace, postspace) - def insert_before(self, lineno, member, prespace, postspace): + def insert_before(self, lineno, new_tor_fname, prespace, postspace): self.lines.insert(lineno, - "{}{}{}\\\n".format(prespace, member, postspace)) + "{}{}{}\\\n".format(prespace, new_tor_fname, + postspace)) - def insert_at_end(self, member, prespace, postspace): + def insert_at_end(self, new_tor_fname, prespace, postspace): lastline = self.lines[-1].strip() self.lines[-1] = '{}{}{}\\\n'.format(prespace, lastline, postspace) - self.lines.append("{}{}\n".format(prespace, member)) + self.lines.append("{}{}\n".format(prespace, new_tor_fname)) def dump(self, f): """Write all the lines in this chunk to the file 'f'.""" @@ -215,15 +216,15 @@ class ParsedAutomake: self.chunks.append(chunk) self.by_type[chunk.kind.lower()] = chunk - def add_file(self, fname, kind): - """Insert a file of kind 'kind' to the appropriate section of this - file. Return True if we added it. + def add_file(self, tor_fname, kind): + """Insert a file tor_fname of kind 'kind' to the appropriate + section of this file. Return True if we added it. This function operates on paths relative to the top-level tor directory. """ if kind.lower() in self.by_type: - self.by_type[kind.lower()].insertMember(fname) + self.by_type[kind.lower()].insertMember(tor_fname) return True else: return False @@ -233,9 +234,9 @@ class ParsedAutomake: for chunk in self.chunks: chunk.dump(f) -def get_include_am_location(fname): - """Find the right include.am file for introducing a new file. Return None - if we can't guess one. +def get_include_am_location(tor_fname): + """Find the right include.am file for introducing a new file + tor_fname. Return None if we can't guess one. Note that this function is imperfect because our include.am layout is not (yet) consistent. @@ -243,20 +244,20 @@ def get_include_am_location(fname): This function operates on paths relative to the top-level tor directory. """ # Strip src for pattern matching, but add it back when returning the path - td = srcdir_file(fname) - m = re.match(r'^(lib|core|feature|app)/([a-z0-9_]*)/', td) + src_fname = srcdir_file(tor_fname) + m = re.match(r'^(lib|core|feature|app)/([a-z0-9_]*)/', src_fname) if m: return "src/{}/{}/include.am".format(m.group(1),m.group(2)) - if re.match(r'^test/', td): + if re.match(r'^test/', src_fname): return "src/test/include.am" return None -def run(fn): +def run(fname): """ - Create a new C file and H file corresponding to the filename "fn", and - add them to the corresponding include.am. + Create a new C file and H file corresponding to the filename "fname", + and add them to the corresponding include.am. This function operates on paths relative to the top-level tor directory. """ @@ -266,31 +267,31 @@ def run(fn): assert(os.path.isdir("src")) # Make the file name relative to the top-level tor directory - fn = tordir_file(fn) + tor_fname = tordir_file(fname) # And check that we're adding files to the "src" directory, # with canonical paths - assert(fn[:4] == "src/") + assert(tor_fname[:4] == "src/") - cf = makeext(fn, "c") - hf = makeext(fn, "h") + c_tor_fname = makeext(tor_fname, "c") + h_tor_fname = makeext(tor_fname, "h") - if os.path.exists(cf): - print("{} already exists".format(cf)) + if os.path.exists(c_tor_fname): + print("{} already exists".format(c_tor_fname)) return 1 - if os.path.exists(hf): - print("{} already exists".format(hf)) + if os.path.exists(h_tor_fname): + print("{} already exists".format(h_tor_fname)) return 1 - with open(cf, 'w') as f: - f.write(instantiate_template(C_FILE_TEMPLATE, cf)) + with open(c_tor_fname, 'w') as f: + f.write(instantiate_template(C_FILE_TEMPLATE, c_tor_fname)) - with open(hf, 'w') as f: - f.write(instantiate_template(HEADER_TEMPLATE, hf)) + with open(h_tor_fname, 'w') as f: + f.write(instantiate_template(HEADER_TEMPLATE, h_tor_fname)) - iam = get_include_am_location(cf) + iam = get_include_am_location(c_tor_fname) if iam is None or not os.path.exists(iam): print("Made files successfully but couldn't identify include.am for {}" - .format(cf)) + .format(c_tor_fname)) return 1 amfile = ParsedAutomake() @@ -302,8 +303,8 @@ def run(fn): cur_chunk = AutomakeChunk() amfile.addChunk(cur_chunk) - amfile.add_file(cf, "sources") - amfile.add_file(hf, "headers") + amfile.add_file(c_tor_fname, "sources") + amfile.add_file(h_tor_fname, "headers") with open(iam+".tmp", 'w') as f: amfile.dump(f) From 0418bc0cb276a6c11f6f05332ca15c87b5a5e56d Mon Sep 17 00:00:00 2001 From: teor Date: Mon, 20 Jan 2020 13:04:02 +1000 Subject: [PATCH 07/10] add_c_file: Improve tor source directory checks Check that the script isn't in a tor build directory, by looking for a src/include.am file. Part of 32962. --- scripts/maint/add_c_file.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index 25a1be5331..a7478cbecf 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -265,6 +265,8 @@ def run(fname): # Make sure we're in the top-level tor directory, # which contains the src directory assert(os.path.isdir("src")) + # And it looks like a tor/src directory + assert(os.path.isfile("src/include.am")) # Make the file name relative to the top-level tor directory tor_fname = tordir_file(fname) From 2c75d4a8d0bea2e9c0ebd5ef07b6f9149ce135cb Mon Sep 17 00:00:00 2001 From: teor Date: Mon, 20 Jan 2020 13:20:14 +1000 Subject: [PATCH 08/10] add_c_file: Improve script documentation Part of 32962. --- scripts/maint/add_c_file.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index a7478cbecf..75e1f556b8 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -4,16 +4,20 @@ Add a C file with matching header to the Tor codebase. Creates both files from templates, and adds them to the right include.am file. - This script takes paths relative to the top-level tor directory. - It creates files, and inserts them into include.am, also relative to - the top-level tor directory. + This script takes paths relative to the top-level tor directory. It + expects to be run from that directory. + + This script creates files, and inserts them into include.am, also + relative to the top-level tor directory. But the template content in those files is relative to tor's src directory. (This script strips "src" from the paths used to create templated comments and macros.) This script expects posix paths, so it should be run with a python - where os.path is posixpath. (Rather than ntpath.) + where os.path is posixpath. (Rather than ntpath.) This probably means + Linux, macOS, or BSD, although it might work on Windows if your python + was compiled with mingw, MSYS, or cygwin. Example usage: From 28c8c63de96f82818b3ce40c027beb73519000da Mon Sep 17 00:00:00 2001 From: teor Date: Mon, 20 Jan 2020 13:20:42 +1000 Subject: [PATCH 09/10] add_c_file: Replace asserts with exceptions Closes 32962. --- scripts/maint/add_c_file.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/scripts/maint/add_c_file.py b/scripts/maint/add_c_file.py index 75e1f556b8..e1e224d8d5 100755 --- a/scripts/maint/add_c_file.py +++ b/scripts/maint/add_c_file.py @@ -268,15 +268,26 @@ def run(fname): # Make sure we're in the top-level tor directory, # which contains the src directory - assert(os.path.isdir("src")) + if not os.path.isdir("src"): + raise RuntimeError("Could not find './src/'. " + "Run this script from the top-level tor source " + "directory.") + # And it looks like a tor/src directory - assert(os.path.isfile("src/include.am")) + if not os.path.isfile("src/include.am"): + raise RuntimeError("Could not find './src/include.am'. " + "Run this script from the top-level tor source " + "directory.") # Make the file name relative to the top-level tor directory tor_fname = tordir_file(fname) # And check that we're adding files to the "src" directory, # with canonical paths - assert(tor_fname[:4] == "src/") + if tor_fname[:4] != "src/": + raise ValueError("Requested file path '{}' canonicalized to '{}', " + "but the canonical path did not start with 'src/'. " + "Please add files to the src directory." + .format(fname, tor_fname)) c_tor_fname = makeext(tor_fname, "c") h_tor_fname = makeext(tor_fname, "h") From 5ad1efa0626263a63481191d3b19fccab9c427e1 Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 16 Jan 2020 09:38:26 +1000 Subject: [PATCH 10/10] add_c_file: Fix "control line not preceded by a blank line" Fix dirauth and relay module include.am add_c_file.py "control line not preceded by a blank line" errors. Also remove a duplicate ADD_C_FILE: SOURCES in the relay module. Obviously correct fixes to already-reviewed code. --- src/feature/dirauth/include.am | 1 + src/feature/relay/include.am | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/feature/dirauth/include.am b/src/feature/dirauth/include.am index ec7b3b2961..2ef629ae35 100644 --- a/src/feature/dirauth/include.am +++ b/src/feature/dirauth/include.am @@ -1,5 +1,6 @@ # The Directory Authority module. + # ADD_C_FILE: INSERT SOURCES HERE. MODULE_DIRAUTH_SOURCES = \ src/feature/dirauth/authmode.c \ diff --git a/src/feature/relay/include.am b/src/feature/relay/include.am index aa9aa3adfa..a4c025ae12 100644 --- a/src/feature/relay/include.am +++ b/src/feature/relay/include.am @@ -1,5 +1,5 @@ -# ADD_C_FILE: INSERT SOURCES HERE. +# Legacy shared relay code: migrate to the relay module over time LIBTOR_APP_A_SOURCES += \ src/feature/relay/dns.c \ src/feature/relay/ext_orport.c \ @@ -9,6 +9,7 @@ LIBTOR_APP_A_SOURCES += \ src/feature/relay/selftest.c # The Relay module. + # ADD_C_FILE: INSERT SOURCES HERE. MODULE_RELAY_SOURCES = \ src/feature/relay/routermode.c \